Makefile revision 1.105
1#	$NetBSD: Makefile,v 1.105 2006/08/03 09:55:56 tron 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 .WAIT 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 !defined(PREVIOUSTOOLDIR)
122.  if exists(PREVIOUSTOOLDIR)
123PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
124.  else
125PREVIOUSTOOLDIR=	
126.  endif
127.endif
128
129CLEANFILES+=	PREVIOUSTOOLDIR
130
131realall realdepend: .MAKE
132.if "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
133	@echo "*** WARNING: TOOLDIR has moved?"
134	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
135	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
136	@echo "*** Cleaning mis-matched tools"
137	rm -f PREVIOUSTOOLDIR
138	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} TOOLDIR=${TOOLDIR} cleandir)
139.endif
140	echo ${TOOLDIR} >PREVIOUSTOOLDIR
141
142# For each .WAIT point, make sure the immediately preceding target is
143# installed before building anything after that point.
144#
145# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
146# to achieve this. These targets look like:
147#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
148#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
149# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
150# places corresponding to the .WAITs in our $SUBDIR variable.
151#
152# Also, since we're now mixing `install' with `all' and `depend' targets
153# an order relationship between those in each individual subdirectory
154# must be established.
155#
156_deps:=
157_prev:=
158
159.for d in ${SUBDIR}
160_this:=		${d}
161
162.if ${_this} == ".WAIT"
163
164# setup dependency to apply to all/depend targets in the next group
165_deps:=		${_deps} ${_prev:S/^/install-/}
166
167# if we're building *only* individual targets (i.e. "dependall-yacc"),
168# make sure prerequisite tools build before installing
169.if !make(all) && !make(dependall)
170install-${_prev}: dependall-${_prev}
171.endif
172
173.else
174
175# order depend/all/install targets for ${d} subdir.  Note the additional
176# .WAIT to achieve "closure" of the predecessor/successor relationships.
177.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
178
179# make all/depend-${d} dependent on list of install targets
180depend-${d} all-${d} dependall-${d}: ${_deps}
181
182.endif
183
184# stash current name in case the next entry is .WAIT
185_prev:=		${d}
186.endfor
187
188cleandir:
189	rm -f ${CLEANFILES}
190