Makefile revision 1.122
1#	$NetBSD: Makefile,v 1.122 2001/05/08 02:04:08 sommerfeld Exp $
2
3# This is the top-level makefile for building NetBSD. For an outline of
4# how to build a snapshot or release, as well as other release engineering
5# information, see http://www.netbsd.org/developers/releng/index.html
6#
7# Not everything you can set or do is documented in this makefile. In
8# particular, you should review the files in /usr/share/mk (especially
9# bsd.README) for general information on building programs and writing
10# Makefiles within this structure, and see the comments in src/etc/Makefile
11# for further information on installation and release set options.
12#
13# Variables listed below can be set on the make command line (highest
14# priority), in /etc/mk.conf (middle priority), or in the environment
15# (lowest priority).
16#
17# Variables:
18#   DESTDIR is the target directory for installation of the compiled
19#	software. It defaults to /. Note that programs are built against
20#	libraries installed in DESTDIR.
21#   MKMAN, if set to `no', will prevent building of manual pages.
22#   MKOBJDIRS, if not set to `no', will build object directories at 
23#	an appropriate point in a build.
24#   MKSHARE, if set to `no', will prevent building and installing
25#	anything in /usr/share.
26#   NBUILDJOBS is the number of jobs to start in parallel during a
27#	'make build'. It defaults to 1.
28#   UPDATE will avoid a `make cleandir' at the start of `make build',
29#	as well as having the effects listed in /usr/share/mk/bsd.README.
30#   NOCLEANDIR will avoid a `make cleandir' at the start of `make build',
31#	but without having the effects listed in /usr/share/mk/bsd.README.
32#   NOINCLUDES will avoid the `make includes' usually done by `make build'.
33#
34# Targets:
35#   build: builds a full release of netbsd in DESTDIR. If BUILD_DONE is
36#	set, this is an empty target.
37#   release: does a `make build,' and then tars up the DESTDIR files
38#	into RELEASEDIR, in release(7) format. (See etc/Makefile for
39#	more information on this.)
40#   snapshot: a synonym for release.
41
42.include <bsd.own.mk>
43
44MKOBJDIRS ?= no
45HAVE_EGCS!=	${CXX} --version | egrep "^(2\.[89]|egcs)" ; echo
46
47.if defined(NBUILDJOBS)
48_J= -j${NBUILDJOBS}
49.endif
50
51.if defined(DESTDIR)
52_M=-m ${DESTDIR}/usr/share/mk
53.endif
54
55# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
56
57SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
58.if make(cleandir) || make(obj)
59SUBDIR+= distrib
60.ifdef MAKEOBJDIRPREFIX
61SUBDIR+= etc
62.endif
63.endif
64
65includes-lib: includes-include includes-sys
66
67.if exists(games)
68SUBDIR+= games
69.endif
70
71SUBDIR+= gnu
72# This is needed for libstdc++ and gen-params.
73includes-gnu: includes-include includes-sys
74
75.if exists(regress)
76.ifmake !(install)
77SUBDIR+= regress
78.endif
79
80regression-tests:
81	@echo Running regression tests...
82	@(cd ${.CURDIR}/regress && ${MAKE} ${_M} regress)
83.endif
84
85buildmsg:
86	@echo -n "Build started at: "
87	@date
88
89# If sharesrc is around, use its share/mk files to bootstrap until the
90# mk files are installed (first step of make build).  If installing to
91# DESTDIR, don't bother, since the build will fail later on anyway.
92
93beforeinstall:
94.ifndef NODISTRIBDIRS
95.ifndef DESTDIR
96.if exists(share/mk)
97	(cd ${.CURDIR}/etc && ${MAKE} -m ${.CURDIR}/share/mk DESTDIR=/ distrib-dirs)
98.else
99	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
100.endif
101.else
102	(cd ${.CURDIR}/etc && ${MAKE} distrib-dirs)
103.endif
104.endif
105
106afterinstall:
107.if ${MKMAN} != "no" && !defined(_BUILD)
108	${MAKE} ${_M} whatis.db
109.endif
110
111whatis.db:
112	(cd ${.CURDIR}/share/man && ${MAKE} ${_M} makedb)
113
114# wrt info/dir below:  It's safe to move this over top of /usr/share/info/dir,
115# as the build will automatically remove/replace the non-pkg entries there.
116
117.if defined(BUILD_DONE)
118build:
119	@echo "Build installed into ${DESTDIR}"
120.else
121build: buildmsg beforeinstall
122.if defined(FORCE_DOMESTIC)
123	@echo '*** CAPUTE!'
124	@echo '    The FORCE_DOMESTIC flag is not compatible with "make build".'
125	@echo '    Please correct the problem and try again.'
126	@false
127.endif
128.if ${MKSHARE} != "no"
129	(cd ${.CURDIR}/share/mk && ${MAKE} install)
130.endif
131.if !defined(UPDATE) && !defined(NOCLEANDIR)
132	${MAKE} ${_J} ${_M} cleandir
133.endif
134.if ${MKOBJDIRS} != "no"
135	${MAKE} ${_J} ${_M} obj
136.endif
137.if empty(HAVE_EGCS)
138.if defined(DESTDIR)
139	@echo "*** CAPUTE!"
140	@echo "    You attempted to compile the world without egcs.  You must"
141	@echo "    first install a native egcs compiler."
142	@false
143.else
144	(cd ${.CURDIR}/gnu/usr.bin/egcs && \
145	    ${MAKE} ${_M} ${_J} dependall MKMAN=no && \
146	    ${MAKE} ${_M} MKMAN=no install && ${MAKE} ${_M} cleandir)
147.endif
148.endif
149.if !defined(NOINCLUDES)
150	${MAKE} ${_M} includes
151.endif
152	(cd ${.CURDIR}/lib/csu && \
153	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
154	    ${MAKE} ${_M} MKSHARE=no install)
155	(cd ${.CURDIR}/lib && \
156	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
157	    ${MAKE} ${_M} MKSHARE=no install)
158	(cd ${.CURDIR}/gnu/lib && \
159	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
160	    ${MAKE} ${_M} MKSHARE=no install)
161	${MAKE} ${_M} ${_J} dependall && ${MAKE} ${_M} _BUILD= install
162.if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
163	(cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_M} ${_J} _SLAVE_BUILD= build)
164.endif
165	${MAKE} ${_M} whatis.db
166	@echo -n "Build finished at: "
167	@date
168.endif
169
170release snapshot: build
171	(cd ${.CURDIR}/etc && ${MAKE} ${_M} INSTALL_DONE=1 release)
172
173.include <bsd.subdir.mk>
174