bsd.subdir.mk revision 94940
1# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 2# $FreeBSD: head/share/mk/bsd.subdir.mk 94940 2002-04-17 13:49:29Z ru $ 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. [bin] 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. 20# 21# +++ targets +++ 22# 23# distribute: 24# This is a variant of install, which will 25# put the stuff into the right "distribution". 26# 27# afterdistribute, afterinstall, all, all-man, beforeinstall, checkdpadd, 28# clean, cleandepend, cleandir, depend, install, lint, maninstall, 29# obj, objlink, realinstall, regress, tags 30# 31 32.include <bsd.init.mk> 33 34_SUBDIRUSE: .USE 35 @for entry in ${SUBDIR}; do \ 36 (if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ 37 ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \ 38 edir=$${entry}.${MACHINE_ARCH}; \ 39 cd ${.CURDIR}/$${edir}; \ 40 else \ 41 ${ECHODIR} "===> ${DIRPRFX}$$entry"; \ 42 edir=$${entry}; \ 43 cd ${.CURDIR}/$${edir}; \ 44 fi; \ 45 ${MAKE} ${.TARGET:realinstall=install} \ 46 DIRPRFX=${DIRPRFX}$$edir/); \ 47 done 48 49${SUBDIR}:: 50 @if test -d ${.TARGET}.${MACHINE_ARCH}; then \ 51 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ 52 else \ 53 cd ${.CURDIR}/${.TARGET}; \ 54 fi; \ 55 ${MAKE} all 56 57 58.for __target in all all-man checkdpadd clean cleandepend cleandir depend lint \ 59 maninstall obj objlink regress tags \ 60 install.debug reinstall.debug 61.if !target(${__target}) 62${__target}: _SUBDIRUSE 63.endif 64.endfor 65 66.if !target(install) 67.if !target(beforeinstall) 68beforeinstall: 69.endif 70.if !target(afterinstall) 71afterinstall: 72.endif 73install: afterinstall 74afterinstall: realinstall 75realinstall: beforeinstall _SUBDIRUSE 76.endif 77 78DISTRIBUTION?= bin 79.if !target(afterdistribute) 80afterdistribute: 81.endif 82.if !target(distribute) 83distribute: _SUBDIRUSE 84.for dist in ${DISTRIBUTION} 85 cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist} 86.endfor 87.endif 88