diff options
author | sjg <sjg@FreeBSD.org> | 2013-08-02 06:25:28 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2013-08-02 06:25:28 +0000 |
commit | ff765cb371f120bb1d6e648a2418a7c9e3f223b2 (patch) | |
tree | 8ceaf694b47a0d2b1022393bf58a564bda1b20a2 /contrib/bmake/var.c | |
parent | 1c55a6beb9a550795753418366eee2961aae82db (diff) | |
download | FreeBSD-src-ff765cb371f120bb1d6e648a2418a7c9e3f223b2.zip FreeBSD-src-ff765cb371f120bb1d6e648a2418a7c9e3f223b2.tar.gz |
Merge bmake-20130730
Main feature of interest is .MAKE.JOB.PREFIX=
to suppress --- job --- tokens.
Diffstat (limited to 'contrib/bmake/var.c')
-rw-r--r-- | contrib/bmake/var.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c index 8ad0a4e..c4a6735 100644 --- a/contrib/bmake/var.c +++ b/contrib/bmake/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; /* * XXX transition hack for FreeBSD ports. * bsd.port.mk can set .MAKE.FreeBSD_UL=yes @@ -668,6 +669,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; @@ -789,7 +799,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 *)); @@ -806,10 +816,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; @@ -933,6 +940,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); @@ -967,31 +982,14 @@ 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 - } #ifdef MAKE_FREEBSD_UL if (strcmp(MAKE_FREEBSD_UL, name) == 0) { FreeBSD_UL = getBoolean(MAKE_FREEBSD_UL, FALSE); } #endif - - + + out: if (expanded_name != NULL) free(expanded_name); |