xref: /netbsd-src/tools/Makefile (revision cef8759bd76c1b621f8eab8faa6f208faabc2e15)
1#	$NetBSD: Makefile,v 1.206 2020/07/28 21:38:15 uwe 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 .WAIT yacc .WAIT awk .WAIT lex
104.if ${TOOLS_BUILDRUMP} == "no"
105SUBDIR+= xz-include .WAIT grep xz-lib pax .WAIT libprop
106
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
122.if ${TOOLS_BUILDRUMP} == "no"
123SUBDIR+= xz-bin
124.endif
125
126.if ${MKLLVM} != "no" || ${MKLLVMRT} != "no"
127SUBDIR+= \
128	llvm .WAIT \
129	llvm-lib/libLLVMDemangle llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
130	llvm-tblgen
131.endif
132.if ${MKLLVM} != "no"
133SUBDIR+= \
134	llvm-clang-tblgen
135.endif
136.if ${MKLLVM} != "no" && !defined(EXTERNAL_TOOLCHAIN)
137SUBDIR+= \
138	.WAIT llvm-include .WAIT \
139	llvm-lib .WAIT \
140	llvm-clang
141.endif
142
143.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
144. if ${MKGROFF} != "no"
145SUBDIR+=	groff
146. endif
147SUBDIR+=	mandoc
148.endif
149
150.if ${TOOLS_BUILDRUMP} == "no"
151
152.if ${MKMAINTAINERTOOLS:Uno} != "no"
153SUBDIR+=	autoconf .WAIT gettext
154.endif
155
156.if ${USE_PIGZGZIP} != "no"
157SUBDIR+=	pigz
158.endif
159
160.if ${MACHINE} == "hppa"
161SUBDIR+=	hppa-mkboot
162.endif
163
164.if ${MACHINE} == "ibmnws"
165SUBDIR+=	ibmnws-ncdcs
166.endif
167
168.if ${MACHINE} == "macppc"
169SUBDIR+=	macppc-fixcoff
170.endif
171
172.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
173SUBDIR+=	powerpc-mkbootimage
174.endif
175
176.if ${MACHINE_CPU} == "arm"
177SUBDIR+=	arm-elf2aout
178.endif
179
180.if ${MACHINE_CPU} == "m68k"
181SUBDIR+=	m68k-elf2aout
182.endif
183
184.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
185     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
186SUBDIR+=	mips-elf2ecoff
187.endif
188
189.if (${MACHINE} == "sgimips")
190SUBDIR+=	sgivol
191.endif
192
193.if ${MACHINE} == "acorn32"
194SUBDIR+=	sparkcrc
195.endif
196
197.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
198SUBDIR+=	fgen
199.endif
200
201.if ${MACHINE} == "amiga"
202SUBDIR+=	amiga-elf2bb
203SUBDIR+=	amiga-txlt
204.endif
205
206.if ${MACHINE} == "hp300"
207SUBDIR+=	hp300-mkboot
208.endif
209
210.if ${MACHINE} == "evbarm" \
211    && ${MACHINE_CPU} == "arm" \
212    && ${TARGET_ENDIANNESS} == "1234"
213SUBDIR+=	elftosb
214.endif
215
216.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
217    ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \
218    ${MACHINE} == "sandpoint"
219SUBDIR+=	mkubootimage
220SUBDIR+=	libfdt .WAIT
221SUBDIR+=	dtc
222.endif
223
224.if ${MKX11} != "no"
225SUBDIR+=	makestrs
226SUBDIR+=	makekeys
227.endif
228
229SUBDIR+= cvslatest
230
231.endif # TOOLS_BUILDRUMP != no
232
233check_MKTOOLS: .PHONY .NOTMAIN
234.if ${MKTOOLS:Uyes} == "no"
235	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
236	@echo '*** updating your host toolchain.  This should be used only as a'
237	@echo '*** temporary workaround for toolchain problems, as it will result'
238	@echo '*** in version skew and build errors over time!'
239.endif
240
241.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
242SUBDIR= # empty
243realall realdepend install: check_MKTOOLS
244.endif							# }
245
246.include <bsd.subdir.mk>
247.include <bsd.buildinstall.mk>
248.include <bsd.obj.mk>
249
250.if !defined(PREVIOUSTOOLDIR)
251.  if exists(PREVIOUSTOOLDIR)
252PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
253.  else
254PREVIOUSTOOLDIR=
255.  endif
256.endif
257
258CLEANFILES+=	PREVIOUSTOOLDIR
259
260realall realdepend: .MAKE
261.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
262	@echo "*** WARNING: TOOLDIR has moved?"
263	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
264	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
265	@echo "*** Cleaning mis-matched tools"
266	rm -f PREVIOUSTOOLDIR
267	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
268.endif
269	echo ${TOOLDIR} >PREVIOUSTOOLDIR
270
271cleandir:
272	rm -f ${CLEANFILES}
273