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