Subject: Re: Communicating Variables to a Sub-make
To: None <netbsd-users@netbsd.org>
From: Petar Bogdanovic <list+2007@smokva.net>
List: netbsd-users
Date: 11/06/2007 22:41:45
On Tue, Nov 06, 2007 at 09:57:03PM +0100, Petar Bogdanovic wrote:
> On Sun, Nov 04, 2007 at 11:01:57PM +0100, Petar Bogdanovic wrote:
> > Hi,
> >
> > the GNU-make syntax of exporting make-variables to a submake or a
> > subshell looks like:
> >
> > export variable = value
> >
> > or
> >
> > variable = value
> > export variable
> >
> >
> > Is something similar possible with NetBSD make?
>
> Somebody just pointed this out (man make):
>
> variable=value
> Set the value of the variable variable to value. Normally, all
> values passed on the command line are also exported to sub-makes
> in the environment. The -X flag disables this behavior. Vari-
> able assignments should follow options for POSIX compatibility
> but no ordering is enforced.
>
>
> That doesn't seem to be valid for the environment of subshells, but
> one apparently could do something like this:
>
> $ cat makefile
> show:
> @./s.sh
> $ cat s.sh
> #!/bin/sh
> echo MYVAR: ${MYVAR-unset}
> $ make -f makefile
> MYVAR: unset
> $ make -f makefile MYVAR=test
> MYVAR: test
Eh, this was pretty inconsistent.
If you want to export a variable to a sub-(make|shell) in bmake you can
pass it on the command line or `.export' it with a newer bmake.
End of my lame monologue. ;)