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