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