Date: Fri, 22 Feb 2002 10:02:08 +0200 From: Ruslan Ermilov <ru@FreeBSD.org> To: arch@FreeBSD.org Cc: Bruce Evans <bde@FreeBSD.org>, Pekka Savola <pekkas@netcore.fi> Subject: MAKEOBJDIRPREFIX Message-ID: <20020222080208.GB81821@sunbay.com>
next in thread | raw e-mail | index | archive | help
--IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi! If I am reading the POSIX specs correctly, MAKEOBJDIRPREFIX could be easily made to be honoured even if specified on a command line. : Before the makefile(s) are read, all of the make utility command : line macro definitions (except the MAKEFLAGS macro or the SHELL : macro) shall be added to the environment of make. Other : implementation-defined variables may also be added to the environment : of make. The attached patch merely moves the `objdir' initialization below the MainParseArgs() call, after all command line arguments have already been parsed. To be honest, the current behavior does not contradict to POSIX (which does not say anything about MAKEOBJDIR[PREFIX]), but the proposed behavior would help users errouneously attempting to set MAKEOBJDIRPREFIX on a command line. (It still does not work if MAKEOBJDIRPREFIX is set as a make's global.) Comments? Cheers, -- Ruslan Ermilov Sysadmin and DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/main.c,v retrieving revision 1.49 diff -u -p -r1.49 main.c --- main.c 25 Apr 2001 14:44:41 -0000 1.49 +++ main.c 22 Feb 2002 07:34:04 -0000 @@ -563,48 +563,6 @@ main(argc, argv) else 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; - } create = Lst_Init(FALSE); makefiles = Lst_Init(FALSE); @@ -646,10 +604,6 @@ main(argc, argv) 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. @@ -676,6 +630,53 @@ main(argc, argv) #endif MainParseArgs(argc, argv); + + /* + * 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; + } + + 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 --IJpNTDwzlM2Ie8A6-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020222080208.GB81821>