Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Use Var_Value() instead of getenv() to obtain M...



details:   https://anonhg.NetBSD.org/src/rev/a1696bb2910b
branches:  trunk
changeset: 793359:a1696bb2910b
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Feb 07 17:23:35 2014 +0000

description:
Use Var_Value() instead of getenv() to obtain MAKEOBJDIR{,PREFIX}.

Fixes "make -X MAKEOBJDIR=foo".  Purely uncoincidentally, build.sh
creates the nbmake wrapper with MAKEFLAGS -X on FreeBSD.

diffstat:

 usr.bin/make/main.c |  21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r 37066aa17897 -r a1696bb2910b usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Feb 07 16:57:05 2014 +0000
+++ b/usr.bin/make/main.c       Fri Feb 07 17:23:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $  */
+/*     $NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $");
+__RCSID("$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1067,11 +1067,12 @@
         */
 #ifndef NO_PWD_OVERRIDE
        if (!ignorePWD) {
-               char *pwd;
+               char *pwd, *ptmp1 = NULL, *ptmp2 = NULL;
 
                if ((pwd = getenv("PWD")) != NULL &&
-                   getenv("MAKEOBJDIRPREFIX") == NULL) {
-                       const char *makeobjdir = getenv("MAKEOBJDIR");
+                   Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &ptmp1) == NULL) {
+                       const char *makeobjdir = Var_Value("MAKEOBJDIR",
+                           VAR_CMD, &ptmp2);
 
                        if (makeobjdir == NULL || !strchr(makeobjdir, '$')) {
                                if (stat(pwd, &sb) == 0 &&
@@ -1080,6 +1081,8 @@
                                        (void)strncpy(curdir, pwd, MAXPATHLEN);
                        }
                }
+               free(ptmp1);
+               free(ptmp2);
        }
 #endif
        Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0);
@@ -1096,11 +1099,13 @@
        Dir_Init(curdir);
        (void)Main_SetObjdir(curdir);
 
-       if ((path = getenv("MAKEOBJDIRPREFIX")) != NULL) {
+       if ((path = Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &p1)) != NULL) {
                (void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir);
                (void)Main_SetObjdir(mdpath);
-       } else if ((path = getenv("MAKEOBJDIR")) != NULL) {
+               free(p1);
+       } else if ((path = Var_Value("MAKEOBJDIR", VAR_CMD, &p1)) != NULL) {
                (void)Main_SetObjdir(path);
+               free(p1);
        } else {
                (void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine);
                if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) {



Home | Main Index | Thread Index | Old Index