[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pattern rules and pattern-specific-variables problem
From: |
Boris Kolpackov |
Subject: |
Re: pattern rules and pattern-specific-variables problem |
Date: |
Mon, 15 Aug 2005 13:21:55 +0000 (UTC) |
User-agent: |
nn/6.6.5+RFC1522 |
Shawn,
Shawn Halpenny <address@hidden> writes:
> dir/dbg/%.o : V = dir/dbg
> dir/dbg/%.o : %.cpp | $$(V)/. dbg ; echo dbg-V:$(V); touch $@
>
> dir/%.o : V = dir/nondbg
> dir/%.o : %.cpp | $$(V)/. nondbg ; echo nondbg-V:$(V); touch $@
>
>
> The value of V seems to come from the nondbg pattern rule, although
> the dbg pattern rule's commands are executed. I think this is also
> why there is no 'mkdir -p dir/dbg' when there should be (because the
> order-only 'dbg' prerequisite was run).
GNU make "gathers" variables in the order they appear in the makefile.
In this case the second definition of patter-specific variable V
overrides the first one.
> This is a serious problem for non-recursive make scenarios that make
> extensive use of pattern rules for commands to build objects from
> source in various subdirectories, because the pattern-specific
> variable values that are used depend on the order of the rules.
Agree. You can fix this in your particular case by rewriting the makefile
like this:
dir/%.o : V = dir/nondbg
dir/dbg/%.o : V = dir/dbg
dir/dbg/%.o : %.cpp | $$(V)/. dbg ; echo dbg-V:$(V); touch $@
dir/%.o : %.cpp | $$(V)/. nondbg ; echo nondbg-V:$(V); touch $@
In other words, you need to write the most specialized variable definitions
last and the most specialized rules first.
Some time ago I proposed changing pattern rules selection algorithm from
picking the first applicable rule to picking the most specialized one
(formally, the one with the shortest stem). I guess this will also be
useful (or even more so) for pattern-specific variables.
> I found this surprising enough to file bug 14126:
> https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=14126
Thanks, I will add a comment.
hth,
-boris
- pattern rules and pattern-specific-variables problem, Shawn Halpenny, 2005/08/14
- Re: pattern rules and pattern-specific-variables problem,
Boris Kolpackov <=
- Re: pattern rules and pattern-specific-variables problem, Shawn Halpenny, 2005/08/15
- Re: pattern rules and pattern-specific-variables problem, Boris Kolpackov, 2005/08/16
- Re: pattern rules and pattern-specific-variables problem, Paul D. Smith, 2005/08/21
- Re: pattern rules and pattern-specific-variables problem, Shawn Halpenny, 2005/08/22
- Re: pattern rules and pattern-specific-variables problem, Paul D. Smith, 2005/08/22
- Re: pattern rules and pattern-specific-variables problem, Boris Kolpackov, 2005/08/22
- Re: pattern rules and pattern-specific-variables problem, Paul D. Smith, 2005/08/22
- Re: pattern rules and pattern-specific-variables problem, Boris Kolpackov, 2005/08/23
- Re: pattern rules and pattern-specific-variables problem, Paul D. Smith, 2005/08/24
- Re: pattern rules and pattern-specific-variables problem, Greg Chicares, 2005/08/24