Last active
February 1, 2021 13:24
-
-
Save wader/2f8fdb3a926a6f3b42e1e387e4365890 to your computer and use it in GitHub Desktop.
make automatic variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ make a/test.out | |
| mkdir -p b | |
| touch "b/test.dep1" | |
| mkdir -p b | |
| touch "b/test.dep2" | |
| mkdir -p b | |
| touch "b/test.dep3" | |
| The file name of the target of the rule $@=a/test.out | |
| The target member name, when the target is an archive member $%= | |
| The name of the first prerequisite $<=b/test.dep1 | |
| The names of all the prerequisites that are newer than the target, with spaces between them $?=b/test.dep1 b/test.dep2 | |
| The names of all the prerequisites, with spaces between them $^=b/test.dep1 b/test.dep2 | |
| This is like ‘$^’, but prerequisites listed more than once are duplicated in the order they were listed in the makefile $+=b/test.dep1 b/test.dep2 b/test.dep2 | |
| The names of all the order-only prerequisites, with spaces between them $|=b/test.dep3 | |
| The stem with which an implicit rule matches $*=test | |
| The directory part of the file name of the target, with the trailing slash removed $(@D)=a | |
| The file-within-directory part of the file name of the target $(@F)=test.out | |
| The directory part and the file-within-directory part of the stem $(*D)=. | |
| The directory part and the file-within-directory part of the stem $(*F)=test | |
| The directory part and the file-within-directory part of the target archive member name $(%D)= | |
| The directory part and the file-within-directory part of the target archive member name $(%F)= | |
| The directory part and the file-within-directory part of the first prerequisite $(<D)=b | |
| The directory part and the file-within-directory part of the first prerequisite $(<F)=test.dep1 | |
| Lists of the directory parts of all prerequisites $(^D)=b b | |
| Lists of the file-within-directory parts of all prerequisites $(^F)=test.dep1 test.dep2 | |
| Lists of the directory parts of all prerequisites, including multiple instances of duplicated prerequisites $(+D)=b b b | |
| Lists of the the file-within-directory parts of all prerequisites, including multiple instances of duplicated prerequisites $(+F)=test.dep1 test.dep2 test.dep2 | |
| Lists of the directory parts of all prerequisites that are newer than the target $(?D)=b b | |
| Lists of the file-within-directory parts of all prerequisites that are newer than the target $(?F)=test.dep1 test.dep2 | |
| rm b/test.dep1 b/test.dep3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html | |
| b/%.dep1: | |
| mkdir -p b | |
| touch "$@" | |
| b/%.dep2: | |
| mkdir -p b | |
| touch "$@" | |
| b/%.dep3: | |
| mkdir -p b | |
| touch "$@" | |
| a/%.out: b/%.dep1 b/%.dep2 b/%.dep2 | b/%.dep3 | |
| @echo "The file name of the target of the rule \$$@=$@" | |
| @echo "The target member name, when the target is an archive member \$$%=$%" | |
| @echo "The name of the first prerequisite \$$<=$<" | |
| @echo "The names of all the prerequisites that are newer than the target, with spaces between them \$$?=$?" | |
| @echo "The names of all the prerequisites, with spaces between them \$$^=$^" | |
| @echo "This is like ‘$$^’, but prerequisites listed more than once are duplicated in the order they were listed in the makefile \$$+=$+" | |
| @echo "The names of all the order-only prerequisites, with spaces between them \$$|=$|" | |
| @echo "The stem with which an implicit rule matches \$$*=$*" | |
| @echo "The directory part of the file name of the target, with the trailing slash removed \$$(@D)=$(@D)" | |
| @echo "The file-within-directory part of the file name of the target \$$(@F)=$(@F)" | |
| @echo "The directory part and the file-within-directory part of the stem \$$(*D)=$(*D)" | |
| @echo "The directory part and the file-within-directory part of the stem \$$(*F)=$(*F)" | |
| @echo "The directory part and the file-within-directory part of the target archive member name \$$(%D)=$(%D)" | |
| @echo "The directory part and the file-within-directory part of the target archive member name \$$(%F)=$(%F)" | |
| @echo "The directory part and the file-within-directory part of the first prerequisite \$$(<D)=$(<D)" | |
| @echo "The directory part and the file-within-directory part of the first prerequisite \$$(<F)=$(<F)" | |
| @echo "Lists of the directory parts of all prerequisites \$$(^D)=$(^D)" | |
| @echo "Lists of the file-within-directory parts of all prerequisites \$$(^F)=$(^F)" | |
| @echo "Lists of the directory parts of all prerequisites, including multiple instances of duplicated prerequisites \$$(+D)=$(+D)" | |
| @echo "Lists of the the file-within-directory parts of all prerequisites, including multiple instances of duplicated prerequisites \$$(+F)=$(+F)" | |
| @echo "Lists of the directory parts of all prerequisites that are newer than the target \$$(?D)=$(?D)" | |
| @echo "Lists of the file-within-directory parts of all prerequisites that are newer than the target \$$(?F)=$(?F)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment