summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2008-03-05 20:11:04 +0000
committeryar <yar@FreeBSD.org>2008-03-05 20:11:04 +0000
commit4905cb8cf9a7c31fd18e562cf1ceb0ea589a2cc0 (patch)
tree4609d400c4fc65fc29466c452a6a7f3c3a4b18c8 /usr.bin
parent31c0a6bb3195f67b0aa31617153cd7119743dc58 (diff)
downloadFreeBSD-src-4905cb8cf9a7c31fd18e562cf1ceb0ea589a2cc0.zip
FreeBSD-src-4905cb8cf9a7c31fd18e562cf1ceb0ea589a2cc0.tar.gz
Don't forget to set MAKEFLAGS in the childs' environment
from the .MAKEFLAGS global variable even if it's empty or unset. This means setting MAKEFLAGS to just an empty string in the latter case. If not doing so, make(1) behaved inconsistently WRT MAKEFLAGS. In particular, it would let a `-f foo' option down to sub-makes if .MAKEFLAGS was unset. E.g., env MAKEFLAGS="-f mymakefile" make would pass `-f mymakefile' down to sub-makes via their environment (unless mymakefile added something to .MAKEFLAGS). But any additional options appearing would change this behaviour to not passing `-f mymakefile' to sub-makes, as in: env MAKEFLAGS="-f mymakefile" make -D DUMMY or env MAKEFLAGS="-f mymakefile -D DUMMY" make (unless mymakefile cleared .MAKEFLAGS). Also make(1) would leave MAKEFLAGS at its initial value if the makefile set .MAKEFLAGS to an empty value. I.e., it was impossible to override MAKEFLAGS with an empty value. (Note well that makefiles are not to touch MAKEFLAGS directly, they alter .MAKEFLAGS instead. So make(1) can filter out things such as -f when copying MAKEFLAGS to .MAKEFLAGS at startup. Direct modifications to MAKEFLAGS just go nowhere.) While the original intentions of the BSD make authors are somewhat unclear here, the bug proves that NOT passing -f options down is the settled behaviour because the opposite behaviour is totally unreliable in the presence of any other options. In addition, not passing down -f's found in the environment is consistent with doing so WRT the command line. Update the manpage accordingly and make the whole description of MAKEFLAGS and .MAKEFLAGS more consistent as this change indeed brings more consistency into the reliable behaviour of make(1). Submitted by: ru (main.c) Tested with: make world
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/main.c2
-rw-r--r--usr.bin/make/make.164
2 files changed, 35 insertions, 31 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 9fde441..a296b2b 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1188,6 +1188,8 @@ main(int argc, char **argv)
/* Install all the flags into the MAKE envariable. */
if (((p = Var_Value(".MAKEFLAGS", VAR_GLOBAL)) != NULL) && *p)
setenv("MAKEFLAGS", p, 1);
+ else
+ setenv("MAKEFLAGS", "", 1);
/*
* For compatibility, look at the directories in the VPATH variable
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 1d52291..f17ab88 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -32,7 +32,7 @@
.\" @(#)make.1 8.8 (Berkeley) 6/13/95
.\" $FreeBSD$
.\"
-.Dd March 4, 2008
+.Dd March 5, 2008
.Dt MAKE 1
.Os
.Sh NAME
@@ -648,7 +648,7 @@ last word in this variable.
.It Ev MAKEFLAGS
The environment variable
.Ev MAKEFLAGS
-may contain anything that
+may initially contain anything that
may be specified on
.Nm Ns 's
command line,
@@ -668,6 +668,29 @@ are appended to the
.Va .MAKEFLAGS
variable.
.Pp
+Whenever
+.Nm
+executes a program, it sets
+.Ev MAKEFLAGS
+in the program's environment to the current value of the
+.Va .MAKEFLAGS
+global variable.
+Thus, if
+.Ev MAKEFLAGS
+in
+.Nm Ns 's
+environment contains any
+.Fl f
+options, they will not be pushed down to child programs automatically.
+The
+.Nm
+utility effectively filters out
+.Fl f
+options from the environment and command line although it
+passes the rest of its options down to sub-makes via
+.Ev MAKEFLAGS
+by default.
+.Pp
When passing macro definitions and flag arguments in the
.Ev MAKEFLAGS
environment variable,
@@ -694,9 +717,15 @@ global variable, the makefile can alter the contents of the
environment variable made available for all programs which
.Nm
executes.
-(This includes adding
+This includes adding
.Fl f
-option(s).)
+option(s).
+The current value of
+.Va .MAKEFLAGS
+is just copied verbatim to
+.Ev MAKEFLAGS
+in the environment of child programs.
+.Pp
Note that any options entered to
.Va .MAKEFLAGS
neither affect the current instance of
@@ -718,33 +747,6 @@ children.
Compare with the
.Ic .MAKEFLAGS
special target below.
-.Pp
-To sum up what was said on
-.Fl f :
-It can appear in
-.Ev MAKEFLAGS
-and affect the current
-.Nm
-only if inherited from
-.Nm Ns 's
-initial environment.
-At the same time, a
-.Fl f
-option from
-.Nm Ns 's
-command line
-does affect
-.Nm ,
-but it is never transferred to
-.Va .MAKEFLAGS
-or pushed down to child programs such as sub-makes.
-Finally,
-.Fl f
-can appear in
-.Va .MAKEFLAGS
-only if added by the makefile itself;
-it will affect sub-makes only, via
-.Ev MAKEFLAGS .
.It Va MFLAGS
This variable is provided for backward compatibility and
contains all the options from the
OpenPOWER on IntegriCloud