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