03173d2ff0
This is to fix 'make all' causing it to recurse on both 'all' and 'buildconfig' due to 'buildconfig' being in ALL_SUBDIR_TARGETS and being a dependency of 'all'. This now adds all of the '*includes', '*files' targets as subdir targets, allowing them to recurse. This also removes the need for some 'realinstall' hacks in bsd.subdir.mk since it no longer recurses; only 'install' will recurse and call the proper 'beforeinstall', 'realinstall', and 'afterinstall' in each sub-directory. This fixes 'make includes' and 'make files' to not be a rerolled ${MAKE} sub-shell but to rather just recurse on 'inclues' and 'files'. This avoids various issues such as the one fixed in r289462. As such revert Makefile.inc1 back to using 'includes' which avoids an extra tree walk and parallelizes the includes phases better. Makefile.inc1 includes a guard so that 'make all' will not use SUBDIR_PARALLEL, added in r289438. This is so users do not get a probably broken build if they run 'make all' from the top-level. Before the change in this commit, the workaround for 'make everything' was 'par-all' which would depend on 'all' and cause a proper parallel recursion. Now that will not work so a new _PARALLEL_SUBUDIR_OK is used to allow it. This is still part of an effort to combine bsd.(files|incs|confs).mk and move some of its logic out of bsd.subdir.mk, as attempted in r289282 and reverted in r289331. This commit fixes the problems found there which was mostly double recursing during 'includes' which would recurse on itself and 'buildincludes' and 'installincludes', all in parallel. The logic is still in bsd.subdir.mk for now. I've been cautious about this commit but have experienced no breakage on the tree except for the 'par-all' case which was already a hack. If something foo is depending on something bar that should recurse, it is very likely that the foo target is being recursed on already meaning that bar will still effectively recurse once sub-directories call foo. Discussed on: arch@ MFC after: never Sponsored by: EMC / Isilon Storage Division
163 lines
4.5 KiB
Makefile
163 lines
4.5 KiB
Makefile
# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
|
|
# $FreeBSD$
|
|
#
|
|
# The include file <bsd.subdir.mk> contains the default targets
|
|
# for building subdirectories.
|
|
#
|
|
# For all of the directories listed in the variable SUBDIRS, the
|
|
# specified directory will be visited and the target made. There is
|
|
# also a default target which allows the command "make subdir" where
|
|
# subdir is any directory listed in the variable SUBDIRS.
|
|
#
|
|
#
|
|
# +++ variables +++
|
|
#
|
|
# DISTRIBUTION Name of distribution. [base]
|
|
#
|
|
# SUBDIR A list of subdirectories that should be built as well.
|
|
# Each of the targets will execute the same target in the
|
|
# subdirectories. SUBDIR.yes is automatically appeneded
|
|
# to this list.
|
|
#
|
|
# +++ targets +++
|
|
#
|
|
# distribute:
|
|
# This is a variant of install, which will
|
|
# put the stuff into the right "distribution".
|
|
#
|
|
# See ALL_SUBDIR_TARGETS for list of targets that will recurse.
|
|
# Custom targets can be added to SUBDIR_TARGETS in src.conf.
|
|
#
|
|
# Targets defined in STANDALONE_SUBDIR_TARGETS will always be ran
|
|
# with SUBDIR_PARALLEL and will not respect .WAIT or SUBDIR_DEPEND_
|
|
# values.
|
|
#
|
|
|
|
.if !target(__<bsd.subdir.mk>__)
|
|
__<bsd.subdir.mk>__:
|
|
|
|
ALL_SUBDIR_TARGETS= all all-man buildconfig buildfiles buildincludes \
|
|
checkdpadd clean cleandepend cleandir cleanilinks \
|
|
cleanobj depend distribute files includes installconfig \
|
|
installfiles installincludes install lint maninstall \
|
|
manlint obj objlink regress tags \
|
|
${SUBDIR_TARGETS}
|
|
|
|
# Described above.
|
|
STANDALONE_SUBDIR_TARGETS?= obj checkdpadd clean cleandepend cleandir \
|
|
cleanilinks cleanobj
|
|
|
|
.include <bsd.init.mk>
|
|
|
|
.if !defined(NEED_SUBDIR)
|
|
.if ${.MAKE.LEVEL} == 0 && ${MK_DIRDEPS_BUILD} == "yes" && !empty(SUBDIR) && !(make(clean*) || make(destroy*))
|
|
.include <meta.subdir.mk>
|
|
# ignore this
|
|
_SUBDIR:
|
|
.endif
|
|
.endif
|
|
.if !target(_SUBDIR)
|
|
|
|
.if defined(SUBDIR)
|
|
SUBDIR:=${SUBDIR} ${SUBDIR.yes}
|
|
SUBDIR:=${SUBDIR:u}
|
|
.endif
|
|
|
|
DISTRIBUTION?= base
|
|
.if !target(distribute)
|
|
distribute: .MAKE
|
|
.for dist in ${DISTRIBUTION}
|
|
${_+_}cd ${.CURDIR}; \
|
|
${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
|
|
.endfor
|
|
.endif
|
|
|
|
# Convenience targets to run 'build${target}' and 'install${target}' when
|
|
# calling 'make ${target}'.
|
|
.for __target in files includes
|
|
.if !target(${__target})
|
|
${__target}: build${__target} install${__target}
|
|
.ORDER: build${__target} install${__target}
|
|
.endif
|
|
.endfor
|
|
|
|
# Make 'install' supports a before and after target. Actual install
|
|
# hooks are placed in 'realinstall'.
|
|
.if !target(install)
|
|
.for __stage in before real after
|
|
.if !target(${__stage}install)
|
|
${__stage}install:
|
|
.endif
|
|
.endfor
|
|
install: beforeinstall realinstall afterinstall
|
|
.ORDER: beforeinstall realinstall afterinstall
|
|
.endif
|
|
|
|
# Subdir code shared among 'make <subdir>', 'make <target>' and SUBDIR_PARALLEL.
|
|
_SUBDIR_SH= \
|
|
if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \
|
|
dir=$${dir}.${MACHINE_ARCH}; \
|
|
fi; \
|
|
${ECHODIR} "===> ${DIRPRFX}$${dir} ($${target})"; \
|
|
cd ${.CURDIR}/$${dir}; \
|
|
${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/
|
|
|
|
_SUBDIR: .USEBEFORE
|
|
.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
|
|
@${_+_}target=${.TARGET}; \
|
|
for dir in ${SUBDIR:N.WAIT}; do ( ${_SUBDIR_SH} ); done
|
|
.endif
|
|
|
|
${SUBDIR:N.WAIT}: .PHONY .MAKE
|
|
${_+_}@target=all; \
|
|
dir=${.TARGET}; \
|
|
${_SUBDIR_SH};
|
|
|
|
# Work around parsing of .if nested in .for by putting .WAIT string into a var.
|
|
__wait= .WAIT
|
|
.for __target in ${ALL_SUBDIR_TARGETS}
|
|
# Can ordering be skipped for this and SUBDIR_PARALLEL forced?
|
|
.if make(${__target}) && ${STANDALONE_SUBDIR_TARGETS:M${__target}}
|
|
_is_standalone_target= 1
|
|
SUBDIR:= ${SUBDIR:N.WAIT}
|
|
.else
|
|
_is_standalone_target= 0
|
|
.endif
|
|
# Only recurse on directly-called targets. I.e., don't recurse on dependencies
|
|
# such as 'install' becoming {before,real,after}install, just recurse
|
|
# 'install'.
|
|
.if make(${__target})
|
|
.if defined(SUBDIR_PARALLEL) || ${_is_standalone_target} == 1
|
|
__subdir_targets=
|
|
.for __dir in ${SUBDIR}
|
|
.if ${__wait} == ${__dir}
|
|
__subdir_targets+= .WAIT
|
|
.else
|
|
__subdir_targets+= ${__target}_subdir_${__dir}
|
|
__deps=
|
|
.if ${_is_standalone_target} == 0
|
|
.for __dep in ${SUBDIR_DEPEND_${__dir}}
|
|
__deps+= ${__target}_subdir_${__dep}
|
|
.endfor
|
|
.endif
|
|
${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps}
|
|
.if !defined(NO_SUBDIR)
|
|
@${_+_}target=${__target}; \
|
|
dir=${__dir}; \
|
|
${_SUBDIR_SH};
|
|
.endif
|
|
.endif
|
|
.endfor # __dir in ${SUBDIR}
|
|
${__target}: ${__subdir_targets}
|
|
.else
|
|
${__target}: _SUBDIR
|
|
.endif # SUBDIR_PARALLEL || _is_standalone_target
|
|
.elif !target(${__target})
|
|
${__target}:
|
|
.endif # make(${__target})
|
|
.endfor # __target in ${ALL_SUBDIR_TARGETS}
|
|
|
|
.endif # !target(_SUBDIR)
|
|
|
|
.endif
|