1 # from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
4 # The include file <bsd.subdir.mk> contains the default targets
5 # for building subdirectories.
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.
15 # DISTRIBUTION Name of distribution. [base]
17 # SUBDIR A list of subdirectories that should be built as well.
18 # Each of the targets will execute the same target in the
24 # This is a variant of install, which will
25 # put the stuff into the right "distribution".
27 # afterinstall, all, all-man, beforeinstall, checkdpadd, clean,
28 # cleandepend, cleandir, cleanilinks depend, install, lint,
29 # maninstall, manlint, obj, objlink, realinstall, regress, tags
32 .include <bsd.init.mk>
35 .if !target(distribute)
37 .for dist in ${DISTRIBUTION}
38 ${_+_}cd ${.CURDIR}; \
39 ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
44 .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
45 @${_+_}set -e; for entry in ${SUBDIR}; do \
46 if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
47 ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:realinstall=install})"; \
48 edir=$${entry}.${MACHINE_ARCH}; \
49 cd ${.CURDIR}/$${edir}; \
51 ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:realinstall=install})"; \
53 cd ${.CURDIR}/$${edir}; \
55 ${MAKE} ${.TARGET:realinstall=install} \
56 DIRPRFX=${DIRPRFX}$$edir/; \
61 ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
62 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
64 cd ${.CURDIR}/${.TARGET}; \
68 .for __target in all all-man checkdpadd clean cleandepend cleandir \
69 cleanilinks depend distribute lint maninstall manlint obj objlink \
70 realinstall regress tags ${SUBDIR_TARGETS}
71 .ifdef SUBDIR_PARALLEL
72 .for __dir in ${SUBDIR}
73 ${__target}: ${__target}_subdir_${__dir}
74 ${__target}_subdir_${__dir}: .MAKE
76 if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \
77 ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \
78 edir=${__dir}.${MACHINE_ARCH}; \
79 cd ${.CURDIR}/$${edir}; \
81 ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \
83 cd ${.CURDIR}/$${edir}; \
85 ${MAKE} ${__target:realinstall=install} \
86 DIRPRFX=${DIRPRFX}$$edir/
93 .for __target in files includes
94 .for __stage in build install
95 ${__stage}${__target}:
96 .if make(${__stage}${__target})
97 ${__stage}${__target}: _SUBDIR
101 ${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
105 .if !target(beforeinstall)
108 .if !target(afterinstall)
111 install: beforeinstall realinstall afterinstall
112 .ORDER: beforeinstall realinstall afterinstall