On Tue, 2010-11-09 at 15:47 +0100, Rafaël Carré wrote:
> Hello,
> 
> I believe I've found a bug in make 3.81, or at least some confusing
> behaviour.
> 
> Here is a comparison of GNU make and netbsd 'pmake'
> 
> A-$(X) isn't expanded to "A-1" because of the comment on the line where
> X is set, although X is set to "1"

X is not set to "1".  It's set to "1 " (note trailing space).  This is
documented and required by the POSIX standard: trailing whitespace on a
variable assignment is preserved.

> % cat Makefile 
> X = 1 #comment
> Y = 1
> A-$(X) = a
> B-$(Y) = b
> 
> all:
>       @echo $(X) $(A-1)
>       @echo $(Y) $(B-1)

It's a hugely bad idea to use simple "echo" when trying to see values,
because the shell will eat whitespace differences.  You should quote the
values and add characters before and after, like this:

all:
        @echo '|$(X)|   |$(A-1)|'
        @echo '|$(Y)|   |$(B-1)|'

then you will immediately see the difference.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psm...@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to