11844Swollman# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 250476Speter# $FreeBSD: stable/10/share/mk/bsd.subdir.mk 313790 2017-02-16 05:14:07Z ngie $ 323549Swosch# 423549Swosch# The include file <bsd.subdir.mk> contains the default targets 5139761Skrion# for building subdirectories. 623549Swosch# 723549Swosch# For all of the directories listed in the variable SUBDIRS, the 823549Swosch# specified directory will be visited and the target made. There is 923549Swosch# also a default target which allows the command "make subdir" where 1023549Swosch# subdir is any directory listed in the variable SUBDIRS. 1123549Swosch# 1223549Swosch# 1323549Swosch# +++ variables +++ 1423549Swosch# 1595327Sobrien# DISTRIBUTION Name of distribution. [base] 1623549Swosch# 1723549Swosch# SUBDIR A list of subdirectories that should be built as well. 1823549Swosch# Each of the targets will execute the same target in the 1923549Swosch# subdirectories. 2023549Swosch# 2123549Swosch# +++ targets +++ 2223549Swosch# 2323549Swosch# distribute: 2423549Swosch# This is a variant of install, which will 2523549Swosch# put the stuff into the right "distribution". 2623549Swosch# 27313790Sngie# afterinstall, all, all-man, beforeinstall, check, checkdpadd, clean, 28200178Sed# cleandepend, cleandir, cleanilinks depend, install, lint, 29313790Sngie# maninstall, manlint, obj, objlink, realinstall, tags 3023549Swosch# 311638Srgrimes 32242711Ssjg.if !target(__<bsd.subdir.mk>__) 33242711Ssjg__<bsd.subdir.mk>__: 34242711Ssjg 3594940Sru.include <bsd.init.mk> 3623549Swosch 3799875SruDISTRIBUTION?= base 3899875Sru.if !target(distribute) 39251749Ssjgdistribute: .MAKE 4099875Sru.for dist in ${DISTRIBUTION} 41133369Sharti ${_+_}cd ${.CURDIR}; \ 4299875Sru ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies 4399875Sru.endfor 4499875Sru.endif 4599875Sru 46251749Ssjg_SUBDIR: .USE .MAKE 4799875Sru.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) 48313789Sngie @${_+_}for entry in ${SUBDIR:N.WAIT}; do \ 4995306Sru if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ 50270187Sian ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \ 5190311Sru edir=$${entry}.${MACHINE_ARCH}; \ 5290311Sru cd ${.CURDIR}/$${edir}; \ 5390311Sru else \ 54270187Sian ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \ 5590311Sru edir=$${entry}; \ 5690311Sru cd ${.CURDIR}/$${edir}; \ 5790311Sru fi; \ 58270187Sian ${MAKE} ${.TARGET:S,realinstall,install,:S,^_sub.,,} \ 5995306Sru DIRPRFX=${DIRPRFX}$$edir/; \ 601638Srgrimes done 6195306Sru.endif 621638Srgrimes 63265934Sian${SUBDIR:N.WAIT}: .PHONY .MAKE 64133369Sharti ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \ 6553152Smarcel cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ 661638Srgrimes else \ 671638Srgrimes cd ${.CURDIR}/${.TARGET}; \ 681638Srgrimes fi; \ 69146817Sru ${MAKE} all 701638Srgrimes 71265934Sian# Work around parsing of .if nested in .for by putting .WAIT string into a var. 72265934Sian__wait= .WAIT 73313790Sngie.for __target in all all-man check checkdpadd clean cleandepend cleandir \ 74200178Sed cleanilinks depend distribute lint maninstall manlint obj objlink \ 75313790Sngie realinstall tags ${SUBDIR_TARGETS} 76264303Sdim.ifdef SUBDIR_PARALLEL 77265934Sian__subdir_targets= 78264303Sdim.for __dir in ${SUBDIR} 79265934Sian.if ${__wait} == ${__dir} 80265934Sian__subdir_targets+= .WAIT 81265934Sian.else 82265934Sian__subdir_targets+= ${__target}_subdir_${__dir} 83270187Sian__deps= 84270187Sian.for __dep in ${SUBDIR_DEPEND_${__dir}} 85270187Sian__deps+= ${__target}_subdir_${__dep} 86270187Sian.endfor 87291777Sbdrewery${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps} 88270187Sian.if !defined(NO_SUBDIR) 89313789Sngie @${_+_}if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ 90264303Sdim ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \ 91264303Sdim edir=${__dir}.${MACHINE_ARCH}; \ 92264303Sdim cd ${.CURDIR}/$${edir}; \ 93264303Sdim else \ 94264303Sdim ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \ 95264303Sdim edir=${__dir}; \ 96264303Sdim cd ${.CURDIR}/$${edir}; \ 97264303Sdim fi; \ 98264303Sdim ${MAKE} ${__target:realinstall=install} \ 99264303Sdim DIRPRFX=${DIRPRFX}$$edir/ 100265934Sian.endif 101270187Sian.endif 102264303Sdim.endfor 103265934Sian${__target}: ${__subdir_targets} 104264303Sdim.else 105270187Sian${__target}: _sub.${__target} 106270187Sian_sub.${__target}: _SUBDIR 107264303Sdim.endif 10815061Swosch.endfor 1091638Srgrimes 11097769Sru.for __target in files includes 11196668Sru.for __stage in build install 11296668Sru${__stage}${__target}: 11396668Sru.if make(${__stage}${__target}) 114270187Sian${__stage}${__target}: _sub.${__stage}${__target} 115270187Sian_sub.${__stage}${__target}: _SUBDIR 11696668Sru.endif 11796668Sru.endfor 118270187Sian.if !target(${__target}) 119251749Ssjg${__target}: .MAKE 120313789Sngie ${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} 121270187Sian.endif 12296668Sru.endfor 12396668Sru 1241638Srgrimes.if !target(install) 1251638Srgrimes.if !target(beforeinstall) 1261638Srgrimesbeforeinstall: 1271638Srgrimes.endif 1281638Srgrimes.if !target(afterinstall) 1291638Srgrimesafterinstall: 1301638Srgrimes.endif 13199215Sruinstall: beforeinstall realinstall afterinstall 13299215Sru.ORDER: beforeinstall realinstall afterinstall 1331638Srgrimes.endif 134242711Ssjg 135242711Ssjg.endif 136