Makefile revision 1.167
11.167Smatt#	$NetBSD: Makefile,v 1.167 2013/02/05 07:27:02 matt Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.167Smatt.include <bsd.endian.mk>
51.3Stv
61.159Sjoerg# Make sure that the ordered build/install processing applies when using
71.159Sjoerg# plain make.
81.159Sjoerg.MAIN: build_install
91.159Sjoerg
101.164Sapb# TOOLDIR must be valid, unless MKTOOLS=no
111.164Sapb.if ${MKTOOLS:Uyes} != "no"
121.164Sapb.if "${TOOLDIR}" == ""
131.164Sapb.error "TOOLDIR is undefined or empty"
141.164Sapb.elif "${TOOLDIR:tW:M/*}" == ""
151.164Sapb.error "TOOLDIR is not an absolute path: ${TOOLDIR}"
161.164Sapb#.elif !exists(TOOLDIR) # XXX .exists fails for directories
171.164Sapb#.error "TOOLDIR does not exist: ${TOOLDIR}"
181.164Sapb.endif
191.164Sapb.endif # MKTOOLS != no
201.164Sapb
211.166Spooka# TOOLS_BUILDRUMP == yes builds only the subset of the tools required
221.166Spooka# for building rump kernels and the hypervisor.  It is typically used
231.166Spooka# when building rump kernels targeted for non-NetBSD systems (via
241.166Spooka# buildrump.sh), and should not be set for a regular "make build".
251.166SpookaTOOLS_BUILDRUMP?=no
261.166Spooka
271.160Spooka.if ${TOOLCHAIN_MISSING} == "no"
281.160Spooka.if defined(HAVE_GCC)
291.94SjmcTOOLCHAIN_BITS= gmake .WAIT
301.156Sjoerg.endif
311.156Sjoerg
321.156Sjoerg.if defined(HAVE_GCC)
331.146Smrg.if ${HAVE_GCC} >= 45
341.146SmrgTOOLCHAIN_BITS+= gmp .WAIT
351.146SmrgTOOLCHAIN_BITS+= mpfr .WAIT
361.146SmrgTOOLCHAIN_BITS+= mpc .WAIT
371.94Sjmc.endif
381.156Sjoerg.endif
391.156Sjoerg.endif
401.156Sjoerg
411.156Sjoerg.if ${TOOLCHAIN_MISSING} == "no"
421.94SjmcTOOLCHAIN_BITS+= binutils .WAIT
431.156Sjoerg.endif
441.156Sjoerg
451.156Sjoerg.if defined(HAVE_GCC)
461.156Sjoerg.if ${TOOLCHAIN_MISSING} == "no"
471.77SmrgTOOLCHAIN_BITS+= gcc
481.97Smrg.  if ${MKCROSSGDB:Uno} != "no"
491.74SclTOOLCHAIN_BITS+= gdb
501.70Smrg.  endif
511.156SjoergTOOLCHAIN_BITS+= .WAIT
521.31Stv.endif
531.118Sgmcgarry.endif
541.118Sgmcgarry
551.118Sgmcgarry.if defined(HAVE_PCC)
561.118Sgmcgarry.if ${TOOLCHAIN_MISSING} == "no"
571.118SgmcgarryTOOLCHAIN_BITS+= pcc
581.118Sgmcgarry.endif
591.118Sgmcgarry.endif
601.31Stv
611.157Spooka.if ${TOOLCHAIN_MISSING} == "no"
621.157Spooka# XXX Eventually, we want to be able to build dbsym and mdsetimage
631.157Spooka# XXX if EXTERNAL_TOOLCHAIN is set.
641.156SjoergTOOLCHAIN_BITS+= dbsym mdsetimage
651.157Spooka.endif
661.156Sjoerg
671.137SdarranDTRACE_BITS=
681.137Sdarran.if ${MKDTRACE} != "no"
691.137SdarranDTRACE_BITS+= .WAIT libelf
701.137SdarranDTRACE_BITS+= .WAIT libdwarf
711.162SapbDTRACE_BITS+= .WAIT libctf
721.137SdarranDTRACE_BITS+= .WAIT ctfconvert ctfmerge
731.137Sdarran.endif
741.137Sdarran
751.99SmrgLINT_BITS=
761.99Smrg.if ${MKLINT} != "no"
771.99SmrgLINT_BITS= lint lint2
781.99Smrg.endif
791.99Smrg
801.165Sapb# All of host-mkdep, compat, and binstall are needed before anything
811.165Sapb# else.  Within this group, they must be built in a specific order, and
821.165Sapb# all of them must be built before any of them is installed.  They may
831.165Sapb# be installed in any order.  This can't be expressed using the .WAIT
841.165Sapb# notation inside the SUBDIR list.
851.165Sapb#
861.165Sapb# XXX .ORDER does not work when multiple targets are passed on the
871.165Sapb# make command line without "-j", so use dependencies in addition to .ORDER.
881.165Sapb#
891.165Sapb.ORDER: dependall-host-mkdep dependall-compat dependall-binstall
901.165Sapb.if make(dependall-host-mkdep) && make(dependall-compat)
911.165Sapbdependall-compat: dependall-host-mkdep
921.165Sapb.endif
931.165Sapb.if make(dependall-compat) && make(dependall-binstall)
941.165Sapbdependall-binstall: dependall-compat
951.165Sapb.endif
961.165Sapb
971.16Stv# Dependencies in SUBDIR below ordered to maximize parallel ability.
981.165Sapb# See above for special treatment for host-mkdep, compat, and binstall.
991.165Sapb#
1001.165SapbSUBDIR=	host-mkdep compat binstall \
1011.166Spooka	.WAIT mktemp .WAIT sed .WAIT
1021.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1031.166SpookaSUBDIR+= cap_mkdb crunchgen ctags genassym gencat hexdump \
1041.99Smrg		${LINT_BITS} \
1051.166Spooka		makewhatis mtree nbperf .WAIT rpcgen uudecode
1061.166Spooka.endif
1071.166Spooka
1081.166SpookaSUBDIR+= join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
1091.166Spooka
1101.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1111.166SpookaSUBDIR += .WAIT texinfo \
1121.153Schristos	.WAIT tic \
1131.132Smrg	.WAIT pax \
1141.132Smrg	.WAIT ${TOOLCHAIN_BITS} \
1151.137Sdarran	${DTRACE_BITS} \
1161.166Spooka		asn1_compile cat cksum compile_et db \
1171.145Selric		file lint1 slc \
1181.144Sriz		makefs .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
1191.132Smrg		.WAIT disklabel \
1201.132Smrg		.WAIT paxctl \
1211.132Smrg		.WAIT fdisk \
1221.132Smrg		.WAIT installboot \
1231.154Snjoly		pwd_mkdb stat strfile sunlabel zic
1241.166Spooka.endif
1251.166SpookaSUBDIR+= .WAIT config
1261.39Stv
1271.142Sjoerg.if ${MKLLVM} != "no"
1281.142SjoergSUBDIR+= \
1291.142Sjoerg	llvm .WAIT \
1301.149Sjoerg	llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
1311.159Sjoerg	llvm-tblgen llvm-clang-tblgen .WAIT \
1321.142Sjoerg	llvm-include .WAIT \
1331.142Sjoerg	llvm-lib .WAIT \
1341.142Sjoerg	llvm-clang
1351.142Sjoerg.endif
1361.142Sjoerg
1371.121Sdyoung.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
1381.136Sjoerg.  if ${MKGROFF} != "no"
1391.39StvSUBDIR+=	groff
1401.136Sjoerg.  endif
1411.128SjoergSUBDIR+=	mandoc
1421.39Stv.endif
1431.22Stv
1441.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1451.166Spooka
1461.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
1471.103SlukemSUBDIR+=	autoconf .WAIT gettext
1481.72Smatt.endif
1491.72Smatt
1501.140Smrg.if ${USE_PIGZGZIP} != "no"
1511.140SmrgSUBDIR+=	pigz
1521.140Smrg.endif
1531.140Smrg
1541.86Sjmc.if ${MACHINE} == "hp700"
1551.83SskrllSUBDIR+=	hp700-mkboot
1561.83Sskrll.endif
1571.83Sskrll
1581.86Sjmc.if ${MACHINE} == "ibmnws"
1591.72SmattSUBDIR+=	ibmnws-ncdcs
1601.79Smatt.endif
1611.79Smatt
1621.86Sjmc.if ${MACHINE} == "macppc"
1631.79SmattSUBDIR+=	macppc-fixcoff
1641.48Skleink.endif
1651.48Skleink
1661.116Sgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
1671.115SgarbledSUBDIR+=	powerpc-mkbootimage
1681.22Stv.endif
1691.37Sgmcgarry
1701.148Stsutsui.if ${MACHINE_ARCH} == "m68k"
1711.148StsutsuiSUBDIR+=	m68k-elf2aout
1721.148Stsutsui.endif
1731.148Stsutsui
1741.147Smrg.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
1751.147Smrg     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
1761.37SgmcgarrySUBDIR+=	mips-elf2ecoff
1771.76Ssekiya.endif
1781.76Ssekiya
1791.76Ssekiya.if (${MACHINE} == "sgimips")
1801.76SsekiyaSUBDIR+=	sgivol
1811.51Sbjh21.endif
1821.51Sbjh21
1831.82Sabs.if ${MACHINE} == "acorn32"
1841.82SabsSUBDIR+=	sparkcrc
1851.82Sabs.endif
1861.82Sabs
1871.125Sabs.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
1881.51Sbjh21SUBDIR+=	fgen
1891.37Sgmcgarry.endif
1901.37Sgmcgarry
1911.85Sjmc.if ${MACHINE} == "amiga"
1921.85SjmcSUBDIR+=	amiga-elf2bb
1931.85SjmcSUBDIR+=	amiga-txlt
1941.85Sjmc.endif
1951.85Sjmc
1961.86Sjmc.if ${MACHINE} == "hp300"
1971.86SjmcSUBDIR+=	hp300-mkboot
1981.86Sjmc.endif
1991.86Sjmc
2001.167Smatt.if ${MACHINE} == "evbarm" \
2011.167Smatt    && ${MACHINE_CPU} == "arm" \
2021.167Smatt    && ${TARGET_ENDIANNESS} == "1234"
2031.158SjkunzSUBDIR+=	elftosb
2041.158Sjkunz.endif
2051.158Sjkunz
2061.143Sphx.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
2071.143Sphx    ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
2081.139SjmcneillSUBDIR+=	mkubootimage
2091.139Sjmcneill.endif
2101.139Sjmcneill
2111.166Spooka.endif # TOOLCHAIN_BUILDRUMP
2121.166Spooka
2131.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
2141.19Sjmc.if ${MKTOOLS:Uyes} == "no"
2151.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
2161.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
2171.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
2181.23Swiz	@echo '*** in version skew and build errors over time!'
2191.18Sjmc.endif
2201.17Stv
2211.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
2221.163SapbSUBDIR= # empty
2231.67Slukemrealall realdepend install: check_MKTOOLS
2241.66Slukem.endif							# }
2251.1Stv
2261.1Stv.include <bsd.subdir.mk>
2271.159Sjoerg.include <bsd.buildinstall.mk>
2281.11Stv.include <bsd.obj.mk>
2291.16Stv
2301.102Stron.if !defined(PREVIOUSTOOLDIR)
2311.102Stron.  if exists(PREVIOUSTOOLDIR)
2321.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
2331.102Stron.  else
2341.162SapbPREVIOUSTOOLDIR=
2351.102Stron.  endif
2361.66Slukem.endif
2371.66Slukem
2381.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
2391.66Slukem
2401.101Stronrealall realdepend: .MAKE
2411.107Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
2421.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
2431.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
2441.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
2451.66Slukem	@echo "*** Cleaning mis-matched tools"
2461.66Slukem	rm -f PREVIOUSTOOLDIR
2471.106Sfreza	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
2481.66Slukem.endif
2491.102Stron	echo ${TOOLDIR} >PREVIOUSTOOLDIR
2501.66Slukem
2511.69Stroncleandir:
2521.69Stron	rm -f ${CLEANFILES}
253