https://devhints.io/makefile
很像shell的语法,如#
表示注释
但还是有些区别的,如a = val
的等号两边是可以有空格的
详细信息参照makefile 节选
Assignment
uglify = $(uglify) # assignment
compressor := $(uglify) # lazy assignment
prefix ?= /usr/local # safe assignment
Magic variables
out.o: src.c src.h
$@ # "out.o" (target)
$< # "src.c" (first prerequisite)
$^ # "src.c src.h" (all prerequisites)
%.o: %.c
$* # the 'stem' with which an implicit rule matches ("foo" in "foo.c")
also:
$+ # prerequisites (all, with duplication)
$? # prerequisites (new ones)
$| # prerequisites (order-only?)
$(@D) # target directory
Find files
js_files := $(wildcard test/*.js)
all_files := $(shell find images -name "*")
Includes
-include foo.make
Conditionals
foo: $(objects)
ifeq ($(CC),gcc)
$(CC) -o foo $(objects) $(libs_for_gcc)
else
$(CC) -o foo $(objects) $(normal_libs)
endif
网友评论