Makefile revision 1.140
11.140Sjmc#	$NetBSD: Makefile,v 1.140 2001/10/21 08:03:01 jmc 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.137Stv#   obj:             creates object directories.
481.137Stv#   cleandir:        cleans the tree.
491.137Stv#   do-make-tools:   builds host toolchain.
501.131Stv#   do-distrib-dirs: creates the distribution directories.
511.137Stv#   includes:        installs include files.
521.137Stv#   do-build:        builds and installs the entire system.
531.32Scgd
541.133Stv.include "${.CURDIR}/share/mk/bsd.own.mk"
551.4Scgd
561.137Stv# Sanity check: make sure that "make build" is not invoked simultaneously
571.137Stv# with a standard recursive target.
581.137Stv
591.137Stv.if make(build) || make(release) || make(snapshot)
601.137Stv.for targ in ${TARGETS:Nobj:Ncleandir}
611.137Stv.if make(${targ}) && !target(.BEGIN)
621.137Stv.BEGIN:
631.137Stv	@echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
641.137Stv	@false
651.137Stv.endif
661.137Stv.endfor
671.137Stv.endif
681.58Stv
691.76Sbouyer.if defined(NBUILDJOBS)
701.137Stv_J=		-j${NBUILDJOBS}
711.76Sbouyer.endif
721.76Sbouyer
731.138Stv.if ${USETOOLS} == "yes"
741.137Stv_SUBDIR+=	tools
751.109Scjs.endif
761.140Sjmc# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
771.140Sjmc
781.137Stv_SUBDIR+=	lib include gnu bin games libexec sbin usr.bin \
791.140Sjmc		usr.sbin share sys regress
801.140Sjmc
811.140Sjmc.if make(cleandir) || make(obj)
821.140Sjmc_SUBDIR+= distrib
831.140Sjmc.ifdef MAKEOBJDIRPREFIX
841.140Sjmc_SUBDIR+= etc
851.140Sjmc.endif
861.140Sjmc.endif
871.105Sassar
881.137Stv# Weed out directories that don't exist.
891.36Sexplorer
901.137Stv.for dir in ${_SUBDIR}
911.137Stv.if exists(${dir}/Makefile)
921.137StvSUBDIR+=	${dir}
931.36Sexplorer.endif
941.137Stv.endfor
951.21Scgd
961.13Sbrezak.if exists(regress)
971.10Scgdregression-tests:
981.10Scgd	@echo Running regression tests...
991.137Stv	@cd ${.CURDIR}/regress && ${MAKE} ${_M} regress
1001.13Sbrezak.endif
1011.20Scgd
1021.137Stv.if ${MKMAN} != "no"
1031.137Stvafterinstall: whatis.db
1041.137Stvwhatis.db:
1051.137Stv	cd ${.CURDIR}/share/man && ${MAKE} ${_M} makedb
1061.137Stv.endif
1071.108Serh
1081.137Stv# Targets (in order!) called by "make build".
1091.123Smrg
1101.137Stv.if ${MKOBJDIRS:Uno} != "no"
1111.137StvBUILDTARGETS+=	obj
1121.81Sscottr.endif
1131.137Stv.if !defined(UPDATE) && !defined(NOCLEANDIR)
1141.137StvBUILDTARGETS+=	cleandir
1151.123Smrg.endif
1161.138Stv.if ${USETOOLS} == "yes"
1171.137StvBUILDTARGETS+=	do-make-tools
1181.131Stv.endif
1191.137Stv.if !defined(NODISTRIBDIRS)
1201.137StvBUILDTARGETS+=	do-distrib-dirs
1211.131Stv.endif
1221.137Stv.if !defined(NOINCLUDES)
1231.137StvBUILDTARGETS+=	includes
1241.131Stv.endif
1251.137StvBUILDTARGETS+=	do-build
1261.131Stv
1271.137Stv# Enforce proper ordering of some rules.
1281.123Smrg
1291.137Stv.ORDER:		${BUILDTARGETS}
1301.137Stvincludes-lib:	includes-include includes-sys
1311.137Stvincludes-gnu:	includes-lib
1321.123Smrg
1331.137Stv# Build the system and install into DESTDIR.
1341.123Smrg
1351.137Stvbuild:
1361.137Stv.if defined(BUILD_DONE)
1371.137Stv	@echo "Build already installed into ${DESTDIR}"
1381.137Stv.else
1391.137Stv	@echo -n "Build started at: " && date
1401.137Stv	@${MAKE} ${_J} ${_M} ${BUILDTARGETS}
1411.137Stv	@echo -n "Build finished at: " && date
1421.71Smycroft.endif
1431.123Smrg
1441.137Stv# Build a release or snapshot (implies "make build").
1451.123Smrg
1461.137Stvrelease snapshot: build
1471.137Stv	cd ${.CURDIR}/etc && ${MAKE} ${_M} INSTALL_DONE=1 release
1481.123Smrg
1491.137Stv# Special components of the "make build" process.
1501.123Smrg
1511.137Stvdo-make-tools:
1521.137Stv	cd ${.CURDIR}/tools && ${MAKE} ${_M} build
1531.123Smrg
1541.137Stvdo-distrib-dirs:
1551.137Stv	cd ${.CURDIR}/etc && ${MAKE} ${_M} DESTDIR=${DESTDIR} distrib-dirs
1561.123Smrg
1571.137Stvdo-build:
1581.137Stv.for dir in lib/csu lib gnu/lib
1591.137Stv.for targ in dependall install
1601.137Stv	cd ${.CURDIR}/${dir} && \
1611.137Stv		${MAKE} ${_M} ${_J} MKSHARE=no MKLINT=no ${targ}
1621.137Stv.endfor
1631.137Stv.endfor
1641.137Stv	${MAKE} ${_M} ${_J} dependall
1651.137Stv	${MAKE} ${_M} ${_J} install
1661.87Scjs
1671.137Stv# Speedup stubs for some subtrees that don't need to run these rules.
1681.137Stv# (Tells <bsd.subdir.mk> not to recurse for them.)
1691.129Stv
1701.129Stvincludes-bin includes-games includes-libexec includes-regress \
1711.137Stvincludes-sbin includes-usr.sbin includes-tools \
1721.139Stvdependall-tools depend-tools all-tools install-tools install-regress:
1731.136Snathanw	@true
1741.130Stv
1751.133Stv.include "${.CURDIR}/share/mk/bsd.subdir.mk"
1761.130Stv
1771.130Stv_M:=	-m ${.CURDIR}/share/mk
178