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