Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does $< and $@ mean in make file

I found these pseudo variable name in my makefile in WDK build environment. What is referenced by these variables? It is a little hard for me to get the answer by search engine because they are special, I believe.

like image 536
Thomson Avatar asked Jan 14 '11 12:01

Thomson


People also ask

What does the special symbol mean in makefile $@ $<?

Inside actions we can use: $@ to represent the full target name of the current target $? returns the dependencies that are newer than the current target $* returns the text that corresponds to % in the target $< returns the name of the first dependency $^ returns the names of all the dependencies with space as the ...

What does $$ mean in makefile?

This special significance of ' $ ' is why you must write ' $$ ' to have the effect of a single dollar sign in a file name or recipe. Variable references can be used in any context: targets, prerequisites, recipes, most directives, and new variable values.

What does := mean in make?

the := will set the value once to the variable, ie it wont be re-evaluated everytime make encouters that variable.

How do you use special characters in makefile?

Special characters in a makefile In macros, a backslash ( \ ) followed by a newline character is replaced by a space. In commands, a percent symbol ( % ) is a file specifier. To represent % literally in a command, specify a double percent sign ( %% ) in place of a single one.


1 Answers

These are automatic variables:

$@ The file name of the target of the rule. If the target is an archive member, then ‘$@’ is the name of the archive file. In a pattern rule that has multiple targets (see Introduction to Pattern Rules), ‘$@’ is the name of whichever target caused the rule's recipe to be run.

$< The name of the first prerequisite. If the target got its recipe from an implicit rule, this will be the first prerequisite added by the implicit rule (see Implicit Rules).

They are used to build rules that can be applied to different targets so that one does not need to repeat the same rule for each and every file that must be worked on...

PS: To find the answer, I first looked for the 'all documentation on a single page' for GNU make, then used my browser's search function...

like image 121
Xavier Nodet Avatar answered Oct 25 '22 21:10

Xavier Nodet