Makefile revision 1.125
11.125Smrg#	$NetBSD: Makefile,v 1.125 2001/06/10 13:15:29 mrg 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.101Ssommerfe#	'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.123Smrg#   beforeinstall: creates the distribution directories.
471.123Smrg#   do-force-domestic: check's that FORCE_DOMESTIC isn't set (deprecated.)
481.123Smrg#   do-share-mk: installs /usr/share/mk files.
491.123Smrg#   do-cleandir: clean's the tree.
501.123Smrg#   do-make-obj: create's object directories if required.
511.123Smrg#   do-check-egcs: check's that we have a modern enough compiler (deprecated.)
521.123Smrg#   do-make-includes: install include files.
531.123Smrg#   do-lib-csu: build & install startup object files.
541.123Smrg#   do-lib: build & install system libraries.
551.123Smrg#   do-gnu-lib: build & install gnu system libraries.
561.123Smrg#   do-dependall: builds & install the entire system.
571.123Smrg#   do-domestic: build & install the domestic tree (deprecated.)
581.123Smrg#   do-whatisdb: build & install the `whatis.db' man database.
591.123Smrg#   buildendmsg: displays the end time of the build.
601.32Scgd
611.118Sthorpej.include <bsd.own.mk>
621.4Scgd
631.100SsommerfeMKOBJDIRS ?= no
641.115SthorpejHAVE_EGCS!=	${CXX} --version | egrep "^(2\.[89]|egcs)" ; echo
651.58Stv
661.76Sbouyer.if defined(NBUILDJOBS)
671.76Sbouyer_J= -j${NBUILDJOBS}
681.76Sbouyer.endif
691.76Sbouyer
701.112Smrg.if defined(DESTDIR)
711.112Smrg_M=-m ${DESTDIR}/usr/share/mk
721.112Smrg.endif
731.112Smrg
741.4Scgd# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
751.2Scgd
761.52SmycroftSUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
771.120Sfredb.if make(cleandir) || make(obj)
781.109ScjsSUBDIR+= distrib
791.114Ssjg.ifdef MAKEOBJDIRPREFIX
801.114SsjgSUBDIR+= etc
811.114Ssjg.endif
821.109Scjs.endif
831.105Sassar
841.105Sassarincludes-lib: includes-include includes-sys
851.36Sexplorer
861.36Sexplorer.if exists(games)
871.36SexplorerSUBDIR+= games
881.36Sexplorer.endif
891.36Sexplorer
901.8ScgdSUBDIR+= gnu
911.52Smycroft# This is needed for libstdc++ and gen-params.
921.52Smycroftincludes-gnu: includes-include includes-sys
931.21Scgd
941.13Sbrezak.if exists(regress)
951.9Scgd.ifmake !(install)
961.9ScgdSUBDIR+= regress
971.9Scgd.endif
981.9Scgd
991.10Scgdregression-tests:
1001.10Scgd	@echo Running regression tests...
1011.112Smrg	@(cd ${.CURDIR}/regress && ${MAKE} ${_M} regress)
1021.13Sbrezak.endif
1031.20Scgd
1041.123Smrgbuildstartmsg:
1051.45Sperry	@echo -n "Build started at: "
1061.45Sperry	@date
1071.108Serh
1081.123Smrgbuildendmsg:
1091.123Smrg	@echo -n "Build finished at: "
1101.123Smrg	@date
1111.123Smrg
1121.121Sdeberg# If sharesrc is around, use its share/mk files to bootstrap until the
1131.121Sdeberg# mk files are installed (first step of make build).  If installing to
1141.121Sdeberg# DESTDIR, don't bother, since the build will fail later on anyway.
1151.121Sdeberg
1161.108Serhbeforeinstall:
1171.112Smrg.ifndef NODISTRIBDIRS
1181.26Stls.ifndef DESTDIR
1191.121Sdeberg.if exists(share/mk)
1201.121Sdeberg	(cd ${.CURDIR}/etc && ${MAKE} -m ${.CURDIR}/share/mk DESTDIR=/ distrib-dirs)
1211.121Sdeberg.else
1221.26Stls	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
1231.121Sdeberg.endif
1241.31Stls.else
1251.117Smrg	(cd ${.CURDIR}/etc && ${MAKE} distrib-dirs)
1261.26Stls.endif
1271.112Smrg.endif
1281.15Scgd
1291.15Scgdafterinstall:
1301.86Slukem.if ${MKMAN} != "no" && !defined(_BUILD)
1311.112Smrg	${MAKE} ${_M} whatis.db
1321.81Sscottr.endif
1331.81Sscottr
1341.81Sscottrwhatis.db:
1351.112Smrg	(cd ${.CURDIR}/share/man && ${MAKE} ${_M} makedb)
1361.15Scgd
1371.84Stv# wrt info/dir below:  It's safe to move this over top of /usr/share/info/dir,
1381.84Stv# as the build will automatically remove/replace the non-pkg entries there.
1391.84Stv
1401.110Sjlam.if defined(BUILD_DONE)
1411.110Sjlambuild:
1421.110Sjlam	@echo "Build installed into ${DESTDIR}"
1431.110Sjlam.else
1441.124Smrgbuild:
1451.124Smrg	@${MAKE} ${_M} buildstartmsg
1461.124Smrg	@${MAKE} ${_M} beforeinstall
1471.124Smrg	@${MAKE} ${_M} do-force-domestic
1481.124Smrg	@${MAKE} ${_M} do-share-mk
1491.124Smrg	@${MAKE} ${_M} do-cleandir
1501.124Smrg	@${MAKE} ${_M} do-make-obj
1511.124Smrg	@${MAKE} ${_M} do-check-egcs
1521.124Smrg	@${MAKE} ${_M} do-make-includes
1531.124Smrg	@${MAKE} ${_M} do-lib-csu
1541.124Smrg	@${MAKE} ${_M} do-lib
1551.124Smrg	@${MAKE} ${_M} do-gnu-lib
1561.124Smrg	@${MAKE} ${_M} do-dependall
1571.124Smrg	@${MAKE} ${_M} do-domestic
1581.124Smrg	@${MAKE} ${_M} do-whatisdb
1591.124Smrg	@${MAKE} ${_M} buildendmsg
1601.123Smrg.endif
1611.123Smrg
1621.123Smrgdo-force-domestic:
1631.96Sscottr.if defined(FORCE_DOMESTIC)
1641.96Sscottr	@echo '*** CAPUTE!'
1651.96Sscottr	@echo '    The FORCE_DOMESTIC flag is not compatible with "make build".'
1661.96Sscottr	@echo '    Please correct the problem and try again.'
1671.96Sscottr	@false
1681.96Sscottr.endif
1691.123Smrg
1701.123Smrgdo-share-mk:
1711.86Slukem.if ${MKSHARE} != "no"
1721.117Smrg	(cd ${.CURDIR}/share/mk && ${MAKE} install)
1731.68Slukem.endif
1741.123Smrg
1751.123Smrgdo-cleandir:
1761.112Smrg.if !defined(UPDATE) && !defined(NOCLEANDIR)
1771.117Smrg	${MAKE} ${_J} ${_M} cleandir
1781.39Schristos.endif
1791.123Smrg
1801.123Smrgdo-make-obj:
1811.103Ssimonb.if ${MKOBJDIRS} != "no"
1821.122Ssommerfe	${MAKE} ${_J} ${_M} obj
1831.103Ssimonb.endif
1841.123Smrg
1851.123Smrgdo-check-egcs:
1861.115Sthorpej.if empty(HAVE_EGCS)
1871.71Smycroft.if defined(DESTDIR)
1881.71Smycroft	@echo "*** CAPUTE!"
1891.84Stv	@echo "    You attempted to compile the world without egcs.  You must"
1901.71Smycroft	@echo "    first install a native egcs compiler."
1911.84Stv	@false
1921.71Smycroft.else
1931.71Smycroft	(cd ${.CURDIR}/gnu/usr.bin/egcs && \
1941.112Smrg	    ${MAKE} ${_M} ${_J} dependall MKMAN=no && \
1951.112Smrg	    ${MAKE} ${_M} MKMAN=no install && ${MAKE} ${_M} cleandir)
1961.112Smrg.endif
1971.71Smycroft.endif
1981.123Smrg
1991.123Smrgdo-make-includes:
2001.112Smrg.if !defined(NOINCLUDES)
2011.112Smrg	${MAKE} ${_M} includes
2021.71Smycroft.endif
2031.123Smrg
2041.123Smrgdo-lib-csu:
2051.61Smycroft	(cd ${.CURDIR}/lib/csu && \
2061.113Smrg	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
2071.113Smrg	    ${MAKE} ${_M} MKSHARE=no install)
2081.123Smrg
2091.123Smrgdo-lib:
2101.61Smycroft	(cd ${.CURDIR}/lib && \
2111.113Smrg	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
2121.113Smrg	    ${MAKE} ${_M} MKSHARE=no install)
2131.123Smrg
2141.123Smrgdo-gnu-lib:
2151.61Smycroft	(cd ${.CURDIR}/gnu/lib && \
2161.113Smrg	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
2171.113Smrg	    ${MAKE} ${_M} MKSHARE=no install)
2181.123Smrg
2191.123Smrgdo-dependall:
2201.112Smrg	${MAKE} ${_M} ${_J} dependall && ${MAKE} ${_M} _BUILD= install
2211.123Smrg
2221.123Smrgdo-domestic:
2231.97Schristos.if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
2241.112Smrg	(cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_M} ${_J} _SLAVE_BUILD= build)
2251.49Slukem.endif
2261.123Smrg
2271.123Smrgdo-whatisdb:
2281.112Smrg	${MAKE} ${_M} whatis.db
2291.87Scjs
2301.87Scjsrelease snapshot: build
2311.112Smrg	(cd ${.CURDIR}/etc && ${MAKE} ${_M} INSTALL_DONE=1 release)
2321.1Scgd
2331.1Scgd.include <bsd.subdir.mk>
234