Makefile generating file with same name but by two different rules
I want to have makefile witch generate one file with two different rules. One for commend make aaa and another for make bbb. I have two files: 1.c and 2.c r开发者_StackOverflow中文版ule aaa need result.o generated from 1.c and bbb need result.o generated from 2.c
How to do that?
From the GNU Make documentation:
A "rule" appears in the makefile and says when and how to remake certain files, called the rule's "targets" (most often only one per rule). It lists the other files that are the "prerequisites" of the target, and "commands" to use to create or update the target.
That is, the purpose of make rules is to generate some target which usually is the result file from some operation - be it a stamp file signalling that a step has executed or an object file from a compilation.
What you want, generate a result.o
target for 2 different dependencies is just not exactly what make is intended to do.
What you can do, is generate targets 1.o
and 2.o
, which than get symlinked to result.o
in a higher-level rule. This means however, that rules aaa
and bbb
have to depend on 1.o
and 2.o
as they have to have separate targets (which coincidentally are the rule's names).
精彩评论