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