用户工具

站点工具


语法:makefile

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
语法:makefile [2026/08/29 13:47] – [根据文件内容循环执行] user01语法:makefile [2026/08/29 13:59] (当前版本) – [2. 根据文件内容循环执行] user01
行 12: 行 12:
  
 ===== - 根据文件内容循环执行 ===== ===== - 根据文件内容循环执行 =====
 +根据gen.txt文件内容,在makefile中循环执行。
  
 +输入文件:
 <code> <code>
 > cat gen.txt  > cat gen.txt 
行 18: 行 20:
 </code> </code>
  
-<code> +Makefile文件: 
-run:+<code cmake> 
 +run1:
  @line=$$(head -n1 gen.txt); \  @line=$$(head -n1 gen.txt); \
  tile_list=$$(echo "$$line" | awk '{for(i=3;i<=NF;i++) printf " %s", $$i}'); \  tile_list=$$(echo "$$line" | awk '{for(i=3;i<=NF;i++) printf " %s", $$i}'); \
行 26: 行 29:
  done  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>
  
 执行结果: 执行结果:
 <code> <code>
-> make+> make run1
 process tile: a process tile: a
 process tile: b process tile: b
 process tile: c 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> </code>
  
语法/makefile.1787982436.txt.gz · 最后更改: 2026/08/29 13:47 由 user01

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki