bsd.subdir.mk revision 34892
1#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
2#	$Id: bsd.subdir.mk,v 1.21 1998/03/23 14:58:29 eivind Exp $
3#
4# The include file <bsd.subdir.mk> contains the default targets
5# for building subdirectories. It has the same seven targets
6# as <bsd.prog.mk>:
7#	all, clean, cleandir, depend, install, lint, and tags.
8#
9# For all of the directories listed in the variable SUBDIRS, the
10# specified directory will be visited and the target made. There is
11# also a default target which allows the command "make subdir" where
12# subdir is any directory listed in the variable SUBDIRS.
13#
14#
15# +++ variables +++
16#
17# DISTRIBUTION	Name of distribution. [bin]
18#
19# SUBDIR	A list of subdirectories that should be built as well.
20#		Each of the targets will execute the same target in the
21#		subdirectories.
22#
23# +++ targets +++
24#
25#	distribute:
26# 		This is a variant of install, which will
27# 		put the stuff into the right "distribution".
28#
29#	afterdistribute, afterinstall, all, beforeinstall, checkdpadd,
30#	clean, cleandepend, cleandir, depend, install, lint, maninstall,
31#	obj, objlink, realinstall, regress, tags
32#
33
34
35.MAIN: all
36
37_SUBDIRUSE: .USE
38	@for entry in ${SUBDIR}; do \
39		(if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
40			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE}"; \
41			edir=$${entry}.${MACHINE}; \
42			cd ${.CURDIR}/$${edir}; \
43		else \
44			${ECHODIR} "===> ${DIRPRFX}$$entry"; \
45			edir=$${entry}; \
46			cd ${.CURDIR}/$${edir}; \
47		fi; \
48		${MAKE} ${.TARGET:realinstall=install} DIRPRFX=${DIRPRFX}$$edir/); \
49	done
50
51${SUBDIR}::
52	@if test -d ${.TARGET}.${MACHINE}; then \
53		cd ${.CURDIR}/${.TARGET}.${MACHINE}; \
54	else \
55		cd ${.CURDIR}/${.TARGET}; \
56	fi; \
57	${MAKE} all
58
59
60.for __target in all checkdpadd clean cleandepend cleandir depend lint \
61		 maninstall obj objlink regress tags
62.if !target(${__target})
63${__target}: _SUBDIRUSE
64.endif
65.endfor
66
67.if !target(install)
68.if !target(beforeinstall)
69beforeinstall:
70.endif
71.if !target(afterinstall)
72afterinstall:
73.endif
74install: afterinstall
75afterinstall: realinstall
76realinstall: beforeinstall _SUBDIRUSE
77.endif
78
79DISTRIBUTION?=	bin
80.if !target(afterdistribute)
81afterdistribute:
82.endif
83.if !target(distribute)
84distribute: _SUBDIRUSE
85.for dist in ${DISTRIBUTION}
86	cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist}
87.endfor
88.endif
89