bsd.subdir.mk revision 99875
1139749Simp# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 2113584Ssimokawa# $FreeBSD: head/share/mk/bsd.subdir.mk 99875 2002-07-12 15:09:35Z ru $ 3103285Sikob# 4103285Sikob# The include file <bsd.subdir.mk> contains the default targets 5103285Sikob# for building subdirectories. 6103285Sikob# 7103285Sikob# For all of the directories listed in the variable SUBDIRS, the 8103285Sikob# specified directory will be visited and the target made. There is 9103285Sikob# also a default target which allows the command "make subdir" where 10103285Sikob# subdir is any directory listed in the variable SUBDIRS. 11103285Sikob# 12103285Sikob# 13103285Sikob# +++ variables +++ 14103285Sikob# 15103285Sikob# DISTRIBUTION Name of distribution. [base] 16103285Sikob# 17103285Sikob# SUBDIR A list of subdirectories that should be built as well. 18103285Sikob# Each of the targets will execute the same target in the 19103285Sikob# subdirectories. 20103285Sikob# 21103285Sikob# +++ targets +++ 22103285Sikob# 23103285Sikob# distribute: 24103285Sikob# This is a variant of install, which will 25103285Sikob# put the stuff into the right "distribution". 26103285Sikob# 27103285Sikob# afterinstall, all, all-man, beforeinstall, checkdpadd, 28103285Sikob# clean, cleandepend, cleandir, depend, install, lint, maninstall, 29103285Sikob# obj, objlink, realinstall, regress, tags 30103285Sikob# 31103285Sikob 32103285Sikob.include <bsd.init.mk> 33103285Sikob 34103285SikobDISTRIBUTION?= base 35103285Sikob.if !target(distribute) 36103285Sikobdistribute: 37113584Ssimokawa.for dist in ${DISTRIBUTION} 38170374Ssimokawa cd ${.CURDIR}; \ 39170374Ssimokawa ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies 40170374Ssimokawa.endfor 41170374Ssimokawa.endif 42127468Ssimokawa 43170374Ssimokawa_SUBDIR: .USE 44113584Ssimokawa.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) 45113584Ssimokawa @for entry in ${SUBDIR}; do \ 46103285Sikob if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ 47103285Sikob ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \ 48103285Sikob edir=$${entry}.${MACHINE_ARCH}; \ 49103285Sikob cd ${.CURDIR}/$${edir}; \ 50103285Sikob else \ 51127468Ssimokawa ${ECHODIR} "===> ${DIRPRFX}$$entry"; \ 52103285Sikob edir=$${entry}; \ 53121506Ssimokawa cd ${.CURDIR}/$${edir}; \ 54103285Sikob fi; \ 55103285Sikob ${MAKE} ${.TARGET:realinstall=install} \ 56103285Sikob DIRPRFX=${DIRPRFX}$$edir/; \ 57103285Sikob done 58103285Sikob.endif 59103285Sikob 60103285Sikob${SUBDIR}:: 61103285Sikob @if test -d ${.TARGET}.${MACHINE_ARCH}; then \ 62103285Sikob cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ 63103285Sikob else \ 64108527Ssimokawa cd ${.CURDIR}/${.TARGET}; \ 65103285Sikob fi; \ 66113584Ssimokawa ${MAKE} all 67113584Ssimokawa 68109379Ssimokawa 69113584Ssimokawa.for __target in all all-man checkdpadd clean cleandepend cleandir \ 70113584Ssimokawa depend distribute lint maninstall \ 71113584Ssimokawa obj objlink realinstall regress tags 72108276Ssimokawa${__target}: _SUBDIR 73103285Sikob.endfor 74129585Sdfr 75113584Ssimokawa.for __target in files includes 76113584Ssimokawa.for __stage in build install 77113584Ssimokawa${__stage}${__target}: 78129585Sdfr.if make(${__stage}${__target}) 79129585Sdfr${__stage}${__target}: _SUBDIR 80170374Ssimokawa.endif 81170374Ssimokawa.endfor 82170374Ssimokawa${__target}: 83167628Ssimokawa cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} 84103285Sikob.endfor 85113584Ssimokawa 86124169Ssimokawa.if !target(install) 87170374Ssimokawa.if !target(beforeinstall) 88124169Ssimokawabeforeinstall: 89124169Ssimokawa.endif 90124169Ssimokawa.if !target(afterinstall) 91124169Ssimokawaafterinstall: 92124169Ssimokawa.endif 93124169Ssimokawainstall: beforeinstall realinstall afterinstall 94.ORDER: beforeinstall realinstall afterinstall 95.endif 96