Makefile revision 1.61
1b8e80941Smrg#	$NetBSD: Makefile,v 1.61 2002/12/21 12:56:08 lukem Exp $
2b8e80941Smrg
3b8e80941Smrg.include <bsd.own.mk>
4b8e80941Smrg
5b8e80941Smrg.if ${TOOLCHAIN_MISSING} != "yes"
6b8e80941SmrgTOOLCHAIN_BITS= toolchain .WAIT dbsym mdsetimage
7b8e80941Smrg# XXX Eventually, we want to be able to build dbsym and mdsetimage
8b8e80941Smrg# XXX if EXTERNAL_TOOLCHAIN is set.
9b8e80941Smrg.endif
10b8e80941Smrg
11b8e80941Smrg# Dependencies in SUBDIR below ordered to maximize parallel ability.
12b8e80941Smrg.if !defined(NOSUBDIR)					# {
13b8e80941Smrg
14b8e80941SmrgSUBDIR=	host-mkdep .WAIT compat .WAIT \
15b8e80941Smrg	binstall .WAIT mktemp .WAIT \
16b8e80941Smrg		cap_mkdb crunchgen ctags gencat lint lint2 lorder \
17b8e80941Smrg		m4 makewhatis mkdep mtree rpcgen tsort uudecode \
18b8e80941Smrg	texinfo .WAIT \
19b8e80941Smrg	yacc .WAIT \
20b8e80941Smrg	lex .WAIT \
21b8e80941Smrg	${TOOLCHAIN_BITS} \
22b8e80941Smrg		asn1_compile cat cksum compile_et config installboot lint1 \
23b8e80941Smrg		makefs menuc mklocale msgc pax pwd_mkdb sunlabel zic
24b8e80941Smrg
25b8e80941Smrg.if ${MKMAN} != "no"
26b8e80941SmrgSUBDIR+=	groff
27b8e80941Smrg.endif
28b8e80941Smrg
29b8e80941Smrg.if ${MKMAINTAINERTOOLS:Uno} != "no"
30b8e80941SmrgSUBDIR+=	autoconf gettext
31b8e80941Smrg.endif
32b8e80941Smrg
33b8e80941Smrg.if ${MACHINE} == prep
34b8e80941SmrgSUBDIR+=	prep-mkbootimage
35b8e80941Smrg.endif
36b8e80941Smrg
37b8e80941Smrg.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
38b8e80941SmrgSUBDIR+=	mips-elf2ecoff
39b8e80941Smrg.endif
40b8e80941Smrg
41b8e80941Smrg.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
42b8e80941SmrgSUBDIR+=	fgen
43b8e80941Smrg.endif
44b8e80941Smrg
45b8e80941Smrg.endif	# ! NOSUBDIR					# }
46b8e80941Smrg
47b8e80941Smrg.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"
48b8e80941Smrgrealall install: _warn
49b8e80941Smrg.if ${MKTOOLS:Uyes} == "no"
50b8e80941Smrg_warn:
51b8e80941Smrg	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
52b8e80941Smrg	@echo '*** updating your host toolchain.  This should be used only as a'
53b8e80941Smrg	@echo '*** temporary workaround for toolchain problems, as it will result'
54b8e80941Smrg	@echo '*** in version skew and build errors over time!'
55b8e80941Smrg.else
56b8e80941Smrg_warn:
57b8e80941Smrg.endif
58b8e80941Smrg
59b8e80941Smrg.for dir in ${SUBDIR:N.WAIT}
60b8e80941Smrgall-${dir} depend-${dir} dependall-${dir} install-${dir}:
61b8e80941Smrg	@true
62b8e80941Smrg.endfor
63b8e80941Smrg.endif
64b8e80941Smrg
65b8e80941Smrg.include <bsd.subdir.mk>
66b8e80941Smrg.include <bsd.obj.mk>
67b8e80941Smrg
68b8e80941Smrg# For each .WAIT point, make sure the immediately preceding target is
69b8e80941Smrg# installed before building anything after that point.
70b8e80941Smrg#
71b8e80941Smrg# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
72b8e80941Smrg# to achieve this. These targets look like:
73b8e80941Smrg#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
74b8e80941Smrg#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
75b8e80941Smrg# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
76b8e80941Smrg# places corresponding to the .WAITs in our $SUBDIR variable.
77b8e80941Smrg#
78b8e80941Smrg# Also, since we're now mixing `install' with `all' and `depend' targets
79b8e80941Smrg# an order relationship between those in each individual subdirectory
80b8e80941Smrg# must be established.
81b8e80941Smrg#
82b8e80941Smrg_deps:=
83b8e80941Smrg_prev:=
84b8e80941Smrg
85b8e80941Smrg.for d in ${SUBDIR}
86b8e80941Smrg_this:=		${d}
87b8e80941Smrg
88b8e80941Smrg.if ${_this} == ".WAIT"
89b8e80941Smrg
90b8e80941Smrg# setup dependency to apply to all/depend targets in the next group
91b8e80941Smrg_deps:=		${_deps} ${_prev:S/^/install-/}
92b8e80941Smrg
93b8e80941Smrg# if we're building *only* individual targets (i.e. "dependall-yacc"),
94b8e80941Smrg# make sure prerequisite tools build before installing
95b8e80941Smrg.if !make(all) && !make(dependall)
96b8e80941Smrginstall-${_prev}: dependall-${_prev}
97b8e80941Smrg.endif
98b8e80941Smrg
99b8e80941Smrg.else
100b8e80941Smrg
101b8e80941Smrg# order depend/all/install targets for ${d} subdir.  Note the additional
102b8e80941Smrg# .WAIT to achieve "closure" of the predecessor/successor relationships.
103b8e80941Smrg.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
104b8e80941Smrg
105b8e80941Smrg# make all/depend-${d} dependent on list of install targets
106b8e80941Smrgdepend-${d} all-${d} dependall-${d}: ${_deps}
107b8e80941Smrg
108b8e80941Smrg.endif
109b8e80941Smrg
110b8e80941Smrg# stash current name in case the next entry is .WAIT
111b8e80941Smrg_prev:=		${d}
112b8e80941Smrg.endfor
113b8e80941Smrg
114b8e80941Smrgcleantools:
115b8e80941Smrg	rm -r -f tools.${HOST_OSTYPE}
116b8e80941Smrg