Makefile revision 1.166
11.166Spooka#	$NetBSD: Makefile,v 1.166 2013/01/31 15:22:50 pooka Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.3Stv
51.159Sjoerg# Make sure that the ordered build/install processing applies when using
61.159Sjoerg# plain make.
71.159Sjoerg.MAIN: build_install
81.159Sjoerg
91.164Sapb# TOOLDIR must be valid, unless MKTOOLS=no
101.164Sapb.if ${MKTOOLS:Uyes} != "no"
111.164Sapb.if "${TOOLDIR}" == ""
121.164Sapb.error "TOOLDIR is undefined or empty"
131.164Sapb.elif "${TOOLDIR:tW:M/*}" == ""
141.164Sapb.error "TOOLDIR is not an absolute path: ${TOOLDIR}"
151.164Sapb#.elif !exists(TOOLDIR) # XXX .exists fails for directories
161.164Sapb#.error "TOOLDIR does not exist: ${TOOLDIR}"
171.164Sapb.endif
181.164Sapb.endif # MKTOOLS != no
191.164Sapb
201.166Spooka# TOOLS_BUILDRUMP == yes builds only the subset of the tools required
211.166Spooka# for building rump kernels and the hypervisor.  It is typically used
221.166Spooka# when building rump kernels targeted for non-NetBSD systems (via
231.166Spooka# buildrump.sh), and should not be set for a regular "make build".
241.166SpookaTOOLS_BUILDRUMP?=no
251.166Spooka
261.160Spooka.if ${TOOLCHAIN_MISSING} == "no"
271.160Spooka.if defined(HAVE_GCC)
281.94SjmcTOOLCHAIN_BITS= gmake .WAIT
291.156Sjoerg.endif
301.156Sjoerg
311.156Sjoerg.if defined(HAVE_GCC)
321.146Smrg.if ${HAVE_GCC} >= 45
331.146SmrgTOOLCHAIN_BITS+= gmp .WAIT
341.146SmrgTOOLCHAIN_BITS+= mpfr .WAIT
351.146SmrgTOOLCHAIN_BITS+= mpc .WAIT
361.94Sjmc.endif
371.156Sjoerg.endif
381.156Sjoerg.endif
391.156Sjoerg
401.156Sjoerg.if ${TOOLCHAIN_MISSING} == "no"
411.94SjmcTOOLCHAIN_BITS+= binutils .WAIT
421.156Sjoerg.endif
431.156Sjoerg
441.156Sjoerg.if defined(HAVE_GCC)
451.156Sjoerg.if ${TOOLCHAIN_MISSING} == "no"
461.77SmrgTOOLCHAIN_BITS+= gcc
471.97Smrg.  if ${MKCROSSGDB:Uno} != "no"
481.74SclTOOLCHAIN_BITS+= gdb
491.70Smrg.  endif
501.156SjoergTOOLCHAIN_BITS+= .WAIT
511.31Stv.endif
521.118Sgmcgarry.endif
531.118Sgmcgarry
541.118Sgmcgarry.if defined(HAVE_PCC)
551.118Sgmcgarry.if ${TOOLCHAIN_MISSING} == "no"
561.118SgmcgarryTOOLCHAIN_BITS+= pcc
571.118Sgmcgarry.endif
581.118Sgmcgarry.endif
591.31Stv
601.157Spooka.if ${TOOLCHAIN_MISSING} == "no"
611.157Spooka# XXX Eventually, we want to be able to build dbsym and mdsetimage
621.157Spooka# XXX if EXTERNAL_TOOLCHAIN is set.
631.156SjoergTOOLCHAIN_BITS+= dbsym mdsetimage
641.157Spooka.endif
651.156Sjoerg
661.137SdarranDTRACE_BITS=
671.137Sdarran.if ${MKDTRACE} != "no"
681.137SdarranDTRACE_BITS+= .WAIT libelf
691.137SdarranDTRACE_BITS+= .WAIT libdwarf
701.162SapbDTRACE_BITS+= .WAIT libctf
711.137SdarranDTRACE_BITS+= .WAIT ctfconvert ctfmerge
721.137Sdarran.endif
731.137Sdarran
741.99SmrgLINT_BITS=
751.99Smrg.if ${MKLINT} != "no"
761.99SmrgLINT_BITS= lint lint2
771.99Smrg.endif
781.99Smrg
791.165Sapb# All of host-mkdep, compat, and binstall are needed before anything
801.165Sapb# else.  Within this group, they must be built in a specific order, and
811.165Sapb# all of them must be built before any of them is installed.  They may
821.165Sapb# be installed in any order.  This can't be expressed using the .WAIT
831.165Sapb# notation inside the SUBDIR list.
841.165Sapb#
851.165Sapb# XXX .ORDER does not work when multiple targets are passed on the
861.165Sapb# make command line without "-j", so use dependencies in addition to .ORDER.
871.165Sapb#
881.165Sapb.ORDER: dependall-host-mkdep dependall-compat dependall-binstall
891.165Sapb.if make(dependall-host-mkdep) && make(dependall-compat)
901.165Sapbdependall-compat: dependall-host-mkdep
911.165Sapb.endif
921.165Sapb.if make(dependall-compat) && make(dependall-binstall)
931.165Sapbdependall-binstall: dependall-compat
941.165Sapb.endif
951.165Sapb
961.16Stv# Dependencies in SUBDIR below ordered to maximize parallel ability.
971.165Sapb# See above for special treatment for host-mkdep, compat, and binstall.
981.165Sapb#
991.165SapbSUBDIR=	host-mkdep compat binstall \
1001.166Spooka	.WAIT mktemp .WAIT sed .WAIT
1011.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1021.166SpookaSUBDIR+= cap_mkdb crunchgen ctags genassym gencat hexdump \
1031.99Smrg		${LINT_BITS} \
1041.166Spooka		makewhatis mtree nbperf .WAIT rpcgen uudecode
1051.166Spooka.endif
1061.166Spooka
1071.166SpookaSUBDIR+= join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
1081.166Spooka
1091.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1101.166SpookaSUBDIR += .WAIT texinfo \
1111.153Schristos	.WAIT tic \
1121.132Smrg	.WAIT pax \
1131.132Smrg	.WAIT ${TOOLCHAIN_BITS} \
1141.137Sdarran	${DTRACE_BITS} \
1151.166Spooka		asn1_compile cat cksum compile_et db \
1161.145Selric		file lint1 slc \
1171.144Sriz		makefs .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
1181.132Smrg		.WAIT disklabel \
1191.132Smrg		.WAIT paxctl \
1201.132Smrg		.WAIT fdisk \
1211.132Smrg		.WAIT installboot \
1221.154Snjoly		pwd_mkdb stat strfile sunlabel zic
1231.166Spooka.endif
1241.166SpookaSUBDIR+= .WAIT config
1251.39Stv
1261.142Sjoerg.if ${MKLLVM} != "no"
1271.142SjoergSUBDIR+= \
1281.142Sjoerg	llvm .WAIT \
1291.149Sjoerg	llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
1301.159Sjoerg	llvm-tblgen llvm-clang-tblgen .WAIT \
1311.142Sjoerg	llvm-include .WAIT \
1321.142Sjoerg	llvm-lib .WAIT \
1331.142Sjoerg	llvm-clang
1341.142Sjoerg.endif
1351.142Sjoerg
1361.121Sdyoung.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
1371.136Sjoerg.  if ${MKGROFF} != "no"
1381.39StvSUBDIR+=	groff
1391.136Sjoerg.  endif
1401.128SjoergSUBDIR+=	mandoc
1411.39Stv.endif
1421.22Stv
1431.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1441.166Spooka
1451.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
1461.103SlukemSUBDIR+=	autoconf .WAIT gettext
1471.72Smatt.endif
1481.72Smatt
1491.140Smrg.if ${USE_PIGZGZIP} != "no"
1501.140SmrgSUBDIR+=	pigz
1511.140Smrg.endif
1521.140Smrg
1531.86Sjmc.if ${MACHINE} == "hp700"
1541.83SskrllSUBDIR+=	hp700-mkboot
1551.83Sskrll.endif
1561.83Sskrll
1571.86Sjmc.if ${MACHINE} == "ibmnws"
1581.72SmattSUBDIR+=	ibmnws-ncdcs
1591.79Smatt.endif
1601.79Smatt
1611.86Sjmc.if ${MACHINE} == "macppc"
1621.79SmattSUBDIR+=	macppc-fixcoff
1631.48Skleink.endif
1641.48Skleink
1651.116Sgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
1661.115SgarbledSUBDIR+=	powerpc-mkbootimage
1671.22Stv.endif
1681.37Sgmcgarry
1691.148Stsutsui.if ${MACHINE_ARCH} == "m68k"
1701.148StsutsuiSUBDIR+=	m68k-elf2aout
1711.148Stsutsui.endif
1721.148Stsutsui
1731.147Smrg.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
1741.147Smrg     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
1751.37SgmcgarrySUBDIR+=	mips-elf2ecoff
1761.76Ssekiya.endif
1771.76Ssekiya
1781.76Ssekiya.if (${MACHINE} == "sgimips")
1791.76SsekiyaSUBDIR+=	sgivol
1801.51Sbjh21.endif
1811.51Sbjh21
1821.82Sabs.if ${MACHINE} == "acorn32"
1831.82SabsSUBDIR+=	sparkcrc
1841.82Sabs.endif
1851.82Sabs
1861.125Sabs.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
1871.51Sbjh21SUBDIR+=	fgen
1881.37Sgmcgarry.endif
1891.37Sgmcgarry
1901.85Sjmc.if ${MACHINE} == "amiga"
1911.85SjmcSUBDIR+=	amiga-elf2bb
1921.85SjmcSUBDIR+=	amiga-txlt
1931.85Sjmc.endif
1941.85Sjmc
1951.86Sjmc.if ${MACHINE} == "hp300"
1961.86SjmcSUBDIR+=	hp300-mkboot
1971.86Sjmc.endif
1981.86Sjmc
1991.161Sjkunz.if ${MACHINE} == "evbarm" && ${MACHINE_ARCH} == "arm"
2001.158SjkunzSUBDIR+=	elftosb
2011.158Sjkunz.endif
2021.158Sjkunz
2031.143Sphx.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
2041.143Sphx    ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
2051.139SjmcneillSUBDIR+=	mkubootimage
2061.139Sjmcneill.endif
2071.139Sjmcneill
2081.166Spooka.endif # TOOLCHAIN_BUILDRUMP
2091.166Spooka
2101.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
2111.19Sjmc.if ${MKTOOLS:Uyes} == "no"
2121.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
2131.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
2141.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
2151.23Swiz	@echo '*** in version skew and build errors over time!'
2161.18Sjmc.endif
2171.17Stv
2181.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
2191.163SapbSUBDIR= # empty
2201.67Slukemrealall realdepend install: check_MKTOOLS
2211.66Slukem.endif							# }
2221.1Stv
2231.1Stv.include <bsd.subdir.mk>
2241.159Sjoerg.include <bsd.buildinstall.mk>
2251.11Stv.include <bsd.obj.mk>
2261.16Stv
2271.102Stron.if !defined(PREVIOUSTOOLDIR)
2281.102Stron.  if exists(PREVIOUSTOOLDIR)
2291.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
2301.102Stron.  else
2311.162SapbPREVIOUSTOOLDIR=
2321.102Stron.  endif
2331.66Slukem.endif
2341.66Slukem
2351.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
2361.66Slukem
2371.101Stronrealall realdepend: .MAKE
2381.107Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
2391.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
2401.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
2411.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
2421.66Slukem	@echo "*** Cleaning mis-matched tools"
2431.66Slukem	rm -f PREVIOUSTOOLDIR
2441.106Sfreza	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
2451.66Slukem.endif
2461.102Stron	echo ${TOOLDIR} >PREVIOUSTOOLDIR
2471.66Slukem
2481.69Stroncleandir:
2491.69Stron	rm -f ${CLEANFILES}
250