aboutsummaryrefslogtreecommitdiffstats
path: root/var.c
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2013-08-02 05:23:57 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2013-08-02 05:23:57 +0000
commite0f69e1d23f496f590728b9bb0cf0778e4df1210 (patch)
tree9f9944063b4983031d8155b70d2f48d1bc3f290e /var.c
parent45f33ab2b2f3f9436d40a229bf4ac6dca9411c05 (diff)
downloadsrc-e0f69e1d23f496f590728b9bb0cf0778e4df1210.tar.gz
src-e0f69e1d23f496f590728b9bb0cf0778e4df1210.zip
Import bmake-20130730 - allows folk to supress job tokens.vendor/NetBSD/bmake/20130730
Notes
Notes: svn path=/vendor/NetBSD/bmake/dist/; revision=253879 svn path=/vendor/NetBSD/bmake/20130730/; revision=253880; tag=vendor/NetBSD/bmake/20130730
Diffstat (limited to 'var.c')
-rw-r--r--var.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/var.c b/var.c
index d0d5266db497..c5c16b8803b6 100644
--- a/var.c
+++ b/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $ */
+/* $NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 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.175 2013/05/29 00:23:31 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -139,6 +139,7 @@ __RCSID("$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $");
#include "dir.h"
#include "job.h"
+extern int makelevel;
/*
* This lets us tell if we have replaced the original environ
* (which we cannot free).
@@ -657,6 +658,15 @@ Var_ExportVars(void)
char *val;
int n;
+ /*
+ * Several make's support this sort of mechanism for tracking
+ * recursion - but each uses a different name.
+ * We allow the makefiles to update MAKELEVEL and ensure
+ * children see a correctly incremented value.
+ */
+ snprintf(tmp, sizeof(tmp), "%d", makelevel + 1);
+ setenv(MAKE_LEVEL_ENV, tmp, 1);
+
if (VAR_EXPORTED_NONE == var_exportedVars)
return;
@@ -778,7 +788,7 @@ Var_UnExport(char *str)
if (unexport_env) {
char **newenv;
- cp = getenv(MAKE_LEVEL); /* we should preserve this */
+ cp = getenv(MAKE_LEVEL_ENV); /* we should preserve this */
if (environ == savedEnv) {
/* we have been here before! */
newenv = bmake_realloc(environ, 2 * sizeof(char *));
@@ -795,10 +805,7 @@ Var_UnExport(char *str)
environ = savedEnv = newenv;
newenv[0] = NULL;
newenv[1] = NULL;
- setenv(MAKE_LEVEL, cp, 1);
-#ifdef MAKE_LEVEL_SAFE
- setenv(MAKE_LEVEL_SAFE, cp, 1);
-#endif
+ setenv(MAKE_LEVEL_ENV, cp, 1);
} else {
for (; *str != '\n' && isspace((unsigned char) *str); str++)
continue;
@@ -922,6 +929,14 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
}
v = VarFind(name, ctxt, 0);
if (v == NULL) {
+ if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
+ /*
+ * This var would normally prevent the same name being added
+ * to VAR_GLOBAL, so delete it from there if needed.
+ * Otherwise -V name may show the wrong value.
+ */
+ Var_Delete(name, VAR_GLOBAL);
+ }
VarAdd(name, val, ctxt);
} else {
Buf_Empty(&v->val);
@@ -956,25 +971,6 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
}
- /*
- * Another special case.
- * Several make's support this sort of mechanism for tracking
- * recursion - but each uses a different name.
- * We allow the makefiles to update .MAKE.LEVEL and ensure
- * children see a correctly incremented value.
- */
- if (ctxt == VAR_GLOBAL && strcmp(MAKE_LEVEL, name) == 0) {
- char tmp[64];
- int level;
-
- level = atoi(val);
- snprintf(tmp, sizeof(tmp), "%u", level + 1);
- setenv(MAKE_LEVEL, tmp, 1);
-#ifdef MAKE_LEVEL_SAFE
- setenv(MAKE_LEVEL_SAFE, tmp, 1);
-#endif
- }
-
out:
if (expanded_name != NULL)