1# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 2# $FreeBSD$ 3# 4# The include file <bsd.subdir.mk> contains the default targets 5# for building subdirectories. 6# 7# For all of the directories listed in the variable SUBDIRS, the 8# specified directory will be visited and the target made. There is 9# also a default target which allows the command "make subdir" where 10# subdir is any directory listed in the variable SUBDIRS. 11# 12# 13# +++ variables +++ 14# 15# DISTRIBUTION Name of distribution. [base] 16# 17# SUBDIR A list of subdirectories that should be built as well. 18# Each of the targets will execute the same target in the 19# subdirectories. SUBDIR.yes is automatically appeneded 20# to this list. 21# 22# +++ targets +++ 23# 24# distribute: 25# This is a variant of install, which will 26# put the stuff into the right "distribution". 27# 28# afterinstall, all, all-man, beforeinstall, checkdpadd, clean, 29# cleandepend, cleandir, cleanilinks depend, install, lint, 30# maninstall, manlint, obj, objlink, realinstall, regress, tags 31# 32 33.if !target(__<bsd.subdir.mk>__) 34__<bsd.subdir.mk>__: 35 36.include <bsd.init.mk> 37 38.if !defined(NEED_SUBDIR) 39.if ${.MAKE.LEVEL} == 0 && ${MK_META_MODE} == "yes" && !empty(SUBDIR) && !(make(clean*) || make(destroy*)) 40.include <meta.subdir.mk> 41# ignore this 42_SUBDIR: 43.endif 44.endif 45.if !target(_SUBDIR) 46 47.if defined(SUBDIR) 48SUBDIR:=${SUBDIR} ${SUBDIR.yes} 49SUBDIR:=${SUBDIR:u} 50.endif 51 52DISTRIBUTION?= base 53.if !target(distribute) 54distribute: .MAKE 55.for dist in ${DISTRIBUTION} 56 ${_+_}cd ${.CURDIR}; \ 57 ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies 58.endfor 59.endif 60 61_SUBDIR: .USE .MAKE 62.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) 63 @${_+_}for entry in ${SUBDIR:N.WAIT}; do \ 64 if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ 65 ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \ 66 edir=$${entry}.${MACHINE_ARCH}; \ 67 cd ${.CURDIR}/$${edir}; \ 68 else \ 69 ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \ 70 edir=$${entry}; \ 71 cd ${.CURDIR}/$${edir}; \ 72 fi; \ 73 ${MAKE} ${.TARGET:S,realinstall,install,:S,^_sub.,,} \ 74 DIRPRFX=${DIRPRFX}$$edir/; \ 75 done 76.endif 77 78${SUBDIR:N.WAIT}: .PHONY .MAKE 79 ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \ 80 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ 81 else \ 82 cd ${.CURDIR}/${.TARGET}; \ 83 fi; \ 84 ${MAKE} all 85 86# Work around parsing of .if nested in .for by putting .WAIT string into a var. 87__wait= .WAIT 88.for __target in all all-man checkdpadd clean cleandepend cleandir \ 89 cleanilinks depend distribute lint maninstall manlint obj objlink \ 90 realinstall regress tags ${SUBDIR_TARGETS} 91.ifdef SUBDIR_PARALLEL 92__subdir_targets= 93.for __dir in ${SUBDIR} 94.if ${__wait} == ${__dir} 95__subdir_targets+= .WAIT 96.else 97__subdir_targets+= ${__target}_subdir_${__dir} 98__deps= 99.for __dep in ${SUBDIR_DEPEND_${__dir}} 100__deps+= ${__target}_subdir_${__dep} 101.endfor 102${__target}_subdir_${__dir}: .MAKE ${__deps} 103.if !defined(NO_SUBDIR) 104 @${_+_}if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ 105 ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \ 106 edir=${__dir}.${MACHINE_ARCH}; \ 107 cd ${.CURDIR}/$${edir}; \ 108 else \ 109 ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \ 110 edir=${__dir}; \ 111 cd ${.CURDIR}/$${edir}; \ 112 fi; \ 113 ${MAKE} ${__target:realinstall=install} \ 114 DIRPRFX=${DIRPRFX}$$edir/ 115.endif 116.endif 117.endfor 118${__target}: ${__subdir_targets} 119.else 120${__target}: _sub.${__target} 121_sub.${__target}: _SUBDIR 122.endif 123.endfor 124 125.for __target in files includes config 126.for __stage in build install 127${__stage}${__target}: 128.if make(${__stage}${__target}) 129${__stage}${__target}: _sub.${__stage}${__target} 130_sub.${__stage}${__target}: _SUBDIR 131.endif 132.endfor 133.if !target(${__target}) 134${__target}: .MAKE 135 ${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} 136.endif 137.endfor 138 139.endif 140 141.if !target(install) 142.if !target(beforeinstall) 143beforeinstall: 144.endif 145.if !target(afterinstall) 146afterinstall: 147.endif 148install: beforeinstall realinstall afterinstall 149.ORDER: beforeinstall realinstall afterinstall 150.endif 151 152.endif 153