[英]Target substitution in Makefile
In a typical regression, there is a CATEGORY which is "basic" and a test-case "abc.c". 在典型的回归中,有一个“基本”类别和一个测试用例“ abc.c”。 To run a test "abc" in category "basic", the user has to key in:
要在类别“基本”中运行测试“ abc”,用户必须输入:
make basic_abc
Then the command should be: 然后,该命令应为:
basic_abc: abc.c
gcc -g -o abc abc.c
How can I write a rule, that WILL CHOP "basic_" in my $@. 我该如何写一条规则,该规则将在我的$ @中选择“ basic_”。 So that I can use the rule for all tests.
这样我就可以将规则用于所有测试。 In pseudo language, how can I get the above rule with pattern substitution
用伪语言,如何通过模式替换获得上述规则
basic_abc: $(patsubst .*_, " ", $@).c
gcc -g -o $(patsubst .*_, " ", $@) $(patsubst .*_, " ", $@).c
Do you mean like this? 你是这个意思吗
.PHONY: basic_%
basic_%: %.c
gcc -g -o $* $<
Make already knows how to compile a .c file, though. 但是,使Make知道如何编译.c文件。 From your question it would seem to make more sense for
basic_x
to depend on the compiled x
, and run it on a bunch of test cases in the recipe, but maybe I misunderstand your setup. 从您的问题来看,
basic_x
依赖于编译后的x
似乎更有意义,并在配方中的一堆测试用例上运行它,但是也许我误解了您的设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.