From owner-svn-src-head@freebsd.org Fri Nov 10 02:09:34 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5C08E62538; Fri, 10 Nov 2017 02:09:34 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A6E321D87; Fri, 10 Nov 2017 02:09:34 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAA29XCx015366; Fri, 10 Nov 2017 02:09:33 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAA29XfS015362; Fri, 10 Nov 2017 02:09:33 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201711100209.vAA29XfS015362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 10 Nov 2017 02:09:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325626 - in head: . share/mk X-SVN-Group: head X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: in head: . share/mk X-SVN-Commit-Revision: 325626 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Nov 2017 02:09:35 -0000 Author: bdrewery Date: Fri Nov 10 02:09:33 2017 New Revision: 325626 URL: https://svnweb.freebsd.org/changeset/base/325626 Log: Handle some .OBJDIR == .CURDIR cases. - If OBJROOT is SRCTOP then don't add on TARGET.TARGET_ARCH. This only happens at the top-level, and for sub-directories when the user is clever with MAKEOBJDIRPREFIX=/. - Don't bother checking 'test -w' on .CURDIR. - Properly set OBJTOP/OBJROOT to SRCTOP in various needed cases. - Check if the OBJDIR is writable even for *clean* targets since it determines which .OBJDIR the user gets; If they cannot write to an existing eligible .OBJDIR then it needs to clean in .CURDIR instead. - Add guard to cleanworld/cleanuniverse from removing SRCTOP. - Ensure OBJTOP is proper for .OBJDIR=.CURDIR which fixes finding libraries since src.libnames.mk is based on OBJTOP. - Avoid some chdir(2) for modifying .OBJDIR Sponsored by: Dell EMC Isilon Modified: head/Makefile.inc1 head/share/mk/bsd.init.mk head/share/mk/bsd.obj.mk head/share/mk/src.sys.obj.mk Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Nov 10 02:00:40 2017 (r325625) +++ head/Makefile.inc1 Fri Nov 10 02:09:33 2017 (r325626) @@ -2776,7 +2776,8 @@ BW_CANONICALOBJDIR:=${OBJROOT} .endif .endif cleanworld cleanuniverse: .PHONY -.if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) +.if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \ + ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA} -rm -rf ${BW_CANONICALOBJDIR}* -chflags -R 0 ${BW_CANONICALOBJDIR} rm -rf ${BW_CANONICALOBJDIR}* Modified: head/share/mk/bsd.init.mk ============================================================================== --- head/share/mk/bsd.init.mk Fri Nov 10 02:00:40 2017 (r325625) +++ head/share/mk/bsd.init.mk Fri Nov 10 02:09:33 2017 (r325626) @@ -13,7 +13,7 @@ ____: .if ${MK_AUTO_OBJ} == "yes" # This is also done in bsd.obj.mk -.if defined(NO_OBJ) +.if defined(NO_OBJ) && ${.OBJDIR} != ${.CURDIR} .OBJDIR: ${.CURDIR} .endif .endif Modified: head/share/mk/bsd.obj.mk ============================================================================== --- head/share/mk/bsd.obj.mk Fri Nov 10 02:00:40 2017 (r325625) +++ head/share/mk/bsd.obj.mk Fri Nov 10 02:09:33 2017 (r325626) @@ -48,7 +48,7 @@ objwarn: .PHONY obj: .PHONY CANONICALOBJDIR= ${.OBJDIR} # This is also done in bsd.init.mk -.if defined(NO_OBJ) +.if defined(NO_OBJ) && ${.OBJDIR} != ${.CURDIR} # but this makefile does not want it! .OBJDIR: ${.CURDIR} .endif Modified: head/share/mk/src.sys.obj.mk ============================================================================== --- head/share/mk/src.sys.obj.mk Fri Nov 10 02:00:40 2017 (r325625) +++ head/share/mk/src.sys.obj.mk Fri Nov 10 02:09:33 2017 (r325626) @@ -70,7 +70,10 @@ OBJROOT:= ${OBJROOT:H:tA}/${OBJROOT:T} .export OBJROOT SRCTOP .endif -.if ${MK_UNIFIED_OBJDIR} == "yes" +# SRCTOP == OBJROOT only happens with clever MAKEOBJDIRPREFIX=/. Don't +# append TARGET.TARGET_ARCH for that case since the user wants to build +# in the source tree. +.if ${MK_UNIFIED_OBJDIR} == "yes" && ${SRCTOP} != ${OBJROOT:tA} OBJTOP:= ${OBJROOT}${TARGET:D${TARGET}.${TARGET_ARCH}:U${MACHINE}.${MACHINE_ARCH}} .else # TARGET.TARGET_ARCH handled in OBJROOT already. @@ -103,13 +106,12 @@ __objdir:= ${MAKEOBJDIR} .endif # Try to enable MK_AUTO_OBJ by default if we can write to the __objdir. Only -# do this if AUTO_OBJ is not disabled by the user, not cleaning, and this is -# the first make ran. +# do this if AUTO_OBJ is not disabled by the user, and this is the first make +# ran. .if ${.MAKE.LEVEL} == 0 && \ ${MK_AUTO_OBJ} == "no" && empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) && \ !defined(WITHOUT_AUTO_OBJ) && !make(showconfig) && !make(print-dir) && \ - !defined(NO_OBJ) && \ - (${.TARGETS} == "" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} != "") + !defined(NO_OBJ) # Find the last existing directory component and check if we can write to it. # If the last component is a symlink then recurse on the new path. CheckAutoObj= \ @@ -147,9 +149,13 @@ CheckAutoObj() { \ fi; \ } .if !empty(__objdir) +.if ${.CURDIR} == ${__objdir} +__objdir_writable?= yes +.else __objdir_writable!= \ ${CheckAutoObj}; CheckAutoObj "${__objdir}" || echo no .endif +.endif __objdir_writable?= no # Export the decision to sub-makes. MK_AUTO_OBJ:= ${__objdir_writable} @@ -179,3 +185,14 @@ MK_AUTO_OBJ:= ${__objdir_writable} # auto.obj.mk or bsd.obj.mk will create the directory and fix .OBJDIR later. .OBJDIR: ${.CURDIR} .endif + +# Ensure .OBJDIR=.CURDIR cases have a proper OBJTOP and .OBJDIR +.if defined(NO_OBJ) || ${__objdir_writable:Uunknown} == "no" || \ + ${__objdir} == ${.CURDIR} +OBJTOP= ${SRCTOP} +OBJROOT= ${SRCTOP}/ +# Compare only to avoid an unneeded chdir(2), :tA purposely left out. +.if ${.OBJDIR} != ${.CURDIR} +.OBJDIR: ${.CURDIR} +.endif +.endif # defined(NO_OBJ)