Tue 14 Jun 2005 03:08:58 PM UTC, original submission:
The documentation for the MAKEFILES variable says "the default goal is never
taken from one of these makefiles". The set of makefiles described below
demonstrate that if a file in MAKEFILES includes another file which contains a
goal definition, that goal gets used as the default goal. While the
documentation for MAKEFILES doesn't explicitly discuss this situation, I think
the present behavior is certainly contrary to reasonable expectations.
To test, create separate files from the makefiles described below, all in a
single directory, and invoke make in that directory. The goal called
indirect_goal from include_bug_indirect.mk will be run, printing the message
"MAKEFILES indirectly included goal used as default."
The expected (and I believe correct behavior) is to instead run the all goal
from include_bug_recurse.mk, printing the message
"This should be the default goal."
The makefiles are:
---------- Makefile ----------
all: ; $(MAKE) -f include_bug_recurse.mk MAKEFILES=include_bug_include.mk
---------- include_bug_recurse.mk ----------
all: ; @echo This should be the default goal.
---------- include_bug_indirect.mk ----------
.PHONY: indirect_goal
indirect_goal: ; @echo MAKEFILES indirectly included goal used as default.
---------- include_bug_include.mk ----------
include include_bug_indirect.mk
---------- (end of makefiles) ----------
|