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