cvs commit: src/share/mk bsd.obj.mk

Ruslan Ermilov ru at FreeBSD.org
Thu Jan 8 08:26:06 PST 2004


On Thu, Jan 08, 2004 at 11:07:52AM -0500, Brian F. Feldman wrote:
> Ruslan Ermilov <ru at FreeBSD.org> wrote:
> > On Wed, Jan 07, 2004 at 03:41:03PM -0500, Brian F. Feldman wrote:
> > > Ruslan Ermilov <ru at FreeBSD.org> wrote:
> > > > On Thu, Jan 01, 2004 at 09:05:48PM -0800, Brian Feldman wrote:
> > > > > green       2004/01/01 21:05:48 PST
> > > > > 
> > > > >   FreeBSD src repository
> > > > > 
> > > > >   Modified files:
> > > > >     share/mk             bsd.obj.mk 
> > > > >   Log:
> > > > >   Fix a very corner case when you want to make cleandir SUBDIRs which
> > > > >   are built using a ${MAKE} that's not just "make".
> > > > >   
> > > > >   Test by:        make universe (followed by cleandirs)
> > > > >   
> > > > >   Revision  Changes    Path
> > > > >   1.49      +2 -2      src/share/mk/bsd.obj.mk
> > > > > 
> > > > The old version used ${MAKE}, why this was a problem at all?
> > > 
> > > The ${MAKE} that it uses would be overridden by the default ${MAKE} value 
> > > each time; this doesn't occur when dependencies are executed, though.
> > > 
> > Please explain in more detail.  With the below makefile,
> > 
> > : all:
> > : 	@cd ${.CURDIR}; ${MAKE} print-make
> > : 
> > : print-make:
> > : 	@echo ${MAKE}
> > 
> > running /usr/bin/make will rightfully print "/usr/bin/make".
> > make(1)'s main() always sets MAKE to argv[0] as its first task.
> 
> Here is the difference in behavior:
> 
> {"/home/green/tmp/x"}$ make print-make all
> make
> make
> {"/home/green/tmp/x"}$ make MAKE='/usr/bin/make -DNONDEF' print-make all
> /usr/bin/make -DNONDEF
> /usr/bin/make
> 
You aren't supposed to set the ${MAKE} variable manually --
it's automatically set by make(1) to the argv[0] value.  By
using it the way you show, you risk because there are four
different types of make variables, and while you set the
command-line type "MAKE" variable, make(1) will set the
global "MAKE" variable to "make":

: $ make MAKE='/usr/bin/make -DFOO' print-make
: /usr/bin/make -DFOO
: $ make MAKE='/usr/bin/make -DFOO' -V MAKE
: make

If you really need to access command-line arguments, there
is the .MAKEFLAGS variable available for that purpose.

But why do you need to ``make MAKE='/usr/bin/make -DFOO' bar''
in the first place instead of simple ``make -DFOO bar''?  If
"bar" is recursive (i.e., runs ${MAKE} subprocesses), then
-DFOO will be properly propagated:

: $ cat Makefile
: all:
: 	@cd ${.CURDIR}; ${MAKE} print-make
: 
: print-make:
: 	@echo ${FOO}
: $ make -DFOO
: 1


Cheers,
-- 
Ruslan Ermilov
FreeBSD committer
ru at FreeBSD.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-all/attachments/20040108/ee6dc278/attachment.bin


More information about the cvs-all mailing list