gpt4 book ai didi

Makefile顺序执行

转载 作者:行者123 更新时间:2023-12-03 03:19:12 25 4
gpt4 key购买 nike

我有以下 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

目标datels分别生成一个文件,目标print将它们打印出来。

如何编写目标全部,以便它首先生成文件,然后然后打印它?

最佳答案

只需添加管道符号:

all: | generate print

来自make manual :

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顺序执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22630996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com