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