From owner-cvs-usrbin Sat Aug 31 14:13:10 1996 Return-Path: owner-cvs-usrbin Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA12522 for cvs-usrbin-outgoing; Sat, 31 Aug 1996 14:13:10 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id OAA12506; Sat, 31 Aug 1996 14:13:03 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.12/8.6.9) id HAA06437; Sun, 1 Sep 1996 07:06:47 +1000 Date: Sun, 1 Sep 1996 07:06:47 +1000 From: Bruce Evans Message-Id: <199608312106.HAA06437@godzilla.zeta.org.au> To: bde@freefall.freebsd.org, jkh@time.cdrom.com Subject: Re: cvs commit: src/usr.bin/make make.1 Cc: cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-usrbin@freefall.freebsd.org Sender: owner-cvs-usrbin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >> except in main.c. I will be changing MAKEOBJDIR back to its old >> behaviour so that the comment in main.c actually applies. >Just don't destroy the read-only source tree behavior please as I'll >be actually using that in a project shortly and if you bring back obj >links then you're going to see dueling CVS commits in the tree and a >pair of very unhappy people. In other words, please feel free to >replace it with something better, just don't eliminate the feature >itself. Thanks for volunteering to test it ;-). Sources will be built in the current directory, or possibly in the obj subdirectory or link, unless this is overridden by setting MAKEOBJDIR or MAKEOBJTREE. Setting MAKEOBJTREE=/usr/obj will give the current behaviour except possibly for support for MACHINE. This already works except for stuff involving .TARGETOBJ. Setting MAKEOBJTREE=obj will give the old default behaviour so I'll probably remove the hard-coded default. Problems: 1. It's not easy to support setting MAKEOBJDIR or MAKEOBJTREE early enough in a makefile. The have to be environment variables now. It's not easy to support substition in these variables early enough. I would have preferred to use MAKEOBJDIR ?= ${.CURDIR:S;^;${MAKEOBJTREE};} The current method is essentially this with the `^' pattern hard-coded. 2. Appending `.${MACHINE}' to the object path is probably incompatible with .TARGETOBJ (because .TARGETOBJ has to be canonical and there's no point in having a tree full of xxx.i386's and xxx.alpha's - the trees may as well be separate under /usr/obj.i386 and /usr/obj.alpha. MAKEOBJTREE can handle this easily). 3. The cleanobj rule in -current is too dangerous. I think it removes the current directory if MAKEOBJDIR is "". Bruce *** pathnames.h~ Sat Jul 13 18:38:10 1996 --- pathnames.h Sat Aug 31 15:33:02 1996 *************** *** 35,39 **** */ ! #define _PATH_OBJDIR "/usr/obj" #define _PATH_DEFSHELLDIR "/bin" #define _PATH_DEFSYSMK "/usr/share/mk/sys.mk" --- 35,39 ---- */ ! #define _PATH_OBJDIR "obj" #define _PATH_DEFSHELLDIR "/bin" #define _PATH_DEFSYSMK "/usr/share/mk/sys.mk" *** main.c~ Thu Jul 18 10:14:59 1996 --- main.c Sat Aug 31 21:09:37 1996 *************** *** 383,388 **** char mdpath[MAXPATHLEN + 1]; char obpath[MAXPATHLEN + 1]; char cdpath[MAXPATHLEN + 1]; - char *realobjdir; /* Where we'd like to go */ struct utsname utsname; char *machine = getenv("MACHINE"); --- 383,388 ---- char mdpath[MAXPATHLEN + 1]; char obpath[MAXPATHLEN + 1]; + char obtreepath[MAXPATHLEN + 1]; char cdpath[MAXPATHLEN + 1]; struct utsname utsname; char *machine = getenv("MACHINE"); *************** *** 434,441 **** * current directory is also placed as a variable for make scripts. */ ! if (!(path = getenv("MAKEOBJDIR"))) ! path = _PATH_OBJDIR; ! (void) snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir); ! realobjdir = mdpath; /* This is where we'd _like_ to be, anyway */ if (stat(mdpath, &sb) == 0 && S_ISDIR(sb.st_mode)) { --- 434,451 ---- * current directory is also placed as a variable for make scripts. */ ! if (!(path = getenv("MAKEOBJDIR"))) { ! if (!(path = getenv("MAKEOBJTREE"))) ! path = _PATH_OBJDIR; ! else { ! (void) sprintf(obtreepath, "%s%s", path, curdir); ! path = obtreepath; ! } ! (void) sprintf(mdpath, "%s.%s", path, machine); ! } ! else ! (void) strncpy(mdpath, path, MAXPATHLEN + 1); ! #if 0 ! printf("path=%s, mdpath=%s\n", path, mdpath); ! #endif if (stat(mdpath, &sb) == 0 && S_ISDIR(sb.st_mode)) { *************** *** 455,460 **** } } ! else ! objdir = curdir; setenv("PWD", objdir, 1); --- 465,489 ---- } } ! else { ! if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) { ! ! if (chdir(path)) { ! (void)fprintf(stderr, "make warning: %s: %s.\n", ! path, strerror(errno)); ! objdir = curdir; ! } ! else { ! if (path[0] != '/') { ! (void) sprintf(obpath, "%s/%s", curdir, ! path); ! objdir = obpath; ! } ! else ! objdir = path; ! } ! } ! else ! objdir = curdir; ! } setenv("PWD", objdir, 1); *************** *** 500,504 **** Dir_AddDir(dirSearchPath, curdir); Var_Set(".CURDIR", curdir, VAR_GLOBAL); - Var_Set(".TARGETOBJDIR", realobjdir, VAR_GLOBAL); Var_Set(".OBJDIR", objdir, VAR_GLOBAL); --- 529,532 ---- *** bsd.obj.mk~ Mon Jul 15 14:48:44 1996 --- bsd.obj.mk Sat Aug 31 16:38:50 1996 *************** *** 77,89 **** .if !target(whereobj) whereobj: ! .if defined(NOOBJ) ! @echo ${.CURDIR} ! .else ! @if ! test -d ${.TARGETOBJDIR}; then \ ! echo ${.CURDIR}; \ ! else \ ! echo ${.TARGETOBJDIR}; \ ! fi ! .endif .endif --- 77,81 ---- .if !target(whereobj) whereobj: ! @cd ${.CURDIR}; ${MAKE} -V .OBJDIR .endif *************** *** 92,100 **** # cleanobj: ! @if [ -d ${.TARGETOBJDIR} ]; then \ ! rm -rf ${.TARGETOBJDIR}; \ ! else \ ! cd ${.CURDIR} && ${MAKE} clean cleandepend; \ ! fi .if defined(OBJLINK) @if [ -h ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi --- 84,88 ---- # cleanobj: ! @if [ -d ${.CURDIR}/obj ]; then rm -rf ${.CURDIR}/obj; fi .if defined(OBJLINK) @if [ -h ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi