diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2015-10-19 23:34:35 +0000 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2015-10-19 23:34:35 +0000 |
commit | 7e742cf0a04e3fcc4ff79b8baad8964671acfd63 (patch) | |
tree | 1d91efaac7abb390debfaccf12a79a9e8d8a0c05 /share/mk | |
parent | dd315e14c555b0b686ca29b5cd709d0069b45c31 (diff) | |
download | FreeBSD-src-7e742cf0a04e3fcc4ff79b8baad8964671acfd63.zip FreeBSD-src-7e742cf0a04e3fcc4ff79b8baad8964671acfd63.tar.gz |
Replace all of the duplicated logic for recursing into a subdir with one
implementation. It is duplicated at run-time but is more easily
maintainable now.
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'share/mk')
-rw-r--r-- | share/mk/bsd.subdir.mk | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk index 9624a11..10a3016 100644 --- a/share/mk/bsd.subdir.mk +++ b/share/mk/bsd.subdir.mk @@ -63,30 +63,25 @@ distribute: .MAKE .endfor .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: .USE .MAKE .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) - @${_+_}for entry in ${SUBDIR:N.WAIT}; do \ - if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ - ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \ - edir=$${entry}.${MACHINE_ARCH}; \ - cd ${.CURDIR}/$${edir}; \ - else \ - ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \ - edir=$${entry}; \ - cd ${.CURDIR}/$${edir}; \ - fi; \ - ${MAKE} ${.TARGET:S,realinstall,install,:S,^_sub.,,} \ - DIRPRFX=${DIRPRFX}$$edir/; \ - done + @${_+_}target=${.TARGET:S,realinstall,install,:S,^_sub.,,}; \ + for dir in ${SUBDIR:N.WAIT}; do ${_SUBDIR_SH}; done .endif ${SUBDIR:N.WAIT}: .PHONY .MAKE - ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \ - cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ - else \ - cd ${.CURDIR}/${.TARGET}; \ - fi; \ - ${MAKE} all + ${_+_}@target=all; \ + dir=${.TARGET}; \ + ${_SUBDIR_SH}; # Work around parsing of .if nested in .for by putting .WAIT string into a var. __wait= .WAIT @@ -104,17 +99,9 @@ __deps+= ${__target}_subdir_${__dep} .endfor ${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps} .if !defined(NO_SUBDIR) - @${_+_}if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ - ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \ - edir=${__dir}.${MACHINE_ARCH}; \ - cd ${.CURDIR}/$${edir}; \ - else \ - ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \ - edir=${__dir}; \ - cd ${.CURDIR}/$${edir}; \ - fi; \ - ${MAKE} ${__target:realinstall=install} \ - DIRPRFX=${DIRPRFX}$$edir/ + @${_+_}target=${__target:realinstall=install}; \ + dir=${__dir}; \ + ${_SUBDIR_SH}; .endif .endif .endfor |