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