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