From owner-freebsd-arch Fri Feb 22 0: 2:30 2002 Delivered-To: freebsd-arch@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 2C0EC37B402; Fri, 22 Feb 2002 00:02:15 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id g1M828q82474; Fri, 22 Feb 2002 10:02:08 +0200 (EET) (envelope-from ru) Date: Fri, 22 Feb 2002 10:02:08 +0200 From: Ruslan Ermilov To: arch@FreeBSD.org Cc: Bruce Evans , Pekka Savola Subject: MAKEOBJDIRPREFIX Message-ID: <20020222080208.GB81821@sunbay.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="IJpNTDwzlM2Ie8A6" Content-Disposition: inline User-Agent: Mutt/1.3.27i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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