楼主:
sshc (My Chemical Romance)
2020-03-09 14:48:00在makefile撰写上遇到了一个问题,以下是我makefile内的一段程式
define collect-names:
cd $1; \
shopt -s nullglob; \
for f1 in $(foreach sub_dir,$2,'(sub_dir)'); do \
echo "Collect Files from...$1$$f1"; \
for f2 in $(foreach file_ext,$3,'$(file_ext)'); do \
echo "**Collect File Type : *$$f2"; \
files=( `echo$$f1$/*$(if $$f2,$$f2)` ); \
if (( $${#files[@] >0} )); \
then \
printf '"%s"\n' $${fiels[@]}; \
fi; \
echo ""; \
done \
done
endef
all:
@$(call collect-names,/root_dir/,sub_dir1/ sub_dir2/,.v .sv)
但是我发现如果将第二层for loop内的 echo ""; \
往上移至第一层for loop内,如下所示
define collect-names:
cd $1; \
shopt -s nullglob; \
for f1 in $(foreach sub_dir,$2,'(sub_dir)'); do \
echo "Collect Files from...$1$$f1"; \
for f2 in $(foreach file_ext,$3,'$(file_ext)'); do \
echo "**Collect File Type : *$$f2"; \
files=( `echo$$f1$/*$(if $$f2,$$f2)` ); \
if (( $${#files[@] >0} )); \
then \
printf '"%s"\n' $${fiels[@]}; \
fi; \
done \
echo ""; \
done
endef
all:
@$(call collect-names,/root_dir/,sub_dir1/ sub_dir2/,.v .sv)
程式便会产生error,想请问这是什么缘故呢?
谢谢各位