Module Name: src
Committed By: sjg
Date: Sun Jun 6 01:13:12 UTC 2010
Modified Files:
src/usr.bin/make: make.1 var.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 src/usr.bin/make/make.1
cvs rdiff -u -r1.158 -r1.159 src/usr.bin/make/var.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.172 src/usr.bin/make/make.1:1.173
--- src/usr.bin/make/make.1:1.172 Thu May 13 18:10:16 2010
+++ src/usr.bin/make/make.1 Sun Jun 6 01:13:12 2010
@@ -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
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.158 src/usr.bin/make/var.c:1.159
--- src/usr.bin/make/var.c:1.158 Wed Apr 21 04:25:27 2010
+++ src/usr.bin/make/var.c Sun Jun 6 01:13:12 2010
@@ -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);
}
}