在makefile中,将伪造目标声明为通配符 [英] in a makefile, declaring a phony target as a wildcard
问题描述
我想将通配符目标声明为phony,但是phony不支持通配符:
I want to declare my wildcard target as phony, but phony doesn't support wildcards:
我的制作文件:
%.config:
gcc <<compile>>
我希望用户能够使用特定配置文件使用我的makefile来编译项目:
I want the user to be able to use my makefile to compile the project, using a specific configuration file:
make something.config
make something_else.config
显然,由于目标文件存在,我需要我的目标是虚假的,但只需编写:
obviously, I need my target to be phony, becuase the target files exist, but simply writing:
.PHONY: %.config
不起作用. 我已经此处看到,makeapp支持另一种语法,这将有所帮助:
doesn't work. I've seen here that makeapp supports another syntax, that would help:
$(phony %.config): ...
但是我只能使用make,不能使用makeapp.
but I can only use make, and not makeapp.
有什么办法可以用make吗?
Is there any way to do it with make?
推荐答案
这些是相互矛盾的目标.虚假目标是与真实文件不对应的目标.就您而言,该文件存在,但实际上并不是目标.
These are conflicting aims. A phony target is one that doesn't correspond to a real file. In your case, the file exists, but it's not really a target.
我建议不要将配置文件的名称用作目标.相反,应基于以下条件之一构建系统:
I would suggest not using the name of the config file as the target. Instead, construct a system based on one of the following:
make something_else
make CONFIG=something_else.config
这篇关于在makefile中,将伪造目标声明为通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!