Makefile revision 1.126 1 # $NetBSD: Makefile,v 1.126 2001/08/02 06:13:33 enami 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: clean's the tree.
50 # do-make-obj: create's object directories if required.
51 # do-check-egcs: check's that we have a modern enough compiler (deprecated.)
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
63 MKOBJDIRS ?= no
64 HAVE_EGCS!= ${CXX} --version | egrep "^(2\.[89]|egcs)" ; echo
65
66 .if defined(NBUILDJOBS)
67 _J= -j${NBUILDJOBS}
68 .endif
69
70 .if defined(DESTDIR)
71 _M=-m ${DESTDIR}/usr/share/mk
72 .endif
73
74 # NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
75
76 SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
77 .if make(cleandir) || make(obj)
78 SUBDIR+= distrib
79 .ifdef MAKEOBJDIRPREFIX
80 SUBDIR+= etc
81 .endif
82 .endif
83
84 includes-lib: includes-include includes-sys
85
86 .if exists(games)
87 SUBDIR+= games
88 .endif
89
90 SUBDIR+= gnu
91 # This is needed for libstdc++ and gen-params.
92 includes-gnu: includes-include includes-sys
93
94 .if exists(regress)
95 .ifmake !(install)
96 SUBDIR+= regress
97 .endif
98
99 regression-tests:
100 @echo Running regression tests...
101 @(cd ${.CURDIR}/regress && ${MAKE} ${_M} regress)
102 .endif
103
104 buildstartmsg:
105 @echo -n "Build started at: "
106 @date
107
108 buildendmsg:
109 @echo -n "Build finished at: "
110 @date
111
112 # If sharesrc is around, use its share/mk files to bootstrap until the
113 # mk files are installed (first step of make build). If installing to
114 # DESTDIR, don't bother, since the build will fail later on anyway.
115
116 beforeinstall:
117 .ifndef NODISTRIBDIRS
118 .ifndef DESTDIR
119 .if exists(share/mk)
120 (cd ${.CURDIR}/etc && \
121 ${MAKE} -m ${.CURDIR}/share/mk DESTDIR=/ distrib-dirs)
122 .else
123 (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
124 .endif
125 .else
126 (cd ${.CURDIR}/etc && ${MAKE} distrib-dirs)
127 .endif
128 .endif
129
130 afterinstall:
131 .if ${MKMAN} != "no" && !defined(_BUILD)
132 ${MAKE} ${_M} whatis.db
133 .endif
134
135 whatis.db:
136 (cd ${.CURDIR}/share/man && ${MAKE} ${_M} makedb)
137
138 # wrt info/dir below: It's safe to move this over top of /usr/share/info/dir,
139 # as the build will automatically remove/replace the non-pkg entries there.
140
141 .if defined(BUILD_DONE)
142 build:
143 @echo "Build installed into ${DESTDIR}"
144 .else
145 build:
146 @${MAKE} ${_M} buildstartmsg
147 @${MAKE} ${_M} beforeinstall
148 @${MAKE} ${_M} do-force-domestic
149 @${MAKE} ${_M} do-share-mk
150 @${MAKE} ${_M} do-cleandir
151 @${MAKE} ${_M} do-make-obj
152 @${MAKE} ${_M} do-check-egcs
153 @${MAKE} ${_M} do-make-includes
154 @${MAKE} ${_M} do-lib-csu
155 @${MAKE} ${_M} do-lib
156 @${MAKE} ${_M} do-gnu-lib
157 @${MAKE} ${_M} do-dependall
158 @${MAKE} ${_M} do-domestic
159 @${MAKE} ${_M} do-whatisdb
160 @${MAKE} ${_M} buildendmsg
161 .endif
162
163 do-force-domestic:
164 .if defined(FORCE_DOMESTIC)
165 @echo '*** CAPUTE!'
166 @echo ' The FORCE_DOMESTIC flag is not compatible with "make build".'
167 @echo ' Please correct the problem and try again.'
168 @false
169 .endif
170
171 do-share-mk:
172 .if ${MKSHARE} != "no"
173 (cd ${.CURDIR}/share/mk && ${MAKE} install)
174 .endif
175
176 do-cleandir:
177 .if !defined(UPDATE) && !defined(NOCLEANDIR)
178 ${MAKE} ${_J} ${_M} cleandir
179 .endif
180
181 do-make-obj:
182 .if ${MKOBJDIRS} != "no"
183 ${MAKE} ${_J} ${_M} obj
184 .endif
185
186 do-check-egcs:
187 .if empty(HAVE_EGCS)
188 .if defined(DESTDIR)
189 @echo "*** CAPUTE!"
190 @echo " You attempted to compile the world without egcs. You must"
191 @echo " first install a native egcs compiler."
192 @false
193 .else
194 (cd ${.CURDIR}/gnu/usr.bin/egcs && \
195 ${MAKE} ${_M} ${_J} dependall MKMAN=no && \
196 ${MAKE} ${_M} MKMAN=no install && ${MAKE} ${_M} cleandir)
197 .endif
198 .endif
199
200 do-make-includes:
201 .if !defined(NOINCLUDES)
202 ${MAKE} ${_M} includes
203 .endif
204
205 do-lib-csu:
206 (cd ${.CURDIR}/lib/csu && \
207 ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
208 ${MAKE} ${_M} MKSHARE=no install)
209
210 do-lib:
211 (cd ${.CURDIR}/lib && \
212 ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
213 ${MAKE} ${_M} MKSHARE=no install)
214
215 do-gnu-lib:
216 (cd ${.CURDIR}/gnu/lib && \
217 ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
218 ${MAKE} ${_M} MKSHARE=no install)
219
220 do-dependall:
221 ${MAKE} ${_M} ${_J} dependall && ${MAKE} ${_M} _BUILD= install
222
223 do-domestic:
224 .if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
225 (cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_M} ${_J} _SLAVE_BUILD= build)
226 .endif
227
228 do-whatisdb:
229 ${MAKE} ${_M} whatis.db
230
231 release snapshot: build
232 (cd ${.CURDIR}/etc && ${MAKE} ${_M} INSTALL_DONE=1 release)
233
234 .include <bsd.subdir.mk>
235