[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: do I have to use recursive make to make one target fall on another?
From: |
Eli Zaretskii |
Subject: |
Re: do I have to use recursive make to make one target fall on another? |
Date: |
Fri, 02 Mar 2012 11:12:24 +0200 |
> From: "Mark Galeck (CW)" <address@hidden>
> Date: Fri, 2 Mar 2012 00:31:33 -0800
>
> I have two goals: goal1 and goal2, and they are both made by the recipe for
> goal2 (goal1 as a side effect). I know this recipe does not follow Paul's
> rules of makefiles, but I can't change it.
>
> What I need to do, is to efficiently accommodate both goals. That means,
> whether goal1, goal2, or both are given on the command line, there should be
> only one call to the recipe for goal2.
> [...]
> What to do? I can't change the rest - the rule for goal2, or the implicit
> rules. I have to add something for goal1, that is as fast as possible in all
> cases. Do I really have to use recursion??
If goal1 and goal2 have something common in their names, you can use
pattern rules. This is from the GNU Make manual:
This pattern rule has two targets:
%.tab.c %.tab.h: %.y
bison -d $<
This tells `make' that the recipe `bison -d X.y' will make both
`X.tab.c' and `X.tab.h'. If the file `foo' depends on the files
`parse.tab.o' and `scan.o' and the file `scan.o' depends on the file
`parse.tab.h', when `parse.y' is changed, the recipe `bison -d parse.y'
will be executed only once, and the prerequisites of both `parse.tab.o'
and `scan.o' will be satisfied. (Presumably the file `parse.tab.o'
will be recompiled from `parse.tab.c' and the file `scan.o' from
`scan.c', while `foo' is linked from `parse.tab.o', `scan.o', and its
other prerequisites, and it will execute happily ever after.)