diff --git Makefile Makefile index 7674e608b6bd..5165c7f3cae7 100644 --- Makefile +++ Makefile @@ -167,18 +167,6 @@ META_TGT_WHITELIST+= \ tinderbox toolchain \ toolchains universe world worlds xdev xdev-build -# Likewise for AUTO_OBJ. Many targets do not need object directories created -# for each visited directory. Only when things are being built are they -# needed. Having AUTO_OBJ disabled in a build target is fine as it should -# fallback to running 'make obj' as needed. If a target is not in this list -# then it is ran with MK_AUTO_OBJ=no in environment. -# 'showconfig' is in the list to avoid forcing MK_AUTO_OBJ=no for it. -AUTO_OBJ_TGT_WHITELIST+= \ - _* all all-man build* depend everything *toolchain* includes \ - libraries obj objlink showconfig tags xdev xdev-build native-xtools \ - stage* create-packages* real-packages sign-packages package-pkg \ - tinderbox universe* kernel kernels world worlds bmake - .ORDER: buildworld installworld .ORDER: buildworld distrib-dirs .ORDER: buildworld distribution @@ -245,7 +233,7 @@ SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk .endif _MAKE= PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \ - TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} + TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS} .if defined(MK_META_MODE) && ${MK_META_MODE} == "yes" # Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST @@ -276,21 +264,6 @@ MK_META_MODE= no .endif # ${MK_META_MODE} == yes .endif # defined(MK_META_MODE) && ${MK_META_MODE} == yes -# Only allow AUTO_OBJ for the whitelisted targets. See AUTO_OBJ_TGT_WHITELIST -# above. MK_AUTO_OBJ not checked here for "yes" as it may not yet be enabled -# since it is opportunistic. -.if empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) -.for _tgt in ${AUTO_OBJ_TGT_WHITELIST} -.if make(${_tgt}) -_CAN_USE_AUTO_OBJ?= yes -.endif -.endfor -.if !defined(_CAN_USE_AUTO_OBJ) -_MAKE+= MK_AUTO_OBJ=no -MK_AUTO_OBJ= no -.endif -.endif # empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) - # Guess target architecture from target type, and vice versa, based on # historic FreeBSD practice of tending to have TARGET == TARGET_ARCH # expanding to TARGET == TARGET_CPUARCH in recent times, with known diff --git Makefile.inc.sys Makefile.inc.sys new file mode 100644 index 000000000000..30eff1e6a3c4 --- /dev/null +++ Makefile.inc.sys @@ -0,0 +1,41 @@ +# $FreeBSD$ +# +# This is included very early from share/mk/src.sys.env.mk, after +# /etc/src-env.conf but before /etc/make.conf, /etc/src.conf, or OBJDIR +# handling. +# - It is not safe to use .OBJDIR/OBJTOP/OBJROOT here. +# - __ENV_ONLY_OPTIONS have been parsed by now except for opporutunistic +# MK_AUTO_OBJ. +# + +# For AUTO_OBJ many targets do not need object directories created at top-level +# for each visited directory. Only when things are being built are they +# needed. Having AUTO_OBJ disabled in a build target is fine as it should +# fallback to running 'make obj' as needed. If a target is not in this list +# then it is ran with MK_AUTO_OBJ=no in environment. +# 'showconfig' is in the list to avoid forcing MK_AUTO_OBJ=no for it. +AUTO_OBJ_TGT_WHITELIST+= \ + _* all all-man build* depend everything *toolchain* includes \ + libraries obj objlink showconfig tags xdev xdev-build native-xtools \ + stage* create-packages* real-packages sign-packages package-pkg \ + tinderbox universe* kernel kernels world worlds bmake + +# Only allow AUTO_OBJ for the whitelisted targets. See AUTO_OBJ_TGT_WHITELIST +# above. MK_AUTO_OBJ not checked here for "yes" as it may not yet be enabled +# since it is opportunistic. +.if empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) +.for _tgt in ${AUTO_OBJ_TGT_WHITELIST} +.if make(${_tgt}) +_CAN_USE_AUTO_OBJ?= yes +.endif +.endfor +.if !defined(_CAN_USE_AUTO_OBJ) +_MAKEARGS+= MK_AUTO_OBJ=no +MK_AUTO_OBJ= no +# This will prevent src.sys.obj.mk from opportunistically enabling AUTO_OBJ +# in this make execution and for sub-makes. For all of these targets we +# just want to read any existing OBJDIR but we don't care if we can create +# or write to them. +.MAKEOVERRIDES+= MK_AUTO_OBJ +.endif +.endif # empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) diff --git share/mk/src.sys.env.mk share/mk/src.sys.env.mk index b100c2ad1429..9c131b2dfe58 100644 --- share/mk/src.sys.env.mk +++ share/mk/src.sys.env.mk @@ -44,4 +44,7 @@ MAKESYSPATH:= ${.PARSEDIR:tA} .export MAKESYSPATH .endif +.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0 +.sinclude "${.CURDIR}/Makefile.inc.sys" +.endif .include diff --git share/mk/src.sys.obj.mk share/mk/src.sys.obj.mk index fe15717d4f05..d3d2a32dcb36 100644 --- share/mk/src.sys.obj.mk +++ share/mk/src.sys.obj.mk @@ -19,6 +19,12 @@ # TARGET.TARGET_ARCH added in as it assumes that MAKEOBJDIRPREFIX is # nested in the existing OBJTOP with TARGET.TARGET_ARCH in it. # +# The expected OBJDIR is stored in __objdir for auto.obj.mk to use. +# +# AUTO_OBJ is opportunistically enabled if the computed .OBJDIR is writable +# by the current user. Some top-level targets disable this behavior in +# Makefile.inc.sys. +# _default_makeobjdirprefix?= /usr/obj _default_makeobjdir= $${.CURDIR:S,^$${SRCTOP},$${OBJTOP},}