介绍几个比较常见的
1 call function
语法规则
$(call macro-name[, param1 ...])
call is a built-in make function that expands its first argument and replaces occur-
rences of $1, $2, etc., with the remaining arguments it is given.
看下面的例子
define parent
echo "parent has two parameters: $1, $2"
$(call child,$1)
endef
define child
echo "child has one parameter: $1"
echo "but child can also see parent's second parameter: $2!"
endef
scoping_issue:
@$(call parent,one,two)
$ make
parent has two parameters: one, two
child has one parameter: one
but child can also see parent's second parameter: two!
2 filter function
words := he the hen other the%
get-the:
@echo he matches: $(filter he, $(words))
@echo %he matches: $(filter %he, $(words))
@echo he% matches: $(filter he%, $(words))
@echo %he% matches: $(filter %he%, $(words))
$ make
he matches: he
%he matches: he the
he% matches: he hen
%he% matches: the%
3 wildcard
sources := $(wildcard *.c *.h)
4 $(foreach variable,list,body)
阅读(1080) | 评论(0) | 转发(0) |