- 论坛徽章:
- 0
|
本帖最后由 rongpmcu 于 2012-12-29 19:59 编辑
回复 8# yfjelley
ifeq ifneq等语句是预编译的,我的理解不能用在执行的时候 我试了一些办法 还是不行
特别注意的是,make 是在读取 Makefile 时就计算条件表达式的值,并根据条件表达式
的值来选择语句,所以,你最好不要把自动化变量(如“$@”等)放入条件表达式中,因为
自动化变量是在运行时才有的。 --摘自 《跟我一起学makefile》
foreach属于函数 只能放在运行的时候 但ifeq 等是在makefile读入时计算,所以这样思路是错的
我以前写过一个类似的,是这样写的:
depend = $(shell cat depend.list)
make = make -C $(1) $(EX_MAKEFLAG)
make_clean = make clean -C $(1) $(EX_MAKEFLAG)
#对同名的裤(包含不同平台的)拷贝会出问题
ifeq ($(lib),"so")
lib=so
else
lib=a
endif
# make += && cp `find $(1) -name *.$(lib)` ./
make += || echo -e '\e[31m'!!!!!!!ERROR!!!!!!! when excute `pwd`/$1/Makefile '\e[m';
make_clean +=;
excute_make_cmd = $(foreach name, $(depend), $(call make,$(name)))
excute_make_clean_cmd = $(foreach name, $(depend), $(call make_clean,$(name)))
all:
$(excute_make_cmd) |
|