I want to wite a makefile rule for a case, whe开发者_开发知识库re files of type .bbb and .ccc are compiled into .aaa.
I could simply write two rules:
%.aaa: %.bbb
process $<
%.aaa: %.ccc
process $<
but I'm wodering whether this could be accomplished in one rule, such as:
%.aaa: %.bbb OR %.ccc
process $<
Note that only one of the files bbb or ccc is enough for compilation, and in my case, only one exists (so either x.bbb OR x.ccc, not both).
The first way is how you express this. All makefile rules are implicitly ored together. Saying you can create %.aaa from either %.bbb or %.ccc is the same as saying you can create %.aaa from %.bbb and you can create %.aaa from %.ccc.
If the body of the rule is complex and you want to "reuse the body", many makes have macro facilities that will let you define it one place and reuse it.
精彩评论