Date: Fri, 17 Jan 2003 05:50:04 -0800 (PST) From: Ulrich Kiermayr <ulrich.kiermayr@univie.ac.at> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/47149: make -C documented but not working - [PATCH] Message-ID: <200301171350.h0HDo4lt066489@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/47149; it has been noted by GNATS. From: Ulrich Kiermayr <ulrich.kiermayr@univie.ac.at> To: freebsd-gnats-submit@FreeBSD.org Cc: Lukas Ertl <l.ertl@univie.ac.at> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301171350.h0HDo4lt066489>