Makefile revision 1.184
11.184Slukem#	$NetBSD: Makefile,v 1.184 2002/08/26 04:40:20 lukem Exp $
21.95Scjs
31.95Scjs# This is the top-level makefile for building NetBSD. For an outline of
41.95Scjs# how to build a snapshot or release, as well as other release engineering
51.95Scjs# information, see http://www.netbsd.org/developers/releng/index.html
61.95Scjs#
71.95Scjs# Not everything you can set or do is documented in this makefile. In
81.95Scjs# particular, you should review the files in /usr/share/mk (especially
91.95Scjs# bsd.README) for general information on building programs and writing
101.95Scjs# Makefiles within this structure, and see the comments in src/etc/Makefile
111.95Scjs# for further information on installation and release set options.
121.95Scjs#
131.95Scjs# Variables listed below can be set on the make command line (highest
141.95Scjs# priority), in /etc/mk.conf (middle priority), or in the environment
151.95Scjs# (lowest priority).
161.95Scjs#
171.95Scjs# Variables:
181.101Ssommerfe#   DESTDIR is the target directory for installation of the compiled
191.101Ssommerfe#	software. It defaults to /. Note that programs are built against
201.101Ssommerfe#	libraries installed in DESTDIR.
211.95Scjs#   MKMAN, if set to `no', will prevent building of manual pages.
221.178Senami#   MKOBJDIRS, if not set to `no', will build object directories at
231.101Ssommerfe#	an appropriate point in a build.
241.95Scjs#   MKSHARE, if set to `no', will prevent building and installing
251.95Scjs#	anything in /usr/share.
261.125Smrg#   UPDATE, if defined, will avoid a `make cleandir' at the start of
271.178Senami#	`make build', as well as having the effects listed in
281.178Senami#	/usr/share/mk/bsd.README.
291.125Smrg#   NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
301.178Senami#	of the `make build'.
311.119Stoddpw#   NOINCLUDES will avoid the `make includes' usually done by `make build'.
321.95Scjs#
331.95Scjs# Targets:
341.137Stv#   build:
351.137Stv#	Builds a full release of NetBSD in DESTDIR.  If BUILD_DONE is
361.110Sjlam#	set, this is an empty target.
371.137Stv#   release:
381.137Stv#	Does a `make build,' and then tars up the DESTDIR files
391.95Scjs#	into RELEASEDIR, in release(7) format. (See etc/Makefile for
401.95Scjs#	more information on this.)
411.137Stv#   regression-tests:
421.137Stv#	Runs the regression tests in "regress" on this host.
431.123Smrg#
441.137Stv# Targets invoked by `make build,' in order:
451.155Stv#   cleandir:        cleans the tree.
461.137Stv#   obj:             creates object directories.
471.152Stv#   do-tools:        builds host toolchain.
481.131Stv#   do-distrib-dirs: creates the distribution directories.
491.137Stv#   includes:        installs include files.
501.168Stv#   do-lib-csu:      builds and installs prerequisites from lib/csu.
511.143Stv#   do-lib:          builds and installs prerequisites from lib.
521.143Stv#   do-gnu-lib:      builds and installs prerequisites from gnu/lib.
531.184Slukem#   do-ld.elf_so:    builds and installs prerequisites from libexec/ld.elf_so
541.137Stv#   do-build:        builds and installs the entire system.
551.32Scgd
561.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
571.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk
581.146Stv.endif
591.163Stv
601.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
611.163Stv# not be the top level objdir, because "make obj" can happen in the *middle*
621.163Stv# of "make build" (long after <bsd.own.mk> is calculated it).  So, pre-set
631.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
641.163Stv_SRC_TOP_OBJ_=
651.148Sjmc
661.146Stv.include <bsd.own.mk>
671.4Scgd
681.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously
691.137Stv# with a standard recursive target.
701.137Stv
711.137Stv.if make(build) || make(release) || make(snapshot)
721.137Stv.for targ in ${TARGETS:Nobj:Ncleandir}
731.137Stv.if make(${targ}) && !target(.BEGIN)
741.137Stv.BEGIN:
751.137Stv	@echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
761.137Stv	@false
771.137Stv.endif
781.137Stv.endfor
791.137Stv.endif
801.58Stv
811.166Ssimonb_SUBDIR=	tools lib include gnu bin games libexec sbin usr.bin
821.183Slukem_SUBDIR+=	usr.sbin share rescue sys etc distrib regress
831.105Sassar
841.137Stv# Weed out directories that don't exist.
851.36Sexplorer
861.137Stv.for dir in ${_SUBDIR}
871.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
881.137StvSUBDIR+=	${dir}
891.36Sexplorer.endif
901.137Stv.endfor
911.21Scgd
921.13Sbrezak.if exists(regress)
931.10Scgdregression-tests:
941.10Scgd	@echo Running regression tests...
951.152Stv	@(cd ${.CURDIR}/regress && ${MAKE} regress)
961.13Sbrezak.endif
971.20Scgd
981.179Sthorpej.if defined(UNPRIVED)
991.179SthorpejNOPOSTINSTALL=	# defined
1001.179Sthorpej.endif
1011.179Sthorpej
1021.176Slukemafterinstall:
1031.137Stv.if ${MKMAN} != "no"
1041.152Stv	(cd ${.CURDIR}/share/man && ${MAKE} makedb)
1051.137Stv.endif
1061.159Sperry.if defined(UNPRIVED) && (${MKINFO} != "no")
1071.164Sjmc	(cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta)
1081.176Slukem.endif
1091.179Sthorpej.if !defined(NOPOSTINSTALL)
1101.180Sdrochner	(cd ${.CURDIR} && ${MAKE} postinstall-check)
1111.159Sperry.endif
1121.170Slukem
1131.170Slukempostinstall-check:
1141.169Slukem	@echo "   === Post installation checks ==="
1151.175Slukem	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check
1161.171Slukem	@echo "   ================================"
1171.171Slukem
1181.171Slukempostinstall-fix: .NOTMAIN
1191.171Slukem	@echo "   === Post installation fixes ==="
1201.175Slukem	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix
1211.169Slukem	@echo "   ================================"
1221.169Slukem
1231.108Serh
1241.137Stv# Targets (in order!) called by "make build".
1251.123Smrg
1261.156StvBUILDTARGETS+=	check-tools
1271.155Stv.if !defined(UPDATE) && !defined(NOCLEANDIR)
1281.155StvBUILDTARGETS+=	cleandir
1291.155Stv.endif
1301.149Stv.if ${MKOBJDIRS} != "no"
1311.137StvBUILDTARGETS+=	obj
1321.123Smrg.endif
1331.138Stv.if ${USETOOLS} == "yes"
1341.152StvBUILDTARGETS+=	do-tools
1351.131Stv.endif
1361.137Stv.if !defined(NODISTRIBDIRS)
1371.137StvBUILDTARGETS+=	do-distrib-dirs
1381.131Stv.endif
1391.137Stv.if !defined(NOINCLUDES)
1401.137StvBUILDTARGETS+=	includes
1411.131Stv.endif
1421.184SlukemBUILDTARGETS+=	do-lib-csu do-lib do-gnu-lib do-ld.elf_so do-build
1431.131Stv
1441.137Stv# Enforce proper ordering of some rules.
1451.123Smrg
1461.137Stv.ORDER:		${BUILDTARGETS}
1471.137Stvincludes-lib:	includes-include includes-sys
1481.137Stvincludes-gnu:	includes-lib
1491.123Smrg
1501.137Stv# Build the system and install into DESTDIR.
1511.123Smrg
1521.137Stvbuild:
1531.137Stv.if defined(BUILD_DONE)
1541.137Stv	@echo "Build already installed into ${DESTDIR}"
1551.137Stv.else
1561.172Sbjh21	@printf "Build started at: " && date
1571.145Stv.for tgt in ${BUILDTARGETS}
1581.173Ssommerfe	@(cd ${.CURDIR} && ${MAKE} ${tgt})
1591.145Stv.endfor
1601.172Sbjh21	@printf "Build finished at: " && date
1611.71Smycroft.endif
1621.160Sthorpej
1631.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into
1641.160Sthorpej# ${RELEASEDIR}).
1651.160Sthorpej
1661.179Sthorpejdistribution:
1671.182Suwe	(cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
1681.160Sthorpej	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
1691.181Sthorpej.if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/"
1701.181Sthorpej	(cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist)
1711.181Sthorpej.endif
1721.123Smrg
1731.181Sthorpej# Build a release or snapshot (implies "make build").  Note that
1741.181Sthorpej# in this case, the set lists will be checked before the tar files
1751.181Sthorpej# are made.
1761.123Smrg
1771.179Sthorpejrelease snapshot:
1781.179Sthorpej	(cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
1791.152Stv	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
1801.123Smrg
1811.137Stv# Special components of the "make build" process.
1821.156Stv
1831.156Stvcheck-tools:
1841.156Stv.if defined(USE_NEW_TOOLCHAIN) && (${USE_NEW_TOOLCHAIN} != "nowarn")
1851.156Stv	@echo '*** WARNING:  Building on MACHINE=${MACHINE} with USE_NEW_TOOLCHAIN.'
1861.156Stv	@echo '*** This platform is not yet verified to work with the new toolchain,'
1871.156Stv	@echo '*** and may result in a failed build or corrupt binaries!'
1881.156Stv.endif
1891.173Ssommerfe.if defined(NBUILDJOBS)
1901.173Ssommerfe	@echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
1911.173Ssommerfe.endif
1921.123Smrg
1931.137Stvdo-distrib-dirs:
1941.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == ""
1951.152Stv	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
1961.147Sjmc.else
1971.152Stv	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
1981.147Sjmc.endif
1991.123Smrg
2001.168Stv.for dir in tools lib/csu lib gnu/lib
2011.143Stvdo-${dir:S/\//-/}:
2021.137Stv.for targ in dependall install
2031.173Ssommerfe	(cd ${.CURDIR}/${dir} && ${MAKE} ${targ})
2041.137Stv.endfor
2051.184Slukem.endfor
2061.184Slukem
2071.184Slukemdo-ld.elf_so:
2081.184Slukem.for targ in dependall install
2091.184Slukem	(cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ})
2101.137Stv.endfor
2111.143Stv
2121.143Stvdo-build:
2131.154Stv.for targ in dependall install
2141.173Ssommerfe	(cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no)
2151.154Stv.endfor
2161.87Scjs
2171.137Stv# Speedup stubs for some subtrees that don't need to run these rules.
2181.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.)
2191.129Stv
2201.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools
2211.152Stvincludes-${dir}:
2221.152Stv	@true
2231.152Stv.endfor
2241.152Stv.for dir in etc distrib regress
2251.152Stvinstall-${dir}:
2261.152Stv	@true
2271.152Stv.endfor
2281.152Stv
2291.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant
2301.152Stvdependall-distrib depend-distrib all-distrib:
2311.136Snathanw	@true
2321.130Stv
2331.151Stv.include <bsd.obj.mk>
2341.146Stv.include <bsd.subdir.mk>
2351.144Stv
2361.150Stvbuild-docs: ${.CURDIR}/BUILDING
2371.150Stv${.CURDIR}/BUILDING: BUILDING.mdoc
2381.150Stv	groff -mdoc -Tascii -P-b -P-u -P-o $> >$@
239