我试图通过 makefile 循环访问特定目录中的 .c 文件。
我使用了以下代码,但它似乎不起作用:
DIR= Sources \
Sources_2
@for entry in ${DIR} ; \
do \
@for i in $${entry}/*.c ; \
do \
echo "Processing $${i}"; \
#Building Commands go here
done \
done
Run Code Online (Sandbox Code Playgroud)
我收到错误:“/bin/sh: -c: 第 3 行:意外标记 `do' 附近出现语法错误”
您不应该@在第二个for循环附近使用 at 符号。@应该在整个 shell 命令的开头使用。以下对我有用:
DIR= Sources \
Sources_2
all:
@for entry in ${DIR}; \
do \
for i in $${entry}/*.c; \
do \
echo "Processing $${i}"; \
done \
done
Run Code Online (Sandbox Code Playgroud)