bsd.subdir.mk revision 265934
11844Swollman# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 250476Speter# $FreeBSD: stable/10/share/mk/bsd.subdir.mk 265934 2014-05-12 21:22:53Z 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 \ 50134903Simp ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:realinstall=install})"; \ 5190311Sru edir=$${entry}.${MACHINE_ARCH}; \ 5290311Sru cd ${.CURDIR}/$${edir}; \ 5390311Sru else \ 54134903Simp ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:realinstall=install})"; \ 5590311Sru edir=$${entry}; \ 5690311Sru cd ${.CURDIR}/$${edir}; \ 5790311Sru fi; \ 5890311Sru ${MAKE} ${.TARGET:realinstall=install} \ 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} 83264303Sdim${__target}_subdir_${__dir}: .MAKE 84264303Sdim @${_+_}set -e; \ 85264303Sdim if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ 86264303Sdim ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \ 87264303Sdim edir=${__dir}.${MACHINE_ARCH}; \ 88264303Sdim cd ${.CURDIR}/$${edir}; \ 89264303Sdim else \ 90264303Sdim ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \ 91264303Sdim edir=${__dir}; \ 92264303Sdim cd ${.CURDIR}/$${edir}; \ 93264303Sdim fi; \ 94264303Sdim ${MAKE} ${__target:realinstall=install} \ 95264303Sdim DIRPRFX=${DIRPRFX}$$edir/ 96265934Sian.endif 97264303Sdim.endfor 98265934Sian${__target}: ${__subdir_targets} 99264303Sdim.else 10095306Sru${__target}: _SUBDIR 101264303Sdim.endif 10215061Swosch.endfor 1031638Srgrimes 10497769Sru.for __target in files includes 10596668Sru.for __stage in build install 10696668Sru${__stage}${__target}: 10796668Sru.if make(${__stage}${__target}) 10896668Sru${__stage}${__target}: _SUBDIR 10996668Sru.endif 11096668Sru.endfor 111251749Ssjg${__target}: .MAKE 112241298Smarcel ${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} 11396668Sru.endfor 11496668Sru 1151638Srgrimes.if !target(install) 1161638Srgrimes.if !target(beforeinstall) 1171638Srgrimesbeforeinstall: 1181638Srgrimes.endif 1191638Srgrimes.if !target(afterinstall) 1201638Srgrimesafterinstall: 1211638Srgrimes.endif 12299215Sruinstall: beforeinstall realinstall afterinstall 12399215Sru.ORDER: beforeinstall realinstall afterinstall 1241638Srgrimes.endif 125242711Ssjg 126242711Ssjg.endif 127