From owner-freebsd-bugs Fri Jan 17 5:50:11 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 83B9137B401 for ; Fri, 17 Jan 2003 05:50:06 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3CEC743F65 for ; Fri, 17 Jan 2003 05:50:05 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h0HDo4NS066490 for ; Fri, 17 Jan 2003 05:50:04 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h0HDo4lt066489; Fri, 17 Jan 2003 05:50:04 -0800 (PST) Date: Fri, 17 Jan 2003 05:50:04 -0800 (PST) Message-Id: <200301171350.h0HDo4lt066489@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Ulrich Kiermayr Subject: Re: bin/47149: make -C documented but not working - [PATCH] Reply-To: Ulrich Kiermayr Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/47149; it has been noted by GNATS. From: Ulrich Kiermayr To: freebsd-gnats-submit@FreeBSD.org Cc: Lukas Ertl Subject: Re: bin/47149: make -C documented but not working - [PATCH] Date: Fri, 17 Jan 2003 14:43:58 +0100 This is the Complete backport of Lukas' Patch under -STABLE: ------------------------- bash-2.05b# cat ~uk/make.patch.stable --- usr.bin/make/main.c.orig Tue Dec 17 20:01:18 2002 +++ usr.bin/make/main.c Fri Jan 17 14:39:29 2003 @@ -176,9 +176,9 @@ optind = 1; /* since we're called more than once */ #ifdef REMOTE -# define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv" +# define OPTFLAGS "BC:D:E:I:L:PSV:Xd:ef:ij:km:nqrstv" #else -# define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv" +# define OPTFLAGS "BC:D:E:I:PSV:Xd:ef:ij:km:nqrstv" #endif rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { switch(c) { @@ -503,17 +503,6 @@ } } #endif - /* - * Find where we are and take care of PWD for the automounter... - * All this code is so that we know where we are when we start up - * on a different machine with pmake. - */ - curdir = cdpath; - if (getcwd(curdir, MAXPATHLEN) == NULL) - err(2, NULL); - - if (stat(curdir, &sa) == -1) - err(2, "%s", curdir); #ifdef WANT_ENV_PWD if ((pwd = getenv("PWD")) != NULL) { @@ -589,51 +578,6 @@ machine_cpu = "unknown"; } - /* - * The object directory location is determined using the - * following order of preference: - * - * 1. MAKEOBJDIRPREFIX`cwd` - * 2. MAKEOBJDIR - * 3. _PATH_OBJDIR.${MACHINE} - * 4. _PATH_OBJDIR - * 5. _PATH_OBJDIRPREFIX`cwd` - * - * If one of the first two fails, use the current directory. - * If the remaining three all fail, use the current directory. - * - * Once things are initted, - * have to add the original directory to the search path, - * and modify the paths for the Makefiles apropriately. The - * current directory is also placed as a variable for make scripts. - */ - if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) { - if (!(path = getenv("MAKEOBJDIR"))) { - path = _PATH_OBJDIR; - pathp = _PATH_OBJDIRPREFIX; - (void) snprintf(mdpath, MAXPATHLEN, "%s.%s", - path, machine); - if (!(objdir = chdir_verify_path(mdpath, obpath))) - if (!(objdir=chdir_verify_path(path, obpath))) { - (void) snprintf(mdpath, MAXPATHLEN, - "%s%s", pathp, curdir); - if (!(objdir=chdir_verify_path(mdpath, - obpath))) - objdir = curdir; - } - } - else if (!(objdir = chdir_verify_path(path, obpath))) - objdir = curdir; - } - else { - (void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir); - if (!(objdir = chdir_verify_path(mdpath, obpath))) - objdir = curdir; - } - -#ifdef WANT_ENV_PWD - setenv("PWD", objdir, 1); -#endif create = Lst_Init(FALSE); makefiles = Lst_Init(FALSE); @@ -675,10 +619,6 @@ Var_Init(); /* As well as the lists of variables for * parsing arguments */ str_init(); - if (objdir != curdir) - Dir_AddDir(dirSearchPath, curdir); - Var_Set(".CURDIR", curdir, VAR_GLOBAL); - Var_Set(".OBJDIR", objdir, VAR_GLOBAL); /* * Initialize various variables. @@ -705,6 +645,69 @@ #endif MainParseArgs(argc, argv); + + /* + * Find where we are and take care of PWD for the automounter... + * All this code is so that we know where we are when we start up + * on a different machine with pmake. + */ + curdir = cdpath; + if (getcwd(curdir, MAXPATHLEN) == NULL) + err(2, NULL); + + if (stat(curdir, &sa) == -1) + err(2, "%s", curdir); + + /* + * The object directory location is determined using the + * following order of preference: + * + * 1. MAKEOBJDIRPREFIX`cwd` + * 2. MAKEOBJDIR + * 3. _PATH_OBJDIR.${MACHINE} + * 4. _PATH_OBJDIR + * 5. _PATH_OBJDIRPREFIX`cwd` + * + * If one of the first two fails, use the current directory. + * If the remaining three all fail, use the current directory. + * + * Once things are initted, + * have to add the original directory to the search path, + * and modify the paths for the Makefiles apropriately. The + * current directory is also placed as a variable for make scripts. + */ + if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) { + if (!(path = getenv("MAKEOBJDIR"))) { + path = _PATH_OBJDIR; + pathp = _PATH_OBJDIRPREFIX; + (void) snprintf(mdpath, MAXPATHLEN, "%s.%s", + path, machine); + if (!(objdir = chdir_verify_path(mdpath, obpath))) + if (!(objdir=chdir_verify_path(path, obpath))) { + (void) snprintf(mdpath, MAXPATHLEN, + "%s%s", pathp, curdir); + if (!(objdir=chdir_verify_path(mdpath, + obpath))) + objdir = curdir; + } + } + else if (!(objdir = chdir_verify_path(path, obpath))) + objdir = curdir; + } + else { + (void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir); + if (!(objdir = chdir_verify_path(mdpath, obpath))) + objdir = curdir; + } + +#ifdef WANT_ENV_PWD + setenv("PWD", objdir, 1); +#endif + + if (objdir != curdir) + Dir_AddDir(dirSearchPath, curdir); + Var_Set(".CURDIR", curdir, VAR_GLOBAL); + Var_Set(".OBJDIR", objdir, VAR_GLOBAL); /* * Be compatible if user did not specify -j and did not explicitly ------------------------- lG uk -- ------------------------------------------------------------------------ Ulrich Kiermayr Zentraler Informatikdienst der Universitaet Wien Network Security Universitaetsstrasse 7, 1010 Wien, Austria ------------------------------------------------------------------------ eMail: ulrich.kiermayr@univie.ac.at Tel: (+43 1) 4277 / 14104 Hotline: security.zid@univie.ac.at Fax: (+43 1) 4277 / 9140 Web: http://www.univie.ac.at/zid/security.html ------------------------------------------------------------------------ GPG Key fingerprint = BF0D 5749 4DC1 ED74 AB67 7180 105F 491D A8D7 64D8 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message