Merge branches 'master' and 'suser_to_priv'
[dragonfly.git] / share / mk / bsd.subdir.mk
blob8309a4d1bd8083fb9a0f4f4707e1ba29ec4a397e
1 # from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
2 # $FreeBSD: src/share/mk/bsd.subdir.mk,v 1.30.2.5 2002/07/22 14:21:51 ru Exp $
3 # $DragonFly: src/share/mk/bsd.subdir.mk,v 1.4 2005/12/09 18:53:44 swildner Exp $
5 # The include file <bsd.subdir.mk> contains the default targets
6 # for building subdirectories.
8 # For all of the directories listed in the variable SUBDIRS, the
9 # specified directory will be visited and the target made. There is
10 # also a default target which allows the command "make subdir" where
11 # subdir is any directory listed in the variable SUBDIRS.
14 # +++ variables +++
16 # DISTRIBUTION Name of distribution. [bin]
18 # SUBDIR A list of subdirectories that should be built as well.
19 # Each of the targets will execute the same target in the
20 # subdirectories.
22 # +++ targets +++
24 # distribute:
25 # This is a variant of install, which will
26 # put the stuff into the right "distribution".
28 # afterinstall, all, all-man, beforeinstall, checkdpadd,
29 # clean, cleandepend, cleandir, depend, install, lint, maninstall,
30 # manlint, obj, objlink, realinstall, regress, tags
33 .include <bsd.init.mk>
35 DISTRIBUTION?= bin
36 .if !target(distribute)
37 distribute:
38 .for dist in ${DISTRIBUTION}
39 cd ${.CURDIR}; \
40 ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
41 .endfor
42 .endif
44 _SUBDIR: .USE
45 .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
46 @for entry in ${SUBDIR}; do \
47 if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
48 ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
49 edir=$${entry}.${MACHINE_ARCH}; \
50 cd ${.CURDIR}/$${edir}; \
51 else \
52 ${ECHODIR} "===> ${DIRPRFX}$$entry"; \
53 edir=$${entry}; \
54 cd ${.CURDIR}/$${edir}; \
55 fi; \
56 ${MAKE} ${.TARGET:realinstall=install} \
57 DIRPRFX=${DIRPRFX}$$edir/; \
58 done
59 .endif
61 ${SUBDIR}::
62 @if test -d ${.TARGET}.${MACHINE_ARCH}; then \
63 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
64 else \
65 cd ${.CURDIR}/${.TARGET}; \
66 fi; \
67 ${MAKE} all
70 .for __target in all all-man checkdpadd clean cleandepend cleandir \
71 depend distribute lint maninstall manlint \
72 obj objlink realinstall regress tags
73 ${__target}: _SUBDIR
74 .endfor
76 .for __target in files includes
77 .for __stage in build install
78 ${__stage}${__target}:
79 .if make(${__stage}${__target})
80 ${__stage}${__target}: _SUBDIR
81 .endif
82 .endfor
83 ${__target}:
84 cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
85 .endfor
87 .if !target(install)
88 .if !target(beforeinstall)
89 beforeinstall:
90 .endif
91 .if !target(afterinstall)
92 afterinstall:
93 .endif
94 install: beforeinstall realinstall afterinstall
95 .ORDER: beforeinstall realinstall afterinstall
96 .endif
98 .ORDER: clean cleandepend cleandir cleanobj \
99 obj objlink tags depend all all-man \
100 install maninstall realinstall distribute