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