Makefile revision 1.213 1 # $NetBSD: Makefile,v 1.213 2022/04/13 17:52:56 jkoshy 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 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 dependall-date
86 .if make(dependall-host-mkdep) && make(dependall-compat)
87 dependall-compat: dependall-host-mkdep
88 .endif
89 .if make(dependall-compat) && make(dependall-binstall)
90 dependall-binstall: dependall-compat
91 .endif
92 .if make(dependall-date)
93 dependall-date: dependall-host-mkdep dependall-compat
94 .endif
95
96 # Dependencies in SUBDIR below ordered to maximize parallel ability.
97 # See above for special treatment for host-mkdep, compat, and binstall.
98 #
99 SUBDIR= host-mkdep compat binstall date \
100 .WAIT mktemp .WAIT sed .WAIT genassym
101 .if ${TOOLS_BUILDRUMP} == "no"
102 SUBDIR+= cap_mkdb crunchgen ctags gencat hexdump \
103 ${LINT_BITS} \
104 makewhatis mtree nbperf .WAIT uudecode
105 .endif
106
107 SUBDIR+= cat rpcgen join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
108 .if ${TOOLS_BUILDRUMP} == "no"
109 SUBDIR+= xz-include .WAIT grep xz-lib pax .WAIT libprop
110
111 SUBDIR += .WAIT texinfo \
112 .WAIT tic \
113 .WAIT ${TOOLCHAIN_BITS} \
114 ${DTRACE_BITS} \
115 asn1_compile cksum compile_et db \
116 file lint1 slc \
117 makefs sortinfo \
118 .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
119 .WAIT disklabel gpt \
120 .WAIT paxctl \
121 .WAIT fdisk \
122 .WAIT installboot \
123 pwd_mkdb strfile sunlabel vgrind zic
124 .endif
125 SUBDIR+= stat .WAIT config
126 .if ${TOOLS_BUILDRUMP} == "no"
127 SUBDIR+= xz-bin
128 .endif
129
130 .if ${MKLLVM} != "no" || ${MKLLVMRT} != "no"
131 SUBDIR+= \
132 llvm .WAIT \
133 llvm-lib/libLLVMDemangle llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
134 llvm-tblgen
135 .endif
136 .if ${MKLLVM} != "no"
137 SUBDIR+= \
138 llvm-clang-tblgen
139 .endif
140 .if ${MKLLVM} != "no" && !defined(EXTERNAL_TOOLCHAIN)
141 SUBDIR+= \
142 .WAIT llvm-include .WAIT \
143 llvm-lib .WAIT \
144 llvm-clang
145 .endif
146
147 .if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
148 . if ${MKGROFF} != "no"
149 SUBDIR+= groff
150 . endif
151 SUBDIR+= mandoc
152 .endif
153
154 .if ${TOOLS_BUILDRUMP} == "no"
155
156 .if ${MKMAINTAINERTOOLS:Uno} != "no"
157 SUBDIR+= autoconf .WAIT gettext
158 .endif
159
160 .if ${USE_PIGZGZIP} != "no"
161 SUBDIR+= pigz
162 .endif
163
164 .if ${MACHINE} == "hppa"
165 SUBDIR+= hppa-mkboot
166 .endif
167
168 .if ${MACHINE} == "ibmnws"
169 SUBDIR+= ibmnws-ncdcs
170 .endif
171
172 .if ${MACHINE} == "macppc"
173 SUBDIR+= macppc-fixcoff
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 ${MKX11} != "no"
238 SUBDIR+= makestrs
239 SUBDIR+= makekeys
240 .endif
241
242 SUBDIR+= cvslatest
243
244 .endif # TOOLS_BUILDRUMP != no
245
246 check_MKTOOLS: .PHONY .NOTMAIN
247 .if ${MKTOOLS:Uyes} == "no"
248 @echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
249 @echo '*** updating your host toolchain. This should be used only as a'
250 @echo '*** temporary workaround for toolchain problems, as it will result'
251 @echo '*** in version skew and build errors over time!'
252 .endif
253
254 .if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes" # {
255 SUBDIR= # empty
256 realall realdepend install: check_MKTOOLS
257 .endif # }
258
259 .include <bsd.subdir.mk>
260 .include <bsd.buildinstall.mk>
261 .include <bsd.obj.mk>
262
263 .if !defined(PREVIOUSTOOLDIR)
264 . if exists(PREVIOUSTOOLDIR)
265 PREVIOUSTOOLDIR!= cat PREVIOUSTOOLDIR
266 . else
267 PREVIOUSTOOLDIR=
268 . endif
269 .endif
270
271 CLEANFILES+= PREVIOUSTOOLDIR
272
273 realall realdepend: .MAKE
274 .if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
275 @echo "*** WARNING: TOOLDIR has moved?"
276 @echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
277 @echo "*** != TOOLDIR '${TOOLDIR}'"
278 @echo "*** Cleaning mis-matched tools"
279 rm -f PREVIOUSTOOLDIR
280 (cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
281 .endif
282 echo ${TOOLDIR} >PREVIOUSTOOLDIR
283
284 cleandir:
285 rm -f ${CLEANFILES}
286