Contiki 2.7 Makefile file (iii)

Source: Internet
Author: User

2, the second part

The usage,targets,savetarget,savedefines here are pseudo-targets.

Unlike all, these pseudo-targets are not executed unless these targets are explicitly specified.

Here are two targets savetarget,savedefines we mentioned before.

The command make target=esb savetarget can save the default TARGET to Makefile.target.

by command make target=esb defines=mytrace,myvalue=4711 savedefines can save the default defines to makefile.$ (TARGET). The defines.

First prepare some preparatory knowledge, the GNU make work to perform the steps:

1. Read into all makefile

2. Read the other makefile in the Include

3. Initialize the variables in the file

4. Derivation of cryptic rules and analysis of all rules

5. Create a dependency chain for all target files

6. Depending on the dependencies, decide which targets to regenerate

7. Execute the Build command

When you execute the make target=esb savetarget command:

1. First read all makefile (including the makefile of include), initialize all variables (TARGET=ESB)

2, the derivation rule, creates the dependency, here is the pseudo target, therefore only executes savetarget behind the command

Savetarget:    [email protected]-F makefile.target    @echo "Saving makefile.target"    @echo > Makefile.target "target = $ (target)"

Meaning:

The first sentence: forcibly delete the file Makefile.target, continue to execute subsequent commands on error (-the role of the symbol)

Note: The function of the @ symbol means that the command is not displayed

Second sentence command: display "Saving makefile.target" prompt message

The third sentence: redirect target = $ (target) to file Makefile.target, which is the default target to file Makefile.target file

You can see that the target = ESB is saved to the file Makefile.target.

Here's a bug tip, Make:msp430-gcc:command not found

The prompt message occurs after reading. /.. /cpu/msp430/makefile.msp430 after this file. The ESB platform is MSP430CPU, so the makefile.msp430 is imported.

Here is my system environment inside no MSP430-GCC caused, but why make target=esb savetarget This command will MSP430-GCC execution, to specifically see makefile.msp430, ignore.

When you execute the make savetarget command:

Because the target variable is not explicitly defined , the order in which make is executed is to initialize the variables in the file before generating the target based on the dependency.

The target is initially initialized to native (2 in the first part)and then saved to the Makefile.target file

Execution Make target=esb defines=mytrace,myvalue=4711 savedefines command

1. First read all makefile (including the makefile of include), initialize all variables (target=esb,defines=mytrace,myvalue=4711)

2, the derivation rule, creates the dependency, here is the pseudo target, therefore only executes savedefines behind the command

Savedefines:    -@rm-F makefile.$ (target). Defines    @echo "Saving makefile.$ (target) defines"    @echo > makefile.$ (TARGET). Defines "defines = $ (defines)"

The first sentence command: Forcibly delete the file makefile. ($TARGET). Defines, continuation of subsequent commands on error (-function of symbols)

Note: The function of the @ symbol means that the command is not displayed

Second sentence: show "Saving Makefile." ($TARGET). Defines "prompt information

The third sentence command: Redirect "defines = $ (defines)" to the file makefile. ($TARGET). Defines, which saves the default defines to file makefile. ($TARGET) in the. defines file

You can see that defines = mytrace,myvalue=4711 is saved to the Makefile.esb.defines file.

Note: The variable is initialized first, and then the target is generated based on the dependency relationship.

When you execute the Make usage command:

Usage:    @echo "Make maketargets ... [Target= (TARGET)] [Savetarget] [Targets] "

The usage is a pseudo-target and executes only the commands behind the usage.

Output make maketargets ... [Target= (TARGET)] [Savetarget] [Targets] Prompt information

Tell us how to use it.

When you execute the Make targets command:

Targets:    @ls-1 $ (Contiki)/platform $ (targetdirs) | Grep-v CVS

Targets is a pseudo-target, only executes the command behind the label targets.

The commands here are divided into two lines:

Ls-1 $ (Contiki)/platform $ (targetdirs)

Grep-v CVS

Where LS's-1 parameter is list one file perline, $CONTIKI/platform directory as the default platform directory .

The targetdirs variable is empty here , and we can define this variable to save our custom platform directory .

| is the pipe that connects the standard output of the previous instruction as the standard input for the next instruction.

Grep-v CVS (select non-matching lines) selects rows without CVS (lines).

I don't know what CVS is, just ignore it.

The final output default platform directory $ (Contiki)/platform and the custom platform directory $ (targetdirs) , does not contain all the file names for CVS.

Because the custom platform directory $ (targetdirs) is empty, only the default platform directory $ (contiki)/platform All files that do not contain CVS (list one file per line) are exported. Take a look at the top three figures.

Contiki 2.7 Makefile file (iii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.