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