Commit | Line | Data |
---|---|---|
984263bc MD |
1 | # The include file <bsd.subdir.mk> contains the default targets |
2 | # for building subdirectories. | |
3 | # | |
4 | # For all of the directories listed in the variable SUBDIRS, the | |
5 | # specified directory will be visited and the target made. There is | |
6 | # also a default target which allows the command "make subdir" where | |
7 | # subdir is any directory listed in the variable SUBDIRS. | |
8 | # | |
9 | # | |
10 | # +++ variables +++ | |
11 | # | |
984263bc MD |
12 | # SUBDIR A list of subdirectories that should be built as well. |
13 | # Each of the targets will execute the same target in the | |
14 | # subdirectories. | |
15 | # | |
67be5538 MD |
16 | # SUBDIR_ORDERED A list of subdirectories which also must be included in |
17 | # in SUBDIR which have ordering requirements. If this | |
18 | # Make variable does not exist then all subdirectories are | |
19 | # assumed to be strictly ordered. | |
20 | # | |
984263bc MD |
21 | # +++ targets +++ |
22 | # | |
984263bc MD |
23 | # afterinstall, all, all-man, beforeinstall, checkdpadd, |
24 | # clean, cleandepend, cleandir, depend, install, lint, maninstall, | |
4d351aa0 | 25 | # manlint, obj, objlink, realinstall, regress, tags |
984263bc MD |
26 | # |
27 | ||
28 | .include <bsd.init.mk> | |
29 | ||
67be5538 MD |
30 | # If SUBDIR_ORDERED not specified we default strongly ordering all |
31 | # subdirectories. | |
32 | # | |
33 | SUBDIR_ORDERED?= ${SUBDIR} | |
34 | ||
35 | __targets= \ | |
36 | checkdpadd clean cleandepend cleandir cleanobj \ | |
37 | obj objlink tags depend all all-man \ | |
38 | maninstall realinstall \ | |
39 | lint manlint regress \ | |
40 | buildfiles buildincludes installfiles installincludes | |
1419a4e1 | 41 | #__targets+= mandiff # XXX temporary target |
67be5538 MD |
42 | |
43 | .for __target in ${__targets} | |
44 | ||
984263bc | 45 | .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) |
67be5538 MD |
46 | |
47 | _SUBDIR_${__target}: ${SUBDIR:S/^/_SUBDIR_${__target}_/} | |
48 | ||
0fe46dc6 | 49 | # order subdirectories for each target, set up dependency |
67be5538 | 50 | # |
0fe46dc6 | 51 | .ORDER: ${SUBDIR_ORDERED:S/^/_SUBDIR_${__target}_/} |
67be5538 | 52 | |
0fe46dc6 MD |
53 | # Now create the command set for each subdirectory and target |
54 | # | |
67be5538 MD |
55 | .for entry in ${SUBDIR} |
56 | _SUBDIR_${__target}_${entry}: | |
57 | @(if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \ | |
58 | ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \ | |
59 | edir=${entry}.${MACHINE_ARCH}; \ | |
984263bc MD |
60 | cd ${.CURDIR}/$${edir}; \ |
61 | else \ | |
67be5538 MD |
62 | ${ECHODIR} "===> ${DIRPRFX}${entry}"; \ |
63 | edir=${entry}; \ | |
984263bc MD |
64 | cd ${.CURDIR}/$${edir}; \ |
65 | fi; \ | |
67be5538 | 66 | ${MAKE} ${__target:realinstall=install} \ |
0fe46dc6 MD |
67 | DIRPRFX=${DIRPRFX}$$edir/;) |
68 | @${ECHODIR} "<=== ${DIRPRFX}${entry}" | |
67be5538 MD |
69 | |
70 | .endfor | |
71 | ||
f5d8234e | 72 | .else # defined(SUBDIR) |
67be5538 MD |
73 | |
74 | _SUBDIR_${__target}: .USE | |
75 | ||
f5d8234e | 76 | .endif # defined(SUBDIR) |
984263bc | 77 | |
f5d8234e | 78 | .endfor # ${__targets} |
67be5538 | 79 | |
3da8e88f | 80 | ${SUBDIR}: .PHONY |
984263bc MD |
81 | @if test -d ${.TARGET}.${MACHINE_ARCH}; then \ |
82 | cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ | |
83 | else \ | |
84 | cd ${.CURDIR}/${.TARGET}; \ | |
85 | fi; \ | |
86 | ${MAKE} all | |
87 | ||
88 | ||
67be5538 MD |
89 | .for __target in ${__targets} |
90 | ${__target}: _SUBDIR_${__target} | |
984263bc MD |
91 | .endfor |
92 | ||
93 | .for __target in files includes | |
94 | .for __stage in build install | |
95 | ${__stage}${__target}: | |
96 | .if make(${__stage}${__target}) | |
67be5538 | 97 | ${__stage}${__target}: _SUBDIR_${__stage}${__target} |
984263bc MD |
98 | .endif |
99 | .endfor | |
100 | ${__target}: | |
101 | cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} | |
102 | .endfor | |
103 | ||
104 | .if !target(install) | |
105 | .if !target(beforeinstall) | |
106 | beforeinstall: | |
107 | .endif | |
108 | .if !target(afterinstall) | |
109 | afterinstall: | |
110 | .endif | |
111 | install: beforeinstall realinstall afterinstall | |
112 | .ORDER: beforeinstall realinstall afterinstall | |
113 | .endif | |
1397f94a | 114 | |
67be5538 | 115 | .ORDER: ${__targets:S/^/_SUBDIR_/} |