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 .export-env which tells make to export a va...



details:   https://anonhg.NetBSD.org/src/rev/4c97caa9909b
branches:  trunk
changeset: 755431:4c97caa9909b
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sun Jun 06 01:13:12 2010 +0000

description:
Add .export-env which tells make to export a variable to the environment
but not to track it - as is done for .export
This allows the variable to be updated without affecting what was put
into the environment.
Older versions of make will simply treat this as .export

diffstat:

 usr.bin/make/make.1 |  15 +++++++++++++--
 usr.bin/make/var.c  |  17 ++++++++++++-----
 2 files changed, 25 insertions(+), 7 deletions(-)

diffs (97 lines):

diff -r 69ba4e4625f6 -r 4c97caa9909b usr.bin/make/make.1
--- a/usr.bin/make/make.1       Sun Jun 06 00:00:33 2010 +0000
+++ b/usr.bin/make/make.1       Sun Jun 06 01:13:12 2010 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.172 2010/05/13 18:10:16 joerg Exp $
+.\"    $NetBSD: make.1,v 1.173 2010/06/06 01:13:12 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -791,8 +791,10 @@
 .Pp
 Variable expansion is performed on the value before it's used,
 so expressions such as
-.Dl ${.CURDIR:C,^/usr/src,/var/obj,}
+.Dl ${.CURDIR:S,^/usr/src,/var/obj,}
 may be used.
+This is especially useful with
+.Ql Ev MAKEOBJDIR .
 .Pp
 .Ql Va .OBJDIR
 may be modified in the makefile as a global variable.
@@ -1320,6 +1322,15 @@
 Appending a variable name to
 .Va .MAKE.EXPORTED
 is equivalent to exporting a variable.
+.It Ic .export-env Ar variable ...
+The same as 
+.Ql .export ,
+except that the variable is not appended to 
+.Va .MAKE.EXPORTED .
+This allows exporting a value to the environment which is different from that 
+used by 
+.Nm
+internally.
 .It Ic .info Ar message
 The message is printed along with the name of the makefile and line number.
 .It Ic .undef Ar variable
diff -r 69ba4e4625f6 -r 4c97caa9909b usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Jun 06 00:00:33 2010 +0000
+++ b/usr.bin/make/var.c        Sun Jun 06 01:13:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $    */
+/*     $NetBSD: var.c,v 1.159 2010/06/06 01:13:12 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.159 2010/06/06 01:13:12 sjg 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.158 2010/04/21 04:25:27 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.159 2010/06/06 01:13:12 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -682,6 +682,7 @@
     char *val;
     char **av;
     char *as;
+    int track;
     int ac;
     int i;
 
@@ -690,6 +691,12 @@
        return;
     }
 
+    if (strncmp(str, "-env", 4) == 0) {
+       track = 0;
+       str += 4;
+    } else {
+       track = VAR_EXPORT_PARENT;
+    }
     val = Var_Subst(NULL, str, VAR_GLOBAL, 0);
     av = brk_string(val, &ac, FALSE, &as);
     for (i = 0; i < ac; i++) {
@@ -709,10 +716,10 @@
                continue;
            }
        }
-       if (Var_Export1(name, VAR_EXPORT_PARENT)) {
+       if (Var_Export1(name, track)) {
            if (VAR_EXPORTED_ALL != var_exportedVars)
                var_exportedVars = VAR_EXPORTED_YES;
-           if (isExport) {
+           if (isExport && track) {
                Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL);
            }
        }



Home | Main Index | Thread Index | Old Index