bsd.subdir.mk revision 35784
1# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 2# $Id: bsd.subdir.mk,v 1.23 1998/03/29 01:10:09 eivind Exp $ 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# SUBDIR_CHANGE A directory-tree that contains overrides for 22# corresponding build subdirs. 23# Each override is a file containing one subdirname per line: 24# 'subdirlist' is a pure override 25# 'subdirdrop' drops directories from the build 26# 'subdiradd' adds directories to the build 27# 28# +++ targets +++ 29# 30# distribute: 31# This is a variant of install, which will 32# put the stuff into the right "distribution". 33# 34# afterdistribute, afterinstall, all, beforeinstall, checkdpadd, 35# clean, cleandepend, cleandir, depend, install, lint, maninstall, 36# obj, objlink, realinstall, regress, tags 37# 38 39 40.MAIN: all 41 42.if defined(SUBDIR_CHANGE) && !empty(SUBDIR_CHANGE) && \ 43 exists(${SUBDIR_CHANGE}/${DIRPRFX}/subdirlist) 44SUBDIR!=cat ${SUBDIR_CHANGE}/${DIRPRFX}/subdirlist 45.endif 46 47.if defined(SUBDIR_CHANGE) && !empty(SUBDIR_CHANGE) && \ 48 exists(${SUBDIR_CHANGE}/${DIRPRFX}/subdirlist) 49_SUBDIR_EXTRA!=cat ${SUBDIR_CHANGE}/${DIRPRFX}/subdiradd 50.endif 51 52_SUBDIRUSE: .USE 53 @for entry in ${SUBDIR} ${_SUBDIR_EXTRA}; do \ 54 (if ! (test -f ${SUBDIR_CHANGE}/${DIRPRFX}/subdirdrop && \ 55 grep -w $${entry} \ 56 ${SUBDIR_CHANGE}/${DIRPRFX}/subdirdrop \ 57 > /dev/null); then \ 58 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 59 ${ECHODIR} \ 60 "===> ${DIRPRFX}$${entry}.${MACHINE}"; \ 61 edir=$${entry}.${MACHINE}; \ 62 cd ${.CURDIR}/$${edir}; \ 63 else \ 64 ${ECHODIR} "===> ${DIRPRFX}$$entry"; \ 65 edir=$${entry}; \ 66 cd ${.CURDIR}/$${edir}; \ 67 fi; \ 68 ${MAKE} ${.TARGET:realinstall=install} \ 69 SUBDIR_CHANGE=${SUBDIR_CHANGE} \ 70 DIRPRFX=${DIRPRFX}$$edir/; \ 71 fi; \ 72 ); \ 73 done 74 75${SUBDIR}:: 76 @if test -d ${.TARGET}.${MACHINE}; then \ 77 cd ${.CURDIR}/${.TARGET}.${MACHINE}; \ 78 else \ 79 cd ${.CURDIR}/${.TARGET}; \ 80 fi; \ 81 ${MAKE} all 82 83 84.for __target in all checkdpadd clean cleandepend cleandir depend lint \ 85 maninstall obj objlink regress tags 86.if !target(${__target}) 87${__target}: _SUBDIRUSE 88.endif 89.endfor 90 91.if !target(install) 92.if !target(beforeinstall) 93beforeinstall: 94.endif 95.if !target(afterinstall) 96afterinstall: 97.endif 98install: afterinstall 99afterinstall: realinstall 100realinstall: beforeinstall _SUBDIRUSE 101.endif 102 103DISTRIBUTION?= bin 104.if !target(afterdistribute) 105afterdistribute: 106.endif 107.if !target(distribute) 108distribute: _SUBDIRUSE 109.for dist in ${DISTRIBUTION} 110 cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist} 111.endfor 112.endif 113