summaryrefslogtreecommitdiffstats
path: root/share/mk/bsd.subdir.mk
diff options
context:
space:
mode:
Diffstat (limited to 'share/mk/bsd.subdir.mk')
-rw-r--r--share/mk/bsd.subdir.mk82
1 files changed, 42 insertions, 40 deletions
diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk
index 037a7fe..f9b9e97 100644
--- a/share/mk/bsd.subdir.mk
+++ b/share/mk/bsd.subdir.mk
@@ -28,6 +28,10 @@
# 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>__:
@@ -38,6 +42,10 @@ ALL_SUBDIR_TARGETS= all all-man buildconfig checkdpadd clean cleandepend \
realinstall regress tags \
${SUBDIR_TARGETS}
+# Described above.
+STANDALONE_SUBDIR_TARGETS?= obj checkdpadd clean cleandepend cleandir \
+ cleanilinks cleanobj
+
.include <bsd.init.mk>
.if !defined(NEED_SUBDIR)
@@ -63,35 +71,37 @@ distribute: .MAKE
.endfor
.endif
-_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}; \
+# 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; \
- ${MAKE} ${.TARGET:S,realinstall,install,:S,^_sub.,,} \
- DIRPRFX=${DIRPRFX}$$edir/; \
- done
+ ${ECHODIR} "===> ${DIRPRFX}$${dir} ($${target})"; \
+ cd ${.CURDIR}/$${dir}; \
+ ${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/
+
+_SUBDIR: .USEBEFORE
+.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
+ @${_+_}target=${.TARGET:S,realinstall,install,}; \
+ 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
.for __target in ${ALL_SUBDIR_TARGETS}
-.ifdef SUBDIR_PARALLEL
+# 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
+.if defined(SUBDIR_PARALLEL) || ${_is_standalone_target} == 1
__subdir_targets=
.for __dir in ${SUBDIR}
.if ${__wait} == ${__dir}
@@ -99,31 +109,24 @@ __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
-${__target}_subdir_${__dir}: .MAKE ${__deps}
+.endif
+${__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
+.endfor # __dir in ${SUBDIR}
${__target}: ${__subdir_targets}
.else
-${__target}: _sub.${__target}
-_sub.${__target}: _SUBDIR
-.endif
-.endfor
+${__target}: _SUBDIR
+.endif # SUBDIR_PARALLEL || _is_standalone_target
+.endfor # __target in ${ALL_SUBDIR_TARGETS}
# This is to support 'make includes' calling 'make buildincludes' and
# 'make installincludes' in the proper order, and to support these
@@ -132,8 +135,7 @@ _sub.${__target}: _SUBDIR
.for __stage in build install
${__stage}${__target}:
.if make(${__stage}${__target})
-${__stage}${__target}: _sub.${__stage}${__target}
-_sub.${__stage}${__target}: _SUBDIR
+${__stage}${__target}: _SUBDIR
.endif
.endfor
.if !target(${__target})
OpenPOWER on IntegriCloud