1*a1307683Sjkoshy# $NetBSD: Makefile,v 1.214 2022/04/18 19:46:35 jkoshy Exp $ 2c5d597ceStv 314e39089Stv.include <bsd.own.mk> 4738f9d71Smatt.include <bsd.endian.mk> 514e39089Stv 6bd4c8d3dSjoerg# Make sure that the ordered build/install processing applies when using 7bd4c8d3dSjoerg# plain make. 8bd4c8d3dSjoerg.MAIN: build_install 9bd4c8d3dSjoerg 10ae4298d1Sapb# TOOLDIR must be valid, unless MKTOOLS=no 11ae4298d1Sapb.if ${MKTOOLS:Uyes} != "no" 12ae4298d1Sapb.if "${TOOLDIR}" == "" 13ae4298d1Sapb.error "TOOLDIR is undefined or empty" 14ae4298d1Sapb.elif "${TOOLDIR:tW:M/*}" == "" 15ae4298d1Sapb.error "TOOLDIR is not an absolute path: ${TOOLDIR}" 16ae4298d1Sapb#.elif !exists(TOOLDIR) # XXX .exists fails for directories 17ae4298d1Sapb#.error "TOOLDIR does not exist: ${TOOLDIR}" 18ae4298d1Sapb.endif 19ae4298d1Sapb.endif # MKTOOLS != no 20ae4298d1Sapb 2166742424Spooka# TOOLS_BUILDRUMP == yes builds only the subset of the tools required 2266742424Spooka# for building rump kernels and the hypervisor. It is typically used 2366742424Spooka# when building rump kernels targeted for non-NetBSD systems (via 2466742424Spooka# buildrump.sh), and should not be set for a regular "make build". 2566742424SpookaTOOLS_BUILDRUMP?=no 2666742424Spooka 27f6e8d099Spooka.if ${TOOLCHAIN_MISSING} == "no" 2817f074a6Sdbj. if (defined(HAVE_GCC) && ${HAVE_GCC} > 0) || \ 2917f074a6Sdbj (defined(HAVE_GDB) && ${HAVE_GDB} > 0 && ${MKCROSSGDB:Uno} != "no") 3017f074a6SdbjTOOLCHAIN_BITS+= gmake .WAIT 31a6f110d1SmrgTOOLCHAIN_BITS+= gmp .WAIT 32a6f110d1SmrgTOOLCHAIN_BITS+= mpfr .WAIT 33a6f110d1SmrgTOOLCHAIN_BITS+= mpc .WAIT 34a6f110d1Smrg. endif 359383a2f2Sjoerg 3667840cd9SjmcTOOLCHAIN_BITS+= binutils .WAIT 379383a2f2Sjoerg 38aa37019dSmatt. if defined(HAVE_GCC) && ${HAVE_GCC} > 0 39949cd54dSmrgTOOLCHAIN_BITS+= gcc 4017f074a6Sdbj. endif 4117f074a6Sdbj 4217f074a6Sdbj. if defined(HAVE_GDB) && ${HAVE_GDB} > 0 && ${MKCROSSGDB:Uno} != "no" 4398f3b47aSclTOOLCHAIN_BITS+= gdb 4498f3b47aScl. endif 4517f074a6Sdbj 469383a2f2SjoergTOOLCHAIN_BITS+= .WAIT 47a328e341Stv.endif 483d345022Sgmcgarry 493d345022Sgmcgarry.if defined(HAVE_PCC) 503d345022Sgmcgarry. if ${TOOLCHAIN_MISSING} == "no" 513d345022SgmcgarryTOOLCHAIN_BITS+= pcc 523d345022Sgmcgarry. endif 533d345022Sgmcgarry.endif 54a328e341Stv 55ece3adc4Schristos.if ${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN) 569383a2f2SjoergTOOLCHAIN_BITS+= dbsym mdsetimage 57ee5f7855Spooka.endif 589383a2f2Sjoerg 595f2f3d9cSdarranDTRACE_BITS= 6019d78de4Sriastradh.if ${MKDTRACE} != "no" || ${MKCTF} != "no" 61deabdccaSjkoshyDTRACE_BITS+= .WAIT elftoolchain 625f2f3d9cSdarranDTRACE_BITS+= .WAIT libctf 6368ce81dbSozaki-r.endif 6468ce81dbSozaki-r.if ${MKCTF} != "no" 655f2f3d9cSdarranDTRACE_BITS+= .WAIT ctfconvert ctfmerge 665f2f3d9cSdarran.endif 675f2f3d9cSdarran 68dbf21d98SmrgLINT_BITS= 69dbf21d98Smrg.if ${MKLINT} != "no" 70dbf21d98SmrgLINT_BITS= lint lint2 71dbf21d98Smrg.endif 72dbf21d98Smrg 731955a7cdSapb# All of host-mkdep, compat, and binstall are needed before anything 741955a7cdSapb# else. Within this group, they must be built in a specific order, and 751955a7cdSapb# all of them must be built before any of them is installed. They may 761955a7cdSapb# be installed in any order. This can't be expressed using the .WAIT 771955a7cdSapb# notation inside the SUBDIR list. 781955a7cdSapb# 791955a7cdSapb# XXX .ORDER does not work when multiple targets are passed on the 801955a7cdSapb# make command line without "-j", so use dependencies in addition to .ORDER. 811955a7cdSapb# 82fea3b3b8Scjep.ORDER: dependall-host-mkdep dependall-compat dependall-binstall \ 83fea3b3b8Scjep dependall-date 841955a7cdSapb.if make(dependall-host-mkdep) && make(dependall-compat) 851955a7cdSapbdependall-compat: dependall-host-mkdep 861955a7cdSapb.endif 871955a7cdSapb.if make(dependall-compat) && make(dependall-binstall) 881955a7cdSapbdependall-binstall: dependall-compat 891955a7cdSapb.endif 90fea3b3b8Scjep.if make(dependall-date) 91fea3b3b8Scjepdependall-date: dependall-host-mkdep dependall-compat 92fea3b3b8Scjep.endif 931955a7cdSapb 94b5cd2489Stv# Dependencies in SUBDIR below ordered to maximize parallel ability. 951955a7cdSapb# See above for special treatment for host-mkdep, compat, and binstall. 961955a7cdSapb# 978cfc46e4SchristosSUBDIR= host-mkdep compat binstall date \ 98aa3e07eaSpooka .WAIT mktemp .WAIT sed .WAIT genassym 9966742424Spooka.if ${TOOLS_BUILDRUMP} == "no" 100aa3e07eaSpookaSUBDIR+= cap_mkdb crunchgen ctags gencat hexdump \ 101dbf21d98Smrg ${LINT_BITS} \ 10214bc59cfSpooka makewhatis mtree nbperf .WAIT uudecode 10366742424Spooka.endif 10466742424Spooka 105f0d170cdSbadSUBDIR+= cat rpcgen join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex 10666742424Spooka.if ${TOOLS_BUILDRUMP} == "no" 107f0d170cdSbadSUBDIR+= xz-include .WAIT grep xz-lib pax .WAIT libprop 108f0d170cdSbad 10966742424SpookaSUBDIR += .WAIT texinfo \ 1100ddd7f21Schristos .WAIT tic \ 1113fa4bcf5Smrg .WAIT ${TOOLCHAIN_BITS} \ 1125f2f3d9cSdarran ${DTRACE_BITS} \ 11314bc59cfSpooka asn1_compile cksum compile_et db \ 1146ef76632Selric file lint1 slc \ 115f6f6e086Schristos makefs sortinfo \ 116f6f6e086Schristos .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \ 117fc614d42Schristos .WAIT disklabel gpt \ 1183fa4bcf5Smrg .WAIT paxctl \ 1193fa4bcf5Smrg .WAIT fdisk \ 1203fa4bcf5Smrg .WAIT installboot \ 121ad65c73fSchristos pwd_mkdb strfile sunlabel vgrind zic 12266742424Spooka.endif 123f0d170cdSbadSUBDIR+= stat .WAIT config 124f0d170cdSbad.if ${TOOLS_BUILDRUMP} == "no" 125f0d170cdSbadSUBDIR+= xz-bin 126f0d170cdSbad.endif 12787d14ee4Stv 1284ad841ecSjoerg.if ${MKLLVM} != "no" || ${MKLLVMRT} != "no" 1296550d01eSjoergSUBDIR+= \ 1306550d01eSjoerg llvm .WAIT \ 131b0ad7fb1Sjoerg llvm-lib/libLLVMDemangle llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \ 1324ad841ecSjoerg llvm-tblgen 1334ad841ecSjoerg.endif 1344ad841ecSjoerg.if ${MKLLVM} != "no" 1354ad841ecSjoergSUBDIR+= \ 1364ad841ecSjoerg llvm-clang-tblgen 1375acd69fdSjoerg.endif 1385acd69fdSjoerg.if ${MKLLVM} != "no" && !defined(EXTERNAL_TOOLCHAIN) 1395acd69fdSjoergSUBDIR+= \ 1405acd69fdSjoerg .WAIT llvm-include .WAIT \ 141e27d69ebSjoerg llvm-lib .WAIT \ 142e27d69ebSjoerg llvm-clang 1436550d01eSjoerg.endif 1446550d01eSjoerg 1455e0c4c78Sdyoung.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no" 1461bd975ffSjoerg. if ${MKGROFF} != "no" 14719ab4b25StvSUBDIR+= groff 1483b68c946Sjoerg. endif 1491bd975ffSjoergSUBDIR+= mandoc 15019ab4b25Stv.endif 15119ab4b25Stv 15266742424Spooka.if ${TOOLS_BUILDRUMP} == "no" 15366742424Spooka 15487d14ee4Stv.if ${MKMAINTAINERTOOLS:Uno} != "no" 155e728c9b0SlukemSUBDIR+= autoconf .WAIT gettext 15687d14ee4Stv.endif 157fc820c72Smrg 15825c3593dSmrg.if ${USE_PIGZGZIP} != "no" 15925c3593dSmrgSUBDIR+= pigz 16025c3593dSmrg.endif 16125c3593dSmrg 162fdfdea60Sskrll.if ${MACHINE} == "hppa" 163fdfdea60SskrllSUBDIR+= hppa-mkboot 164bc26aea7Sskrll.endif 165bc26aea7Sskrll 1669bfe9b99Sjmc.if ${MACHINE} == "ibmnws" 16710c0014bSmattSUBDIR+= ibmnws-ncdcs 16810c0014bSmatt.endif 16910c0014bSmatt 1709bfe9b99Sjmc.if ${MACHINE} == "macppc" 171ca1e0d59SmattSUBDIR+= macppc-fixcoff 172ca1e0d59Smatt.endif 173ca1e0d59Smatt 1740c4a5c6fSgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox") 175c3408ed0SgarbledSUBDIR+= powerpc-mkbootimage 176c30b41caSkleink.endif 177c30b41caSkleink 17898a7fb8dSchristos.if ${MACHINE_CPU} == "arm" 1792cef058cSchristosSUBDIR+= arm-elf2aout 1802cef058cSchristos.endif 1812cef058cSchristos 18298a7fb8dSchristos.if ${MACHINE_CPU} == "m68k" 183a81fe125StsutsuiSUBDIR+= m68k-elf2aout 184a81fe125Stsutsui.endif 185a81fe125Stsutsui 186c1b2172eSchristos.if !empty(MACHINE_ARCH:Mmips*) 1870d9e66cdSgmcgarrySUBDIR+= mips-elf2ecoff 1880d9e66cdSgmcgarry.endif 1890d9e66cdSgmcgarry 1900ac35082Ssekiya.if (${MACHINE} == "sgimips") 1910ac35082SsekiyaSUBDIR+= sgivol 1920ac35082Ssekiya.endif 1930ac35082Ssekiya 194ef4ecddaSabs.if ${MACHINE} == "acorn32" 195ef4ecddaSabsSUBDIR+= sparkcrc 196ef4ecddaSabs.endif 197ef4ecddaSabs 198515e5215Sabs.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") 199bf9ec67eSbjh21SUBDIR+= fgen 200bf9ec67eSbjh21.endif 201bf9ec67eSbjh21 202c7464d49Sjmc.if ${MACHINE} == "amiga" 203c7464d49SjmcSUBDIR+= amiga-elf2bb 204c7464d49SjmcSUBDIR+= amiga-txlt 205c7464d49Sjmc.endif 206c7464d49Sjmc 2079bfe9b99Sjmc.if ${MACHINE} == "hp300" 2089bfe9b99SjmcSUBDIR+= hp300-mkboot 2099bfe9b99Sjmc.endif 2109bfe9b99Sjmc 211738f9d71Smatt.if ${MACHINE} == "evbarm" \ 212738f9d71Smatt && ${MACHINE_CPU} == "arm" \ 213738f9d71Smatt && ${TARGET_ENDIANNESS} == "1234" 214b3979f3aSjkunzSUBDIR+= elftosb 215b3979f3aSjkunz.endif 216b3979f3aSjkunz 2176a3fb81fSphx.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \ 2180044f1d5Suwe ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \ 2190044f1d5Suwe ${MACHINE} == "sandpoint" 220192740f5SjmcneillSUBDIR+= mkubootimage 221747b2fcfSskrll.endif 222747b2fcfSskrll 223747b2fcfSskrll.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \ 224747b2fcfSskrll ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \ 225747b2fcfSskrll ${MACHINE} == "sandpoint" || \ 226747b2fcfSskrll ${MACHINE_CPU} == "riscv" 2278a857a49SskrllSUBDIR+= libfdt .WAIT 2288a857a49SskrllSUBDIR+= dtc 229192740f5Sjmcneill.endif 230192740f5Sjmcneill 2310d845a20Srin.if ${MACHINE} == "mvme68k" 2320d845a20SrinSUBDIR+= mvme68k-wrtvid 2330d845a20Srin.endif 2340d845a20Srin 235fe18025dSmrg.if ${MKX11} != "no" 236155e1446SmattSUBDIR+= makestrs 237155e1446SmattSUBDIR+= makekeys 2383711cbc0Sjoerg.endif 2393711cbc0Sjoerg 24081bbec95SchristosSUBDIR+= cvslatest 24181bbec95Schristos 24210c343c6Suwe.endif # TOOLS_BUILDRUMP != no 24366742424Spooka 2443fd7f6dbSlukemcheck_MKTOOLS: .PHONY .NOTMAIN 2455a0f427eSjmc.if ${MKTOOLS:Uyes} == "no" 246259ff4e7Stv @echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and' 247259ff4e7Stv @echo '*** updating your host toolchain. This should be used only as a' 248259ff4e7Stv @echo '*** temporary workaround for toolchain problems, as it will result' 249ecc52c58Swiz @echo '*** in version skew and build errors over time!' 2500d11dd01Sjmc.endif 251259ff4e7Stv 2523fd7f6dbSlukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes" # { 25351920ba5SapbSUBDIR= # empty 254355436d5Slukemrealall realdepend install: check_MKTOOLS 2553fd7f6dbSlukem.endif # } 256259ff4e7Stv 257c5d597ceStv.include <bsd.subdir.mk> 258bd4c8d3dSjoerg.include <bsd.buildinstall.mk> 259c9a6a2c3Stv.include <bsd.obj.mk> 26061be23b4Stv 261c1af61f8Stron.if !defined(PREVIOUSTOOLDIR) 2623fd7f6dbSlukem. if exists(PREVIOUSTOOLDIR) 2633fd7f6dbSlukemPREVIOUSTOOLDIR!= cat PREVIOUSTOOLDIR 2643fd7f6dbSlukem. else 2653fd7f6dbSlukemPREVIOUSTOOLDIR= 2663fd7f6dbSlukem. endif 267c1af61f8Stron.endif 2683fd7f6dbSlukem 2693fd7f6dbSlukemCLEANFILES+= PREVIOUSTOOLDIR 2703fd7f6dbSlukem 271fe4611e5Stronrealall realdepend: .MAKE 27250ef6180Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}" 2733fd7f6dbSlukem @echo "*** WARNING: TOOLDIR has moved?" 2743fd7f6dbSlukem @echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'" 2753fd7f6dbSlukem @echo "*** != TOOLDIR '${TOOLDIR}'" 2763fd7f6dbSlukem @echo "*** Cleaning mis-matched tools" 2773fd7f6dbSlukem rm -f PREVIOUSTOOLDIR 2783d00583fSfreza (cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir) 2793fd7f6dbSlukem.endif 2803fd7f6dbSlukem echo ${TOOLDIR} >PREVIOUSTOOLDIR 2813fd7f6dbSlukem 28278da845dStroncleandir: 28378da845dStron rm -f ${CLEANFILES} 284