[comp.sys.next] /bin/make: possible bug in nested macro expansion??

simon@mmpe.mineral.ualberta.ca (Simon Tortike) (03/15/91)

I have been preparing a makefile that can choose the right compiler options
depending on the exported host variable HOSTTYPE, so I can compile directly
on the Sun or the NeXT which share that disk. A simple makefile is as follows:

FFLAGS-sun3= -g -f68881
FFLAGS-sparc= -g
FFLAGS-NeXT= -f -g
FFLAGS=${FFLAGS-$(HOSTTYPE)}

all:
        f77 $(FFLAGS) fooxxx.f

Now, $(FFLAGS) is expanded correctly in this version.  However, it
did not work right on the NeXT at
first because its make was unwilling to expand the nested macro correctly
if the embedding was done only in normal brackets $($()).  It ignored the
last bracket and left it in the makefile output!  Oddly enough, it would expand
$($() without any problem, despite the unbalanced parenthesis.  Needless,
to say, the Sun make did not like this disturbance in the karma.  The NeXT
make could expand ${$()} without making a mistake, and is what you see in
the final version.

Has anyone noticed this behaviour before, and is it a bug or a correct
consequence of the rules of make?
--
W. Simon Tortike,                   | tel     : 403/492-3338
Dept of Mining, Metallurgical       | fax     : 403/492-7219
      and Petroleum Engineering,    |
University of Alberta,              | CA*net  : simon@mmpe.mineral.UAlberta.CA
Edmonton, AB, CANADA T6G 2G6.       | NeXTmail: simon@nawab.mineral.UAlberta.CA