Makefile revision 1.168
11.168Sjoerg#	$NetBSD: Makefile,v 1.168 2013/02/27 21:25:11 joerg 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.168Sjoerg.if ${MKMCLINKER} != "no"
1361.168SjoergSUBDIR+=	llvm-mcld
1371.168Sjoerg.endif
1381.142Sjoerg.endif
1391.142Sjoerg
1401.121Sdyoung.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
1411.136Sjoerg.  if ${MKGROFF} != "no"
1421.39StvSUBDIR+=	groff
1431.136Sjoerg.  endif
1441.128SjoergSUBDIR+=	mandoc
1451.39Stv.endif
1461.22Stv
1471.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1481.166Spooka
1491.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
1501.103SlukemSUBDIR+=	autoconf .WAIT gettext
1511.72Smatt.endif
1521.72Smatt
1531.140Smrg.if ${USE_PIGZGZIP} != "no"
1541.140SmrgSUBDIR+=	pigz
1551.140Smrg.endif
1561.140Smrg
1571.86Sjmc.if ${MACHINE} == "hp700"
1581.83SskrllSUBDIR+=	hp700-mkboot
1591.83Sskrll.endif
1601.83Sskrll
1611.86Sjmc.if ${MACHINE} == "ibmnws"
1621.72SmattSUBDIR+=	ibmnws-ncdcs
1631.79Smatt.endif
1641.79Smatt
1651.86Sjmc.if ${MACHINE} == "macppc"
1661.79SmattSUBDIR+=	macppc-fixcoff
1671.48Skleink.endif
1681.48Skleink
1691.116Sgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
1701.115SgarbledSUBDIR+=	powerpc-mkbootimage
1711.22Stv.endif
1721.37Sgmcgarry
1731.148Stsutsui.if ${MACHINE_ARCH} == "m68k"
1741.148StsutsuiSUBDIR+=	m68k-elf2aout
1751.148Stsutsui.endif
1761.148Stsutsui
1771.147Smrg.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
1781.147Smrg     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
1791.37SgmcgarrySUBDIR+=	mips-elf2ecoff
1801.76Ssekiya.endif
1811.76Ssekiya
1821.76Ssekiya.if (${MACHINE} == "sgimips")
1831.76SsekiyaSUBDIR+=	sgivol
1841.51Sbjh21.endif
1851.51Sbjh21
1861.82Sabs.if ${MACHINE} == "acorn32"
1871.82SabsSUBDIR+=	sparkcrc
1881.82Sabs.endif
1891.82Sabs
1901.125Sabs.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
1911.51Sbjh21SUBDIR+=	fgen
1921.37Sgmcgarry.endif
1931.37Sgmcgarry
1941.85Sjmc.if ${MACHINE} == "amiga"
1951.85SjmcSUBDIR+=	amiga-elf2bb
1961.85SjmcSUBDIR+=	amiga-txlt
1971.85Sjmc.endif
1981.85Sjmc
1991.86Sjmc.if ${MACHINE} == "hp300"
2001.86SjmcSUBDIR+=	hp300-mkboot
2011.86Sjmc.endif
2021.86Sjmc
2031.167Smatt.if ${MACHINE} == "evbarm" \
2041.167Smatt    && ${MACHINE_CPU} == "arm" \
2051.167Smatt    && ${TARGET_ENDIANNESS} == "1234"
2061.158SjkunzSUBDIR+=	elftosb
2071.158Sjkunz.endif
2081.158Sjkunz
2091.143Sphx.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
2101.143Sphx    ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
2111.139SjmcneillSUBDIR+=	mkubootimage
2121.139Sjmcneill.endif
2131.139Sjmcneill
2141.166Spooka.endif # TOOLCHAIN_BUILDRUMP
2151.166Spooka
2161.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
2171.19Sjmc.if ${MKTOOLS:Uyes} == "no"
2181.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
2191.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
2201.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
2211.23Swiz	@echo '*** in version skew and build errors over time!'
2221.18Sjmc.endif
2231.17Stv
2241.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
2251.163SapbSUBDIR= # empty
2261.67Slukemrealall realdepend install: check_MKTOOLS
2271.66Slukem.endif							# }
2281.1Stv
2291.1Stv.include <bsd.subdir.mk>
2301.159Sjoerg.include <bsd.buildinstall.mk>
2311.11Stv.include <bsd.obj.mk>
2321.16Stv
2331.102Stron.if !defined(PREVIOUSTOOLDIR)
2341.102Stron.  if exists(PREVIOUSTOOLDIR)
2351.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
2361.102Stron.  else
2371.162SapbPREVIOUSTOOLDIR=
2381.102Stron.  endif
2391.66Slukem.endif
2401.66Slukem
2411.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
2421.66Slukem
2431.101Stronrealall realdepend: .MAKE
2441.107Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
2451.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
2461.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
2471.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
2481.66Slukem	@echo "*** Cleaning mis-matched tools"
2491.66Slukem	rm -f PREVIOUSTOOLDIR
2501.106Sfreza	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
2511.66Slukem.endif
2521.102Stron	echo ${TOOLDIR} >PREVIOUSTOOLDIR
2531.66Slukem
2541.69Stroncleandir:
2551.69Stron	rm -f ${CLEANFILES}
256