[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make bug or feature
From: |
Paul D. Smith |
Subject: |
Re: make bug or feature |
Date: |
Thu, 24 Apr 2003 23:35:50 -0400 |
%% Debjani Saha <address@hidden> writes:
ds> The following is a bug which was reported and i came across this
ds> in the GNU make bug list. I am having a the same problem in
ds> solaris 2.8 systems and i am not able to figure out why. Could you
ds> explain why make behaves this way ?
Not sure which part of the message is the "this way" you are talking
about, so I can't say.
ds> [/tmp]% cat Makefile1
ds> all: $(FOO)
ds> @echo abcde
ds> [/tmp]% make-3.80rc1/make -f Makefile1
ds> abcde
ds> (description)
ds> The above makefile is somewhat erroneous, but `make' does
ds> not print a warning message by default.
It is not in any way erroneous. It could well be exactly what you
wanted. The POSIX standard for make requires that unset variables
expand into empty strings and there is no version of make anywhere which
will warn about this by default.
ds> [/tmp]% cat Makefile2
ds> MAKEFLAGS := --warn-undefined-variables
ds> all: $(FOO)
ds> @echo abcde
ds> [/tmp]% make-3.80rc1/make -f Makefile2
ds> abcde
ds> (description)
ds> `make' does not print a warning message when I specify
ds> --warn-undefined-variables option via the MAKEFLAGS
ds> variable in the makefile. Hmmm....
Make parses the contents of MAKEFLAGS twice: once before any makefiles
are read, and once after all the makefiles are read. It does not
re-parse MAKEFLAGS every time the contents of MAKEFLAGS are changed
while the makefiles are being read.
So, by the time make realizes that this option is specified it's already
read in all the makefiles and expanded the variable $(FOO) in the
prerequisites list.
If you were to write this:
MAKEFLAGS := --warn-undefined-variables
all:
@echo $(FOO)
Then make would warn about _that_ use of $(FOO), because it is not
expanded until make runs the "all" rule.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist