Enable AUTO_OBJ by default if the OBJDIR is writable, only for in-tree builds.
This can be disabled by putting WITHOUT_AUTO_OBJ=yes in /etc/src-env.conf, not /etc/src.conf, or passing it in the environment. The purpose of this rather than simply flipping the default of AUTO_OBJ to yes is to avoid hassling users with auto.obj.mk failures if the wanted OBJDIR is not writable. It will fallback to writing to the source directory like it does today if MAKEOBJDIRPREFIX is not writable. The act of enabling MK_AUTO_OBJ disables all 'make obj' treewalks since previous work has made those not run if MK_AUTO_OBJ==yes in Makefile.inc1. Relnotes: yes Reviewed by: sjg Discussed at: https://lists.freebsd.org/pipermail/freebsd-arch/2016-May/017805.html Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12841
This commit is contained in:
parent
4dc89c4d51
commit
615a1e70b0
8
UPDATING
8
UPDATING
@ -51,6 +51,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
|
||||
|
||||
****************************** SPECIAL WARNING: ******************************
|
||||
|
||||
20171102:
|
||||
Building in a FreeBSD src checkout will automatically create object
|
||||
directories now rather than store files in the current directory if
|
||||
'make obj' was not ran. Calling 'make obj' is no longer necesarry.
|
||||
This feature can be disabled by setting WITHOUT_AUTO_OBJ=yes in
|
||||
/etc/src-env.conf (not /etc/src.conf), or passing the option in the
|
||||
environment.
|
||||
|
||||
20171101:
|
||||
The default MAKEOBJDIR has changed from /usr/obj/<srcdir> for native
|
||||
builds, and /usr/obj/<arch>/<srcdir> for cross-builds, to a unified
|
||||
|
@ -14,7 +14,7 @@ SRCCONF?= /etc/src.conf
|
||||
|
||||
# Validate that the user didn't try setting an env-only variable in
|
||||
# their src.conf. This benefits from already including bsd.mkopt.mk.
|
||||
.for var in ${__ENV_ONLY_OPTIONS}
|
||||
.for var in ${__ENV_ONLY_OPTIONS:O:u}
|
||||
__presrcconf_${var}:= ${MK_${var}:U-}${WITHOUT_${var}:Uno:Dyes}${WITH_${var}:Uno:Dyes}
|
||||
.endfor
|
||||
|
||||
@ -22,7 +22,7 @@ __presrcconf_${var}:= ${MK_${var}:U-}${WITHOUT_${var}:Uno:Dyes}${WITH_${var}:Uno
|
||||
_srcconf_included_: .NOTMAIN
|
||||
|
||||
# Validate the env-only variables.
|
||||
.for var in ${__ENV_ONLY_OPTIONS}
|
||||
.for var in ${__ENV_ONLY_OPTIONS:O:u}
|
||||
__postrcconf_${var}:= ${MK_${var}:U-}${WITHOUT_${var}:Uno:Dyes}${WITH_${var}:Uno:Dyes}
|
||||
.if ${__presrcconf_${var}} != ${__postrcconf_${var}}
|
||||
.error Option ${var} may only be defined in ${SRC_ENV_CONF}, environment, or make argument, not ${SRCCONF}.
|
||||
|
@ -94,7 +94,68 @@ OBJTOP:= ${MAKEOBJDIRPREFIX}${SRCTOP}
|
||||
OBJROOT:= ${OBJTOP}/
|
||||
.endif
|
||||
|
||||
# Assign this directory as .OBJDIR if possible
|
||||
# Try to enable MK_AUTO_OBJ by default if we can write to the OBJROOT. Only
|
||||
# do this if AUTO_OBJ is not disabled by the user, not cleaning, 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*} != "")
|
||||
# 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= \
|
||||
DirIsCreatable() { \
|
||||
[ -w "$${1}" ] && return 0; \
|
||||
d="$${1}"; \
|
||||
IFS=/; \
|
||||
set -- $${d}; \
|
||||
unset dir; \
|
||||
while [ $$\# -gt 0 ]; do \
|
||||
d="$${1}"; \
|
||||
shift; \
|
||||
if [ ! -d "$${dir}$${d}/" ]; then \
|
||||
if [ -L "$${dir}$${d}" ]; then \
|
||||
dir="$$(readlink "$${dir}$${d}")/"; \
|
||||
for d in "$${@}"; do \
|
||||
dir="$${dir}$${d}/"; \
|
||||
done; \
|
||||
ret=0; \
|
||||
DirIsCreatable "$${dir%/}" || ret=$$?; \
|
||||
return $${ret}; \
|
||||
else \
|
||||
break; \
|
||||
fi; \
|
||||
fi; \
|
||||
dir="$${dir}$${d}/"; \
|
||||
done; \
|
||||
[ -w "$${dir}" ]; \
|
||||
}; \
|
||||
CheckAutoObj() { \
|
||||
if DirIsCreatable "$${1}"; then \
|
||||
echo yes; \
|
||||
else \
|
||||
echo no; \
|
||||
fi; \
|
||||
}
|
||||
.if !empty(MAKEOBJDIRPREFIX)
|
||||
WANTED_OBJDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}
|
||||
.else
|
||||
WANTED_OBJDIR= ${MAKEOBJDIR}
|
||||
.endif
|
||||
OBJDIR_WRITABLE!= \
|
||||
${CheckAutoObj}; CheckAutoObj "${WANTED_OBJDIR}" || echo no
|
||||
# Export the decision to sub-makes.
|
||||
MK_AUTO_OBJ:= ${OBJDIR_WRITABLE}
|
||||
.export MK_AUTO_OBJ
|
||||
.elif make(showconfig)
|
||||
# Need to export for showconfig internally running make -dg1. It is enabled
|
||||
# in sys.mk by default.
|
||||
.export MK_AUTO_OBJ
|
||||
.endif # ${MK_AUTO_OBJ} == "no" && ...
|
||||
|
||||
# Assign this directory as .OBJDIR if possible after determining if AUTO_OBJ
|
||||
# can be enabled by default.
|
||||
.if ${MK_AUTO_OBJ} == "no"
|
||||
# The expected OBJDIR already exists, set it as .OBJDIR.
|
||||
.if !empty(MAKEOBJDIRPREFIX) && exists(${MAKEOBJDIRPREFIX}${.CURDIR})
|
||||
|
@ -20,6 +20,12 @@ MACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}}
|
||||
__DEFAULT_YES_OPTIONS+= \
|
||||
UNIFIED_OBJDIR
|
||||
|
||||
# src.sys.obj.mk enables AUTO_OBJ by default if possible but it is otherwise
|
||||
# disabled. Ensure src.conf.5 shows it as default on.
|
||||
.if make(showconfig)
|
||||
__DEFAULT_YES_OPTIONS+= AUTO_OBJ
|
||||
.endif
|
||||
|
||||
# Some options we need now
|
||||
__DEFAULT_NO_OPTIONS= \
|
||||
DIRDEPS_BUILD \
|
||||
|
3
tools/build/options/WITHOUT_AUTO_OBJ
Normal file
3
tools/build/options/WITHOUT_AUTO_OBJ
Normal file
@ -0,0 +1,3 @@
|
||||
.\" $FreeBSD$
|
||||
Disable automatic creation of objdirs.
|
||||
This is enabled by default if the wanted OBJDIR is writable by the current user.
|
Loading…
x
Reference in New Issue
Block a user