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 _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
