Makefile revision 1.166
1#	$NetBSD: Makefile,v 1.166 2013/01/31 15:22:50 pooka Exp $
2
3.include <bsd.own.mk>
4
5# Make sure that the ordered build/install processing applies when using
6# plain make.
7.MAIN: build_install
8
9# TOOLDIR must be valid, unless MKTOOLS=no
10.if ${MKTOOLS:Uyes} != "no"
11.if "${TOOLDIR}" == ""
12.error "TOOLDIR is undefined or empty"
13.elif "${TOOLDIR:tW:M/*}" == ""
14.error "TOOLDIR is not an absolute path: ${TOOLDIR}"
15#.elif !exists(TOOLDIR) # XXX .exists fails for directories
16#.error "TOOLDIR does not exist: ${TOOLDIR}"
17.endif
18.endif # MKTOOLS != no
19
20# TOOLS_BUILDRUMP == yes builds only the subset of the tools required
21# for building rump kernels and the hypervisor.  It is typically used
22# when building rump kernels targeted for non-NetBSD systems (via
23# buildrump.sh), and should not be set for a regular "make build".
24TOOLS_BUILDRUMP?=no
25
26.if ${TOOLCHAIN_MISSING} == "no"
27.if defined(HAVE_GCC)
28TOOLCHAIN_BITS= gmake .WAIT
29.endif
30
31.if defined(HAVE_GCC)
32.if ${HAVE_GCC} >= 45
33TOOLCHAIN_BITS+= gmp .WAIT
34TOOLCHAIN_BITS+= mpfr .WAIT
35TOOLCHAIN_BITS+= mpc .WAIT
36.endif
37.endif
38.endif
39
40.if ${TOOLCHAIN_MISSING} == "no"
41TOOLCHAIN_BITS+= binutils .WAIT
42.endif
43
44.if defined(HAVE_GCC)
45.if ${TOOLCHAIN_MISSING} == "no"
46TOOLCHAIN_BITS+= gcc
47.  if ${MKCROSSGDB:Uno} != "no"
48TOOLCHAIN_BITS+= gdb
49.  endif
50TOOLCHAIN_BITS+= .WAIT
51.endif
52.endif
53
54.if defined(HAVE_PCC)
55.if ${TOOLCHAIN_MISSING} == "no"
56TOOLCHAIN_BITS+= pcc
57.endif
58.endif
59
60.if ${TOOLCHAIN_MISSING} == "no"
61# XXX Eventually, we want to be able to build dbsym and mdsetimage
62# XXX if EXTERNAL_TOOLCHAIN is set.
63TOOLCHAIN_BITS+= dbsym mdsetimage
64.endif
65
66DTRACE_BITS=
67.if ${MKDTRACE} != "no"
68DTRACE_BITS+= .WAIT libelf
69DTRACE_BITS+= .WAIT libdwarf
70DTRACE_BITS+= .WAIT libctf
71DTRACE_BITS+= .WAIT ctfconvert ctfmerge
72.endif
73
74LINT_BITS=
75.if ${MKLINT} != "no"
76LINT_BITS= lint lint2
77.endif
78
79# All of host-mkdep, compat, and binstall are needed before anything
80# else.  Within this group, they must be built in a specific order, and
81# all of them must be built before any of them is installed.  They may
82# be installed in any order.  This can't be expressed using the .WAIT
83# notation inside the SUBDIR list.
84#
85# XXX .ORDER does not work when multiple targets are passed on the
86# make command line without "-j", so use dependencies in addition to .ORDER.
87#
88.ORDER: dependall-host-mkdep dependall-compat dependall-binstall
89.if make(dependall-host-mkdep) && make(dependall-compat)
90dependall-compat: dependall-host-mkdep
91.endif
92.if make(dependall-compat) && make(dependall-binstall)
93dependall-binstall: dependall-compat
94.endif
95
96# Dependencies in SUBDIR below ordered to maximize parallel ability.
97# See above for special treatment for host-mkdep, compat, and binstall.
98#
99SUBDIR=	host-mkdep compat binstall \
100	.WAIT mktemp .WAIT sed .WAIT
101.if ${TOOLS_BUILDRUMP} == "no"
102SUBDIR+= cap_mkdb crunchgen ctags genassym gencat hexdump \
103		${LINT_BITS} \
104		makewhatis mtree nbperf .WAIT rpcgen uudecode
105.endif
106
107SUBDIR+= join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
108
109.if ${TOOLS_BUILDRUMP} == "no"
110SUBDIR += .WAIT texinfo \
111	.WAIT tic \
112	.WAIT pax \
113	.WAIT ${TOOLCHAIN_BITS} \
114	${DTRACE_BITS} \
115		asn1_compile cat cksum compile_et db \
116		file lint1 slc \
117		makefs .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
118		.WAIT disklabel \
119		.WAIT paxctl \
120		.WAIT fdisk \
121		.WAIT installboot \
122		pwd_mkdb stat strfile sunlabel zic
123.endif
124SUBDIR+= .WAIT config
125
126.if ${MKLLVM} != "no"
127SUBDIR+= \
128	llvm .WAIT \
129	llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
130	llvm-tblgen llvm-clang-tblgen .WAIT \
131	llvm-include .WAIT \
132	llvm-lib .WAIT \
133	llvm-clang
134.endif
135
136.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
137.  if ${MKGROFF} != "no"
138SUBDIR+=	groff
139.  endif
140SUBDIR+=	mandoc
141.endif
142
143.if ${TOOLS_BUILDRUMP} == "no"
144
145.if ${MKMAINTAINERTOOLS:Uno} != "no"
146SUBDIR+=	autoconf .WAIT gettext
147.endif
148
149.if ${USE_PIGZGZIP} != "no"
150SUBDIR+=	pigz
151.endif
152
153.if ${MACHINE} == "hp700"
154SUBDIR+=	hp700-mkboot
155.endif
156
157.if ${MACHINE} == "ibmnws"
158SUBDIR+=	ibmnws-ncdcs
159.endif
160
161.if ${MACHINE} == "macppc"
162SUBDIR+=	macppc-fixcoff
163.endif
164
165.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
166SUBDIR+=	powerpc-mkbootimage
167.endif
168
169.if ${MACHINE_ARCH} == "m68k"
170SUBDIR+=	m68k-elf2aout
171.endif
172
173.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
174     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
175SUBDIR+=	mips-elf2ecoff
176.endif
177
178.if (${MACHINE} == "sgimips")
179SUBDIR+=	sgivol
180.endif
181
182.if ${MACHINE} == "acorn32"
183SUBDIR+=	sparkcrc
184.endif
185
186.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
187SUBDIR+=	fgen
188.endif
189
190.if ${MACHINE} == "amiga"
191SUBDIR+=	amiga-elf2bb
192SUBDIR+=	amiga-txlt
193.endif
194
195.if ${MACHINE} == "hp300"
196SUBDIR+=	hp300-mkboot
197.endif
198
199.if ${MACHINE} == "evbarm" && ${MACHINE_ARCH} == "arm"
200SUBDIR+=	elftosb
201.endif
202
203.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
204    ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
205SUBDIR+=	mkubootimage
206.endif
207
208.endif # TOOLCHAIN_BUILDRUMP
209
210check_MKTOOLS: .PHONY .NOTMAIN
211.if ${MKTOOLS:Uyes} == "no"
212	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
213	@echo '*** updating your host toolchain.  This should be used only as a'
214	@echo '*** temporary workaround for toolchain problems, as it will result'
215	@echo '*** in version skew and build errors over time!'
216.endif
217
218.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
219SUBDIR= # empty
220realall realdepend install: check_MKTOOLS
221.endif							# }
222
223.include <bsd.subdir.mk>
224.include <bsd.buildinstall.mk>
225.include <bsd.obj.mk>
226
227.if !defined(PREVIOUSTOOLDIR)
228.  if exists(PREVIOUSTOOLDIR)
229PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
230.  else
231PREVIOUSTOOLDIR=
232.  endif
233.endif
234
235CLEANFILES+=	PREVIOUSTOOLDIR
236
237realall realdepend: .MAKE
238.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
239	@echo "*** WARNING: TOOLDIR has moved?"
240	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
241	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
242	@echo "*** Cleaning mis-matched tools"
243	rm -f PREVIOUSTOOLDIR
244	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
245.endif
246	echo ${TOOLDIR} >PREVIOUSTOOLDIR
247
248cleandir:
249	rm -f ${CLEANFILES}
250