diff options
| author | sjg <sjg@NetBSD.org> | 2010-06-06 01:13:12 +0000 |
|---|---|---|
| committer | sjg <sjg@NetBSD.org> | 2010-06-06 01:13:12 +0000 |
| commit | fbb620d711b44afa0d64fc975dbfad54a1c826bb (patch) | |
| tree | 0637a59f54909113eb9a42d487fe39dbe0eb7af1 | |
| parent | 90abead58e2b966647f4e70b4b92a721a5e49f82 (diff) | |
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
| -rw-r--r-- | usr.bin/make/make.1 | 15 | ||||
| -rw-r--r-- | usr.bin/make/var.c | 17 |
2 files changed, 25 insertions, 7 deletions
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 8a068156896..3a9db7fcd60 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -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 @@ is set in the environment or on the command line.) .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 @@ flag, so should be used with caution. 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 --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 770e688f5c2..d644674c7ac 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -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 @@ Var_Export(char *str, int isExport) char *val; char **av; char *as; + int track; int ac; int i; @@ -690,6 +691,12 @@ Var_Export(char *str, int isExport) 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 @@ Var_Export(char *str, int isExport) 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); } } |
