3 prism_languages: [makefile]
12 bar = $(foo) foo # dynamic (renewing) assignment
13 foo := "boo" # one time assignment, $(bar) now is "boo foo"
14 foo ?= /usr/local # safe assignment, $(foo) and $(bar) still the same
15 bar += world # append, "boo foo world"
16 foo != echo fooo # exec shell command and assign to foo
17 # $(bar) now is "fooo foo world"
20 `=` expressions are only evaluated when they're being used.
27 $< # "src.c" (first prerequisite)
28 $^ # "src.c src.h" (all prerequisites)
31 $* # the 'stem' with which an implicit rule matches ("foo" in "foo.c")
34 $+ # prerequisites (all, with duplication)
35 $? # prerequisites (new ones)
36 $| # prerequisites (order-only?)
38 $(@D) # target directory
43 | Prefix | Description |
44 | ------ | ------------------------------------------- |
45 | `-` | Ignore errors |
46 | `@` | Don't print command |
47 | `+` | Run even if Make is in 'don't execute' mode |
60 js_files := $(wildcard test/*.js)
61 all_files := $(shell find images -name "*")
67 file = $(SOURCE:.cpp=.o) # foo.cpp => foo.o
68 outputs = $(files:src/%.coffee=lib/%.js)
70 outputs = $(patsubst %.c, %.o, $(wildcard *.c))
71 assets = $(patsubst images/%, assets/%, $(wildcard images/*))
77 $(strip $(string_var))
79 $(filter %.less, $(files))
80 $(filter-out %.less, $(files))
87 ffmpeg -i $< > $@ # Input and output
101 -e, --environment-overrides
104 -j, --jobs=N # parallel processing
112 $(CC) -o foo $(objects) $(libs_for_gcc)
114 $(CC) -o foo $(objects) $(normal_libs)
127 - [isaacs's Makefile](https://gist.github.com/isaacs/62a2d1825d04437c6f08)
128 - [Your Makefiles are wrong](https://tech.davis-hansson.com/p/make/)
129 - [Manual](https://www.gnu.org/software/make/manual/html_node/index.html)