bsd.subdir.mk revision 90311
1#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
2# $FreeBSD: head/share/mk/bsd.subdir.mk 90311 2002-02-06 18:05:53Z ru $
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. [bin]
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#	afterdistribute, afterinstall, all, all-man, beforeinstall, checkdpadd,
28#	clean, cleandepend, cleandir, depend, install, lint, maninstall,
29#	obj, objlink, realinstall, regress, tags
30#
31
32.if !target(__initialized__)
33__initialized__:
34.if exists(${.CURDIR}/../Makefile.inc)
35.include "${.CURDIR}/../Makefile.inc"
36.endif
37.endif  
38
39.MAIN: all
40
41_SUBDIRUSE: .USE
42	@for entry in ${SUBDIR}; do \
43		(if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
44			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
45			edir=$${entry}.${MACHINE_ARCH}; \
46			cd ${.CURDIR}/$${edir}; \
47		else \
48			${ECHODIR} "===> ${DIRPRFX}$$entry"; \
49			edir=$${entry}; \
50			cd ${.CURDIR}/$${edir}; \
51		fi; \
52		${MAKE} ${.TARGET:realinstall=install} \
53		    DIRPRFX=${DIRPRFX}$$edir/); \
54	done
55
56${SUBDIR}::
57	@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
58		cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
59	else \
60		cd ${.CURDIR}/${.TARGET}; \
61	fi; \
62	${MAKE} all
63
64
65.for __target in all all-man checkdpadd clean cleandepend cleandir depend lint \
66		 maninstall obj objlink regress tags \
67		 install.debug reinstall.debug
68.if !target(${__target})
69${__target}: _SUBDIRUSE
70.endif
71.endfor
72
73.if !target(install)
74.if !target(beforeinstall)
75beforeinstall:
76.endif
77.if !target(afterinstall)
78afterinstall:
79.endif
80install: afterinstall
81afterinstall: realinstall
82realinstall: beforeinstall _SUBDIRUSE
83.endif
84
85DISTRIBUTION?=	bin
86.if !target(afterdistribute)
87afterdistribute:
88.endif
89.if !target(distribute)
90distribute: _SUBDIRUSE
91.for dist in ${DISTRIBUTION}
92	cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist}
93.endfor
94.endif
95