1*fc614d42Schristos# $NetBSD: Makefile,v 1.178 2014/09/30 19:38:25 christos 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" 28aa37019dSmatt. if defined(HAVE_GCC) && ${HAVE_GCC} > 0 2967840cd9SjmcTOOLCHAIN_BITS= gmake .WAIT 30a6f110d1SmrgTOOLCHAIN_BITS+= gmp .WAIT 31a6f110d1SmrgTOOLCHAIN_BITS+= mpfr .WAIT 32a6f110d1SmrgTOOLCHAIN_BITS+= mpc .WAIT 33a6f110d1Smrg. endif 349383a2f2Sjoerg.endif 359383a2f2Sjoerg 369383a2f2Sjoerg.if ${TOOLCHAIN_MISSING} == "no" 3767840cd9SjmcTOOLCHAIN_BITS+= binutils .WAIT 389383a2f2Sjoerg.endif 399383a2f2Sjoerg 40aa37019dSmatt.if defined(HAVE_GCC) && ${HAVE_GCC} > 0 419383a2f2Sjoerg. if ${TOOLCHAIN_MISSING} == "no" 42949cd54dSmrgTOOLCHAIN_BITS+= gcc 43d310cf3bSmatt. if ${MKCROSSGDB:Uno} != "no" || make(obj) 4498f3b47aSclTOOLCHAIN_BITS+= gdb 4598f3b47aScl. endif 469383a2f2SjoergTOOLCHAIN_BITS+= .WAIT 47a328e341Stv. endif 483d345022Sgmcgarry.endif 493d345022Sgmcgarry 503d345022Sgmcgarry.if defined(HAVE_PCC) 513d345022Sgmcgarry. if ${TOOLCHAIN_MISSING} == "no" 523d345022SgmcgarryTOOLCHAIN_BITS+= pcc 533d345022Sgmcgarry. endif 543d345022Sgmcgarry.endif 55a328e341Stv 56ee5f7855Spooka.if ${TOOLCHAIN_MISSING} == "no" 57ee5f7855Spooka# XXX Eventually, we want to be able to build dbsym and mdsetimage 58ee5f7855Spooka# XXX if EXTERNAL_TOOLCHAIN is set. 599383a2f2SjoergTOOLCHAIN_BITS+= dbsym mdsetimage 60ee5f7855Spooka.endif 619383a2f2Sjoerg 625f2f3d9cSdarranDTRACE_BITS= 6319d78de4Sriastradh.if ${MKDTRACE} != "no" || ${MKCTF} != "no" 645f2f3d9cSdarranDTRACE_BITS+= .WAIT libelf 655f2f3d9cSdarranDTRACE_BITS+= .WAIT libdwarf 665f2f3d9cSdarranDTRACE_BITS+= .WAIT libctf 6768ce81dbSozaki-r.endif 6868ce81dbSozaki-r.if ${MKCTF} != "no" 695f2f3d9cSdarranDTRACE_BITS+= .WAIT ctfconvert ctfmerge 705f2f3d9cSdarran.endif 715f2f3d9cSdarran 72dbf21d98SmrgLINT_BITS= 73dbf21d98Smrg.if ${MKLINT} != "no" 74dbf21d98SmrgLINT_BITS= lint lint2 75dbf21d98Smrg.endif 76dbf21d98Smrg 771955a7cdSapb# All of host-mkdep, compat, and binstall are needed before anything 781955a7cdSapb# else. Within this group, they must be built in a specific order, and 791955a7cdSapb# all of them must be built before any of them is installed. They may 801955a7cdSapb# be installed in any order. This can't be expressed using the .WAIT 811955a7cdSapb# notation inside the SUBDIR list. 821955a7cdSapb# 831955a7cdSapb# XXX .ORDER does not work when multiple targets are passed on the 841955a7cdSapb# make command line without "-j", so use dependencies in addition to .ORDER. 851955a7cdSapb# 861955a7cdSapb.ORDER: dependall-host-mkdep dependall-compat dependall-binstall 871955a7cdSapb.if make(dependall-host-mkdep) && make(dependall-compat) 881955a7cdSapbdependall-compat: dependall-host-mkdep 891955a7cdSapb.endif 901955a7cdSapb.if make(dependall-compat) && make(dependall-binstall) 911955a7cdSapbdependall-binstall: dependall-compat 921955a7cdSapb.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# 971955a7cdSapbSUBDIR= host-mkdep compat binstall \ 9866742424Spooka .WAIT mktemp .WAIT sed .WAIT 9966742424Spooka.if ${TOOLS_BUILDRUMP} == "no" 10066742424SpookaSUBDIR+= cap_mkdb crunchgen ctags genassym gencat hexdump \ 101dbf21d98Smrg ${LINT_BITS} \ 10214bc59cfSpooka makewhatis mtree nbperf .WAIT uudecode 10366742424Spooka.endif 10466742424Spooka 10514bc59cfSpookaSUBDIR+= cat rpcgen join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex 10666742424Spooka 10766742424Spooka.if ${TOOLS_BUILDRUMP} == "no" 10866742424SpookaSUBDIR += .WAIT texinfo \ 1090ddd7f21Schristos .WAIT tic \ 1103fa4bcf5Smrg .WAIT pax \ 1113fa4bcf5Smrg .WAIT ${TOOLCHAIN_BITS} \ 1125f2f3d9cSdarran ${DTRACE_BITS} \ 11314bc59cfSpooka asn1_compile cksum compile_et db \ 1146ef76632Selric file lint1 slc \ 1153c7d868bSriz makefs .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \ 116*fc614d42Schristos .WAIT disklabel gpt \ 1173fa4bcf5Smrg .WAIT paxctl \ 1183fa4bcf5Smrg .WAIT fdisk \ 1193fa4bcf5Smrg .WAIT installboot \ 120ad65c73fSchristos pwd_mkdb strfile sunlabel vgrind zic 12166742424Spooka.endif 12214bc59cfSpookaSUBDIR+= stat .WAIT config 12387d14ee4Stv 1246550d01eSjoerg.if ${MKLLVM} != "no" 1256550d01eSjoergSUBDIR+= \ 1266550d01eSjoerg llvm .WAIT \ 127d9936c4aSjoerg llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \ 128bd4c8d3dSjoerg llvm-tblgen llvm-clang-tblgen .WAIT \ 1296550d01eSjoerg llvm-include .WAIT \ 1306550d01eSjoerg llvm-lib .WAIT \ 1316550d01eSjoerg llvm-clang 132cb28f822Sjoerg. if ${MKLLD} != "no" 133cb28f822SjoergSUBDIR+= llvm-lld 134cb28f822Sjoerg. endif 13579752264Sjoerg. if ${MKMCLINKER} != "no" 13679752264SjoergSUBDIR+= llvm-mcld 13779752264Sjoerg. endif 1386550d01eSjoerg.endif 1396550d01eSjoerg 1405e0c4c78Sdyoung.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no" 1411bd975ffSjoerg. if ${MKGROFF} != "no" 14219ab4b25StvSUBDIR+= groff 1433b68c946Sjoerg. endif 1441bd975ffSjoergSUBDIR+= mandoc 14519ab4b25Stv.endif 14619ab4b25Stv 14766742424Spooka.if ${TOOLS_BUILDRUMP} == "no" 14866742424Spooka 14987d14ee4Stv.if ${MKMAINTAINERTOOLS:Uno} != "no" 150e728c9b0SlukemSUBDIR+= autoconf .WAIT gettext 15187d14ee4Stv.endif 152fc820c72Smrg 15325c3593dSmrg.if ${USE_PIGZGZIP} != "no" 15425c3593dSmrgSUBDIR+= pigz 15525c3593dSmrg.endif 15625c3593dSmrg 157fdfdea60Sskrll.if ${MACHINE} == "hppa" 158fdfdea60SskrllSUBDIR+= hppa-mkboot 159bc26aea7Sskrll.endif 160bc26aea7Sskrll 1619bfe9b99Sjmc.if ${MACHINE} == "ibmnws" 16210c0014bSmattSUBDIR+= ibmnws-ncdcs 16310c0014bSmatt.endif 16410c0014bSmatt 1659bfe9b99Sjmc.if ${MACHINE} == "macppc" 166ca1e0d59SmattSUBDIR+= macppc-fixcoff 167ca1e0d59Smatt.endif 168ca1e0d59Smatt 1690c4a5c6fSgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox") 170c3408ed0SgarbledSUBDIR+= powerpc-mkbootimage 171c30b41caSkleink.endif 172c30b41caSkleink 173a81fe125Stsutsui.if ${MACHINE_ARCH} == "m68k" 174a81fe125StsutsuiSUBDIR+= m68k-elf2aout 175a81fe125Stsutsui.endif 176a81fe125Stsutsui 1777cc6c105Smrg.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \ 1787cc6c105Smrg ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb") 1790d9e66cdSgmcgarrySUBDIR+= mips-elf2ecoff 1800d9e66cdSgmcgarry.endif 1810d9e66cdSgmcgarry 1820ac35082Ssekiya.if (${MACHINE} == "sgimips") 1830ac35082SsekiyaSUBDIR+= sgivol 1840ac35082Ssekiya.endif 1850ac35082Ssekiya 186ef4ecddaSabs.if ${MACHINE} == "acorn32" 187ef4ecddaSabsSUBDIR+= sparkcrc 188ef4ecddaSabs.endif 189ef4ecddaSabs 190515e5215Sabs.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") 191bf9ec67eSbjh21SUBDIR+= fgen 192bf9ec67eSbjh21.endif 193bf9ec67eSbjh21 194c7464d49Sjmc.if ${MACHINE} == "amiga" 195c7464d49SjmcSUBDIR+= amiga-elf2bb 196c7464d49SjmcSUBDIR+= amiga-txlt 197c7464d49Sjmc.endif 198c7464d49Sjmc 1999bfe9b99Sjmc.if ${MACHINE} == "hp300" 2009bfe9b99SjmcSUBDIR+= hp300-mkboot 2019bfe9b99Sjmc.endif 2029bfe9b99Sjmc 203738f9d71Smatt.if ${MACHINE} == "evbarm" \ 204738f9d71Smatt && ${MACHINE_CPU} == "arm" \ 205738f9d71Smatt && ${TARGET_ENDIANNESS} == "1234" 206b3979f3aSjkunzSUBDIR+= elftosb 207b3979f3aSjkunz.endif 208b3979f3aSjkunz 2096a3fb81fSphx.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \ 2106a3fb81fSphx ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint" 211192740f5SjmcneillSUBDIR+= mkubootimage 212192740f5Sjmcneill.endif 213192740f5Sjmcneill 21466742424Spooka.endif # TOOLCHAIN_BUILDRUMP 21566742424Spooka 2163fd7f6dbSlukemcheck_MKTOOLS: .PHONY .NOTMAIN 2175a0f427eSjmc.if ${MKTOOLS:Uyes} == "no" 218259ff4e7Stv @echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and' 219259ff4e7Stv @echo '*** updating your host toolchain. This should be used only as a' 220259ff4e7Stv @echo '*** temporary workaround for toolchain problems, as it will result' 221ecc52c58Swiz @echo '*** in version skew and build errors over time!' 2220d11dd01Sjmc.endif 223259ff4e7Stv 2243fd7f6dbSlukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes" # { 22551920ba5SapbSUBDIR= # empty 226355436d5Slukemrealall realdepend install: check_MKTOOLS 2273fd7f6dbSlukem.endif # } 228259ff4e7Stv 229c5d597ceStv.include <bsd.subdir.mk> 230bd4c8d3dSjoerg.include <bsd.buildinstall.mk> 231c9a6a2c3Stv.include <bsd.obj.mk> 23261be23b4Stv 233c1af61f8Stron.if !defined(PREVIOUSTOOLDIR) 2343fd7f6dbSlukem. if exists(PREVIOUSTOOLDIR) 2353fd7f6dbSlukemPREVIOUSTOOLDIR!= cat PREVIOUSTOOLDIR 2363fd7f6dbSlukem. else 2373fd7f6dbSlukemPREVIOUSTOOLDIR= 2383fd7f6dbSlukem. endif 239c1af61f8Stron.endif 2403fd7f6dbSlukem 2413fd7f6dbSlukemCLEANFILES+= PREVIOUSTOOLDIR 2423fd7f6dbSlukem 243fe4611e5Stronrealall realdepend: .MAKE 24450ef6180Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}" 2453fd7f6dbSlukem @echo "*** WARNING: TOOLDIR has moved?" 2463fd7f6dbSlukem @echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'" 2473fd7f6dbSlukem @echo "*** != TOOLDIR '${TOOLDIR}'" 2483fd7f6dbSlukem @echo "*** Cleaning mis-matched tools" 2493fd7f6dbSlukem rm -f PREVIOUSTOOLDIR 2503d00583fSfreza (cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir) 2513fd7f6dbSlukem.endif 2523fd7f6dbSlukem echo ${TOOLDIR} >PREVIOUSTOOLDIR 2533fd7f6dbSlukem 25478da845dStroncleandir: 25578da845dStron rm -f ${CLEANFILES} 256