Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Add a -X option, which prevents make(1) from pu...



details:   https://anonhg.NetBSD.org/src/rev/1cffc205fdbc
branches:  trunk
changeset: 544186:1cffc205fdbc
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Mar 14 05:19:43 2003 +0000

description:
Add a -X option, which prevents make(1) from putting variables
set on the command line into the environment individually.  This
can be useful on systems which have a tight limit on the size
of the argument space.

diffstat:

 usr.bin/make/main.c |  15 ++++++++++-----
 usr.bin/make/make.1 |  18 ++++++++++++++++--
 usr.bin/make/make.h |   5 ++++-
 usr.bin/make/var.c  |  15 +++++++++++----
 4 files changed, 41 insertions(+), 12 deletions(-)

diffs (163 lines):

diff -r e5c5a6ce2528 -r 1cffc205fdbc usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Mar 14 04:34:27 2003 +0000
+++ b/usr.bin/make/main.c       Fri Mar 14 05:19:43 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.86 2003/02/26 08:59:12 sjg Exp $    */
+/*     $NetBSD: main.c,v 1.87 2003/03/14 05:19:43 thorpej Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,7 +39,7 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: main.c,v 1.86 2003/02/26 08:59:12 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.87 2003/03/14 05:19:43 thorpej Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -51,7 +51,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.86 2003/02/26 08:59:12 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.87 2003/03/14 05:19:43 thorpej Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -141,6 +141,7 @@
 Boolean                        checkEnvFirst;  /* -e flag */
 Boolean                        parseWarnFatal; /* -W flag */
 Boolean                        jobServer;      /* -J flag */
+Boolean                        varNoExportEnv; /* -X flag */
 static Boolean         jobsRunning;    /* TRUE if the jobs might be running */
 static const char *    tracefile;
 static char *          Check_Cwd_av(int, char **, int);
@@ -178,9 +179,9 @@
 
        optind = 1;     /* since we're called more than once */
 #ifdef REMOTE
-# define OPTFLAGS "BD:I:J:L:NPST:V:Wd:ef:ij:km:nqrst"
+# define OPTFLAGS "BD:I:J:L:NPST:V:WXd:ef:ij:km:nqrst"
 #else
-# define OPTFLAGS "BD:I:J:NPST:V:Wd:ef:ij:km:nqrst"
+# define OPTFLAGS "BD:I:J:NPST:V:WXd:ef:ij:km:nqrst"
 #endif
 rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
                switch(c) {
@@ -261,6 +262,10 @@
                case 'W':
                        parseWarnFatal = TRUE;
                        break;
+               case 'X':
+                       varNoExportEnv = TRUE;
+                       Var_Append(MAKEFLAGS, "-X", VAR_GLOBAL);
+                       break;
                case 'd': {
                        char *modules = optarg;
 
diff -r e5c5a6ce2528 -r 1cffc205fdbc usr.bin/make/make.1
--- a/usr.bin/make/make.1       Fri Mar 14 04:34:27 2003 +0000
+++ b/usr.bin/make/make.1       Fri Mar 14 05:19:43 2003 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.74 2003/02/25 10:35:47 wiz Exp $
+.\"    $NetBSD: make.1,v 1.75 2003/03/14 05:19:43 thorpej Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -41,7 +41,7 @@
 .Nd maintain program dependencies
 .Sh SYNOPSIS
 .Nm
-.Op Fl BeikNnqrstW
+.Op Fl BeikNnqrstWX
 .Bk -words
 .Op Fl D Ar variable
 .Ek
@@ -233,11 +233,25 @@
 with a blank line for each null or undefined variable.
 .It Fl W
 Treat any warnings during makefile parsing as errors.
+.It Fl X
+Don't export variables passed on the command line to the environment
+individually.
+Variables passed on the command line are still exported
+via the
+.Va MAKEFLAGS
+environment variable.
+This option may be useful on systems which have a small limit on the
+size of command arguments.
 .It Ar variable=value
 Set the value of the variable
 .Ar variable
 to
 .Ar value .
+Normally, all values passed on the command line are also exported to
+sub-makes in the environment.
+The
+.Fl X
+flag disables this behavior.
 .El
 .Pp
 There are seven different types of lines in a makefile: file dependency
diff -r e5c5a6ce2528 -r 1cffc205fdbc usr.bin/make/make.h
--- a/usr.bin/make/make.h       Fri Mar 14 04:34:27 2003 +0000
+++ b/usr.bin/make/make.h       Fri Mar 14 05:19:43 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.44 2002/06/15 18:24:57 wiz Exp $    */
+/*     $NetBSD: make.h,v 1.45 2003/03/14 05:19:43 thorpej Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -336,6 +336,9 @@
 extern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are
                                 * treated as errors */
 
+extern Boolean varNoExportEnv; /* TRUE if we should not export variables
+                                * set on the command line to the env. */
+
 extern GNode    *DEFAULT;      /* .DEFAULT rule */
 
 extern GNode    *VAR_GLOBAL;           /* Variables defined in a global context, e.g
diff -r e5c5a6ce2528 -r 1cffc205fdbc usr.bin/make/var.c
--- a/usr.bin/make/var.c        Fri Mar 14 04:34:27 2003 +0000
+++ b/usr.bin/make/var.c        Fri Mar 14 05:19:43 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.70 2002/06/15 18:24:58 wiz Exp $     */
+/*     $NetBSD: var.c,v 1.71 2003/03/14 05:19:43 thorpej Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: var.c,v 1.70 2002/06/15 18:24:58 wiz Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.71 2003/03/14 05:19:43 thorpej Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.70 2002/06/15 18:24:58 wiz Exp $");
+__RCSID("$NetBSD: var.c,v 1.71 2003/03/14 05:19:43 thorpej Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -471,7 +471,14 @@
      */
     if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
 
-       setenv(name, val, 1);
+       /*
+        * If requested, don't export these in the environment
+        * individually.  We still put them in MAKEOVERRIDES so
+        * that the command-line settings continue to override
+        * Makefile settings.
+        */
+       if (varNoExportEnv != TRUE)
+           setenv(name, val, 1);
 
        Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
     }



Home | Main Index | Thread Index | Old Index