Merge branch 'vendor/OPENSSL'
[dragonfly.git] / share / mk / bsd.subdir.mk
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 $
4 #
5 # The include file <bsd.subdir.mk> contains the default targets
6 # for building subdirectories. 
7 #
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.
12 #
13 #
14 # +++ variables +++
15 #
16 # SUBDIR        A list of subdirectories that should be built as well.
17 #               Each of the targets will execute the same target in the
18 #               subdirectories.
19 #
20 # +++ targets +++
21 #
22 #       afterinstall, all, all-man, beforeinstall, checkdpadd,
23 #       clean, cleandepend, cleandir, depend, install, lint, maninstall,
24 #       manlint, obj, objlink, realinstall, regress, tags
25 #
26
27 .include <bsd.init.mk>
28
29 _SUBDIR: .USE
30 .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
31         @for entry in ${SUBDIR}; do \
32                 if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
33                         ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
34                         edir=$${entry}.${MACHINE_ARCH}; \
35                         cd ${.CURDIR}/$${edir}; \
36                 else \
37                         ${ECHODIR} "===> ${DIRPRFX}$$entry"; \
38                         edir=$${entry}; \
39                         cd ${.CURDIR}/$${edir}; \
40                 fi; \
41                 ${MAKE} ${.TARGET:realinstall=install} \
42                     DIRPRFX=${DIRPRFX}$$edir/; \
43         done
44 .endif
45
46 ${SUBDIR}::
47         @if test -d ${.TARGET}.${MACHINE_ARCH}; then \
48                 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
49         else \
50                 cd ${.CURDIR}/${.TARGET}; \
51         fi; \
52         ${MAKE} all
53
54
55 .for __target in all all-man checkdpadd clean cleandepend cleandir \
56     depend lint maninstall manlint \
57     obj objlink realinstall regress tags
58 ${__target}: _SUBDIR
59 .endfor
60
61 .for __target in files includes
62 .for __stage in build install
63 ${__stage}${__target}:
64 .if make(${__stage}${__target})
65 ${__stage}${__target}: _SUBDIR
66 .endif
67 .endfor
68 ${__target}:
69         cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
70 .endfor
71
72 .if !target(install)
73 .if !target(beforeinstall)
74 beforeinstall:
75 .endif
76 .if !target(afterinstall)
77 afterinstall:
78 .endif
79 install: beforeinstall realinstall afterinstall
80 .ORDER: beforeinstall realinstall afterinstall
81 .endif
82
83 .ORDER: clean cleandepend cleandir cleanobj \
84         obj objlink tags depend all all-man \
85         install maninstall realinstall