Changeset View
Changeset View
Standalone View
Standalone View
share/mk/bsd.subdir.mk
Show All 13 Lines | |||||
# | # | ||||
# DISTRIBUTION Name of distribution. [base] | # DISTRIBUTION Name of distribution. [base] | ||||
# | # | ||||
# SUBDIR A list of subdirectories that should be built as well. | # SUBDIR A list of subdirectories that should be built as well. | ||||
# Each of the targets will execute the same target in the | # Each of the targets will execute the same target in the | ||||
# subdirectories. SUBDIR.yes and SUBDIR.yes.yes are | # subdirectories. SUBDIR.yes and SUBDIR.yes.yes are | ||||
# automatically appended to this list. | # automatically appended to this list. | ||||
# | # | ||||
# SUBDIR_WITH_INCS A list of subdirectories that installs includes. If this | |||||
# variable is not set, it will behave as if set to SUBDIR excluding "test" | |||||
# and "tests". | |||||
# | |||||
# +++ targets +++ | # +++ targets +++ | ||||
# | # | ||||
# distribute: | # distribute: | ||||
# This is a variant of install, which will | # This is a variant of install, which will | ||||
# put the stuff into the right "distribution". | # put the stuff into the right "distribution". | ||||
# | # | ||||
# See SUBDIR_TARGETS for list of targets that will recurse. | # See SUBDIR_TARGETS for list of targets that will recurse. | ||||
# | # | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
# Subdir code shared among 'make <subdir>', 'make <target>' and SUBDIR_PARALLEL. | # Subdir code shared among 'make <subdir>', 'make <target>' and SUBDIR_PARALLEL. | ||||
_SUBDIR_SH= \ | _SUBDIR_SH= \ | ||||
if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \ | if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \ | ||||
dir=$${dir}.${MACHINE_ARCH}; \ | dir=$${dir}.${MACHINE_ARCH}; \ | ||||
fi; \ | fi; \ | ||||
${ECHODIR} "===> ${DIRPRFX}$${dir} ($${target})"; \ | ${ECHODIR} "===> ${DIRPRFX}$${dir} ($${target})"; \ | ||||
cd ${.CURDIR}/$${dir}; \ | cd ${.CURDIR}/$${dir}; \ | ||||
${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/ | _HAVE_INCS=$${have_incs} ${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/ | ||||
# This is kept for compatibility only. The normal handling of attaching to | # This is kept for compatibility only. The normal handling of attaching to | ||||
# SUBDIR_TARGETS will create a target for each directory. | # SUBDIR_TARGETS will create a target for each directory. | ||||
_SUBDIR: .USEBEFORE | _SUBDIR: .USEBEFORE | ||||
.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) | .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) | ||||
@${_+_}target=${.TARGET:realinstall=install}; \ | @${_+_}target=${.TARGET:realinstall=install}; \ | ||||
for dir in ${SUBDIR:N.WAIT}; do ( ${_SUBDIR_SH} ); done | for dir in ${SUBDIR:N.WAIT}; do ( ${_SUBDIR_SH} ); done | ||||
.endif | .endif | ||||
# Create 'make subdir' targets to run the real 'all' target. | # Create 'make subdir' targets to run the real 'all' target. | ||||
.for __dir in ${SUBDIR:N.WAIT} | .for __dir in ${SUBDIR:N.WAIT} | ||||
${__dir}: all_subdir_${DIRPRFX}${__dir} .PHONY | ${__dir}: all_subdir_${DIRPRFX}${__dir} .PHONY | ||||
.endfor | .endfor | ||||
# Skip the includes/installincludes target for subdirs that don't have includes | |||||
# as this massively speeds up the make includes part of buildworld. | |||||
# We assume that tests don't need to install includes by default (if they do, | |||||
# you can just set SUBDIR_WITH_INCS=tests in the Makefile). | |||||
bdrewery: Can we make it optional and default on? I don't think we need a MK_FOO option just a `.if ! | |||||
.for __dir in ${SUBDIR:N.WAIT} | |||||
.if defined(SUBDIR_WITH_INCS) | |||||
.if ${SUBDIR_WITH_INCS:M${__dir}} == "${__dir}" | |||||
brooksUnsubmitted Done Inline ActionsIs the == "${__dir}" needed? brooks: Is the `== "${__dir}"` needed? | |||||
arichardsonAuthorUnsubmitted Done Inline ActionsGood catch, :M can be used as a boolean expression. arichardson: Good catch, :M can be used as a boolean expression. | |||||
__have_incs_${__dir}=yes | |||||
.else | |||||
__have_incs_${__dir}=no | |||||
.endif | |||||
.else | |||||
.if ${__dir} == "test" || ${__dir} == "tests" | |||||
# Assume that tests don't need to install includes by default | |||||
__have_incs_${__dir}=no | |||||
.else | |||||
__have_incs_${__dir}=maybe | |||||
.endif | |||||
.endif | |||||
.endfor | |||||
.for __target in ${SUBDIR_TARGETS} | .for __target in ${SUBDIR_TARGETS} | ||||
# Can ordering be skipped for this and SUBDIR_PARALLEL forced? | # Can ordering be skipped for this and SUBDIR_PARALLEL forced? | ||||
.if ${STANDALONE_SUBDIR_TARGETS:M${__target}} | .if ${STANDALONE_SUBDIR_TARGETS:M${__target}} | ||||
_is_standalone_target= 1 | _is_standalone_target= 1 | ||||
_subdir_filter= N.WAIT | _subdir_filter= N.WAIT | ||||
.else | .else | ||||
_is_standalone_target= 0 | _is_standalone_target= 0 | ||||
_subdir_filter= | _subdir_filter= | ||||
Show All 10 Lines | |||||
.for __dep in ${SUBDIR_DEPEND_${__dir}} | .for __dep in ${SUBDIR_DEPEND_${__dir}} | ||||
__deps+= ${__target}_subdir_${DIRPRFX}${__dep} | __deps+= ${__target}_subdir_${DIRPRFX}${__dep} | ||||
.endfor | .endfor | ||||
.else | .else | ||||
# For non-parallel builds, directories depend on all targets before them. | # For non-parallel builds, directories depend on all targets before them. | ||||
__deps:= ${__subdir_targets} | __deps:= ${__subdir_targets} | ||||
.endif # defined(SUBDIR_PARALLEL) | .endif # defined(SUBDIR_PARALLEL) | ||||
.endif # ${_is_standalone_target} == 0 | .endif # ${_is_standalone_target} == 0 | ||||
.if (${__target} != "installincludes" && ${__target} != "includes") || \ | |||||
${__have_incs_${__dir}} != "no" || defined(_SANITITY_CHECK_INCS) | |||||
${__target}_subdir_${DIRPRFX}${__dir}: .PHONY .MAKE .SILENT ${__deps} | ${__target}_subdir_${DIRPRFX}${__dir}: .PHONY .MAKE .SILENT ${__deps} | ||||
@${_+_}target=${__target:realinstall=install}; \ | @${_+_}target=${__target:realinstall=install}; \ | ||||
dir=${__dir}; \ | dir=${__dir}; have_incs=${__have_incs_${__dir}}; \ | ||||
${_SUBDIR_SH}; | ${_SUBDIR_SH}; | ||||
__subdir_targets+= ${__target}_subdir_${DIRPRFX}${__dir} | __subdir_targets+= ${__target}_subdir_${DIRPRFX}${__dir} | ||||
.endif | |||||
.endif # ${__dir} == .WAIT | .endif # ${__dir} == .WAIT | ||||
.endfor # __dir in ${SUBDIR} | .endfor # __dir in ${SUBDIR} | ||||
# Attach the subdir targets to the real target. | # Attach the subdir targets to the real target. | ||||
# Only recurse on directly-called targets. I.e., don't recurse on dependencies | # Only recurse on directly-called targets. I.e., don't recurse on dependencies | ||||
# such as 'install' becoming {before,real,after}install, just recurse | # such as 'install' becoming {before,real,after}install, just recurse | ||||
# 'install'. Despite that, 'realinstall' is special due to ordering issues | # 'install'. Despite that, 'realinstall' is special due to ordering issues | ||||
# with 'afterinstall'. | # with 'afterinstall'. | ||||
Show All 16 Lines |
Can we make it optional and default on? I don't think we need a MK_FOO option just a .if !defined(SUBDIR_INCS_ALL_DIRS) or something wrapping the logic here. Then at least it will be easier to flip later if we find a problem or complaints.