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