Makefile revision 1.212 1 1.212 lukem # $NetBSD: Makefile,v 1.212 2003/07/17 07:46:11 lukem Exp $
2 1.95 cjs
3 1.193 lukem #
4 1.95 cjs # This is the top-level makefile for building NetBSD. For an outline of
5 1.95 cjs # how to build a snapshot or release, as well as other release engineering
6 1.95 cjs # information, see http://www.netbsd.org/developers/releng/index.html
7 1.95 cjs #
8 1.95 cjs # Not everything you can set or do is documented in this makefile. In
9 1.95 cjs # particular, you should review the files in /usr/share/mk (especially
10 1.95 cjs # bsd.README) for general information on building programs and writing
11 1.95 cjs # Makefiles within this structure, and see the comments in src/etc/Makefile
12 1.95 cjs # for further information on installation and release set options.
13 1.95 cjs #
14 1.95 cjs # Variables listed below can be set on the make command line (highest
15 1.95 cjs # priority), in /etc/mk.conf (middle priority), or in the environment
16 1.95 cjs # (lowest priority).
17 1.95 cjs #
18 1.95 cjs # Variables:
19 1.101 sommerfe # DESTDIR is the target directory for installation of the compiled
20 1.101 sommerfe # software. It defaults to /. Note that programs are built against
21 1.101 sommerfe # libraries installed in DESTDIR.
22 1.95 cjs # MKMAN, if set to `no', will prevent building of manual pages.
23 1.178 enami # MKOBJDIRS, if not set to `no', will build object directories at
24 1.101 sommerfe # an appropriate point in a build.
25 1.95 cjs # MKSHARE, if set to `no', will prevent building and installing
26 1.95 cjs # anything in /usr/share.
27 1.125 mrg # UPDATE, if defined, will avoid a `make cleandir' at the start of
28 1.178 enami # `make build', as well as having the effects listed in
29 1.178 enami # /usr/share/mk/bsd.README.
30 1.125 mrg # NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
31 1.178 enami # of the `make build'.
32 1.119 toddpw # NOINCLUDES will avoid the `make includes' usually done by `make build'.
33 1.95 cjs #
34 1.95 cjs # Targets:
35 1.137 tv # build:
36 1.196 lukem # Builds a full release of NetBSD in DESTDIR, except for the
37 1.196 lukem # /etc configuration files.
38 1.196 lukem # If BUILD_DONE is set, this is an empty target.
39 1.196 lukem # distribution:
40 1.196 lukem # Builds a full release of NetBSD in DESTDIR, including the /etc
41 1.196 lukem # configuration files.
42 1.196 lukem # buildworld:
43 1.196 lukem # As per `make distribution', except that it ensures that DESTDIR
44 1.196 lukem # is not the root directory.
45 1.196 lukem # installworld:
46 1.196 lukem # Install the distribution from DESTDIR to INSTALLWORLDDIR (which
47 1.196 lukem # defaults to the root directory). Ensures that INSTALLWORLDDIR
48 1.196 lukem # is the not root directory if cross compiling.
49 1.137 tv # release:
50 1.196 lukem # Does a `make build', and then tars up the DESTDIR files
51 1.196 lukem # into RELEASEDIR/${MACHINE}, in release(7) format.
52 1.196 lukem # (See etc/Makefile for more information on this.)
53 1.137 tv # regression-tests:
54 1.137 tv # Runs the regression tests in "regress" on this host.
55 1.206 lukem # sets:
56 1.206 lukem # Populate ${RELEASEDIR}/${MACHINE}/binary/sets from ${DESTDIR}
57 1.206 lukem # sourcesets:
58 1.206 lukem # Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR}
59 1.123 mrg #
60 1.137 tv # Targets invoked by `make build,' in order:
61 1.155 tv # cleandir: cleans the tree.
62 1.137 tv # obj: creates object directories.
63 1.152 tv # do-tools: builds host toolchain.
64 1.208 lukem # do-distrib-dirs: creates the distribution directories.
65 1.208 lukem # includes: installs include files.
66 1.202 thorpej # do-tools-compat: builds the "libnbcompat" library; needed for some
67 1.202 thorpej # random host tool programs in the source tree.
68 1.208 lukem # do-gnu-lib-libgcc: builds and installs prerequisites from gnu/lib/libgcc
69 1.168 tv # do-lib-csu: builds and installs prerequisites from lib/csu.
70 1.186 thorpej # do-lib-libc: builds and installs prerequisites from lib/libc.
71 1.143 tv # do-lib: builds and installs prerequisites from lib.
72 1.143 tv # do-gnu-lib: builds and installs prerequisites from gnu/lib.
73 1.189 itohy # do-ld.so: builds and installs prerequisites from libexec/ld.*_so.
74 1.137 tv # do-build: builds and installs the entire system.
75 1.208 lukem # do-obsolete: builds and installs the entire system.
76 1.193 lukem #
77 1.32 cgd
78 1.146 tv .if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
79 1.146 tv .MAKEFLAGS: -m ${.CURDIR}/share/mk
80 1.146 tv .endif
81 1.163 tv
82 1.193 lukem #
83 1.163 tv # If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
84 1.163 tv # not be the top level objdir, because "make obj" can happen in the *middle*
85 1.163 tv # of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set
86 1.163 tv # _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
87 1.193 lukem #
88 1.163 tv _SRC_TOP_OBJ_=
89 1.148 jmc
90 1.146 tv .include <bsd.own.mk>
91 1.4 cgd
92 1.193 lukem #
93 1.137 tv # Sanity check: make sure that "make build" is not invoked simultaneously
94 1.137 tv # with a standard recursive target.
95 1.193 lukem #
96 1.137 tv
97 1.137 tv .if make(build) || make(release) || make(snapshot)
98 1.137 tv .for targ in ${TARGETS:Nobj:Ncleandir}
99 1.137 tv .if make(${targ}) && !target(.BEGIN)
100 1.137 tv .BEGIN:
101 1.137 tv @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
102 1.137 tv @false
103 1.137 tv .endif
104 1.137 tv .endfor
105 1.137 tv .endif
106 1.58 tv
107 1.166 simonb _SUBDIR= tools lib include gnu bin games libexec sbin usr.bin
108 1.205 thorpej _SUBDIR+= usr.sbin share rescue sys etc .WAIT distrib regress
109 1.105 assar
110 1.193 lukem #
111 1.137 tv # Weed out directories that don't exist.
112 1.193 lukem #
113 1.36 explorer
114 1.137 tv .for dir in ${_SUBDIR}
115 1.154 tv .if exists(${dir}/Makefile) && (${BUILD_${dir}:Uyes} != "no")
116 1.137 tv SUBDIR+= ${dir}
117 1.36 explorer .endif
118 1.137 tv .endfor
119 1.21 cgd
120 1.13 brezak .if exists(regress)
121 1.10 cgd regression-tests:
122 1.10 cgd @echo Running regression tests...
123 1.152 tv @(cd ${.CURDIR}/regress && ${MAKE} regress)
124 1.13 brezak .endif
125 1.20 cgd
126 1.179 thorpej .if defined(UNPRIVED)
127 1.179 thorpej NOPOSTINSTALL= # defined
128 1.179 thorpej .endif
129 1.179 thorpej
130 1.176 lukem afterinstall:
131 1.137 tv .if ${MKMAN} != "no"
132 1.152 tv (cd ${.CURDIR}/share/man && ${MAKE} makedb)
133 1.137 tv .endif
134 1.159 perry .if defined(UNPRIVED) && (${MKINFO} != "no")
135 1.164 jmc (cd ${.CURDIR}/gnu/usr.bin/texinfo/install-info && ${MAKE} infodir-meta)
136 1.176 lukem .endif
137 1.179 thorpej .if !defined(NOPOSTINSTALL)
138 1.180 drochner (cd ${.CURDIR} && ${MAKE} postinstall-check)
139 1.159 perry .endif
140 1.170 lukem
141 1.170 lukem postinstall-check:
142 1.169 lukem @echo " === Post installation checks ==="
143 1.212 lukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ check
144 1.171 lukem @echo " ================================"
145 1.171 lukem
146 1.171 lukem postinstall-fix: .NOTMAIN
147 1.171 lukem @echo " === Post installation fixes ==="
148 1.212 lukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix
149 1.212 lukem @echo " ==============================="
150 1.212 lukem
151 1.212 lukem postinstall-fix-obsolete: .NOTMAIN
152 1.212 lukem @echo " === Removing obsolete files ==="
153 1.212 lukem ${HOST_SH} ${.CURDIR}/etc/postinstall -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete
154 1.212 lukem @echo " ==============================="
155 1.169 lukem
156 1.108 erh
157 1.193 lukem #
158 1.137 tv # Targets (in order!) called by "make build".
159 1.193 lukem #
160 1.123 mrg
161 1.156 tv BUILDTARGETS+= check-tools
162 1.155 tv .if !defined(UPDATE) && !defined(NOCLEANDIR)
163 1.155 tv BUILDTARGETS+= cleandir
164 1.155 tv .endif
165 1.149 tv .if ${MKOBJDIRS} != "no"
166 1.137 tv BUILDTARGETS+= obj
167 1.123 mrg .endif
168 1.138 tv .if ${USETOOLS} == "yes"
169 1.152 tv BUILDTARGETS+= do-tools
170 1.131 tv .endif
171 1.137 tv .if !defined(NODISTRIBDIRS)
172 1.137 tv BUILDTARGETS+= do-distrib-dirs
173 1.131 tv .endif
174 1.137 tv .if !defined(NOINCLUDES)
175 1.137 tv BUILDTARGETS+= includes
176 1.131 tv .endif
177 1.202 thorpej BUILDTARGETS+= do-tools-compat
178 1.207 drochner .if ${MKGCC} != "no"
179 1.207 drochner BUILDTARGETS+= do-gnu-lib-libgcc
180 1.207 drochner .endif
181 1.204 thorpej BUILDTARGETS+= do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.so do-build
182 1.200 lukem BUILDTARGETS+= do-obsolete
183 1.131 tv
184 1.193 lukem #
185 1.137 tv # Enforce proper ordering of some rules.
186 1.193 lukem #
187 1.123 mrg
188 1.137 tv .ORDER: ${BUILDTARGETS}
189 1.137 tv includes-lib: includes-include includes-sys
190 1.137 tv includes-gnu: includes-lib
191 1.123 mrg
192 1.193 lukem #
193 1.137 tv # Build the system and install into DESTDIR.
194 1.193 lukem #
195 1.123 mrg
196 1.191 lukem START_TIME!= date
197 1.191 lukem
198 1.137 tv build:
199 1.137 tv .if defined(BUILD_DONE)
200 1.137 tv @echo "Build already installed into ${DESTDIR}"
201 1.137 tv .else
202 1.191 lukem @echo "Build started at: ${START_TIME}"
203 1.145 tv .for tgt in ${BUILDTARGETS}
204 1.173 sommerfe @(cd ${.CURDIR} && ${MAKE} ${tgt})
205 1.145 tv .endfor
206 1.191 lukem @echo "Build started at: ${START_TIME}"
207 1.172 bjh21 @printf "Build finished at: " && date
208 1.71 mycroft .endif
209 1.160 thorpej
210 1.193 lukem #
211 1.160 thorpej # Build a full distribution, but not a release (i.e. no sets into
212 1.193 lukem # ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != /
213 1.193 lukem #
214 1.160 thorpej
215 1.193 lukem distribution buildworld:
216 1.194 lukem .if make(buildworld) && \
217 1.194 lukem (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
218 1.193 lukem @echo "Won't make ${.TARGET} with DESTDIR=/"
219 1.193 lukem @false
220 1.193 lukem .endif
221 1.182 uwe (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
222 1.160 thorpej (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 distribution)
223 1.181 thorpej .if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/"
224 1.212 lukem ${MAKE} postinstall-fix-obsolete
225 1.181 thorpej (cd ${.CURDIR}/distrib/sets && ${MAKE} checkflist)
226 1.181 thorpej .endif
227 1.192 lukem @echo "make ${.TARGET} started at: ${START_TIME}"
228 1.185 lukem @printf "make ${.TARGET} finished at: " && date
229 1.123 mrg
230 1.193 lukem #
231 1.193 lukem # Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/')
232 1.193 lukem # If installing to /, ensures that the host's operating system is NetBSD and
233 1.193 lukem # the host's `uname -m` == ${MACHINE}.
234 1.193 lukem #
235 1.193 lukem
236 1.193 lukem HOST_UNAME_S!= uname -s
237 1.193 lukem HOST_UNAME_M!= uname -m
238 1.193 lukem
239 1.193 lukem installworld:
240 1.194 lukem .if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
241 1.193 lukem @echo "Can't make ${.TARGET} to DESTDIR=/"
242 1.193 lukem @false
243 1.193 lukem .endif
244 1.193 lukem .if !defined(INSTALLWORLDDIR) || \
245 1.193 lukem ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/"
246 1.193 lukem .if (${HOST_UNAME_S} != "NetBSD")
247 1.193 lukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLWORLDDIR=/"
248 1.193 lukem @false
249 1.193 lukem .endif
250 1.193 lukem .if (${HOST_UNAME_M} != ${MACHINE})
251 1.193 lukem @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/"
252 1.193 lukem @false
253 1.193 lukem .endif
254 1.193 lukem .endif
255 1.193 lukem (cd ${.CURDIR}/distrib/sets && \
256 1.193 lukem ${MAKE} INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS= installsets)
257 1.193 lukem (cd ${.CURDIR} && \
258 1.193 lukem ${MAKE} DESTDIR=${INSTALLWORLDDIR} postinstall-check)
259 1.193 lukem @echo "make ${.TARGET} started at: ${START_TIME}"
260 1.193 lukem @printf "make ${.TARGET} finished at: " && date
261 1.199 lukem
262 1.199 lukem #
263 1.206 lukem # Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR
264 1.199 lukem #
265 1.199 lukem
266 1.206 lukem .for tgt in sets sourcesets
267 1.206 lukem ${tgt}:
268 1.206 lukem (cd ${.CURDIR}/distrib/sets && ${MAKE} $@)
269 1.206 lukem .endfor
270 1.193 lukem
271 1.193 lukem #
272 1.181 thorpej # Build a release or snapshot (implies "make build"). Note that
273 1.181 thorpej # in this case, the set lists will be checked before the tar files
274 1.181 thorpej # are made.
275 1.193 lukem #
276 1.123 mrg
277 1.179 thorpej release snapshot:
278 1.179 thorpej (cd ${.CURDIR} && ${MAKE} NOPOSTINSTALL=1 build)
279 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} INSTALL_DONE=1 release)
280 1.192 lukem @echo "make ${.TARGET} started at: ${START_TIME}"
281 1.185 lukem @printf "make ${.TARGET} finished at: " && date
282 1.123 mrg
283 1.193 lukem #
284 1.137 tv # Special components of the "make build" process.
285 1.193 lukem #
286 1.156 tv
287 1.156 tv check-tools:
288 1.187 thorpej .if ${TOOLCHAIN_MISSING} == "yes" && !defined(EXTERNAL_TOOLCHAIN)
289 1.187 thorpej @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.'
290 1.187 thorpej @echo '*** May result in a failed build or corrupt binaries!'
291 1.187 thorpej .elif defined(EXTERNAL_TOOLCHAIN)
292 1.187 thorpej @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.'
293 1.156 tv .endif
294 1.173 sommerfe .if defined(NBUILDJOBS)
295 1.173 sommerfe @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
296 1.173 sommerfe .endif
297 1.123 mrg
298 1.137 tv do-distrib-dirs:
299 1.147 jmc .if !defined(DESTDIR) || ${DESTDIR} == ""
300 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
301 1.147 jmc .else
302 1.152 tv (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=${DESTDIR} distrib-dirs)
303 1.147 jmc .endif
304 1.190 lukem
305 1.190 lukem .for targ in cleandir obj includes
306 1.190 lukem do-${targ}: ${targ}
307 1.190 lukem @true
308 1.190 lukem .endfor
309 1.123 mrg
310 1.207 drochner .for dir in tools tools/compat lib/csu gnu/lib/libgcc lib/libc lib gnu/lib
311 1.207 drochner do-${dir:S/\//-/g}:
312 1.137 tv .for targ in dependall install
313 1.173 sommerfe (cd ${.CURDIR}/${dir} && ${MAKE} ${targ})
314 1.137 tv .endfor
315 1.184 lukem .endfor
316 1.184 lukem
317 1.189 itohy do-ld.so:
318 1.184 lukem .for targ in dependall install
319 1.189 itohy .if (${OBJECT_FMT} == "a.out")
320 1.189 itohy (cd ${.CURDIR}/libexec/ld.aout_so && ${MAKE} ${targ})
321 1.189 itohy .endif
322 1.189 itohy .if (${OBJECT_FMT} == "ELF")
323 1.184 lukem (cd ${.CURDIR}/libexec/ld.elf_so && ${MAKE} ${targ})
324 1.189 itohy .endif
325 1.137 tv .endfor
326 1.143 tv
327 1.143 tv do-build:
328 1.154 tv .for targ in dependall install
329 1.173 sommerfe (cd ${.CURDIR} && ${MAKE} ${targ} BUILD_tools=no BUILD_lib=no)
330 1.154 tv .endfor
331 1.200 lukem
332 1.200 lukem do-obsolete:
333 1.200 lukem (cd ${.CURDIR}/etc && ${MAKE} install-obsolete-lists)
334 1.87 cjs
335 1.193 lukem #
336 1.137 tv # Speedup stubs for some subtrees that don't need to run these rules.
337 1.137 tv # (Tells <bsd.subdir.mk> not to recurse for them.)
338 1.193 lukem #
339 1.129 tv
340 1.152 tv .for dir in bin etc distrib games libexec regress sbin usr.sbin tools
341 1.152 tv includes-${dir}:
342 1.152 tv @true
343 1.152 tv .endfor
344 1.152 tv .for dir in etc distrib regress
345 1.152 tv install-${dir}:
346 1.152 tv @true
347 1.152 tv .endfor
348 1.152 tv
349 1.193 lukem #
350 1.152 tv # XXX this needs to change when distrib Makefiles are recursion compliant
351 1.193 lukem # XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first...
352 1.193 lukem #
353 1.152 tv dependall-distrib depend-distrib all-distrib:
354 1.136 nathanw @true
355 1.130 tv
356 1.211 lukem .include <bsd.sys.mk>
357 1.151 tv .include <bsd.obj.mk>
358 1.209 lukem .include <bsd.kernobj.mk>
359 1.146 tv .include <bsd.subdir.mk>
360 1.144 tv
361 1.150 tv build-docs: ${.CURDIR}/BUILDING
362 1.188 lukem ${.CURDIR}/BUILDING: doc/BUILDING.mdoc
363 1.211 lukem ${TOOL_GROFF} -mdoc -Tascii -P-b -P-u -P-o $> >$@
364 1.209 lukem
365 1.209 lukem
366 1.209 lukem #
367 1.209 lukem # Display current make(1) parameters
368 1.209 lukem #
369 1.209 lukem params:
370 1.209 lukem .for var in BSDSRCDIR BSDOBJDIR BUILDID DESTDIR EXTERNAL_TOOLCHAIN \
371 1.209 lukem KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
372 1.210 lukem MACHINE MACHINE_ARCH MAKECONF MAKEFLAGS \
373 1.210 lukem MAKEOBJDIR MAKEOBJDIRPREFIX MKOBJDIRS \
374 1.210 lukem RELEASEDIR TOOLCHAIN_MISSING TOOLDIR \
375 1.209 lukem UNPRIVED UPDATE USETOOLS
376 1.209 lukem .if defined(${var})
377 1.209 lukem @printf "%20s = '%-s'\n" ${var} ${${var}:Q}
378 1.209 lukem .else
379 1.209 lukem @printf "%20s = (undefined)\n" ${var}
380 1.209 lukem .endif
381 1.209 lukem .endfor
382