我的Makefile中有以下代码:
Target0: Deps0
Common Rule to build Target
Target1: Deps1
Common Rule to build Target
...
我的问题是,由于所有目标都有一个共同的规则,有没有办法将目标组合成一个目标并指定目标特定的依赖关系?
答案 0 :(得分:2)
请参阅Multiple Targets in a Rule:
中的Multiple Rules for One Target和GNU Make Manual$ cat Makefile.common
all: Target0 Target1
Target0: Deps0
Target1: Deps1
Deps%:
@echo 'Making $@'
Target0 Target1:
@echo 'Making $@ from $^'
$ make -f Makefile.common
Making Deps0
Making Target0 from Deps0
Making Deps1
Making Target1 from Deps1