Makefile revision 1.176
11.176Slukem#	$NetBSD: Makefile,v 1.176 2002/06/19 00:17:11 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.101Ssommerfe#   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.125Smrg#     `make build', as well as having the effects listed in
281.125Smrg#     /usr/share/mk/bsd.README.
291.125Smrg#   NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
301.125Smrg#     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.137Stv#   do-build:        builds and installs the entire system.
541.32Scgd
551.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
561.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk
571.146Stv.endif
581.163Stv
591.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
601.163Stv# not be the top level objdir, because "make obj" can happen in the *middle*
611.163Stv# of "make build" (long after <bsd.own.mk> is calculated it).  So, pre-set
621.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
631.163Stv_SRC_TOP_OBJ_=
641.148Sjmc
651.146Stv.include <bsd.own.mk>
661.4Scgd
671.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously
681.137Stv# with a standard recursive target.
691.137Stv
701.137Stv.if make(build) || make(release) || make(snapshot)
711.137Stv.for targ in ${TARGETS:Nobj:Ncleandir}
721.137Stv.if make(${targ}) && !target(.BEGIN)
731.137Stv.BEGIN:
741.137Stv	@echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
751.137Stv	@false
761.137Stv.endif
771.137Stv.endfor
781.137Stv.endif
791.58Stv
801.166Ssimonb_SUBDIR=	tools lib include gnu bin games libexec sbin usr.bin
811.166Ssimonb_SUBDIR+=	usr.sbin share sys etc distrib regress
821.105Sassar
831.137Stv# Weed out directories that don't exist.
841.36Sexplorer
851.137Stv.for dir in ${_SUBDIR}
861.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
871.137StvSUBDIR+=	${dir}
881.36Sexplorer.endif
891.137Stv.endfor
901.21Scgd
911.13Sbrezak.if exists(regress)
921.10Scgdregression-tests:
931.10Scgd	@echo Running regression tests...
941.152Stv	@(cd ${.CURDIR}/regress && ${MAKE} regress)
951.13Sbrezak.endif
961.20Scgd
971.176Slukemafterinstall:
981.137Stv.if ${MKMAN} != "no"
991.152Stv	(cd ${.CURDIR}/share/man && ${MAKE} makedb)
1001.137Stv.endif
1011.159Sperry.if defined(UNPRIVED) && (${MKINFO} != "no")
1021.164Sjmc	(cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta)
1031.176Slukem.endif
1041.176Slukem.if !defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/"
1051.176Slukem	(${MAKE} postinstall-check)
1061.159Sperry.endif
1071.170Slukem
1081.170Slukempostinstall-check:
1091.169Slukem	@echo "   === Post installation checks ==="
1101.175Slukem	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check
1111.171Slukem	@echo "   ================================"
1121.171Slukem
1131.171Slukempostinstall-fix: .NOTMAIN
1141.171Slukem	@echo "   === Post installation fixes ==="
1151.175Slukem	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix
1161.169Slukem	@echo "   ================================"
1171.169Slukem
1181.108Serh
1191.137Stv# Targets (in order!) called by "make build".
1201.123Smrg
1211.156StvBUILDTARGETS+=	check-tools
1221.155Stv.if !defined(UPDATE) && !defined(NOCLEANDIR)
1231.155StvBUILDTARGETS+=	cleandir
1241.155Stv.endif
1251.149Stv.if ${MKOBJDIRS} != "no"
1261.137StvBUILDTARGETS+=	obj
1271.123Smrg.endif
1281.138Stv.if ${USETOOLS} == "yes"
1291.152StvBUILDTARGETS+=	do-tools
1301.131Stv.endif
1311.137Stv.if !defined(NODISTRIBDIRS)
1321.137StvBUILDTARGETS+=	do-distrib-dirs
1331.131Stv.endif
1341.137Stv.if !defined(NOINCLUDES)
1351.137StvBUILDTARGETS+=	includes
1361.131Stv.endif
1371.168StvBUILDTARGETS+=	do-lib-csu do-lib do-gnu-lib do-build
1381.131Stv
1391.137Stv# Enforce proper ordering of some rules.
1401.123Smrg
1411.137Stv.ORDER:		${BUILDTARGETS}
1421.137Stvincludes-lib:	includes-include includes-sys
1431.137Stvincludes-gnu:	includes-lib
1441.123Smrg
1451.137Stv# Build the system and install into DESTDIR.
1461.123Smrg
1471.137Stvbuild:
1481.137Stv.if defined(BUILD_DONE)
1491.137Stv	@echo "Build already installed into ${DESTDIR}"
1501.137Stv.else
1511.172Sbjh21	@printf "Build started at: " && date
1521.145Stv.for tgt in ${BUILDTARGETS}
1531.173Ssommerfe	@(cd ${.CURDIR} && ${MAKE} ${tgt})
1541.145Stv.endfor
1551.172Sbjh21	@printf "Build finished at: " && date
1561.71Smycroft.endif
1571.160Sthorpej
1581.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into
1591.160Sthorpej# ${RELEASEDIR}).
1601.160Sthorpej
1611.160Sthorpejdistribution: build
1621.160Sthorpej	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
1631.123Smrg
1641.137Stv# Build a release or snapshot (implies "make build").
1651.123Smrg
1661.137Stvrelease snapshot: build
1671.152Stv	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
1681.123Smrg
1691.137Stv# Special components of the "make build" process.
1701.156Stv
1711.156Stvcheck-tools:
1721.156Stv.if defined(USE_NEW_TOOLCHAIN) && (${USE_NEW_TOOLCHAIN} != "nowarn")
1731.156Stv	@echo '*** WARNING:  Building on MACHINE=${MACHINE} with USE_NEW_TOOLCHAIN.'
1741.156Stv	@echo '*** This platform is not yet verified to work with the new toolchain,'
1751.156Stv	@echo '*** and may result in a failed build or corrupt binaries!'
1761.156Stv.endif
1771.173Ssommerfe.if defined(NBUILDJOBS)
1781.173Ssommerfe	@echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
1791.173Ssommerfe.endif
1801.123Smrg
1811.137Stvdo-distrib-dirs:
1821.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == ""
1831.152Stv	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
1841.147Sjmc.else
1851.152Stv	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
1861.147Sjmc.endif
1871.123Smrg
1881.168Stv.for dir in tools lib/csu lib gnu/lib
1891.143Stvdo-${dir:S/\//-/}:
1901.137Stv.for targ in dependall install
1911.173Ssommerfe	(cd ${.CURDIR}/${dir} && ${MAKE} ${targ})
1921.137Stv.endfor
1931.137Stv.endfor
1941.143Stv
1951.143Stvdo-build:
1961.154Stv.for targ in dependall install
1971.173Ssommerfe	(cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no)
1981.154Stv.endfor
1991.87Scjs
2001.137Stv# Speedup stubs for some subtrees that don't need to run these rules.
2011.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.)
2021.129Stv
2031.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools
2041.152Stvincludes-${dir}:
2051.152Stv	@true
2061.152Stv.endfor
2071.152Stv.for dir in etc distrib regress
2081.152Stvinstall-${dir}:
2091.152Stv	@true
2101.152Stv.endfor
2111.152Stv
2121.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant
2131.152Stvdependall-distrib depend-distrib all-distrib:
2141.136Snathanw	@true
2151.130Stv
2161.151Stv.include <bsd.obj.mk>
2171.146Stv.include <bsd.subdir.mk>
2181.144Stv
2191.150Stvbuild-docs: ${.CURDIR}/BUILDING
2201.150Stv${.CURDIR}/BUILDING: BUILDING.mdoc
2211.150Stv	groff -mdoc -Tascii -P-b -P-u -P-o $> >$@
222