release.sh: restore -jJAILDIR option
[minix3.git] / Makefile
blob0455875bc36ade1f0aee47f6982591f1e6dc3137
1 # $NetBSD: Makefile,v 1.299 2012/08/17 16:22:27 joerg Exp $
4 # This is the top-level makefile for building NetBSD. For an outline of
5 # how to build a snapshot or release, as well as other release engineering
6 # information, see http://www.NetBSD.org/developers/releng/index.html
8 # Not everything you can set or do is documented in this makefile. In
9 # particular, you should review the files in /usr/share/mk (especially
10 # bsd.README) for general information on building programs and writing
11 # Makefiles within this structure, and see the comments in src/etc/Makefile
12 # for further information on installation and release set options.
14 # Variables listed below can be set on the make command line (highest
15 # priority), in /etc/mk.conf (middle priority), or in the environment
16 # (lowest priority).
18 # Variables:
19 # DESTDIR is the target directory for installation of the compiled
20 # software. It defaults to /. Note that programs are built against
21 # libraries installed in DESTDIR.
22 # MKMAN, if `no', will prevent building of manual pages.
23 # MKOBJDIRS, if not `no', will build object directories at
24 # an appropriate point in a build.
25 # MKSHARE, if `no', will prevent building and installing
26 # anything in /usr/share.
27 # MKUPDATE, if not `no', will avoid a `make cleandir' at the start of
28 # `make build', as well as having the effects listed in
29 # /usr/share/mk/bsd.README.
30 # NOCLEANDIR, if defined, will avoid a `make cleandir' at the start
31 # of the `make build'.
32 # NOINCLUDES will avoid the `make includes' usually done by `make build'.
34 # See mk.conf(5) for more details.
37 # Targets:
38 # build:
39 # Builds a full release of NetBSD in DESTDIR, except for the
40 # /etc configuration files.
41 # If BUILD_DONE is set, this is an empty target.
42 # distribution:
43 # Builds a full release of NetBSD in DESTDIR, including the /etc
44 # configuration files.
45 # buildworld:
46 # As per `make distribution', except that it ensures that DESTDIR
47 # is not the root directory.
48 # installworld:
49 # Install the distribution from DESTDIR to INSTALLWORLDDIR (which
50 # defaults to the root directory). Ensures that INSTALLWORLDDIR
51 # is not the root directory if cross compiling.
52 # release:
53 # Does a `make distribution', and then tars up the DESTDIR files
54 # into ${RELEASEDIR}/${RELEASEMACHINEDIR}, in release(7) format.
55 # (See etc/Makefile for more information on this.)
56 # regression-tests:
57 # Runs the regression tests in "regress" on this host.
58 # sets:
59 # Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
60 # from ${DESTDIR}
61 # sourcesets:
62 # Populate ${RELEASEDIR}/source/sets from ${NETBSDSRCDIR}
63 # syspkgs:
64 # Populate ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs
65 # from ${DESTDIR}
66 # iso-image:
67 # Create CD-ROM image in RELEASEDIR/iso.
68 # RELEASEDIR must already have been populated by `make release'
69 # or equivalent.
70 # iso-image-source:
71 # Create CD-ROM image with source in RELEASEDIR/iso.
72 # RELEASEDIR must already have been populated by
73 # `make release sourcesets' or equivalent.
74 # live-image:
75 # Create bootable live image for emulators or USB stick etc.
76 # in RELEASEDIR/liveimage.
77 # RELEASEDIR must already have been populated by `make release'
78 # or equivalent.
79 # install-image:
80 # Create bootable installation image for USB stick etc.
81 # in RELEASEDIR/installimage.
82 # RELEASEDIR must already have been populated by `make release'
83 # or equivalent.
85 # Targets invoked by `make build,' in order:
86 # cleandir: cleans the tree.
87 # do-top-obj: creates the top level object directory.
88 # do-tools-obj: creates object directories for the host toolchain.
89 # do-tools: builds host toolchain.
90 # obj: creates object directories.
91 # do-distrib-dirs: creates the distribution directories.
92 # includes: installs include files.
93 # do-tools-compat: builds the "libnbcompat" library; needed for some
94 # random host tool programs in the source tree.
95 # do-lib: builds and installs prerequisites from lib
96 # if ${MKCOMPAT} != "no".
97 # do-compat-lib: builds and installs prerequisites from compat/lib
98 # if ${MKCOMPAT} != "no".
99 # do-build: builds and installs the entire system.
100 # do-x11: builds and installs X11 if ${MKX11} != "no"; either
101 # X11R7 from src/external/mit/xorg if ${X11FLAVOUR} == "Xorg"
102 # or X11R6 from src/x11
103 # do-extsrc: builds and installs extsrc if ${MKEXTSRC} != "no".
104 # do-obsolete: installs the obsolete sets (for the postinstall-* targets).
107 .if ${.MAKEFLAGS:M${.CURDIR}/share/mk} == ""
108 .MAKEFLAGS: -m ${.CURDIR}/share/mk
109 .endif
112 # If _SRC_TOP_OBJ_ gets set here, we will end up with a directory that may
113 # not be the top level objdir, because "make obj" can happen in the *middle*
114 # of "make build" (long after <bsd.own.mk> is calculated it). So, pre-set
115 # _SRC_TOP_OBJ_ here so it will not be added to ${.MAKEOVERRIDES}.
117 _SRC_TOP_OBJ_=
119 .include <bsd.own.mk>
122 # Sanity check: make sure that "make build" is not invoked simultaneously
123 # with a standard recursive target.
126 .if make(build) || make(release) || make(snapshot)
127 .for targ in ${TARGETS:Nobj:Ncleandir}
128 .if make(${targ}) && !target(.BEGIN)
129 .BEGIN:
130 @echo 'BUILD ABORTED: "make build" and "make ${targ}" are mutually exclusive.'
131 @false
132 .endif
133 .endfor
134 .endif
137 # _SUBDIR is used to set SUBDIR, after removing directories that have
138 # BUILD_${dir}=no, or that have no ${dir}/Makefile.
140 _SUBDIR= tools lib .WAIT include gnu external crypto/external bin games
141 _SUBDIR+= libexec sbin usr.bin
142 _SUBDIR+= commands man
143 _SUBDIR+= common drivers kernel servers
144 _SUBDIR+= usr.sbin share rescue sys etc tests compat .WAIT distrib regress
146 .for dir in ${_SUBDIR}
147 .if "${dir}" == ".WAIT" \
148 || (${BUILD_${dir}:Uyes} != "no" && exists(${dir}/Makefile))
149 SUBDIR+= ${dir}
150 .endif
151 .endfor
153 .if exists(regress)
154 regression-tests: .PHONY .MAKE
155 @echo Running regression tests...
156 ${MAKEDIRTARGET} regress regress
157 .endif
159 .if ${MKUNPRIVED} != "no"
160 NOPOSTINSTALL= # defined
161 .endif
163 afterinstall: .PHONY .MAKE
164 .if ${MKMAN} != "no"
165 .if !defined(__MINIX)
166 ${MAKEDIRTARGET} share/man makedb
167 .else
168 ${MAKEDIRTARGET} man makedb
169 .endif # !defined(__MINIX)
170 .endif
171 .if !defined(__MINIX)
172 .if (${MKUNPRIVED} != "no" && ${MKINFO} != "no")
173 ${MAKEDIRTARGET} gnu/usr.bin/texinfo/install-info infodir-meta
174 .endif
175 .endif # !defined(__MINIX)
176 .if !defined(NOPOSTINSTALL)
177 ${MAKEDIRTARGET} . postinstall-check
178 .endif
180 _POSTINSTALL= ${.CURDIR}/usr.sbin/postinstall/postinstall
181 _POSTINSTALL_ENV= \
182 AWK=${TOOL_AWK:Q} \
183 DB=${TOOL_DB:Q} \
184 HOST_SH=${HOST_SH:Q} \
185 MAKE=${MAKE:Q} \
186 PWD_MKDB=${TOOL_PWD_MKDB:Q} \
187 STAT=${TOOL_STAT:Q}
189 postinstall-check: .PHONY
190 @echo " === Post installation checks ==="
191 ${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ check; if [ $$? -gt 1 ]; then exit 1; fi
192 @echo " ================================"
194 postinstall-fix: .NOTMAIN .PHONY
195 @echo " === Post installation fixes ==="
196 ${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix
197 @echo " ==============================="
199 postinstall-fix-obsolete: .NOTMAIN .PHONY
200 @echo " === Removing obsolete files ==="
201 ${_POSTINSTALL_ENV} ${HOST_SH} ${_POSTINSTALL} -s ${.CURDIR} -d ${DESTDIR}/ fix obsolete
202 @echo " ==============================="
206 # Targets (in order!) called by "make build".
208 .if defined(HAVE_GCC)
209 .if ${HAVE_GCC} == "4"
210 LIBGCC_EXT=4
211 BUILD_CC_LIB_BASEDIR= gnu/lib
212 BUILD_CC_LIB_BASETARGET= gnu-lib
213 .else
214 LIBGCC_EXT=
215 BUILD_CC_LIB_BASEDIR= external/gpl3/gcc/lib
216 BUILD_CC_LIB_BASETARGET= external-gpl3-gcc-lib
217 .endif
218 .endif
220 BUILDTARGETS+= check-tools
221 .if ${MKUPDATE} == "no" && !defined(NOCLEANDIR)
222 BUILDTARGETS+= cleandir
223 .endif
224 .if ${MKOBJDIRS} != "no"
225 BUILDTARGETS+= do-top-obj
226 .endif
227 .if ${USETOOLS} == "yes" # {
228 .if ${MKOBJDIRS} != "no"
229 BUILDTARGETS+= do-tools-obj
230 .endif
231 BUILDTARGETS+= do-tools
232 .endif # USETOOLS # }
233 .if ${MKOBJDIRS} != "no"
234 BUILDTARGETS+= obj
235 .endif
236 BUILDTARGETS+= clean_METALOG
237 .if !defined(NODISTRIBDIRS)
238 BUILDTARGETS+= do-distrib-dirs
239 .endif
240 .if !defined(NOINCLUDES)
241 BUILDTARGETS+= includes
242 .endif
243 BUILDTARGETS+= do-lib
244 .if !defined(__MINIX)
245 # LSC Not used in MINIX3
246 BUILDTARGETS+= do-compat-lib
247 .endif # !defined(__MINIX)
248 BUILDTARGETS+= do-build
249 .if ${MKX11} != "no"
250 BUILDTARGETS+= do-x11
251 .endif
252 .if ${MKEXTSRC} != "no"
253 BUILDTARGETS+= do-extsrc
254 .endif
255 BUILDTARGETS+= do-obsolete
258 # Enforce proper ordering of some rules.
261 .ORDER: ${BUILDTARGETS}
262 includes-lib: .PHONY includes-include includes-sys
263 includes-gnu: .PHONY includes-lib
266 # Build the system and install into DESTDIR.
269 START_TIME!= date
271 .if defined(__MINIX)
272 world: build .PHONY .MAKE
273 ${MAKEDIRTARGET} . etcfiles
274 @echo "WARNING: "
275 @echo "WARNING: The 'world' target is obsolete, please use 'build' instead."
276 @echo "WARNING: "
278 etcfiles: .PHONY .MAKE
279 ${MAKEDIRTARGET} etc install-etc-files-safe DESTDIR=${DESTDIR:U/}
281 etcforce: .PHONY .MAKE
282 ${MAKEDIRTARGET} etc install-etc-files DESTDIR=${DESTDIR:U/}
284 .endif # defined(__MINIX)
286 build: .PHONY .MAKE
287 .if defined(BUILD_DONE)
288 @echo "Build already installed into ${DESTDIR}"
289 .else
290 @echo "Build started at: ${START_TIME}"
291 .for tgt in ${BUILDTARGETS}
292 ${MAKEDIRTARGET} . ${tgt}
293 .endfor
294 ${MAKEDIRTARGET} etc install-etc-release
295 .if defined(__MINIX)
296 ${MAKEDIRTARGET} releasetools do-hdboot
297 .endif # defined(__MINIX)
298 @echo "Build started at: ${START_TIME}"
299 @printf "Build finished at: " && date
300 .endif
303 # Build a full distribution, but not a release (i.e. no sets into
304 # ${RELEASEDIR}). "buildworld" enforces a build to ${DESTDIR} != /
307 distribution buildworld: .PHONY .MAKE
308 .if make(buildworld) && \
309 (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
310 @echo "Won't make ${.TARGET} with DESTDIR=/"
311 @false
312 .endif
313 ${MAKEDIRTARGET} . build NOPOSTINSTALL=1
314 ${MAKEDIRTARGET} etc distribution INSTALL_DONE=1
315 .if defined(DESTDIR) && ${DESTDIR} != "" && ${DESTDIR} != "/" && ${CHECKFLIST:Uyes} == "yes"
316 ${MAKEDIRTARGET} . postinstall-fix-obsolete
317 ${MAKEDIRTARGET} distrib/sets checkflist
318 .endif
319 @echo "make ${.TARGET} started at: ${START_TIME}"
320 @printf "make ${.TARGET} finished at: " && date
323 # Install the distribution from $DESTDIR to $INSTALLWORLDDIR (defaults to `/')
324 # If installing to /, ensures that the host's operating system is NetBSD and
325 # the host's `uname -m` == ${MACHINE}.
328 HOST_UNAME_S!= uname -s
329 .if ${HOST_OSTYPE:C/\-.*//} != "Minix"
330 HOST_UNAME_M!= uname -m
331 .else
332 HOST_UNAME_M:= ${MACHINE}
333 .endif
335 installworld: .PHONY .MAKE
336 .if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
337 @echo "Can't make ${.TARGET} to DESTDIR=/"
338 @false
339 .endif
340 .if !defined(INSTALLWORLDDIR) || \
341 ${INSTALLWORLDDIR} == "" || ${INSTALLWORLDDIR} == "/"
342 .if (${HOST_UNAME_S} != "Minix")
343 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to Minix with INSTALLWORLDDIR=/"
344 @false
345 .endif
346 .if (${HOST_UNAME_M} != ${MACHINE})
347 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLWORLDDIR=/"
348 @false
349 .endif
350 .endif
351 ${MAKEDIRTARGET} distrib/sets installsets \
352 INSTALLDIR=${INSTALLWORLDDIR:U/} INSTALLSETS=${INSTALLSETS:Q}
353 ${MAKEDIRTARGET} . postinstall-check DESTDIR=${INSTALLWORLDDIR}
354 @echo "make ${.TARGET} started at: ${START_TIME}"
355 @printf "make ${.TARGET} finished at: " && date
358 # Install modules from $DESTDIR to $INSTALLMODULESDIR
360 installmodules: .PHONY .MAKE
361 .if (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
362 @echo "Can't make ${.TARGET} to DESTDIR=/"
363 @false
364 .endif
365 .if !defined(INSTALLMODULESDIR) || \
366 ${INSTALLMODULESDIR} == "" || ${INSTALLMODULESDIR} == "/"
367 .if (${HOST_UNAME_S} != "NetBSD")
368 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_S} to NetBSD with INSTALLMODULESDIR=/"
369 @false
370 .endif
371 .if (${HOST_UNAME_M} != ${MACHINE})
372 @echo "Won't cross-make ${.TARGET} from ${HOST_UNAME_M} to ${MACHINE} with INSTALLMODULESDIR=/"
373 @false
374 .endif
375 .endif
376 ${MAKEDIRTARGET} sys/modules install DESTDIR=${INSTALLMODULESDIR:U/}
377 @echo "make ${.TARGET} started at: ${START_TIME}"
378 @printf "make ${.TARGET} finished at: " && date
381 # Create sets from $DESTDIR or $NETBSDSRCDIR into $RELEASEDIR
384 .for tgt in sets sourcesets syspkgs
385 ${tgt}: .PHONY .MAKE
386 ${MAKEDIRTARGET} distrib/sets ${tgt}
387 .endfor
390 # Build a release or snapshot (implies "make distribution"). Note that
391 # in this case, the set lists will be checked before the tar files
392 # are made.
395 release snapshot: .PHONY .MAKE
396 ${MAKEDIRTARGET} . distribution
397 ${MAKEDIRTARGET} etc release DISTRIBUTION_DONE=1
398 @echo "make ${.TARGET} started at: ${START_TIME}"
399 @printf "make ${.TARGET} finished at: " && date
402 # Create a CD-ROM image.
405 iso-image: .PHONY
406 ${MAKEDIRTARGET} distrib iso_image
407 ${MAKEDIRTARGET} etc iso-image
408 @echo "make ${.TARGET} started at: ${START_TIME}"
409 @printf "make ${.TARGET} finished at: " && date
411 iso-image-source: .PHONY
412 ${MAKEDIRTARGET} distrib iso_image CDSOURCE=true
413 ${MAKEDIRTARGET} etc iso-image
414 @echo "make ${.TARGET} started at: ${START_TIME}"
415 @printf "make ${.TARGET} finished at: " && date
418 # Create bootable live images.
421 live-image: .PHONY
422 ${MAKEDIRTARGET} etc live-image
423 @echo "make ${.TARGET} started at: ${START_TIME}"
424 @printf "make ${.TARGET} finished at: " && date
427 # Create bootable installation images.
430 install-image: .PHONY
431 ${MAKEDIRTARGET} etc install-image
432 @echo "make ${.TARGET} started at: ${START_TIME}"
433 @printf "make ${.TARGET} finished at: " && date
436 # Special components of the "make build" process.
439 check-tools: .PHONY
440 .if ${TOOLCHAIN_MISSING} != "no" && !defined(EXTERNAL_TOOLCHAIN)
441 @echo '*** WARNING: Building on MACHINE=${MACHINE} with missing toolchain.'
442 @echo '*** May result in a failed build or corrupt binaries!'
443 .elif defined(EXTERNAL_TOOLCHAIN)
444 @echo '*** Using external toolchain rooted at ${EXTERNAL_TOOLCHAIN}.'
445 .endif
446 .if defined(NBUILDJOBS)
447 @echo '*** WARNING: NBUILDJOBS is obsolete; use -j directly instead!'
448 .endif
450 # Delete or sanitise a leftover METALOG from a previous build.
451 clean_METALOG: .PHONY .MAKE
452 .if ${MKUPDATE} != "no"
453 ${MAKEDIRTARGET} distrib/sets clean_METALOG
454 .endif
456 do-distrib-dirs: .PHONY .MAKE
457 .if !defined(DESTDIR) || ${DESTDIR} == ""
458 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=/
459 .else
460 ${MAKEDIRTARGET} etc distrib-dirs DESTDIR=${DESTDIR}
461 .endif
463 .for targ in cleandir obj includes
464 do-${targ}: .PHONY ${targ}
465 @true
466 .endfor
468 .for dir in tools tools/compat
469 do-${dir:S/\//-/g}: .PHONY .MAKE
470 .for targ in dependall install
471 ${MAKEDIRTARGET} ${dir} ${targ}
472 .endfor
473 .endfor
475 do-lib: .PHONY .MAKE
476 ${MAKEDIRTARGET} lib build_install
478 do-compat-lib: .PHONY .MAKE
479 ${MAKEDIRTARGET} compat build_install BOOTSTRAP_SUBDIRS="../../../lib"
481 do-top-obj: .PHONY .MAKE
482 ${MAKEDIRTARGET} . obj NOSUBDIR=
484 do-tools-obj: .PHONY .MAKE
485 ${MAKEDIRTARGET} tools obj
487 do-build: .PHONY .MAKE
488 .for targ in dependall install
489 ${MAKEDIRTARGET} . ${targ} BUILD_tools=no BUILD_lib=no
490 .endfor
492 do-x11: .PHONY .MAKE
493 .if ${MKX11} != "no"
494 .if ${X11FLAVOUR} == "Xorg"
495 ${MAKEDIRTARGET} external/mit/xorg build
496 .else
497 ${MAKEDIRTARGET} x11 build
498 .endif
499 .else
500 @echo "MKX11 is not enabled"
501 @false
502 .endif
504 do-extsrc: .PHONY .MAKE
505 .if ${MKEXTSRC} != "no"
506 ${MAKEDIRTARGET} extsrc build
507 .else
508 @echo "MKEXTSRC is not enabled"
509 @false
510 .endif
512 do-obsolete: .PHONY .MAKE
513 ${MAKEDIRTARGET} etc install-obsolete-lists
516 # Speedup stubs for some subtrees that don't need to run these rules.
517 # (Tells <bsd.subdir.mk> not to recurse for them.)
520 .for dir in bin etc distrib games libexec regress sbin usr.bin usr.sbin tools
521 includes-${dir}: .PHONY
522 @true
523 .endfor
524 .for dir in etc distrib regress
525 install-${dir}: .PHONY
526 @true
527 .endfor
530 # XXX this needs to change when distrib Makefiles are recursion compliant
531 # XXX many distrib subdirs need "cd etc && make snap_pre snap_kern" first...
533 dependall-distrib depend-distrib all-distrib: .PHONY
534 @true
536 .include <bsd.sys.mk>
537 .include <bsd.obj.mk>
538 .include <bsd.kernobj.mk>
539 .include <bsd.subdir.mk>
542 # Display current make(1) parameters
544 params: .PHONY .MAKE
545 ${MAKEDIRTARGET} etc params