1 # The include file <bsd.subdir.mk> contains the default targets
2 # for building subdirectories.
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.
12 # SUBDIR A list of subdirectories that should be built as well.
13 # Each of the targets will execute the same target in the
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.
23 # afterinstall, all, all-man, beforeinstall, checkdpadd,
24 # clean, cleandepend, cleandir, depend, install, lint, maninstall,
25 # manlint, obj, objlink, realinstall, regress, tags
28 .
include <bsd.init.mk
>
30 # If SUBDIR_ORDERED not specified we default strongly ordering all
33 SUBDIR_ORDERED?
= ${SUBDIR}
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
41 __targets
+= mandiff
# XXX temporary target
43 .for __target in
${__targets}
45 .if defined
(SUBDIR
) && !empty
(SUBDIR
) && !defined
(NO_SUBDIR
)
47 _SUBDIR_
${__target}: ${SUBDIR
:S
/^
/_SUBDIR_
${__target}_
/}
49 # Now create the command set for each subdirectory and target
52 .for entry in
${SUBDIR}
53 _SUBDIR_
${__target}_
${entry}:
54 @
(if
test -d
${.CURDIR
}/${entry}.
${MACHINE_ARCH}; then \
55 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
56 edir
=${entry}.
${MACHINE_ARCH}; \
57 cd
${.CURDIR
}/$${edir}; \
59 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
61 cd
${.CURDIR
}/$${edir}; \
63 ${MAKE} ${__target
:realinstall
=install} \
64 DIRPRFX
=${DIRPRFX}$$edir/;)
68 # order subdirectories for each target, set up dependency
70 .ORDER
: ${SUBDIR_ORDERED
:S
/^
/_SUBDIR_
${__target}_
/}
74 _SUBDIR_
${__target}: .USE
81 @if
test -d
${.TARGET
}.
${MACHINE_ARCH}; then \
82 cd
${.CURDIR
}/${.TARGET
}.
${MACHINE_ARCH}; \
84 cd
${.CURDIR
}/${.TARGET
}; \
89 .for __target in
${__targets}
90 ${__target}: _SUBDIR_
${__target}
93 .for __target in files includes
94 .for __stage in build
install
95 ${__stage}${__target}:
96 .if make
(${__stage}${__target})
97 ${__stage}${__target}: _SUBDIR_
${__stage}${__target}
101 cd
${.CURDIR
}; ${MAKE} build
${__target}; ${MAKE} install${__target}
105 .if
!target
(beforeinstall
)
108 .if
!target
(afterinstall
)
111 install: beforeinstall realinstall afterinstall
112 .ORDER
: beforeinstall realinstall afterinstall
115 .ORDER
: ${__targets
:S
/^
/_SUBDIR_
/}