BUILDING revision 1.70 1 BUILDING(8) NetBSD System Manager's Manual BUILDING(8)
2
3 NAME
4 BUILDING -- Procedure for building NetBSD from source code.
5
6 REQUIREMENTS
7 NetBSD is designed to be buildable on most POSIX-compliant host systems.
8 The basic build procedure is the same whether compiling natively (on the
9 same NetBSD architecture) or cross compiling (on another architecture or
10 OS).
11
12 This source tree contains a special subtree, ``tools'', which uses the
13 host system to create a build toolchain for the target architecture. The
14 host system must have at least C and C++ compilers in order to create the
15 toolchain (make is not required); all other tools are created as part of
16 the NetBSD build process. (See the environment variables section below
17 if you need to override or manually select your compilers.)
18
19 FILES
20 Source tree layout
21 doc/BUILDING.mdoc
22 This document (in -mdoc troff format; the original copy).
23
24 BUILDING This document (in plaintext).
25
26 tools/compat/README
27 Special notes for cross-hosting a NetBSD build on non-
28 NetBSD platforms.
29
30 Makefile The main Makefile for NetBSD; should only be run for
31 native builds with an appropriately up-to-date version of
32 NetBSD make(1). (For building from out-of-date systems or
33 on a non-native host, see the build.sh shell script.)
34
35 UPDATING Special notes for updating from an earlier revision of
36 NetBSD. It is important to read this file before every
37 build of an updated source tree.
38
39 build.sh Bourne-compatible shell script used for building the host
40 build tools and the NetBSD system from scratch. Can be
41 used for both native and cross builds, and should be used
42 instead of make(1) for any source tree that is updated and
43 recompiled regularly.
44
45 crypto/dist/, dist/, gnu/dist/
46 Sources imported verbatim from third parties, without man-
47 gling the existing build structure. Other source trees in
48 bin through usr.sbin use the NetBSD make(1) ``reachover''
49 Makefile semantics when building these programs for a
50 native host.
51
52 distrib/, etc/
53 Sources for items used when making a full release snap-
54 shot, such as files installed in DESTDIR/etc on the desti-
55 nation system, boot media, and release notes.
56
57 tests/, regress/
58 Regression test harness. Can be cross-compiled, but only
59 run natively. tests/ uses the atf(7) test framework;
60 regress/ contains older tests that have not yet been
61 migrated to atf(7).
62
63 sys/ NetBSD kernel sources.
64
65 tools/ ``Reachover'' build structure for the host build tools.
66 This has a special method of determining out-of-date sta-
67 tus.
68
69 bin/ ... usr.sbin/
70 Sources to the NetBSD userland (non-kernel) programs. If
71 any of these directories are missing, they will be skipped
72 during the build.
73
74 x11/ ``Reachover'' build structure for X11R6; the source is in
75 X11SRCDIR.
76
77 Build tree layout
78 The NetBSD build tree is described in hier(7), and the release layout is
79 described in release(7).
80
81 CONFIGURATION
82 Environment variables
83 Several environment variables control the behaviour of NetBSD builds.
84
85 HOST_SH Path name to a POSIX-compliant shell. If this is not
86 set explicitly, then the default is set using heuris-
87 tics dependent on the host platform, or from the shell
88 under which build.sh is executed (if that can be deter-
89 mined), or using the first copy of sh found in PATH.
90 If the host system's /bin/sh is not POSIX-compliant, we
91 suggest that you build using commands like
92
93 HOST_SH=/path/to/working/shell
94 export HOST_SH
95 ${HOST_SH} build.sh [options]
96
97 HOST_CC Path name to C compiler used to create the toolchain.
98
99 HOST_CXX Path name to C++ compiler used to create the toolchain.
100
101 MACHINE Machine type, e.g., ``macppc''.
102
103 MACHINE_ARCH Machine architecture, e.g., ``powerpc''.
104
105 MAKE Path name to invoke make(1) as.
106
107 MAKEFLAGS Flags to invoke make(1) with.
108
109 MAKEOBJDIR Directory to use as the .OBJDIR for the current direc-
110 tory. The value is subjected to variable expansion by
111 make(1). Used only if MAKEOBJDIRPREFIX is not defined.
112 MAKEOBJDIR can only be provided in the environment or
113 via the -O flag of build.sh.
114
115 MAKEOBJDIRPREFIX Top level directory of the object directory tree. If
116 specified, must be an absolute path. If this is
117 defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the
118 .OBJDIR for the current directory. The current direc-
119 tory may be read only. MAKEOBJDIRPREFIX can only be
120 provided in the environment or via the -M flag of
121 build.sh.
122
123 "make" variables
124 Several variables control the behavior of NetBSD builds. Unless other-
125 wise specified, these variables may be set in either the process environ-
126 ment or the make(1) configuration file specified by MAKECONF.
127
128 BUILDID Identifier for the build. The identifier will be appended to
129 object directory names, and can be consulted in the make(1)
130 configuration file in order to set additional build parame-
131 ters, such as compiler flags.
132
133 DESTDIR Directory to contain the built NetBSD system. If set, spe-
134 cial options are passed to the compilation tools to prevent
135 their default use of the host system's /usr/include,
136 /usr/lib, and so forth. This pathname must be an absolute
137 path, and should not end with a slash (/) character. (For
138 installation into the system's root directory, set DESTDIR to
139 an empty string, not to ``/''). The directory must reside on
140 a file system which supports long file names and hard links.
141
142 Default: Empty string if USETOOLS is ``yes''; unset other-
143 wise.
144
145 Note: build.sh will provide a default of destdir.MACHINE (in
146 the top-level .OBJDIR) unless run in `expert' mode.
147
148 MAKECONF The name of the make(1) configuration file. Only settable in
149 the process environment.
150
151 Default: ``/etc/mk.conf''
152
153 MAKEVERBOSE
154 Level of verbosity of status messages. Supported values:
155
156 0 No descriptive messages are shown.
157
158 1 Descriptive messages are shown.
159
160 2 Descriptive messages (prefixed with a `#') and command
161 output is not suppressed.
162
163 Default: 2
164
165 MKCATPAGES Can be set to ``yes'' or ``no''. Indicates whether prefor-
166 matted plaintext manual pages will be created during a build.
167
168 Default: ``yes''
169
170 MKCRYPTO Can be set to ``yes'' or ``no''. Indicates whether crypto-
171 graphic code will be included in a build; provided for the
172 benefit of countries that do not allow strong cryptography.
173 Will not affect use of the standard low-security password
174 encryption system, crypt(3).
175
176 Default: ``yes''
177
178 MKDOC Can be set to ``yes'' or ``no''. Indicates whether system
179 documentation destined for DESTDIR/usr/share/doc will be
180 installed during a build.
181
182 Default: ``yes''
183
184 MKHOSTOBJ Can be set to ``yes'' or ``no''. If set to ``yes'', then for
185 programs intended to be run on the compile host, the name,
186 release, and architecture of the host operating system will
187 be suffixed to the name of the object directory created by
188 ``make obj''. (This allows multiple host systems to compile
189 NetBSD for a single target.) If set to ``no'', then programs
190 built to be run on the compile host will use the same object
191 directory names as programs built to be run on the target.
192
193 Default: ``no''
194
195 MKINFO Can be set to ``yes'' or ``no''. Indicates whether GNU Info
196 files, used for the documentation for most of the compilation
197 tools, will be created and installed during a build.
198
199 Default: ``yes''
200
201 MKLINT Can be set to ``yes'' or ``no''. Indicates whether lint(1)
202 will be run against portions of the NetBSD source code during
203 the build, and whether lint libraries will be installed into
204 DESTDIR/usr/libdata/lint.
205
206 Default: ``yes''
207
208 MKMAN Can be set to ``yes'' or ``no''. Indicates whether manual
209 pages will be installed during a build.
210
211 Default: ``yes''
212
213 MKNLS Can be set to ``yes'' or ``no''. Indicates whether Native
214 Language System locale zone files will be compiled and
215 installed during a build.
216
217 Default: ``yes''
218
219 MKOBJ Can be set to ``yes'' or ``no''. Indicates whether object
220 directories will be created when running ``make obj''. If
221 set to ``no'', then all built files will be located inside
222 the regular source tree.
223
224 Default: ``yes''
225
226 Note that setting MKOBJ to ``no'' is not recommended and may
227 cause problems when updating the tree with cvs(1).
228
229 MKPIC Can be set to ``yes'' or ``no''. Indicates whether shared
230 objects and libraries will be created and installed during a
231 build. If set to ``no'', the entire built system will be
232 statically linked.
233
234 Default: Platform dependent. As of this writing, all plat-
235 forms except sh3 default to ``yes''.
236
237 MKPICINSTALL
238 Can be set to ``yes'' or ``no''. Indicates whether the ar(1)
239 format libraries (lib*_pic.a), used to generate shared
240 libraries, are installed during a build.
241
242 Default: ``yes''
243
244 MKPROFILE Can be set to ``yes'' or ``no''. Indicates whether profiled
245 libraries (lib*_p.a) will be built and installed during a
246 build.
247
248 Default: ``yes''; however, some platforms turn off MKPROFILE
249 by default at times due to toolchain problems with profiled
250 code.
251
252 MKSHARE Can be set to ``yes'' or ``no''. Indicates whether files
253 destined to reside in DESTDIR/usr/share will be built and
254 installed during a build. If set to ``no'', then all of
255 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
256 ``no'' unconditionally.
257
258 Default: ``yes''
259
260 MKTTINTERP Can be set to ``yes'' or ``no''. For X builds, decides if
261 the TrueType bytecode interpreter is turned on. See
262 http://www.freetype.org/patents.html for details.
263
264 Default: ``no''
265
266 MKUNPRIVED Can be set to ``yes'' or ``no''. Indicates whether an
267 unprivileged install will occur. The user, group, permis-
268 sions, and file flags, will not be set on the installed
269 items; instead the information will be appended to a file
270 called METALOG in DESTDIR. The contents of METALOG are used
271 during the generation of the distribution tar files to ensure
272 that the appropriate file ownership is stored.
273
274 Default: ``no''
275
276 MKUPDATE Can be set to ``yes'' or ``no''. Indicates whether all
277 install operations intended to write to DESTDIR will compare
278 file timestamps before installing, and skip the install phase
279 if the destination files are up-to-date. This also has
280 implications on full builds (see next subsection).
281
282 Default: ``no''
283
284 MKX11 Can be set to ``yes'' or ``no''. Indicates whether X11R6 is
285 built from X11SRCDIR.
286
287 Default: ``no''
288
289 TOOLDIR Directory to hold the host tools, once built. If specified,
290 must be an absolute path. This directory should be unique to
291 a given host system and NetBSD source tree. (However, multi-
292 ple targets may share the same TOOLDIR; the target-dependent
293 files have unique names.) If unset, a default based on the
294 uname(1) information of the host platform will be created in
295 the .OBJDIR of src.
296
297 Default: Unset.
298
299 USETOOLS Indicates whether the tools specified by TOOLDIR should be
300 used as part of a build in progress. Must be set to ``yes''
301 if cross-compiling.
302
303 yes Use the tools from TOOLDIR.
304
305 no Do not use the tools from TOOLDIR, but refuse to build
306 native compilation tool components that are version-
307 specific for that tool.
308
309 never Do not use the tools from TOOLDIR, even when building
310 native tool components. This is similar to the tradi-
311 tional NetBSD build method, but does not verify that
312 the compilation tools in use are up-to-date enough in
313 order to build the tree successfully. This may cause
314 build or runtime problems when building the whole
315 NetBSD source tree.
316
317 Default: ``yes''
318
319 X11SRCDIR Directory containing the X11R6 source. If specified, must be
320 an absolute path. The main X11R6 source is found in
321 X11SRCDIR/xfree/xc.
322
323 Default: ``/usr/xsrc''
324
325 "make" variables for full builds
326 These variables only affect the top level ``Makefile'' and do not affect
327 manually building subtrees of the NetBSD source code.
328
329 INSTALLWORLDDIR Location for the ``make installworld'' target to install
330 to. If specified, must be an absolute path.
331
332 Default: ``/''
333
334 MKOBJDIRS Can be set to ``yes'' or ``no''. Indicates whether
335 object directories will be created automatically (via a
336 ``make obj'' pass) at the start of a build.
337
338 Default: ``no''
339
340 If using build.sh, the default is ``yes''. This may be
341 set back to ``no'' by giving build.sh the -o option.
342
343 MKUPDATE Can be set to ``yes'' or ``no''. If set, then in addi-
344 tion to the effects described for MKUPDATE=yes above,
345 this implies the effects of NOCLEANDIR (i.e., ``make
346 cleandir'' is avoided).
347
348 Default: ``no''
349
350 If using build.sh, this may be set by giving the -u
351 option.
352
353 NBUILDJOBS Now obsolete. Use the make(1) option -j, instead. See
354 below.
355
356 Default: Unset.
357
358 NOCLEANDIR If set, avoids the ``make cleandir'' phase of a full
359 build. This has the effect of allowing only changed
360 files in a source tree to be recompiled. This can speed
361 up builds when updating only a few files in the tree.
362
363 Default: Unset.
364
365 See also MKUPDATE.
366
367 NODISTRIBDIRS If set, avoids the ``make distrib-dirs'' phase of a full
368 build. This skips running mtree(8) on DESTDIR, useful
369 on systems where building as an unprivileged user, or
370 where it is known that the system-wide mtree files have
371 not changed.
372
373 Default: Unset.
374
375 NOINCLUDES If set, avoids the ``make includes'' phase of a full
376 build. This has the effect of preventing make(1) from
377 thinking that some programs are out-of-date simply
378 because the system include files have changed. However,
379 this option should not be used when updating the entire
380 NetBSD source tree arbitrarily; it is suggested to use
381 MKUPDATE=yes instead in that case.
382
383 Default: Unset.
384
385 RELEASEDIR If set, specifies the directory to which a release(7)
386 layout will be written at the end of a ``make release''.
387 If specified, must be an absolute path.
388
389 Default: Unset.
390
391 Note: build.sh will provide a default of releasedir (in
392 the top-level .OBJDIR) unless run in `expert' mode.
393
394 BUILDING
395 "make" command line options
396 This is not a summary of all the options available to make(1); only the
397 options used most frequently with NetBSD builds are listed here.
398
399 -j njob Run up to njob make(1) subjobs in parallel. Makefiles should
400 use .WAIT or have explicit dependencies as necessary to
401 enforce build ordering. If you see build failures with -j,
402 please save complete build logs so the failures can be ana-
403 lyzed.
404
405 -m dir Specify the default directory for searching for system Make-
406 file segments, mainly the <bsd.*.mk> files. When building any
407 full NetBSD source tree, this should be set to the
408 ``share/mk'' directory in the source tree. This is set auto-
409 matically when building from the top level, or when using
410 build.sh.
411
412 -n Display the commands that would have been executed, but do not
413 actually execute them. This will still cause recursion to
414 take place.
415
416 -V var Print make(1)'s idea of the value of var. Does not build any
417 targets.
418
419 var=value Set the variable var to value, overriding any setting speci-
420 fied by the process environment, the MAKECONF configuration
421 file, or the system Makefile segments.
422
423 "make" targets
424 These default targets may be built by running make(1) in any subtree of
425 the NetBSD source code. It is recommended that none of these be used
426 from the top level Makefile; as a specific exception, ``make obj'' and
427 ``make cleandir'' are useful in that context.
428
429 all Build programs, libraries, and preformatted documentation.
430
431 clean Remove program and library object code files.
432
433 cleandir Same as clean, but also remove preformatted documentation,
434 dependency files generated by ``make depend'', and any other
435 files known to be created at build time.
436
437 depend Create dependency files (.depend) containing more detailed
438 information about the dependencies of source code on header
439 files. Allows programs to be recompiled automatically when a
440 dependency changes.
441
442 dependall Does a ``make depend'' immediately followed by a ``make all''.
443 This improves cache locality of the build since both passes
444 read the source files in their entirety.
445
446 distclean Synonym for cleandir.
447
448 includes Build and install system header files. Typically needed
449 before any system libraries or programs can be built.
450
451 install Install programs, libraries, and documentation into DESTDIR.
452 Few files will be installed to DESTDIR/dev, DESTDIR/etc,
453 DESTDIR/root or DESTDIR/var in order to prevent user supplied
454 configuration data from being overwritten.
455
456 lint Run lint(1) against the C source code, where appropriate, and
457 generate system-installed lint libraries.
458
459 obj Create object directories to be used for built files, instead
460 of building directly in the source tree.
461
462 tags Create ctags(1) searchable function lists usable by the ex(1)
463 and vi(1) text editors.
464
465 "make" targets for the top level
466 Additional make(1) targets are usable specifically from the top source
467 level to facilitate building the entire NetBSD source tree.
468
469 build Build the entire NetBSD system (except the kernel). This
470 orders portions of the source tree such that prerequisites
471 will be built in the proper order.
472
473 distribution Do a ``make build'', and then install a full distribution
474 (which does not include a kernel) into DESTDIR, including
475 files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
476 DESTDIR/var.
477
478 buildworld As per ``make distribution'', except that it ensures that
479 DESTDIR is not the root directory.
480
481 installworld Install the distribution from DESTDIR to INSTALLWORLDDIR,
482 which defaults to the root directory. Ensures that
483 INSTALLWORLDDIR is not the root directory if cross compil-
484 ing.
485
486 The INSTALLSETS environment variable may be set to a list
487 of distribution sets to be installed. By default, all sets
488 except ``etc'' and ``xetc'' are installed, so most files in
489 INSTALLWORLDDIR/etc will not be installed or modified.
490
491 Note: Before performing this operation with
492 INSTALLWORLDDIR=/, it is highly recommended that you
493 upgrade your kernel and reboot. After performing this
494 operation, it is recommended that you use etcupdate(8) to
495 update files in INSTALLWORLDDIR/etc and that you use
496 postinstall(8) to check for inconsistencies (and possibly
497 to fix them).
498
499 sets Create distribution sets from DESTDIR into
500 RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run
501 after ``make distribution'', as ``make build'' alone does
502 not install all of the required files.
503
504 sourcesets Create source sets of the source tree into
505 RELEASEDIR/source/sets.
506
507 syspkgs Create syspkgs from DESTDIR into
508 RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run
509 after ``make distribution'', as ``make build'' alone does
510 not install all of the required files.
511
512 release Do a ``make distribution'', build kernels, distribution
513 media, and install sets (this as per ``make sets''), and
514 then package the system into a standard release layout as
515 described by release(7). This requires that RELEASEDIR be
516 set (see above).
517
518 iso-image Create a NetBSD installation CD-ROM image in the
519 RELEASEDIR/iso directory. The CD-ROM file system will have
520 a layout as described in release(7).
521
522 For most machine types, the CD-ROM will be bootable, and
523 will automatically run the sysinst(8) menu-based installa-
524 tion program, which can be used to install or upgrade a
525 NetBSD system. Bootable CD-ROMs also contain tools that
526 may be useful in repairing a damaged NetBSD installation.
527
528 Before ``make iso-image'' is attempted, RELEASEDIR must be
529 populated by ``make release'' or equivalent.
530
531 Note that other, smaller, CD-ROM images may be created in
532 the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
533 tory by ``make release''. These smaller images usually
534 contain the same tools as the larger images in
535 RELEASEDIR/iso, but do not contain additional content such
536 as the distribution sets.
537
538 Note that the mac68k port still uses an older method of
539 creating CD-ROM images. This requires the mkisofs(1) util-
540 ity, which is not part of NetBSD, but which can be
541 installed from pkgsrc/sysutils/cdrtools.
542
543 iso-image-source
544 Create a NetBSD installation CD-ROM image in the
545 RELEASEDIR/iso directory. The CD-ROM file system will have
546 a layout as described in release(7). It will have top
547 level directories for the machine type and source.
548
549 For most machine types, the CD-ROM will be bootable, and
550 will automatically run the sysinst(8) menu-based installa-
551 tion program, which can be used to install or upgrade a
552 NetBSD system. Bootable CD-ROMs also contain tools that
553 may be useful in repairing a damaged NetBSD installation.
554
555 Before ``make iso-image-source'' is attempted, RELEASEDIR
556 must be populated by ``make sourcesets release'' or equiva-
557 lent.
558
559 Note that other, smaller, CD-ROM images may be created in
560 the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
561 tory by ``make release''. These smaller images usually
562 contain the same tools as the larger images in
563 RELEASEDIR/iso, but do not contain additional content such
564 as the distribution sets.
565
566 Note that the mac68k port still uses an older method of
567 creating CD-ROM images. This requires the mkisofs(1) util-
568 ity, which is not part of NetBSD, but which can be
569 installed from pkgsrc/sysutils/cdrtools.
570
571 regression-tests
572 Can only be run after building the regression tests in the
573 directory ``regress''. Runs those compiled regression
574 tests on the local host. Note that most tests are now man-
575 aged instead using atf(7); this target should probably run
576 those as well but currently does not.
577
578 The "build.sh" script
579 This script file is a Bourne shell script designed to build the entire
580 NetBSD system on any host with a Bourne shell in /bin/sh, including many
581 that are not POSIX compliant. Note that if a host system's /bin/sh is
582 unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
583 a usable alternative.
584
585 All cross-compile builds, and most native builds, of the entire system
586 should make use of build.sh rather than just running ``make''. This way,
587 the make(1) program will be bootstrapped properly, in case the host sys-
588 tem has an older or incompatible ``make'' program.
589
590 When compiling the entire system via build.sh, many make(1) variables are
591 set for you in order to help encapsulate the build process. In the list
592 of options below, variables that are automatically set by build.sh are
593 noted where applicable.
594
595 The following operations are supported by build.sh:
596
597 build Build the system as per ``make build''. Before the main
598 part of the build commences, this command runs the obj
599 operation (unless the -o option is given), ``make
600 cleandir'' (unless the -u option is given), and the tools
601 operation.
602
603 distribution Build a full distribution as per ``make distribution''.
604 This command first runs the build operation.
605
606 release Build a full release as per ``make release''. This command
607 first runs the distribution operation.
608
609 makewrapper Create the nbmake-MACHINE wrapper. This operation is auto-
610 matically performed for any of the other operations.
611
612 obj Perform ``make obj''.
613
614 tools Build and install the host tools from src/tools. This com-
615 mand will first run ``make obj'' and ``make cleandir'' in
616 the tools subdirectory unless the -o or -u options (respec-
617 tively) are given.
618
619 install=idir Install the contents of DESTDIR to idir, using ``make
620 installworld''. Note that files that are part of the
621 ``etc'' or ``xetc'' sets will not be installed.
622
623 kernel=kconf Build a new kernel. The kconf argument is the name of a
624 configuration file suitable for use by config(1). If kconf
625 does not contain any `/' characters, the configuration file
626 is expected to be found in the KERNCONFDIR directory, which
627 is typically sys/arch/MACHINE/conf. The new kernel will be
628 built in a subdirectory of KERNOBJDIR, which is typically
629 sys/arch/MACHINE/compile or an associated object directory.
630
631 This command does not imply the tools command; run the
632 tools command first unless it is certain that the tools
633 already exist and are up to date.
634
635 This command will run ``make cleandir'' on the kernel in
636 question first unless the -u option is given.
637
638 releasekernel=kconf
639 Install a gzip(1)ed copy of the kernel previously built by
640 kernel=kconf into
641 RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
642 netbsd-kconf.gz, although the ``netbsd'' prefix is deter-
643 mined from the ``config'' directives in kconf.
644
645 sets Perform ``make sets''.
646
647 sourcesets Perform ``make sourcesets''.
648
649 syspkgs Perform ``make syspkgs''.
650
651 iso-image Perform ``make iso-image''.
652
653 iso-image-source
654 Perform ``make iso-image-source''.
655
656 The following command line options alter the behaviour of the build.sh
657 operations described above:
658
659 -a arch Set the value of MACHINE_ARCH to arch.
660
661 -B buildid
662 Set the value of BUILDID to buildid. This will also append the
663 build identifier to the name of the ``make'' wrapper script so
664 that the resulting name is of the form
665 ``nbmake-MACHINE-BUILDID''.
666
667 -C cdextras
668 Set the value of CDEXTRA to cdextras which is a space-separated
669 list of files or directories which will be added in order to
670 the CD-ROM image when used in conjunction with ``iso-image'' or
671 ``iso-image-source''. Files will be added to the root of the
672 CD-ROM image, whereas directories will be copied recursively.
673 If relative paths are specified, they will be converted to
674 absolute paths before being used.
675
676 -D dest Set the value of DESTDIR to dest. If a relative path is speci-
677 fied, it will be converted to an absolute path before being
678 used.
679
680 -E Set `expert' mode. This overrides various sanity checks, and
681 allows: DESTDIR does not have to be set to a non-root path for
682 builds, and MKUNPRIVED=yes does not have to be set when build-
683 ing as a non-root user.
684
685 Note: It is highly recommended that you know what you are doing
686 when you use this option.
687
688 -h Print a help message.
689
690 -j njob Run up to njob make(1) subjobs in parallel; passed through to
691 make(1). Makefiles should use .WAIT or have explicit dependan-
692 cies as necessary to enforce build ordering. If you see build
693 failures with -j, please save complete build logs so the fail-
694 ures can be analyzed.
695
696 -M obj Set MAKEOBJDIRPREFIX to obj. If a relative path is specified,
697 it will be converted to an absolute path before being used.
698 Unsets MAKEOBJDIR.
699
700 -m mach Set the value of MACHINE to mach, except in some special cases
701 listed below. This will also override any value of
702 MACHINE_ARCH in the process environment with a value deduced
703 from mach, unless -a is specified. All cross builds require
704 -m, but if unset on a NetBSD host, the host's value of MACHINE
705 will be detected and used automatically.
706
707 Some machines support multiple values for MACHINE_ARCH. The
708 following special cases for the mach argument are defined to
709 set the listed values of MACHINE and MACHINE_ARCH:
710
711 mach MACHINE MACHINE_ARCH
712 evbarm evbarm (not set)
713 evbarm-eb evbarm armeb
714 evbarm-el evbarm arm
715 evbmips evbmips (not set)
716 evbmips-eb evbmips mipseb
717 evbmips-el evbmips mipsel
718 evbsh3 evbsh3 (not set)
719 evbsh3-eb evbsh3 sh3eb
720 evbsh3-el evbsh3 sh3el
721 sbmips sbmips (not set)
722 sbmips-eb sbmips mipseb
723 sbmips-el sbmips mipsel
724
725 -N noiselevel
726 Set the ``noisyness'' level of the build, by setting
727 MAKEVERBOSE to noiselevel.
728
729 -n Show the commands that would be executed by build.sh, but do
730 not make any changes. This is similar in concept to ``make
731 -n''.
732
733 -O obj Create an appropriate transform macro for MAKEOBJDIR that will
734 place the built object files under obj. If a relative path is
735 specified, it will be converted to an absolute path before
736 being used. For instance, a setting of /usr/obj will place
737 build-time files under /usr/obj/bin, /usr/obj/lib,
738 /usr/obj/usr.bin, and so forth. Unsets MAKEOBJDIRPREFIX.
739
740 -o Set the value of MKOBJDIRS to ``no''. Otherwise, it will be
741 automatically set to ``yes''. This default is opposite to the
742 behaviour when not using build.sh.
743
744 -R rel Set the value of RELEASEDIR to rel. If a relative path is
745 specified, it will be converted to an absolute path before
746 being used.
747
748 -r Remove the contents of DESTDIR and TOOLDIR before building
749 (provides a clean starting point). This will skip deleting
750 DESTDIR if building on a native system to the root directory.
751
752 -T tools Set the value of TOOLDIR to tools. If a relative path is spec-
753 ified, it will be converted to an absolute path before being
754 used. If set, the bootstrap ``make'' will only be rebuilt if
755 the source files for make(1) have changed.
756
757 -U Set MKUNPRIVED=yes.
758
759 -u Set MKUPDATE=yes.
760
761 -V var=[value]
762 Set the environment variable var to an optional value. This is
763 propagated to the nbmake wrapper.
764
765 -w wrapper
766 Create the nbmake wrapper script (see below) in a custom loca-
767 tion, specified by wrapper. This allows, for instance, to
768 place the wrapper in PATH automatically. Note that wrapper is
769 the full name of the file, not just a directory name. If a
770 relative path is specified, it will be converted to an absolute
771 path before being used.
772
773 -X x11src
774 Set the value of X11SRCDIR to x11src. If a relative path is
775 specified, it will be converted to an absolute path before
776 being used.
777
778 -x Set MKX11=yes.
779
780 -Z var Unset ("zap") the environment variable var. This is propagated
781 to the nbmake wrapper.
782
783 The "nbmake-MACHINE" wrapper script
784 If using the build.sh script to build NetBSD, a nbmake-MACHINE script
785 will be created in TOOLDIR/bin upon the first build to assist in building
786 subtrees on a cross-compile host.
787
788 nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
789 the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
790 eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
791 nbmake-MACHINE will also set variables specified with -V, and unset vari-
792 ables specified with -Z.
793
794 This script can be symlinked into a directory listed in PATH, or called
795 with an absolute path.
796
797 EXAMPLES
798 1. % ./build.sh tools kernel=GENERIC
799
800 Build a new toolchain, and use the new toolchain to configure and
801 build a new GENERIC kernel.
802
803 2. % ./build.sh -U distribution
804
805 Using unprivileged mode, build a complete distribution to a DESTDIR
806 directory that build.sh selects (and will display).
807
808 3. # ./build.sh -U install=/
809
810 As root, install to / the distribution that was built by example 2.
811 Even though this is run as root, -U is required so that the permis-
812 sions stored in DESTDIR/METALOG are correctly applied to the files
813 as they're copied to /.
814
815 4. % ./build.sh -U -u release
816
817 Using unprivileged mode, build a complete release to DESTDIR and
818 RELEASEDIR directories that build.sh selects (and will display).
819 MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that
820 if this is run after example 2, it doesn't need to redo that portion
821 of the release build.
822
823 OBSOLETE VARIABLES
824 NBUILDJOBS Use the make(1) option -j instead.
825
826 USE_NEW_TOOLCHAIN
827 The new toolchain is now the default. To disable, use
828 TOOLCHAIN_MISSING=yes.
829
830 SEE ALSO
831 make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8),
832 pkgsrc/sysutils/cdrtools
833
834 HISTORY
835 The build.sh based build scheme was introduced for NetBSD 1.6 as
836 USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
837
838 BUGS
839 A few platforms are not yet using this build system.
840
841 NetBSD March 18, 2008 NetBSD
842