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