SHELL语句中不能用Makefile的函数(如dir, notdir, basename 等),这些函数不能返回正确的结果,需要用相应的Shell命令代替。比如下面的的函数是错误的 define GET_NAME for i in dir1/file1 /path/to/dir2/file2; do R=$(dir "$$i") && echo $$R; done for i in dir1/file1 /path/to/dir2/file2; do R=$(basename "$$i") && echo $$R; done endef 应该替换成 define GET_NAME
define GET_NAME for i in dir1/file1 /path/to/dir2/file2; do
R=`dirname "$$i"` && echo $$R; done for i in dir1/file1
/path/to/dir2/file2; do R=`basename "$$i"` && echo $$R; done
endef
eg: define BUILD for i in ${1}; do \
echo $${i}; \ $(GCC) -c ${{i}}; \ done endef
define
CREATE_PATH for d in `echo $1 | sed 's/\//\n/g'`; do \
if [ -n $d ]; then \ if [ -z $${tmpPath} ]; then\
tmpPath=$$d; \ else \
tmpPath=$$tmpPath/$$d; \ fi; \