xref: /netbsd-src/tools/Makefile (revision 0953dc8744b62dfdecb2f203329e730593755659)
1#	$NetBSD: Makefile,v 1.155 2011/11/03 07:42:56 joerg Exp $
2
3.include <bsd.own.mk>
4
5.if defined(HAVE_GCC)
6TOOLCHAIN_BITS= gmake .WAIT
7.if ${TOOLCHAIN_MISSING} == "no"
8.if ${HAVE_GCC} >= 45
9TOOLCHAIN_BITS+= gmp .WAIT
10TOOLCHAIN_BITS+= mpfr .WAIT
11TOOLCHAIN_BITS+= mpc .WAIT
12.endif
13TOOLCHAIN_BITS+= binutils .WAIT
14TOOLCHAIN_BITS+= gcc
15.  if ${MKCROSSGDB:Uno} != "no"
16TOOLCHAIN_BITS+= gdb
17.  endif
18TOOLCHAIN_BITS+= .WAIT dbsym mdsetimage
19# XXX Eventually, we want to be able to build dbsym and mdsetimage
20# XXX if EXTERNAL_TOOLCHAIN is set.
21.endif
22.endif
23
24.if defined(HAVE_PCC)
25TOOLCHAIN_BITS= gmake .WAIT
26.if ${TOOLCHAIN_MISSING} == "no"
27TOOLCHAIN_BITS+= binutils .WAIT
28TOOLCHAIN_BITS+= pcc
29.endif
30TOOLCHAIN_BITS+= .WAIT dbsym mdsetimage
31.endif
32
33DTRACE_BITS=
34.if ${MKDTRACE} != "no"
35DTRACE_BITS+= .WAIT libelf
36DTRACE_BITS+= .WAIT libdwarf
37DTRACE_BITS+= .WAIT libctf
38DTRACE_BITS+= .WAIT ctfconvert ctfmerge
39.endif
40
41LINT_BITS=
42.if ${MKLINT} != "no"
43LINT_BITS= lint lint2
44.endif
45
46# Dependencies in SUBDIR below ordered to maximize parallel ability.
47SUBDIR=	host-mkdep .WAIT compat .WAIT \
48	binstall .WAIT mktemp .WAIT sed .WAIT \
49		cap_mkdb crunchgen ctags genassym gencat hexdump join \
50		${LINT_BITS} \
51		lorder makewhatis mkdep mtree nbperf .WAIT rpcgen tsort \
52		uudecode m4 \
53	.WAIT texinfo \
54	.WAIT yacc \
55	.WAIT awk \
56	.WAIT tic \
57	.WAIT lex \
58	.WAIT pax \
59	.WAIT ${TOOLCHAIN_BITS} \
60	${DTRACE_BITS} \
61		asn1_compile cat cksum compile_et config db \
62		file lint1 slc \
63		makefs .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
64		.WAIT disklabel \
65		.WAIT paxctl \
66		.WAIT fdisk \
67		.WAIT installboot \
68		pwd_mkdb stat strfile sunlabel zic
69
70.if ${MKLLVM} != "no"
71# .WAIT between llvm-tblgen and llvm-clang-tblgen ensures install
72# rules works correctly
73SUBDIR+= \
74	llvm .WAIT \
75	llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
76	llvm-tblgen .WAIT llvm-clang-tblgen .WAIT \
77	llvm-include .WAIT \
78	llvm-lib .WAIT \
79	llvm-clang
80.endif
81
82.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
83.  if ${MKGROFF} != "no"
84SUBDIR+=	groff
85.  endif
86SUBDIR+=	mandoc
87.endif
88
89.if ${MKMAINTAINERTOOLS:Uno} != "no"
90SUBDIR+=	autoconf .WAIT gettext
91.endif
92
93.if ${USE_PIGZGZIP} != "no"
94SUBDIR+=	pigz
95.endif
96
97.if ${MACHINE} == "hp700"
98SUBDIR+=	hp700-mkboot
99.endif
100
101.if ${MACHINE} == "ibmnws"
102SUBDIR+=	ibmnws-ncdcs
103.endif
104
105.if ${MACHINE} == "macppc"
106SUBDIR+=	macppc-fixcoff
107.endif
108
109.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
110SUBDIR+=	powerpc-mkbootimage
111.endif
112
113.if ${MACHINE_ARCH} == "m68k"
114SUBDIR+=	m68k-elf2aout
115.endif
116
117.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
118     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
119SUBDIR+=	mips-elf2ecoff
120.endif
121
122.if (${MACHINE} == "sgimips")
123SUBDIR+=	sgivol
124.endif
125
126.if ${MACHINE} == "acorn32"
127SUBDIR+=	sparkcrc
128.endif
129
130.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
131SUBDIR+=	fgen
132.endif
133
134.if ${MACHINE} == "amiga"
135SUBDIR+=	amiga-elf2bb
136SUBDIR+=	amiga-txlt
137.endif
138
139.if ${MACHINE} == "hp300"
140SUBDIR+=	hp300-mkboot
141.endif
142
143.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
144    ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
145SUBDIR+=	mkubootimage
146.endif
147
148check_MKTOOLS: .PHONY .NOTMAIN
149.if ${MKTOOLS:Uyes} == "no"
150	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
151	@echo '*** updating your host toolchain.  This should be used only as a'
152	@echo '*** temporary workaround for toolchain problems, as it will result'
153	@echo '*** in version skew and build errors over time!'
154.endif
155
156.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
157realall realdepend install: check_MKTOOLS
158
159.for dir in ${SUBDIR:N.WAIT}
160all-${dir} depend-${dir} dependall-${dir} install-${dir}:
161	@true
162.endfor
163.endif							# }
164
165.include <bsd.subdir.mk>
166.include <bsd.obj.mk>
167
168.if !defined(PREVIOUSTOOLDIR)
169.  if exists(PREVIOUSTOOLDIR)
170PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
171.  else
172PREVIOUSTOOLDIR=
173.  endif
174.endif
175
176CLEANFILES+=	PREVIOUSTOOLDIR
177
178realall realdepend: .MAKE
179.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
180	@echo "*** WARNING: TOOLDIR has moved?"
181	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
182	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
183	@echo "*** Cleaning mis-matched tools"
184	rm -f PREVIOUSTOOLDIR
185	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
186.endif
187	echo ${TOOLDIR} >PREVIOUSTOOLDIR
188
189# For each .WAIT point, make sure the immediately preceding target is
190# installed before building anything after that point.
191# (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the
192# install of 'b', but not the install of 'a'.)
193#
194# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
195# to achieve this. These targets look like:
196#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
197#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
198# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
199# places corresponding to the .WAITs in our $SUBDIR variable.
200#
201# Also, since we're now mixing `install' with `all' and `depend' targets
202# an order relationship between those in each individual subdirectory
203# must be established.
204#
205_deps:=
206_prev:=
207
208.for d in ${SUBDIR}				# {
209_this:=		${d}
210
211.if ${_this} == ".WAIT"				# {
212
213# setup dependency to apply to all/depend targets in the next group
214_deps:=		${_deps} ${_prev:S/^/install-/}
215
216# if we're building *only* individual targets (i.e. "dependall-yacc"),
217# make sure prerequisite tools build before installing
218# XXX: dsl: this is likely to generate a dependency loop since there is
219# a .ORDER releation between the nodes as well.
220.if !make(all) && !make(dependall) && !make(install)
221install-${_prev}: dependall-${_prev}
222.endif
223
224.else # ${_this} != ".WAIT"			# } {
225
226# order depend/all/install targets for ${d} subdir.
227.ORDER: depend-${d} all-${d} dependall-${d} install-${d}
228
229# prevent cleandir in real{all,depend} from interfering with subdir makes
230.ORDER: realdepend dependall-${d}
231.ORDER: realdepend depend-${d}
232.ORDER: realall all-${d}
233
234# make all/depend-${d} dependent on list of install targets
235depend-${d} all-${d} dependall-${d}: ${_deps}
236
237.endif # ${_this} != ".WAIT"			# }
238
239# stash current name in case the next entry is .WAIT
240_prev:=		${d}
241.endfor						# }
242
243cleandir:
244	rm -f ${CLEANFILES}
245