From e54caebe4d2404ffc6992355eae07820219e31c2 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 22 Aug 2016 22:51:01 +0000 Subject: [PATCH] Stop using _SUBDIR internally for non-SUBDIR_PARALLEL builds. This is unifying more of the logic. Rather than create targets such as 'all: all_subdir_foo' when using SUBDIR_PARALLEL and using 'all: _SUBDIR' when not using SUBDIR_PARALLEL, always use the expanded out _subdir_ pattern. When not using SUBDIR_PARALLEL, have each directory-target depend on the previously defined targets as to respect the *order* of SUBDIR. Using 'make -N' now prints all directory traversals individually rather than using a loop, since a loop is no longer used to traverse. This is part of an effort to cleanup handling of some edge cases involving 'make ' and making it simpler in the sense that the pattern used to build is the same for all modes. MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division --- share/mk/bsd.subdir.mk | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk index 504ef3f6a3dc..39e001c7ee15 100644 --- a/share/mk/bsd.subdir.mk +++ b/share/mk/bsd.subdir.mk @@ -114,6 +114,8 @@ _SUBDIR_SH= \ cd ${.CURDIR}/$${dir}; \ ${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/ +# This is kept for compatibility only. The normal handling of attaching to +# SUBDIR_TARGETS will create a target for each directory. _SUBDIR: .USEBEFORE .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) @${_+_}target=${.TARGET:realinstall=install}; \ @@ -139,29 +141,31 @@ SUBDIR:= ${SUBDIR:N.WAIT} .else _is_standalone_target= 0 .endif -.if defined(SUBDIR_PARALLEL) || ${_is_standalone_target} == 1 __subdir_targets= .for __dir in ${SUBDIR} .if ${__dir} == .WAIT __subdir_targets+= .WAIT .else -__subdir_targets+= ${__target}_subdir_${DIRPRFX}${__dir} __deps= .if ${_is_standalone_target} == 0 +.if defined(SUBDIR_PARALLEL) +# Apply SUBDIR_DEPEND dependencies for SUBDIR_PARALLEL. .for __dep in ${SUBDIR_DEPEND_${__dir}} __deps+= ${__target}_subdir_${DIRPRFX}${__dep} .endfor -.endif +.else +# For non-parallel builds, directories depend on all targets before them. +__deps:= ${__subdir_targets} +.endif # defined(SUBDIR_PARALLEL) +.endif # ${_is_standalone_target} == 0 ${__target}_subdir_${DIRPRFX}${__dir}: .PHONY .MAKE .SILENT ${__deps} @${_+_}target=${__target:realinstall=install}; \ dir=${__dir}; \ ${_SUBDIR_SH}; -.endif +__subdir_targets+= ${__target}_subdir_${DIRPRFX}${__dir} +.endif # ${__dir} == .WAIT .endfor # __dir in ${SUBDIR} ${__target}: ${__subdir_targets} .PHONY -.else -${__target}: _SUBDIR .PHONY -.endif # SUBDIR_PARALLEL || _is_standalone_target .endif # make(${__target}) .endfor # __target in ${SUBDIR_TARGETS}