svn commit: r325626 - in head: . share/mk

Bryan Drewery bdrewery at FreeBSD.org
Fri Nov 10 02:09:35 UTC 2017


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 @@ __<bsd.init.mk>__:
 
 .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)


More information about the svn-src-all mailing list