子目录./test1/test9 ./test1/test6含有两个正确的makefile
1 SUBDIRS:=./test1/test9 ./test1/test6
2 subdirs:
3 for dir in $(SUBDIRS);do\
4 $(MAKE) -C $$dir;\
5 done
make之后:
for dir in ./test1/test9 ./test1/test6;do
/bin/sh: 1: Syntax error: end of file unexpected
makea:3: recipe for target 'subdirs' failed
make: *** [subdirs] Error 2
SUBDIRS:=./test1/test9 ./test1/test6
当在for循环中取SUBDIRS变量时,会把“./test1/test9 ./test1/test6”当成一个完整的变量,
make -C $$dir -> make -C ./test1/test9 ./test1/test6
所以在for循环使用的时候需要将SUBDIRS变量拆分一下:
for dir in echo $(SUBDIRS) | cut -d'<空格>' -f 1-
; \
do \
make -C $$dir; \
done \