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". 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 libelf 63DTRACE_BITS+= .WAIT libdwarf 64DTRACE_BITS+= .WAIT libctf 65.endif 66.if ${MKCTF} != "no" 67DTRACE_BITS+= .WAIT ctfconvert ctfmerge 68.endif 69 70LINT_BITS= 71.if ${MKLINT} != "no" 72LINT_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) 87dependall-compat: dependall-host-mkdep 88.endif 89.if make(dependall-compat) && make(dependall-binstall) 90dependall-binstall: dependall-compat 91.endif 92.if make(dependall-date) 93dependall-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# 99SUBDIR= host-mkdep compat binstall date \ 100 .WAIT mktemp .WAIT sed .WAIT genassym 101.if ${TOOLS_BUILDRUMP} == "no" 102SUBDIR+= cap_mkdb crunchgen ctags gencat hexdump \ 103 ${LINT_BITS} \ 104 makewhatis mtree nbperf .WAIT uudecode 105.endif 106 107SUBDIR+= cat rpcgen join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex 108.if ${TOOLS_BUILDRUMP} == "no" 109SUBDIR+= xz-include .WAIT grep xz-lib pax .WAIT libprop 110 111SUBDIR += .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 125SUBDIR+= stat .WAIT config 126.if ${TOOLS_BUILDRUMP} == "no" 127SUBDIR+= xz-bin 128.endif 129 130.if ${MKLLVM} != "no" || ${MKLLVMRT} != "no" 131SUBDIR+= \ 132 llvm .WAIT \ 133 llvm-lib/libLLVMDemangle llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \ 134 llvm-tblgen 135.endif 136.if ${MKLLVM} != "no" 137SUBDIR+= \ 138 llvm-clang-tblgen 139.endif 140.if ${MKLLVM} != "no" && !defined(EXTERNAL_TOOLCHAIN) 141SUBDIR+= \ 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" 149SUBDIR+= groff 150. endif 151SUBDIR+= mandoc 152.endif 153 154.if ${TOOLS_BUILDRUMP} == "no" 155 156.if ${MKMAINTAINERTOOLS:Uno} != "no" 157SUBDIR+= autoconf .WAIT gettext 158.endif 159 160.if ${USE_PIGZGZIP} != "no" 161SUBDIR+= pigz 162.endif 163 164.if ${MACHINE} == "hppa" 165SUBDIR+= hppa-mkboot 166.endif 167 168.if ${MACHINE} == "ibmnws" 169SUBDIR+= ibmnws-ncdcs 170.endif 171 172.if ${MACHINE} == "macppc" 173SUBDIR+= macppc-fixcoff 174.endif 175 176.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox") 177SUBDIR+= powerpc-mkbootimage 178.endif 179 180.if ${MACHINE_CPU} == "arm" 181SUBDIR+= arm-elf2aout 182.endif 183 184.if ${MACHINE_CPU} == "m68k" 185SUBDIR+= m68k-elf2aout 186.endif 187 188.if !empty(MACHINE_ARCH:Mmips*) 189SUBDIR+= mips-elf2ecoff 190.endif 191 192.if (${MACHINE} == "sgimips") 193SUBDIR+= sgivol 194.endif 195 196.if ${MACHINE} == "acorn32" 197SUBDIR+= sparkcrc 198.endif 199 200.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") 201SUBDIR+= fgen 202.endif 203 204.if ${MACHINE} == "amiga" 205SUBDIR+= amiga-elf2bb 206SUBDIR+= amiga-txlt 207.endif 208 209.if ${MACHINE} == "hp300" 210SUBDIR+= hp300-mkboot 211.endif 212 213.if ${MACHINE} == "evbarm" \ 214 && ${MACHINE_CPU} == "arm" \ 215 && ${TARGET_ENDIANNESS} == "1234" 216SUBDIR+= elftosb 217.endif 218 219.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \ 220 ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \ 221 ${MACHINE} == "sandpoint" 222SUBDIR+= mkubootimage 223.endif 224 225.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \ 226 ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \ 227 ${MACHINE} == "sandpoint" || \ 228 ${MACHINE_CPU} == "riscv" 229SUBDIR+= libfdt .WAIT 230SUBDIR+= dtc 231.endif 232 233.if ${MACHINE} == "mvme68k" 234SUBDIR+= mvme68k-wrtvid 235.endif 236 237.if ${MKX11} != "no" 238SUBDIR+= makestrs 239SUBDIR+= makekeys 240.endif 241 242SUBDIR+= cvslatest 243 244.endif # TOOLS_BUILDRUMP != no 245 246check_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" # { 255SUBDIR= # empty 256realall 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) 265PREVIOUSTOOLDIR!= cat PREVIOUSTOOLDIR 266. else 267PREVIOUSTOOLDIR= 268. endif 269.endif 270 271CLEANFILES+= PREVIOUSTOOLDIR 272 273realall 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 284cleandir: 285 rm -f ${CLEANFILES} 286