bsd.subdir.mk revision 270187
11844Swollman# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 250476Speter# $FreeBSD: stable/10/share/mk/bsd.subdir.mk 270187 2014-08-19 23:33:51Z ian $ 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# 27200178Sed# afterinstall, all, all-man, beforeinstall, checkdpadd, clean, 28200178Sed# cleandepend, cleandir, cleanilinks depend, install, lint, 29200178Sed# maninstall, manlint, obj, objlink, realinstall, regress, 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) 48265934Sian @${_+_}set -e; 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 7395509Sru.for __target in all all-man checkdpadd clean cleandepend cleandir \ 74200178Sed cleanilinks depend distribute lint maninstall manlint obj objlink \ 75200178Sed realinstall regress 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 87270187Sian${__target}_subdir_${__dir}: .MAKE ${__deps} 88270187Sian.if !defined(NO_SUBDIR) 89264303Sdim @${_+_}set -e; \ 90264303Sdim if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ 91264303Sdim ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \ 92264303Sdim edir=${__dir}.${MACHINE_ARCH}; \ 93264303Sdim cd ${.CURDIR}/$${edir}; \ 94264303Sdim else \ 95264303Sdim ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \ 96264303Sdim edir=${__dir}; \ 97264303Sdim cd ${.CURDIR}/$${edir}; \ 98264303Sdim fi; \ 99264303Sdim ${MAKE} ${__target:realinstall=install} \ 100264303Sdim DIRPRFX=${DIRPRFX}$$edir/ 101265934Sian.endif 102270187Sian.endif 103264303Sdim.endfor 104265934Sian${__target}: ${__subdir_targets} 105264303Sdim.else 106270187Sian${__target}: _sub.${__target} 107270187Sian_sub.${__target}: _SUBDIR 108264303Sdim.endif 10915061Swosch.endfor 1101638Srgrimes 11197769Sru.for __target in files includes 11296668Sru.for __stage in build install 11396668Sru${__stage}${__target}: 11496668Sru.if make(${__stage}${__target}) 115270187Sian${__stage}${__target}: _sub.${__stage}${__target} 116270187Sian_sub.${__stage}${__target}: _SUBDIR 11796668Sru.endif 11896668Sru.endfor 119270187Sian.if !target(${__target}) 120251749Ssjg${__target}: .MAKE 121241298Smarcel ${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} 122270187Sian.endif 12396668Sru.endfor 12496668Sru 1251638Srgrimes.if !target(install) 1261638Srgrimes.if !target(beforeinstall) 1271638Srgrimesbeforeinstall: 1281638Srgrimes.endif 1291638Srgrimes.if !target(afterinstall) 1301638Srgrimesafterinstall: 1311638Srgrimes.endif 13299215Sruinstall: beforeinstall realinstall afterinstall 13399215Sru.ORDER: beforeinstall realinstall afterinstall 1341638Srgrimes.endif 135242711Ssjg 136242711Ssjg.endif 137