]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - share/mk/bsd.subdir.mk
MFC r263778:
[FreeBSD/stable/8.git] / share / mk / bsd.subdir.mk
1 #       from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
2 # $FreeBSD$
3 #
4 # The include file <bsd.subdir.mk> contains the default targets
5 # for building subdirectories.
6 #
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.
11 #
12 #
13 # +++ variables +++
14 #
15 # DISTRIBUTION  Name of distribution. [base]
16 #
17 # SUBDIR        A list of subdirectories that should be built as well.
18 #               Each of the targets will execute the same target in the
19 #               subdirectories.
20 #
21 # +++ targets +++
22 #
23 #       distribute:
24 #               This is a variant of install, which will
25 #               put the stuff into the right "distribution".
26 #
27 #       afterinstall, all, all-man, beforeinstall, checkdpadd,
28 #       clean, cleandepend, cleandir, depend, install, lint, maninstall,
29 #       manlint, obj, objlink, realinstall, regress, tags
30 #
31
32 .include <bsd.init.mk>
33
34 DISTRIBUTION?=  base
35 .if !target(distribute)
36 distribute:
37 .for dist in ${DISTRIBUTION}
38         ${_+_}cd ${.CURDIR}; \
39             ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
40 .endfor
41 .endif
42
43 _SUBDIR: .USE
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}; \
50                 else \
51                         ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:realinstall=install})"; \
52                         edir=$${entry}; \
53                         cd ${.CURDIR}/$${edir}; \
54                 fi; \
55                 ${MAKE} ${.TARGET:realinstall=install} \
56                     DIRPRFX=${DIRPRFX}$$edir/; \
57         done
58 .endif
59
60 ${SUBDIR}: .PHONY
61         ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
62                 cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
63         else \
64                 cd ${.CURDIR}/${.TARGET}; \
65         fi; \
66         ${MAKE} all
67
68 .for __target in all all-man checkdpadd clean cleandepend cleandir \
69     depend distribute lint maninstall manlint \
70     obj objlink realinstall regress tags \
71     ${SUBDIR_TARGETS}
72 .ifdef SUBDIR_PARALLEL
73 .for __dir in ${SUBDIR}
74 ${__target}: ${__target}_subdir_${__dir}
75 ${__target}_subdir_${__dir}: .MAKE
76         @${_+_}set -e; \
77                 if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \
78                         ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \
79                         edir=${__dir}.${MACHINE_ARCH}; \
80                         cd ${.CURDIR}/$${edir}; \
81                 else \
82                         ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \
83                         edir=${__dir}; \
84                         cd ${.CURDIR}/$${edir}; \
85                 fi; \
86                 ${MAKE} ${__target:realinstall=install} \
87                     DIRPRFX=${DIRPRFX}$$edir/
88 .endfor
89 .else
90 ${__target}: _SUBDIR
91 .endif
92 .endfor
93
94 .for __target in files includes
95 .for __stage in build install
96 ${__stage}${__target}:
97 .if make(${__stage}${__target})
98 ${__stage}${__target}: _SUBDIR
99 .endif
100 .endfor
101 ${__target}:
102         ${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
103 .endfor
104
105 .if !target(install)
106 .if !target(beforeinstall)
107 beforeinstall:
108 .endif
109 .if !target(afterinstall)
110 afterinstall:
111 .endif
112 install: beforeinstall realinstall afterinstall
113 .ORDER: beforeinstall realinstall afterinstall
114 .endif