Module Name: src Committed By: sjg Date: Sat Jul 6 18:19:17 UTC 2013
Modified Files: src/usr.bin/make: main.c var.c Log Message: If using gmake's MAKELEVEL; use it the same way To generate a diff of this commit: cvs rdiff -u -r1.215 -r1.216 src/usr.bin/make/main.c cvs rdiff -u -r1.179 -r1.180 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.215 src/usr.bin/make/main.c:1.216 --- src/usr.bin/make/main.c:1.215 Sat Jun 29 15:19:32 2013 +++ src/usr.bin/make/main.c Sat Jul 6 18:19:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.215 2013/06/29 15:19:32 christos Exp $ */ +/* $NetBSD: main.c,v 1.216 2013/07/06 18:19:17 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.215 2013/06/29 15:19:32 christos Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.216 2013/07/06 18:19:17 sjg 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.215 2013/06/29 15:19:32 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.216 2013/07/06 18:19:17 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -940,7 +940,7 @@ main(int argc, char **argv) char tmp[64], *ep; snprintf(tmp, sizeof(tmp), "%d", - (ep = getenv(MAKE_LEVEL_ENV)) ? atoi(ep) + 1 : 0); + ((ep = getenv(MAKE_LEVEL_ENV)) && *ep) ? atoi(ep) : 0); Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL, 0); snprintf(tmp, sizeof(tmp), "%u", myPid); Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0); Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.179 src/usr.bin/make/var.c:1.180 --- src/usr.bin/make/var.c:1.179 Tue Jun 18 20:06:09 2013 +++ src/usr.bin/make/var.c Sat Jul 6 18:19:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.179 2013/06/18 20:06:09 sjg Exp $ */ +/* $NetBSD: var.c,v 1.180 2013/07/06 18:19:17 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.179 2013/06/18 20:06:09 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.180 2013/07/06 18:19:17 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.179 2013/06/18 20:06:09 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.180 2013/07/06 18:19:17 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -960,9 +960,14 @@ 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) - setenv(MAKE_LEVEL_ENV, val, 1); - + 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_ENV, tmp, 1); + } out: if (expanded_name != NULL)