The info page (make)Setting says
> These two settings of the variable `FOO' are identical [snip]:
>
> FOO ?= bar
>
> and
>
> ifeq ($(origin FOO), undefined)
> FOO = bar
> endif
yet I had trouble with the former and not with the latter. It seems
that in the former syntax, `make' assigns the value verbatim, and the
reference is then expanded by the shell. Here's the broken behaviour:
$ cat Makefile
FOO ?= $(HOME)/etc
foo :
echo $(FOO)
$ make
echo $(HOME)/etc
/bin/sh: HOME: command not found
/etc
Notes: ${HOME} and $HOME worked, since the shell accepts them;
ordinary assignments FOO = $(HOME) and FOO = ${HOME} worked and FOO =
$HOME failed as expected.
Here's the working behaviour:
$ cat Makefile
ifeq ($(origin FOO), undefined)
FOO = $(HOME)/etc
endif
foo :
echo $(FOO)
$ make
echo /export/home/j/p/jpiitula/etc
/export/home/j/p/jpiitula/etc
The info page (make)Reference says,
> Variable references can be used in any context: targets,
> dependencies, commands, most directives, and new variable values.
so I don't think it should make any difference that the assigned value
depends on the value of a variable. "New variable values" mean the
right hand side of an assignment, right?
This is a Pentium II running a Red Hat that was current last August or
so. I don't think I have the config.h file.
$ uname -a
Linux linna 2.2.5-15 #1 Mon Apr 19 23:00:46 EDT 1999 i686 unknown
$ echo $SHELL
/bin/bash
$ make --version
GNU Make version 3.77, by Richard Stallman and Roland McGrath.
...
The manual says, This edition of the `GNU Make Manual', last updated
20 May 1998, documents GNU `make' Version 3.77.
(I tried to try it on an alpha with Make version 3.75, but it says
`foo' is up to date and doesn't exercise the relevant code at all.
Let me know if I can provide more detail.)
--
Jussi