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, check, checkdpadd, clean,
28 # cleandepend, cleandir, cleanilinks depend, install, lint,
29 # maninstall, manlint, obj, objlink, realinstall, tags
32 .if !target(__<bsd.subdir.mk>__)
35 .include <bsd.init.mk>
38 .if !target(distribute)
40 .for dist in ${DISTRIBUTION}
41 ${_+_}cd ${.CURDIR}; \
42 ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
47 .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
48 @${_+_}for entry in ${SUBDIR:N.WAIT}; do \
49 if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
50 ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \
51 edir=$${entry}.${MACHINE_ARCH}; \
52 cd ${.CURDIR}/$${edir}; \
54 ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \
56 cd ${.CURDIR}/$${edir}; \
58 ${MAKE} ${.TARGET:S,realinstall,install,:S,^_sub.,,} \
59 DIRPRFX=${DIRPRFX}$$edir/; \
63 ${SUBDIR:N.WAIT}: .PHONY .MAKE
64 ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
65 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
67 cd ${.CURDIR}/${.TARGET}; \
71 # Work around parsing of .if nested in .for by putting .WAIT string into a var.
73 .for __target in all all-man check checkdpadd clean cleandepend cleandir \
74 cleanilinks depend distribute lint maninstall manlint obj objlink \
75 realinstall tags ${SUBDIR_TARGETS}
76 .ifdef SUBDIR_PARALLEL
78 .for __dir in ${SUBDIR}
79 .if ${__wait} == ${__dir}
80 __subdir_targets+= .WAIT
82 __subdir_targets+= ${__target}_subdir_${__dir}
84 .for __dep in ${SUBDIR_DEPEND_${__dir}}
85 __deps+= ${__target}_subdir_${__dep}
87 ${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps}
88 .if !defined(NO_SUBDIR)
89 @${_+_}if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \
90 ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \
91 edir=${__dir}.${MACHINE_ARCH}; \
92 cd ${.CURDIR}/$${edir}; \
94 ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \
96 cd ${.CURDIR}/$${edir}; \
98 ${MAKE} ${__target:realinstall=install} \
99 DIRPRFX=${DIRPRFX}$$edir/
103 ${__target}: ${__subdir_targets}
105 ${__target}: _sub.${__target}
106 _sub.${__target}: _SUBDIR
110 .for __target in files includes
111 .for __stage in build install
112 ${__stage}${__target}:
113 .if make(${__stage}${__target})
114 ${__stage}${__target}: _sub.${__stage}${__target}
115 _sub.${__stage}${__target}: _SUBDIR
118 .if !target(${__target})
120 ${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
125 .if !target(beforeinstall)
128 .if !target(afterinstall)
131 install: beforeinstall realinstall afterinstall
132 .ORDER: beforeinstall realinstall afterinstall