gpt4 book ai didi

makefile - 隐式 Makefile 目标

转载 作者:行者123 更新时间:2023-12-04 06:23:49 24 4
gpt4 key购买 nike

http://www.cprogramming.com/tutorial/makefiles_continued.html解释隐式目标:

There are some actions that are nearly ubiquitous: for instance, you might have a collection of .c files that you may wish to execute the same command for. Ideally, the name of the file would be the target; using the implicit target ".c" you can specify a command to execute for any target that corresponds to the name of a .c file (minus the .c extension).



但是,当我尝试时,隐式目标被简单地忽略了。我的测试makefile如下:
Default: Foo.bar
echo "In default."

.bar:
echo "In .bar."
make: *** No rule to make target `Foo.bar', needed by `Default'.  Stop.

我错过了什么?

最佳答案

尝试:

default: foo.bar
echo "In default."

%.bar:
echo "In .bar."

您可能会询问旧式后缀规则 - 例如这个规则:
.c.o:
cc -c $<

告诉 make 如何从 .c 源构建 .o 文件。带有 '%' 的形式被称为模式规则,更“现代”。我建议你阅读 GNU Make manual ,这是关于此类内容的非常有用的信息,并且易于阅读。

关于makefile - 隐式 Makefile 目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6252437/

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