util:make
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | util:make [2009/06/07 14:01] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== make ====== | ||
+ | Things worth knowing about '' | ||
+ | |||
+ | ====== Makefiles ====== | ||
+ | |||
+ | ===== Hints ===== | ||
+ | * a literal ''' | ||
+ | <code make> | ||
+ | bla: | ||
+ | rm $$(echo "-rf /") | ||
+ | </ | ||
+ | * place a dash (''' | ||
+ | <code make> | ||
+ | bla: | ||
+ | -rm $$(echo "-rf /") | ||
+ | </ | ||
+ | |||
+ | ===== $(builtins ) ===== | ||
+ | * subst | ||
+ | <code make> | ||
+ | $(OBJECTS) : | ||
+ | javac $(subst .class, | ||
+ | </ | ||
+ | * filter | ||
+ | <code make> | ||
+ | FILES = Bla.java Blub.java Wrong.here | ||
+ | $(filter %.java, | ||
+ | javac $@ | ||
+ | $(filter %.here, | ||
+ | echo "Wrong here? | ||
+ | </ | ||
+ | |||
+ | ===== Static Patterns ===== | ||
+ | < | ||
+ | targets ...: target-pattern: | ||
+ | commands | ||
+ | </ | ||
+ | Sample usage: | ||
+ | <code make> | ||
+ | objects = foo.o bar.o | ||
+ | all: $(objects) | ||
+ | $(objects): %.o: %.c | ||
+ | $(CC) -c $(CFLAGS) $< -o $@ | ||
+ | </ | ||
+ | |||
+ | ===== Misc Goodies ===== | ||
+ | |||
+ | * recursing paths: | ||
+ | <code make> | ||
+ | PATH=/ | ||
+ | |||
+ | PLIST:= | ||
+ | define recurse | ||
+ | ifneq ($(strip $(shell dirname ${1})),/) | ||
+ | $$(eval $$(call recurse, | ||
+ | PLIST+= $(shell dirname ${1}) | ||
+ | endif | ||
+ | endef | ||
+ | |||
+ | all: $(eval $(call recurse, | ||
+ | @for i in ${PLIST}; do echo $$i; done | ||
+ | </ | ||
+ | |||
+ | * a more advanced version of the above: | ||
+ | <code make> | ||
+ | PATH=/ | ||
+ | ifneq (${REVERSE}, | ||
+ | REVERSE: | ||
+ | endif | ||
+ | REVERSE? | ||
+ | |||
+ | PLIST:= | ||
+ | define get_dirname | ||
+ | $(strip $(shell dirname ${1})) | ||
+ | endef | ||
+ | |||
+ | define list_add | ||
+ | ifneq (${2},${3}) | ||
+ | PLIST += $$(call get_dirname, | ||
+ | endif | ||
+ | endef | ||
+ | |||
+ | define recurse | ||
+ | DNAME: | ||
+ | ifneq ($${DNAME},/ | ||
+ | $$(eval $$(call list_add, | ||
+ | $$(eval $$(call recurse, | ||
+ | $$(eval $$(call list_add, | ||
+ | endif | ||
+ | endef | ||
+ | |||
+ | all: $(eval $(call recurse, ${PATH})) | ||
+ | @for i in ${PLIST}; do echo $$i; done | ||
+ | </ | ||
+ | |||
+ | ====== Links ====== | ||
+ | [[http:// | ||
util/make.txt · Last modified: 2009/06/07 14:01 by 127.0.0.1