Module Name: src
Committed By: christos
Date: Mon Jun 10 16:46:19 UTC 2013
Modified Files:
src/usr.bin/make: main.c var.c
Log Message:
1. Don't export .MAKE.LEVEL, because this is an illegal variable name for
some shells; export MAKELEVEL like gmake(1) does.
2. It is absurd for the environment variable to be one greater than the
make variable!?!?! To wit...
printf 'all:\n\t@echo ${.MAKE.LEVEL}; printenv .MAKE.LEVEL' | make -f -
To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/make/main.c
cvs rdiff -u -r1.175 -r1.176 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/main.c
diff -u src/usr.bin/make/main.c:1.210 src/usr.bin/make/main.c:1.211
--- src/usr.bin/make/main.c:1.210 Sat Mar 23 01:31:29 2013
+++ src/usr.bin/make/main.c Mon Jun 10 12:46:19 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $ */
+/* $NetBSD: main.c,v 1.211 2013/06/10 16:46:19 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.211 2013/06/10 16:46:19 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.211 2013/06/10 16:46:19 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -937,13 +937,11 @@ main(int argc, char **argv)
* Set some other useful macros
*/
{
- char tmp[64];
- const char *ep;
+ char tmp[64], *ep;
- if (!(ep = getenv(MAKE_LEVEL))) {
- ep = "0";
- }
- Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0);
+ snprintf(tmp, sizeof(tmp), "%d",
+ (ep = getenv("MAKELEVEL")) ? atoi(ep) + 1 : 0);
+ Var_Set(MAKELEVEL, tmp, VAR_GLOBAL, 0);
snprintf(tmp, sizeof(tmp), "%u", myPid);
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
snprintf(tmp, sizeof(tmp), "%u", getppid());
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.175 src/usr.bin/make/var.c:1.176
--- src/usr.bin/make/var.c:1.175 Tue May 28 20:23:31 2013
+++ src/usr.bin/make/var.c Mon Jun 10 12:46:19 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $ */
+/* $NetBSD: var.c,v 1.176 2013/06/10 16:46:19 christos 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.176 2013/06/10 16:46:19 christos 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.176 2013/06/10 16:46:19 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -778,7 +778,7 @@ Var_UnExport(char *str)
if (unexport_env) {
char **newenv;
- cp = getenv(MAKE_LEVEL); /* we should preserve this */
+ cp = getenv("MAKELEVEL"); /* we should preserve this */
if (environ == savedEnv) {
/* we have been here before! */
newenv = bmake_realloc(environ, 2 * sizeof(char *));
@@ -795,7 +795,7 @@ Var_UnExport(char *str)
environ = savedEnv = newenv;
newenv[0] = NULL;
newenv[1] = NULL;
- setenv(MAKE_LEVEL, cp, 1);
+ setenv("MAKELEVEL", cp, 1);
} else {
for (; *str != '\n' && isspace((unsigned char) *str); str++)
continue;
@@ -960,14 +960,8 @@ Var_Set(const char *name, const char *va
* 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);
- }
+ if (ctxt == VAR_GLOBAL && strcmp(MAKELEVEL, name) == 0)
+ setenv("MAKELEVEL", val, 1);
out: