Makefile revision 1.172
11.172Sbjh21#	$NetBSD: Makefile,v 1.172 2002/05/02 16:36:21 bjh21 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.101Ssommerfe#   NBUILDJOBS is the number of jobs to start in parallel during a
271.127Stv#	`make build'. It defaults to 1.
281.125Smrg#   UPDATE, if defined, will avoid a `make cleandir' at the start of
291.125Smrg#     `make build', as well as having the effects listed in
301.125Smrg#     /usr/share/mk/bsd.README.
311.125Smrg#   NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
321.125Smrg#     of the `make build'.
331.119Stoddpw#   NOINCLUDES will avoid the `make includes' usually done by `make build'.
341.95Scjs#
351.95Scjs# Targets:
361.137Stv#   build:
371.137Stv#	Builds a full release of NetBSD in DESTDIR.  If BUILD_DONE is
381.110Sjlam#	set, this is an empty target.
391.137Stv#   release:
401.137Stv#	Does a `make build,' and then tars up the DESTDIR files
411.95Scjs#	into RELEASEDIR, in release(7) format. (See etc/Makefile for
421.95Scjs#	more information on this.)
431.137Stv#   regression-tests:
441.137Stv#	Runs the regression tests in "regress" on this host.
451.123Smrg#
461.137Stv# Targets invoked by `make build,' in order:
471.155Stv#   cleandir:        cleans the tree.
481.137Stv#   obj:             creates object directories.
491.152Stv#   do-tools:        builds host toolchain.
501.131Stv#   do-distrib-dirs: creates the distribution directories.
511.137Stv#   includes:        installs include files.
521.168Stv#   do-lib-csu:      builds and installs prerequisites from lib/csu.
531.143Stv#   do-lib:          builds and installs prerequisites from lib.
541.143Stv#   do-gnu-lib:      builds and installs prerequisites from gnu/lib.
551.137Stv#   do-build:        builds and installs the entire system.
561.32Scgd
571.146Stv.if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
581.146Stv.MAKEFLAGS: -m ${.CURDIR}/share/mk
591.146Stv.endif
601.163Stv
611.163Stv# If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
621.163Stv# not be the top level objdir, because "make obj" can happen in the *middle*
631.163Stv# of "make build" (long after <bsd.own.mk> is calculated it).  So, pre-set
641.163Stv# _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
651.163Stv_SRC_TOP_OBJ_=
661.148Sjmc
671.146Stv.include <bsd.own.mk>
681.4Scgd
691.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously
701.137Stv# with a standard recursive target.
711.137Stv
721.137Stv.if make(build) || make(release) || make(snapshot)
731.137Stv.for targ in ${TARGETS:Nobj:Ncleandir}
741.137Stv.if make(${targ}) && !target(.BEGIN)
751.137Stv.BEGIN:
761.137Stv	@echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
771.137Stv	@false
781.137Stv.endif
791.137Stv.endfor
801.137Stv.endif
811.58Stv
821.76Sbouyer.if defined(NBUILDJOBS)
831.162Stv.if !target(.BEGIN)
841.162Stv.BEGIN:
851.162Stv	@echo 'NBUILDJOBS is currently broken; see PR toolchain/14837.'
861.162Stv	@false
871.162Stv.endif
881.162Stv#_J=		-j${NBUILDJOBS}
891.76Sbouyer.endif
901.76Sbouyer
911.166Ssimonb_SUBDIR=	tools lib include gnu bin games libexec sbin usr.bin
921.166Ssimonb_SUBDIR+=	usr.sbin share sys etc distrib regress
931.105Sassar
941.137Stv# Weed out directories that don't exist.
951.36Sexplorer
961.137Stv.for dir in ${_SUBDIR}
971.154Stv.if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
981.137StvSUBDIR+=	${dir}
991.36Sexplorer.endif
1001.137Stv.endfor
1011.21Scgd
1021.13Sbrezak.if exists(regress)
1031.10Scgdregression-tests:
1041.10Scgd	@echo Running regression tests...
1051.152Stv	@(cd ${.CURDIR}/regress && ${MAKE} regress)
1061.13Sbrezak.endif
1071.20Scgd
1081.170Slukemafterinstall: postinstall-check
1091.137Stv.if ${MKMAN} != "no"
1101.152Stv	(cd ${.CURDIR}/share/man && ${MAKE} makedb)
1111.137Stv.endif
1121.159Sperry.if defined(UNPRIVED) && (${MKINFO} != "no")
1131.164Sjmc	(cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta)
1141.159Sperry.endif
1151.170Slukem
1161.170Slukempostinstall-check:
1171.169Slukem	@echo "   === Post installation checks ==="
1181.169Slukem	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR}/etc -d ${DESTDIR}/etc check
1191.171Slukem	@echo "   ================================"
1201.171Slukem
1211.171Slukempostinstall-fix: .NOTMAIN
1221.171Slukem	@echo "   === Post installation fixes ==="
1231.171Slukem	sh ${.CURDIR}/etc/postinstall -s ${.CURDIR}/etc -d ${DESTDIR}/etc fix
1241.169Slukem	@echo "   ================================"
1251.169Slukem
1261.108Serh
1271.137Stv# Targets (in order!) called by "make build".
1281.123Smrg
1291.156StvBUILDTARGETS+=	check-tools
1301.155Stv.if !defined(UPDATE) && !defined(NOCLEANDIR)
1311.155StvBUILDTARGETS+=	cleandir
1321.155Stv.endif
1331.149Stv.if ${MKOBJDIRS} != "no"
1341.137StvBUILDTARGETS+=	obj
1351.123Smrg.endif
1361.138Stv.if ${USETOOLS} == "yes"
1371.152StvBUILDTARGETS+=	do-tools
1381.131Stv.endif
1391.137Stv.if !defined(NODISTRIBDIRS)
1401.137StvBUILDTARGETS+=	do-distrib-dirs
1411.131Stv.endif
1421.137Stv.if !defined(NOINCLUDES)
1431.137StvBUILDTARGETS+=	includes
1441.131Stv.endif
1451.168StvBUILDTARGETS+=	do-lib-csu do-lib do-gnu-lib do-build
1461.131Stv
1471.137Stv# Enforce proper ordering of some rules.
1481.123Smrg
1491.137Stv.ORDER:		${BUILDTARGETS}
1501.137Stvincludes-lib:	includes-include includes-sys
1511.137Stvincludes-gnu:	includes-lib
1521.123Smrg
1531.137Stv# Build the system and install into DESTDIR.
1541.123Smrg
1551.137Stvbuild:
1561.137Stv.if defined(BUILD_DONE)
1571.137Stv	@echo "Build already installed into ${DESTDIR}"
1581.137Stv.else
1591.172Sbjh21	@printf "Build started at: " && date
1601.145Stv.for tgt in ${BUILDTARGETS}
1611.156Stv	@(cd ${.CURDIR} && ${MAKE} ${_J} ${tgt})
1621.145Stv.endfor
1631.172Sbjh21	@printf "Build finished at: " && date
1641.71Smycroft.endif
1651.160Sthorpej
1661.160Sthorpej# Build a full distribution, but not a release (i.e. no sets into
1671.160Sthorpej# ${RELEASEDIR}).
1681.160Sthorpej
1691.160Sthorpejdistribution: build
1701.160Sthorpej	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
1711.123Smrg
1721.137Stv# Build a release or snapshot (implies "make build").
1731.123Smrg
1741.137Stvrelease snapshot: build
1751.152Stv	(cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
1761.123Smrg
1771.137Stv# Special components of the "make build" process.
1781.156Stv
1791.156Stvcheck-tools:
1801.156Stv.if defined(USE_NEW_TOOLCHAIN) && (${USE_NEW_TOOLCHAIN} != "nowarn")
1811.156Stv	@echo '*** WARNING:  Building on MACHINE=${MACHINE} with USE_NEW_TOOLCHAIN.'
1821.156Stv	@echo '*** This platform is not yet verified to work with the new toolchain,'
1831.156Stv	@echo '*** and may result in a failed build or corrupt binaries!'
1841.156Stv.endif
1851.123Smrg
1861.137Stvdo-distrib-dirs:
1871.147Sjmc.if !defined(DESTDIR) || ${DESTDIR} == ""
1881.152Stv	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
1891.147Sjmc.else
1901.152Stv	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
1911.147Sjmc.endif
1921.123Smrg
1931.168Stv.for dir in tools lib/csu lib gnu/lib
1941.143Stvdo-${dir:S/\//-/}:
1951.137Stv.for targ in dependall install
1961.154Stv	(cd ${.CURDIR}/${dir} && ${MAKE} ${_J} ${targ})
1971.137Stv.endfor
1981.137Stv.endfor
1991.143Stv
2001.143Stvdo-build:
2011.154Stv.for targ in dependall install
2021.154Stv	(cd ${.CURDIR} && ${MAKE} ${_J} ${targ} BUILD_tools=no BUILD_lib=no)
2031.154Stv.endfor
2041.87Scjs
2051.137Stv# Speedup stubs for some subtrees that don't need to run these rules.
2061.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.)
2071.129Stv
2081.152Stv.for dir in bin etc distrib games libexec regress sbin usr.sbin tools
2091.152Stvincludes-${dir}:
2101.152Stv	@true
2111.152Stv.endfor
2121.152Stv.for dir in etc distrib regress
2131.152Stvinstall-${dir}:
2141.152Stv	@true
2151.152Stv.endfor
2161.152Stv
2171.152Stv# XXX this needs to change when distrib Makefiles are recursion compliant
2181.152Stvdependall-distrib depend-distrib all-distrib:
2191.136Snathanw	@true
2201.161Slukem
2211.161Slukemclean:
2221.161Slukem	rm -f METALOG
2231.130Stv
2241.151Stv.include <bsd.obj.mk>
2251.146Stv.include <bsd.subdir.mk>
2261.144Stv
2271.150Stvbuild-docs: ${.CURDIR}/BUILDING
2281.150Stv${.CURDIR}/BUILDING: BUILDING.mdoc
2291.150Stv	groff -mdoc -Tascii -P-b -P-u -P-o $> >$@
230