Date: Thu, 2 Nov 2017 18:09:07 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325330 - in head: . share/mk tools/build/options Message-ID: <201711021809.vA2I97HI071697@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdrewery Date: Thu Nov 2 18:09:07 2017 New Revision: 325330 URL: https://svnweb.freebsd.org/changeset/base/325330 Log: 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 Added: head/tools/build/options/WITHOUT_AUTO_OBJ (contents, props changed) Modified: head/UPDATING head/share/mk/src.sys.mk head/share/mk/src.sys.obj.mk head/share/mk/sys.mk Modified: head/UPDATING ============================================================================== --- head/UPDATING Thu Nov 2 18:08:36 2017 (r325329) +++ head/UPDATING Thu Nov 2 18:09:07 2017 (r325330) @@ -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 Modified: head/share/mk/src.sys.mk ============================================================================== --- head/share/mk/src.sys.mk Thu Nov 2 18:08:36 2017 (r325329) +++ head/share/mk/src.sys.mk Thu Nov 2 18:09:07 2017 (r325330) @@ -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}: _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}. Modified: head/share/mk/src.sys.obj.mk ============================================================================== --- head/share/mk/src.sys.obj.mk Thu Nov 2 18:08:36 2017 (r325329) +++ head/share/mk/src.sys.obj.mk Thu Nov 2 18:09:07 2017 (r325330) @@ -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}) Modified: head/share/mk/sys.mk ============================================================================== --- head/share/mk/sys.mk Thu Nov 2 18:08:36 2017 (r325329) +++ head/share/mk/sys.mk Thu Nov 2 18:09:07 2017 (r325330) @@ -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 \ Added: head/tools/build/options/WITHOUT_AUTO_OBJ ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITHOUT_AUTO_OBJ Thu Nov 2 18:09:07 2017 (r325330) @@ -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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711021809.vA2I97HI071697>