[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
pattern rules and pattern-specific-variables problem
From: |
Shawn Halpenny |
Subject: |
pattern rules and pattern-specific-variables problem |
Date: |
Sun, 14 Aug 2005 19:04:59 -0400 |
Something's not right with pattern-rule-specific variables in make 3.81beta3:
$ ls
makefile
makefile.good
$ cat makefile
.PHONY: all dbg nondbg
all: blah.cpp dir/dbg/blah.o dir/blah.o
blah.cpp: ; touch $@
dbg: ; echo dbg
nondbg: ; echo nondbg
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 $@
.PRECIOUS: %/.
%/.: ; mkdir -p $*
$ make-3.81beta3
touch blah.cpp
echo dbg
mkdir -p dir/nondbg
echo dbg-V:dir/nondbg; touch dir/dbg/blah.o
echo nondbg
echo nondbg-V:dir/nondbg; touch dir/blah.o
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).
The nasty thing is, if you reverse the order of the dbg and nondbg
pattern rules in the makefile, you get the proper behavior:
$ cat makefile.good
.PHONY: all dbg nondbg
all: blah.cpp dir/dbg/blah.o dir/blah.o
blah.cpp: ; touch $@
dbg: ; echo dbg
nondbg: ; echo nondbg
dir/%.o : V = dir/nondbg
dir/%.o : %.cpp | $$(V)/. nondbg ; echo nondbg-V:$(V); touch $@
dir/dbg/%.o : V = dir/dbg
dir/dbg/%.o : %.cpp | $$(V)/. dbg ; echo dbg-V:$(V); touch $@
.PRECIOUS: %/.
%/.: ; mkdir -p $*
$ make-3.81beta3 -f makefile.good
touch blah.cpp
echo dbg
mkdir -p dir/dbg
echo dbg-V:dir/dbg; touch dir/dbg/blah.o
echo nondbg
mkdir -p dir/nondbg
echo nondbg-V:dir/nondbg; touch dir/blah.o
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.
I found this surprising enough to file bug 14126:
https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=14126
--
Shawn Halpenny
- pattern rules and pattern-specific-variables problem,
Shawn Halpenny <=
- Re: pattern rules and pattern-specific-variables problem, Boris Kolpackov, 2005/08/15
- 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