Makefile revision 1.136
11.136Snathanw#	$NetBSD: Makefile,v 1.136 2001/10/12 21:05:08 nathanw 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.125Smrg
351.95Scjs#
361.95Scjs# Targets:
371.110Sjlam#   build: builds a full release of netbsd in DESTDIR. If BUILD_DONE is
381.110Sjlam#	set, this is an empty target.
391.95Scjs#   release: does a `make build,' and then tars up the DESTDIR files
401.95Scjs#	into RELEASEDIR, in release(7) format. (See etc/Makefile for
411.95Scjs#	more information on this.)
421.95Scjs#   snapshot: a synonym for release.
431.123Smrg#
441.123Smrg# Sub targets of `make build,' in order:
451.123Smrg#   buildstartmsg: displays the start time of the build.
461.131Stv#   do-make-tools: builds host toolchain.
471.131Stv#   do-distrib-dirs: creates the distribution directories.
481.123Smrg#   do-force-domestic: check's that FORCE_DOMESTIC isn't set (deprecated.)
491.127Stv#   do-cleandir: cleans the tree.
501.127Stv#   do-make-obj: creates object directories if required.
511.123Smrg#   do-make-includes: install include files.
521.123Smrg#   do-lib-csu: build & install startup object files.
531.123Smrg#   do-lib: build & install system libraries.
541.123Smrg#   do-gnu-lib: build & install gnu system libraries.
551.123Smrg#   do-dependall: builds & install the entire system.
561.123Smrg#   do-domestic: build & install the domestic tree (deprecated.)
571.123Smrg#   do-whatisdb: build & install the `whatis.db' man database.
581.123Smrg#   buildendmsg: displays the end time of the build.
591.32Scgd
601.133Stv.include "${.CURDIR}/share/mk/bsd.own.mk"
611.4Scgd
621.100SsommerfeMKOBJDIRS ?= no
631.58Stv
641.76Sbouyer.if defined(NBUILDJOBS)
651.76Sbouyer_J= -j${NBUILDJOBS}
661.76Sbouyer.endif
671.76Sbouyer
681.4Scgd# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
691.2Scgd
701.52SmycroftSUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
711.120Sfredb.if make(cleandir) || make(obj)
721.135SjwiseSUBDIR+= distrib
731.135Sjwise.if ${USETOOLS} != "no"
741.135SjwiseSUBDIR+= tools
751.135Sjwise.endif
761.114Ssjg.ifdef MAKEOBJDIRPREFIX
771.114SsjgSUBDIR+= etc
781.114Ssjg.endif
791.109Scjs.endif
801.105Sassar
811.105Sassarincludes-lib: includes-include includes-sys
821.36Sexplorer
831.36Sexplorer.if exists(games)
841.36SexplorerSUBDIR+= games
851.36Sexplorer.endif
861.36Sexplorer
871.8ScgdSUBDIR+= gnu
881.52Smycroft# This is needed for libstdc++ and gen-params.
891.52Smycroftincludes-gnu: includes-include includes-sys
901.21Scgd
911.13Sbrezak.if exists(regress)
921.9Scgd.ifmake !(install)
931.9ScgdSUBDIR+= regress
941.9Scgd.endif
951.9Scgd
961.10Scgdregression-tests:
971.10Scgd	@echo Running regression tests...
981.112Smrg	@(cd ${.CURDIR}/regress && ${MAKE} ${_M} regress)
991.13Sbrezak.endif
1001.20Scgd
1011.123Smrgbuildstartmsg:
1021.45Sperry	@echo -n "Build started at: "
1031.45Sperry	@date
1041.108Serh
1051.123Smrgbuildendmsg:
1061.123Smrg	@echo -n "Build finished at: "
1071.123Smrg	@date
1081.123Smrg
1091.15Scgdafterinstall:
1101.86Slukem.if ${MKMAN} != "no" && !defined(_BUILD)
1111.112Smrg	${MAKE} ${_M} whatis.db
1121.81Sscottr.endif
1131.81Sscottr
1141.81Sscottrwhatis.db:
1151.112Smrg	(cd ${.CURDIR}/share/man && ${MAKE} ${_M} makedb)
1161.15Scgd
1171.84Stv# wrt info/dir below:  It's safe to move this over top of /usr/share/info/dir,
1181.84Stv# as the build will automatically remove/replace the non-pkg entries there.
1191.84Stv
1201.110Sjlam.if defined(BUILD_DONE)
1211.110Sjlambuild:
1221.110Sjlam	@echo "Build installed into ${DESTDIR}"
1231.110Sjlam.else
1241.124Smrgbuild:
1251.124Smrg	@${MAKE} ${_M} buildstartmsg
1261.131Stv	@${MAKE} ${_M} do-make-tools
1271.131Stv	@${MAKE} ${_M} do-distrib-dirs
1281.124Smrg	@${MAKE} ${_M} do-force-domestic
1291.124Smrg	@${MAKE} ${_M} do-cleandir
1301.124Smrg	@${MAKE} ${_M} do-make-obj
1311.124Smrg	@${MAKE} ${_M} do-make-includes
1321.124Smrg	@${MAKE} ${_M} do-lib-csu
1331.124Smrg	@${MAKE} ${_M} do-lib
1341.124Smrg	@${MAKE} ${_M} do-gnu-lib
1351.124Smrg	@${MAKE} ${_M} do-dependall
1361.124Smrg	@${MAKE} ${_M} do-domestic
1371.124Smrg	@${MAKE} ${_M} do-whatisdb
1381.124Smrg	@${MAKE} ${_M} buildendmsg
1391.123Smrg.endif
1401.123Smrg
1411.131Stvdo-make-tools:
1421.132Smason.if ${USETOOLS} != "no"
1431.131Stv.if ${MKOBJDIRS} != "no"
1441.131Stv	cd ${.CURDIR}/tools && ${MAKE} ${_M} obj
1451.131Stv.endif
1461.131Stv	cd ${.CURDIR}/tools && ${MAKE} ${_M} build
1471.132Smason.endif
1481.131Stv
1491.131Stvdo-distrib-dirs:
1501.131Stv.ifndef NODISTRIBDIRS
1511.131Stv.ifndef DESTDIR
1521.131Stv	(cd ${.CURDIR}/etc && ${MAKE} ${_M} DESTDIR=/ distrib-dirs)
1531.131Stv.else
1541.131Stv	(cd ${.CURDIR}/etc && ${MAKE} ${_M} DESTDIR=${DESTDIR} distrib-dirs)
1551.131Stv.endif
1561.131Stv.endif
1571.131Stv
1581.123Smrgdo-force-domestic:
1591.96Sscottr.if defined(FORCE_DOMESTIC)
1601.96Sscottr	@echo '*** CAPUTE!'
1611.96Sscottr	@echo '    The FORCE_DOMESTIC flag is not compatible with "make build".'
1621.96Sscottr	@echo '    Please correct the problem and try again.'
1631.96Sscottr	@false
1641.96Sscottr.endif
1651.123Smrg
1661.123Smrgdo-cleandir:
1671.112Smrg.if !defined(UPDATE) && !defined(NOCLEANDIR)
1681.117Smrg	${MAKE} ${_J} ${_M} cleandir
1691.39Schristos.endif
1701.123Smrg
1711.123Smrgdo-make-obj:
1721.103Ssimonb.if ${MKOBJDIRS} != "no"
1731.122Ssommerfe	${MAKE} ${_J} ${_M} obj
1741.127Stv.endif
1751.123Smrg
1761.123Smrgdo-make-includes:
1771.112Smrg.if !defined(NOINCLUDES)
1781.112Smrg	${MAKE} ${_M} includes
1791.71Smycroft.endif
1801.123Smrg
1811.123Smrgdo-lib-csu:
1821.61Smycroft	(cd ${.CURDIR}/lib/csu && \
1831.113Smrg	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
1841.113Smrg	    ${MAKE} ${_M} MKSHARE=no install)
1851.123Smrg
1861.123Smrgdo-lib:
1871.61Smycroft	(cd ${.CURDIR}/lib && \
1881.113Smrg	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
1891.113Smrg	    ${MAKE} ${_M} MKSHARE=no install)
1901.123Smrg
1911.123Smrgdo-gnu-lib:
1921.61Smycroft	(cd ${.CURDIR}/gnu/lib && \
1931.113Smrg	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
1941.113Smrg	    ${MAKE} ${_M} MKSHARE=no install)
1951.123Smrg
1961.123Smrgdo-dependall:
1971.112Smrg	${MAKE} ${_M} ${_J} dependall && ${MAKE} ${_M} _BUILD= install
1981.123Smrg
1991.123Smrgdo-domestic:
2001.97Schristos.if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
2011.112Smrg	(cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_M} ${_J} _SLAVE_BUILD= build)
2021.49Slukem.endif
2031.123Smrg
2041.123Smrgdo-whatisdb:
2051.112Smrg	${MAKE} ${_M} whatis.db
2061.87Scjs
2071.87Scjsrelease snapshot: build
2081.112Smrg	(cd ${.CURDIR}/etc && ${MAKE} ${_M} INSTALL_DONE=1 release)
2091.129Stv
2101.129Stv# Speedup stubs for some subtrees that don't need to run these rules
2111.129Stvincludes-bin includes-games includes-libexec includes-regress \
2121.129Stvincludes-sbin includes-usr.sbin:
2131.136Snathanw	@true
2141.1Scgd
2151.130Stv.if !exists(${.CURDIR}/share/mk)
2161.130Stv.BEGIN:
2171.130Stv	@echo 'BUILD ABORTED: share/mk does not exist, cannot run make.'
2181.130Stv	@false
2191.130Stv.endif
2201.130Stv
2211.133Stv.include "${.CURDIR}/share/mk/bsd.subdir.mk"
2221.130Stv
2231.130Stv_M:=	-m ${.CURDIR}/share/mk
224