Summary of answers: feeding CFLAGS of "make CFLAGS=-g" to sub-makes

Arthur David Olson ado at elsie.UUCP
Tue Jan 6 10:05:32 AEST 1987


Thanks to everyone who replied to my question about how to ensure that
"arguments" such as "CFLAGS=-g" in a command line such as

	make CFLAGS=-g whatever ...

get fed to recursively-invoked makes.

The bad news:  you can't ensure that the "CFLAGS=-g" value gets fed to
sub-makes if you use a command line of the above form.

The good news:  if you're using a recent (System V) version of "make",
and you're a "sh" user, you can use a command such as

	CFLAGS=-g make whatever ...

to get the desired effect--since the
	
	CFLAGS=-g

precedes the word "make", it gets put in the environment; System V make
(and in particular, sub-makes) looks in the environment for variables.

More bad news:  4.xBSD systems come with a version of make that doesn't
look through the environment for variable values.

Mixed news:  MORE/bsd 4.3 systems come with /usr/5bin/make,
a version of make derived from System V that runs under BSD.
This version does pay attention to the environment.
But even with a MORE/bsd source license, you don't get /usr/5bin/make source.
Still, if you're willing to run an unmaintainable program, you can follow the
directions in the Mt. Xinu documentation and use /usr/5bin/make.

Final news:  if you're on a straight BSD system (or are on a MORE/bsd system
and are unwilling to run an unmaintainable program) and you're a "sh" user,
putting this script in your personal "bin" directory:

	#! /bin/csh -f

	exec /bin/make $*:q "`printenv`"

should allow you to use commands such as

	CFLAGS=-g make whatever ...

and get the desired effect.
--
UNIX is a registered trademark of AT&T.
--
	UUCP: ..decvax!seismo!elsie!ado   ARPA: elsie!ado at seismo.ARPA
	DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.



More information about the Comp.unix.questions mailing list