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