5.22 Morning foreign teacher Linux listening 812

Source: Internet
Author: User

Makefile those weird symbols.

These strange symbols are present in the implicit rules of the preceding, and are carried out separately because we often use them.

These symbols are the automatic variables we often call:

[Email protected] : The target set in the rule

$^ : All prerequisites in the rule

$< : Represents the first prerequisite in a rule

again , the difference between $VAR and $ $VAR :

Makefilemost of the rules in a file are usedShellcommand to implement, this involves the use of variables, includingMakefilethe variables in andShellvariables within the scope of the command. In theMakefileThe rule command line is used in the$varis to refer to it in the command.Makefilethe variable, here is just the readMakefilevariable is then extended, passing its value as a parameter to aShellorder;$ $varis to access aShellvariables defined within the command, rather thanMakefilethe variable. If a rule hasNaShellcommand-line composition, and no use to each other'; 'and the' \ 'connected, there's no correlation between them.Shellcommands, and cannot share variables with each other.

pseudo target of Makefile

Use reason one: avoid conflicting files with the same name

in reality, it is inevitable that the defined goal is the same name as the existing target, How does Makefile deal with this situation? the Makefile (phonytarget) can solve this problem.

false targets can be used . The phony keyword is declared, and for a false target, it can be imagined that, because it does not depend on a file, the command of its rule will be executed when the target is made.

If you write a rule that does not produce a target file, its commands are executed every time that you make the target.

For example:

Clean

RM *.O Temp

because the "RM" command does not produce a "clean" file, the command executes every time you execute " make clean ." If the "clean" file appears in the directory, the rule is invalidated: no dependent files, the file "clean" is always up-to- date, the command will never be executed; To avoid this problem, you can use ". Phony " indicates the target. such as:

. Phony:clean

doing so will disregard the presence or absence of the clean file.

The known phony target is not an actual file generated by another file, and make skips the implicit rule search. That's why declaring phony goals can improve performance, even if you're not worried about the actual file existence or not.

The complete example is as follows:

. Phony:clean

Clean:

RM *.O Temp

5.22 Morning foreign teacher Linux listening 812

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.