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 21:57:03
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


or install -current and use `.export':

http://mail-index.netbsd.org/source-changes/2007/10/05/0034.html


Regards,

Petar