Makefile revision 1.129
1#	$NetBSD: Makefile,v 1.129 2001/09/21 21:01:13 tv 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, if defined, will avoid a `make cleandir' at the start of
29#     `make build', as well as having the effects listed in
30#     /usr/share/mk/bsd.README.
31#   NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
32#     of the `make build'.
33#   NOINCLUDES will avoid the `make includes' usually done by `make build'.
34
35#
36# Targets:
37#   build: builds a full release of netbsd in DESTDIR. If BUILD_DONE is
38#	set, this is an empty target.
39#   release: does a `make build,' and then tars up the DESTDIR files
40#	into RELEASEDIR, in release(7) format. (See etc/Makefile for
41#	more information on this.)
42#   snapshot: a synonym for release.
43#
44# Sub targets of `make build,' in order:
45#   buildstartmsg: displays the start time of the build.
46#   beforeinstall: creates the distribution directories.
47#   do-force-domestic: check's that FORCE_DOMESTIC isn't set (deprecated.)
48#   do-share-mk: installs /usr/share/mk files.
49#   do-cleandir: cleans the tree.
50#   do-make-obj: creates object directories if required.
51#   do-make-tools: builds host toolchain.
52#   do-make-includes: install include files.
53#   do-lib-csu: build & install startup object files.
54#   do-lib: build & install system libraries.
55#   do-gnu-lib: build & install gnu system libraries.
56#   do-dependall: builds & install the entire system.
57#   do-domestic: build & install the domestic tree (deprecated.)
58#   do-whatisdb: build & install the `whatis.db' man database.
59#   buildendmsg: displays the end time of the build.
60
61.include <bsd.own.mk>
62
63MKOBJDIRS ?= no
64
65.if defined(NBUILDJOBS)
66_J= -j${NBUILDJOBS}
67.endif
68
69.if defined(DESTDIR)
70_M=-m ${DESTDIR}/usr/share/mk
71.endif
72
73# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
74
75SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
76.if make(cleandir) || make(obj)
77SUBDIR+= distrib
78.ifdef MAKEOBJDIRPREFIX
79SUBDIR+= etc
80.endif
81.endif
82
83includes-lib: includes-include includes-sys
84
85.if exists(games)
86SUBDIR+= games
87.endif
88
89SUBDIR+= gnu
90# This is needed for libstdc++ and gen-params.
91includes-gnu: includes-include includes-sys
92
93.if exists(regress)
94.ifmake !(install)
95SUBDIR+= regress
96.endif
97
98regression-tests:
99	@echo Running regression tests...
100	@(cd ${.CURDIR}/regress && ${MAKE} ${_M} regress)
101.endif
102
103buildstartmsg:
104	@echo -n "Build started at: "
105	@date
106
107buildendmsg:
108	@echo -n "Build finished at: "
109	@date
110
111# If sharesrc is around, use its share/mk files to bootstrap until the
112# mk files are installed (first step of make build).  If installing to
113# DESTDIR, don't bother, since the build will fail later on anyway.
114
115beforeinstall:
116.ifndef NODISTRIBDIRS
117.ifndef DESTDIR
118.if exists(share/mk)
119	(cd ${.CURDIR}/etc && \
120	    ${MAKE} -m ${.CURDIR}/share/mk DESTDIR=/ distrib-dirs)
121.else
122	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
123.endif
124.else
125	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
126.endif
127.endif
128
129afterinstall:
130.if ${MKMAN} != "no" && !defined(_BUILD)
131	${MAKE} ${_M} whatis.db
132.endif
133
134whatis.db:
135	(cd ${.CURDIR}/share/man && ${MAKE} ${_M} makedb)
136
137# wrt info/dir below:  It's safe to move this over top of /usr/share/info/dir,
138# as the build will automatically remove/replace the non-pkg entries there.
139
140.if defined(BUILD_DONE)
141build:
142	@echo "Build installed into ${DESTDIR}"
143.else
144build:
145	@${MAKE} ${_M} buildstartmsg
146	@${MAKE} ${_M} beforeinstall
147	@${MAKE} ${_M} do-force-domestic
148	@${MAKE} ${_M} do-share-mk
149	@${MAKE} ${_M} do-cleandir
150	@${MAKE} ${_M} do-make-obj
151	@${MAKE} ${_M} do-make-tools
152	@${MAKE} ${_M} do-make-includes
153	@${MAKE} ${_M} do-lib-csu
154	@${MAKE} ${_M} do-lib
155	@${MAKE} ${_M} do-gnu-lib
156	@${MAKE} ${_M} do-dependall
157	@${MAKE} ${_M} do-domestic
158	@${MAKE} ${_M} do-whatisdb
159	@${MAKE} ${_M} buildendmsg
160.endif
161
162do-force-domestic:
163.if defined(FORCE_DOMESTIC)
164	@echo '*** CAPUTE!'
165	@echo '    The FORCE_DOMESTIC flag is not compatible with "make build".'
166	@echo '    Please correct the problem and try again.'
167	@false
168.endif
169
170do-share-mk:
171.if ${MKSHARE} != "no"
172	(cd ${.CURDIR}/share/mk && ${MAKE} install)
173.endif
174
175do-cleandir:
176.if !defined(UPDATE) && !defined(NOCLEANDIR)
177	${MAKE} ${_J} ${_M} cleandir
178.endif
179
180do-make-obj:
181.if ${MKOBJDIRS} != "no"
182	${MAKE} ${_J} ${_M} obj
183.if defined(USE_NEW_TOOLCHAIN)
184	cd ${.CURDIR}/tools && ${MAKE} ${_M} obj
185.endif
186.endif
187
188do-make-tools:
189.if defined(USE_NEW_TOOLCHAIN)
190	cd ${.CURDIR}/tools && ${MAKE} ${_M} build
191.endif
192
193do-make-includes:
194.if !defined(NOINCLUDES)
195	${MAKE} ${_M} includes
196.endif
197
198do-lib-csu:
199	(cd ${.CURDIR}/lib/csu && \
200	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
201	    ${MAKE} ${_M} MKSHARE=no install)
202
203do-lib:
204	(cd ${.CURDIR}/lib && \
205	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
206	    ${MAKE} ${_M} MKSHARE=no install)
207
208do-gnu-lib:
209	(cd ${.CURDIR}/gnu/lib && \
210	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
211	    ${MAKE} ${_M} MKSHARE=no install)
212
213do-dependall:
214	${MAKE} ${_M} ${_J} dependall && ${MAKE} ${_M} _BUILD= install
215
216do-domestic:
217.if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
218	(cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_M} ${_J} _SLAVE_BUILD= build)
219.endif
220
221do-whatisdb:
222	${MAKE} ${_M} whatis.db
223
224release snapshot: build
225	(cd ${.CURDIR}/etc && ${MAKE} ${_M} INSTALL_DONE=1 release)
226
227# Speedup stubs for some subtrees that don't need to run these rules
228includes-bin includes-games includes-libexec includes-regress \
229includes-sbin includes-usr.sbin:
230	@${TRUE}
231
232.include <bsd.subdir.mk>
233