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