语法:makefile
这是本文档旧的修订版!
makefile
1. for
<code c> NAME := a b c run:
@for tmp in $(NAME); do \ echo $$tmp; \ done
</code>
2. 根据文件内容循环执行
根据gen.txt文件内容,在makefile中循环执行。
输入文件: <code>
cat gen.txt
items = a b c </code>
Makefile文件: <code cmake> run1:
@line=$$(head -n1 gen.txt); \
tile_list=$$(echo "$$line" | awk '{for(i=3;i<=NF;i++) printf " %s", $$i}'); \
for tile in $$tile_list; do \
echo "process tile: $$tile"; \
done
ITEMS = $(shell head -n1 gen.txt | awk '{for(i=3;i<=NF;i++) printf “ %s”, $$i}') run2:
@for tile in $(ITEMS); do \ echo "process tile: $$tile"; \ done
ITEMS_3 = $(shell head -n1 gen.txt | awk '{for(i=3;i<=NF;i++) printf “%s”, $$i}') run3:
@for tile in $(ITEMS_3); do \ echo "process tile: $$tile"; \ done
ITEMS_4 = $(shell head -n1 gen.txt | awk '{for(i=3;i<=NF;i++) printf $$i}') run4:
@for tile in $(ITEMS_4); do \ echo "process tile: $$tile"; \ done
</code>
执行结果: <code>
make run1
process tile: a process tile: b process tile: c
make run2
process tile: a process tile: b process tile: c
make run3
process tile: abc
make run4
process tile: abc </code>
语法/makefile.1791900372.txt.gz · 最后更改: 由 127.0.0.1
