Makefile顺序执行 [英] Makefile sequential execution
本文介绍了Makefile顺序执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下Makefile:
I have the following Makefile:
all: generate print # <-- doesn't work
date:
date > date.txt
ls:
ls -la > ls.txt
generate: ls date
print: *.txt
cat $^
clean:
rm *.txt
目标 date 和 ls 分别生成一个文件,目标 print 将其打印出来.
The targets date and ls generate a file each, the target print, prints them out.
如何编写目标 all ,以便它先 生成文件,然后然后打印?
How do I write the target all, so that it first generates the files and then prints it?
推荐答案
只需添加管道符号:
all: | generate print
从制作手册:>
可以通过在先决条件列表中放置管道符号(|
)来指定仅订购的先决条件.右侧的所有先决条件都是仅可订购的:
Order-only prerequisites can be specified by placing a pipe symbol (
|
) in the prerequisites list: any prerequisites to the left of the pipe symbol are normal; any prerequisites to the right are order-only:
targets : normal-prerequisites | order-only-prerequisites
这篇关于Makefile顺序执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文