1 BUILDING(8) NetBSD System Manager's Manual BUILDING(8)
4 BUILDING -- Procedure for building NetBSD from source code.
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
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.)
22 This document (in -mdoc troff format; the original copy).
24 BUILDING This document (in plaintext).
27 Special notes for cross-hosting a NetBSD build on non-
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.)
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.
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
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
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.
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
63 sys/ NetBSD kernel sources.
65 tools/ ``Reachover'' build structure for the host build tools.
66 This has a special method of determining out-of-date sta-
70 Sources to the NetBSD userland (non-kernel) programs. If
71 any of these directories are missing, they will be skipped
74 x11/ ``Reachover'' build structure for X11R6; the source is in
78 The NetBSD build tree is described in hier(7), and the release layout is
79 described in release(7).
83 Several environment variables control the behaviour of NetBSD builds.
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
93 HOST_SH=/path/to/working/shell
95 ${HOST_SH} build.sh [options]
97 HOST_CC Path name to C compiler used to create the toolchain.
99 HOST_CXX Path name to C++ compiler used to create the toolchain.
101 MACHINE Machine type, e.g., ``macppc''.
103 MACHINE_ARCH Machine architecture, e.g., ``powerpc''.
105 MAKE Path name to invoke make(1) as.
107 MAKEFLAGS Flags to invoke make(1) with.
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). Typical usage is to set this variable to a
112 value involving the use of `${.CURDIR:S...}' or
113 `${.CURDIR:C...}', to derive the value of .OBJDIR from
114 the value of .CURDIR. Used only if MAKEOBJDIRPREFIX is
115 not defined. MAKEOBJDIR can be provided only in the
116 environment or via the -O flag of build.sh; it cannot
117 usefully be set inside a Makefile, including mk.conf or
120 MAKEOBJDIRPREFIX Top level directory of the object directory tree. If
121 specified, must be an absolute path. If this is
122 defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the
123 .OBJDIR for the current directory. The current direc-
124 tory may be read only. MAKEOBJDIRPREFIX can be pro-
125 vided only in the environment or via the -M flag of
126 build.sh; it cannot usefully be set inside a Makefile,
127 including mk.conf or ${MAKECONF}.
130 Several variables control the behavior of NetBSD builds. Unless other-
131 wise specified, these variables may be set in either the process environ-
132 ment or the make(1) configuration file specified by MAKECONF.
134 BUILDID Identifier for the build. The identifier will be appended to
135 object directory names, and can be consulted in the make(1)
136 configuration file in order to set additional build parame-
137 ters, such as compiler flags.
139 BUILDSEED GCC uses random numbers when compiling C++ code. This vari-
140 able seeds the gcc random number generator using the -fran-
141 dom-seed flag with this value. By default, it is set to
142 NetBSD-(majorversion). Using a fixed value causes C++ bina-
143 ries to be the same when built from the same sources. Addi-
144 tional information is available in the GCC documentation of
147 DESTDIR Directory to contain the built NetBSD system. If set, spe-
148 cial options are passed to the compilation tools to prevent
149 their default use of the host system's /usr/include,
150 /usr/lib, and so forth. This pathname must be an absolute
151 path, and should not end with a slash (/) character. (For
152 installation into the system's root directory, set DESTDIR to
153 an empty string, not to ``/''). The directory must reside on
154 a file system which supports long file names and hard links.
156 Default: Empty string if USETOOLS is ``yes''; unset other-
159 Note: build.sh will provide a default of destdir.MACHINE (in
160 the top-level .OBJDIR) unless run in `expert' mode.
162 MAKECONF The name of the make(1) configuration file. Only settable in
163 the process environment.
165 Default: ``/etc/mk.conf''
168 Level of verbosity of status messages. Supported values:
170 0 No descriptive messages or commands executed by make(1)
173 1 Brief messages are shown describing what is being done,
174 but the actual commands executed by make(1) are not dis-
177 2 Descriptive messages are shown as above (prefixed with a
178 `#'), and ordinary commands performed by make(1) are
181 3 In addition to the above, all commands performed by
182 make(1) are displayed, even if they would ordinarily
183 have been hidden through use of the ``@'' prefix in the
186 4 In addition to the above, commands executed by make(1)
187 are traced through use of the sh(1) ``-x'' flag.
191 MKCATPAGES Can be set to ``yes'' or ``no''. Indicates whether prefor-
192 matted plaintext manual pages will be created during a build.
196 MKCRYPTO Can be set to ``yes'' or ``no''. Indicates whether crypto-
197 graphic code will be included in a build; provided for the
198 benefit of countries that do not allow strong cryptography.
199 Will not affect use of the standard low-security password
200 encryption system, crypt(3).
204 MKDOC Can be set to ``yes'' or ``no''. Indicates whether system
205 documentation destined for DESTDIR/usr/share/doc will be
206 installed during a build.
210 MKHTML Can be set to ``yes'' or ``no''. Indicates whether prefor-
211 matted HTML manual pages will be built and installed
215 MKHOSTOBJ Can be set to ``yes'' or ``no''. If set to ``yes'', then for
216 programs intended to be run on the compile host, the name,
217 release, and architecture of the host operating system will
218 be suffixed to the name of the object directory created by
219 ``make obj''. (This allows multiple host systems to compile
220 NetBSD for a single target.) If set to ``no'', then programs
221 built to be run on the compile host will use the same object
222 directory names as programs built to be run on the target.
226 MKINFO Can be set to ``yes'' or ``no''. Indicates whether GNU Info
227 files, used for the documentation for most of the compilation
228 tools, will be created and installed during a build.
232 MKLINT Can be set to ``yes'' or ``no''. Indicates whether lint(1)
233 will be run against portions of the NetBSD source code during
234 the build, and whether lint libraries will be installed into
235 DESTDIR/usr/libdata/lint.
239 MKMAN Can be set to ``yes'' or ``no''. Indicates whether manual
240 pages will be installed during a build.
244 MKNLS Can be set to ``yes'' or ``no''. Indicates whether Native
245 Language System locale zone files will be compiled and
246 installed during a build.
250 MKOBJ Can be set to ``yes'' or ``no''. Indicates whether object
251 directories will be created when running ``make obj''. If
252 set to ``no'', then all built files will be located inside
253 the regular source tree.
257 Note that setting MKOBJ to ``no'' is not recommended and may
258 cause problems when updating the tree with cvs(1).
260 MKPIC Can be set to ``yes'' or ``no''. Indicates whether shared
261 objects and libraries will be created and installed during a
262 build. If set to ``no'', the entire built system will be
265 Default: Platform dependent. As of this writing, all plat-
266 forms except sh3 default to ``yes''.
269 Can be set to ``yes'' or ``no''. Indicates whether the ar(1)
270 format libraries (lib*_pic.a), used to generate shared
271 libraries, are installed during a build.
275 MKPROFILE Can be set to ``yes'' or ``no''. Indicates whether profiled
276 libraries (lib*_p.a) will be built and installed during a
279 Default: ``yes''; however, some platforms turn off MKPROFILE
280 by default at times due to toolchain problems with profiled
283 MKSHARE Can be set to ``yes'' or ``no''. Indicates whether files
284 destined to reside in DESTDIR/usr/share will be built and
285 installed during a build. If set to ``no'', then all of
286 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
287 ``no'' unconditionally.
292 Can be set to ``yes'' or ``no''. Indicates whether program
293 binaries and shared libraries should be built to include RCS
294 IDs for use with ident(1).
298 MKSUBPIXEL Can be set to ``yes'' or ``no''. For X builds, decides if
299 subpixel rendering code in FreeType is turned on. Turned off
300 by default because of patent issues.
304 MKTTINTERP Can be set to ``yes'' or ``no''. For X builds, decides if
305 the TrueType bytecode interpreter is turned on. See
306 http://www.freetype.org/patents.html for details.
310 MKUNPRIVED Can be set to ``yes'' or ``no''. Indicates whether an
311 unprivileged install will occur. The user, group, permis-
312 sions, and file flags, will not be set on the installed
313 items; instead the information will be appended to a file
314 called METALOG in DESTDIR. The contents of METALOG are used
315 during the generation of the distribution tar files to ensure
316 that the appropriate file ownership is stored.
320 MKUPDATE Can be set to ``yes'' or ``no''. Indicates whether all
321 install operations intended to write to DESTDIR will compare
322 file timestamps before installing, and skip the install phase
323 if the destination files are up-to-date. This also has
324 implications on full builds (see next subsection).
328 MKX11 Can be set to ``yes'' or ``no''. Indicates whether X11 is
329 built from X11SRCDIR.
333 TOOLDIR Directory to hold the host tools, once built. If specified,
334 must be an absolute path. This directory should be unique to
335 a given host system and NetBSD source tree. (However, multi-
336 ple targets may share the same TOOLDIR; the target-dependent
337 files have unique names.) If unset, a default based on the
338 uname(1) information of the host platform will be created in
343 USETOOLS Indicates whether the tools specified by TOOLDIR should be
344 used as part of a build in progress. Must be set to ``yes''
347 yes Use the tools from TOOLDIR.
349 no Do not use the tools from TOOLDIR, but refuse to build
350 native compilation tool components that are version-
351 specific for that tool.
353 never Do not use the tools from TOOLDIR, even when building
354 native tool components. This is similar to the tradi-
355 tional NetBSD build method, but does not verify that
356 the compilation tools in use are up-to-date enough in
357 order to build the tree successfully. This may cause
358 build or runtime problems when building the whole
361 Default: ``yes'', unless TOOLCHAIN_MISSING is set to ``yes''.
363 USETOOLS is also set to ``no'' when using <bsd.*.mk> outside
364 the NetBSD source tree.
366 X11SRCDIR Directory containing the X11R6 source. If specified, must be
367 an absolute path. The main X11R6 source is found in
370 Default: ``/usr/xsrc''
372 X11FLAVOUR The style of X11 cross-built, set to either ``Xorg'' or
375 Default: ``Xorg'' on amd64, i386, macppc, shark and sparc64
376 platforms, ``XFree86'' on everything else.
378 "make" variables for full builds
379 These variables only affect the top level ``Makefile'' and do not affect
380 manually building subtrees of the NetBSD source code.
382 INSTALLWORLDDIR Location for the ``make installworld'' target to install
383 to. If specified, must be an absolute path.
387 MKOBJDIRS Can be set to ``yes'' or ``no''. Indicates whether
388 object directories will be created automatically (via a
389 ``make obj'' pass) at the start of a build.
393 If using build.sh, the default is ``yes''. This may be
394 set back to ``no'' by giving build.sh the -o option.
396 MKUPDATE Can be set to ``yes'' or ``no''. If set, then in addi-
397 tion to the effects described for MKUPDATE=yes above,
398 this implies the effects of NOCLEANDIR (i.e., ``make
399 cleandir'' is avoided).
403 If using build.sh, this may be set by giving the -u
406 NBUILDJOBS Now obsolete. Use the make(1) option -j, instead. See
411 NOCLEANDIR If set, avoids the ``make cleandir'' phase of a full
412 build. This has the effect of allowing only changed
413 files in a source tree to be recompiled. This can speed
414 up builds when updating only a few files in the tree.
420 NODISTRIBDIRS If set, avoids the ``make distrib-dirs'' phase of a full
421 build. This skips running mtree(8) on DESTDIR, useful
422 on systems where building as an unprivileged user, or
423 where it is known that the system-wide mtree files have
428 NOINCLUDES If set, avoids the ``make includes'' phase of a full
429 build. This has the effect of preventing make(1) from
430 thinking that some programs are out-of-date simply
431 because the system include files have changed. However,
432 this option should not be used when updating the entire
433 NetBSD source tree arbitrarily; it is suggested to use
434 MKUPDATE=yes instead in that case.
438 RELEASEDIR If set, specifies the directory to which a release(7)
439 layout will be written at the end of a ``make release''.
440 If specified, must be an absolute path.
444 Note: build.sh will provide a default of releasedir (in
445 the top-level .OBJDIR) unless run in `expert' mode.
448 "make" command line options
449 This is not a summary of all the options available to make(1); only the
450 options used most frequently with NetBSD builds are listed here.
452 -j njob Run up to njob make(1) subjobs in parallel. Makefiles should
453 use .WAIT or have explicit dependencies as necessary to
454 enforce build ordering.
456 -m dir Specify the default directory for searching for system Make-
457 file segments, mainly the <bsd.*.mk> files. When building any
458 full NetBSD source tree, this should be set to the
459 ``share/mk'' directory in the source tree. This is set auto-
460 matically when building from the top level, or when using
463 -n Display the commands that would have been executed, but do not
464 actually execute them. This will still cause recursion to
467 -V var Print make(1)'s idea of the value of var. Does not build any
470 var=value Set the variable var to value, overriding any setting speci-
471 fied by the process environment, the MAKECONF configuration
472 file, or the system Makefile segments.
475 These default targets may be built by running make(1) in any subtree of
476 the NetBSD source code. It is recommended that none of these be used
477 from the top level Makefile; as a specific exception, ``make obj'' and
478 ``make cleandir'' are useful in that context.
480 all Build programs, libraries, and preformatted documentation.
482 clean Remove program and library object code files.
484 cleandir Same as clean, but also remove preformatted documentation,
485 dependency files generated by ``make depend'', and any other
486 files known to be created at build time.
488 depend Create dependency files (.depend) containing more detailed
489 information about the dependencies of source code on header
490 files. Allows programs to be recompiled automatically when a
493 dependall Does a ``make depend'' immediately followed by a ``make all''.
494 This improves cache locality of the build since both passes
495 read the source files in their entirety.
497 distclean Synonym for cleandir.
499 includes Build and install system header files. Typically needed
500 before any system libraries or programs can be built.
502 install Install programs, libraries, and documentation into DESTDIR.
503 Few files will be installed to DESTDIR/dev, DESTDIR/etc,
504 DESTDIR/root or DESTDIR/var in order to prevent user supplied
505 configuration data from being overwritten.
507 lint Run lint(1) against the C source code, where appropriate, and
508 generate system-installed lint libraries.
510 obj Create object directories to be used for built files, instead
511 of building directly in the source tree.
513 tags Create ctags(1) searchable function lists usable by the ex(1)
514 and vi(1) text editors.
516 "make" targets for the top level
517 Additional make(1) targets are usable specifically from the top source
518 level to facilitate building the entire NetBSD source tree.
520 build Build the entire NetBSD system (except the kernel). This
521 orders portions of the source tree such that prerequisites
522 will be built in the proper order.
524 distribution Do a ``make build'', and then install a full distribution
525 (which does not include a kernel) into DESTDIR, including
526 files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
529 buildworld As per ``make distribution'', except that it ensures that
530 DESTDIR is not the root directory.
532 installworld Install the distribution from DESTDIR to INSTALLWORLDDIR,
533 which defaults to the root directory. Ensures that
534 INSTALLWORLDDIR is not the root directory if cross compil-
537 The INSTALLSETS environment variable may be set to a list
538 of distribution sets to be installed. By default, all sets
539 except ``etc'' and ``xetc'' are installed, so most files in
540 INSTALLWORLDDIR/etc will not be installed or modified.
542 Note: Before performing this operation with
543 INSTALLWORLDDIR=/, it is highly recommended that you
544 upgrade your kernel and reboot. After performing this
545 operation, it is recommended that you use etcupdate(8) to
546 update files in INSTALLWORLDDIR/etc and that you use
547 postinstall(8) to check for inconsistencies (and possibly
550 sets Create distribution sets from DESTDIR into
551 RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run
552 after ``make distribution'', as ``make build'' alone does
553 not install all of the required files.
555 sourcesets Create source sets of the source tree into
556 RELEASEDIR/source/sets.
558 syspkgs Create syspkgs from DESTDIR into
559 RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run
560 after ``make distribution'', as ``make build'' alone does
561 not install all of the required files.
563 release Do a ``make distribution'', build kernels, distribution
564 media, and install sets (this as per ``make sets''), and
565 then package the system into a standard release layout as
566 described by release(7). This requires that RELEASEDIR be
569 iso-image Create a NetBSD installation CD-ROM image in the
570 RELEASEDIR/iso directory. The CD-ROM file system will have
571 a layout as described in release(7).
573 For most machine types, the CD-ROM will be bootable, and
574 will automatically run the sysinst(8) menu-based installa-
575 tion program, which can be used to install or upgrade a
576 NetBSD system. Bootable CD-ROMs also contain tools that
577 may be useful in repairing a damaged NetBSD installation.
579 Before ``make iso-image'' is attempted, RELEASEDIR must be
580 populated by ``make release'' or equivalent.
582 Note that other, smaller, CD-ROM images may be created in
583 the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
584 tory by ``make release''. These smaller images usually
585 contain the same tools as the larger images in
586 RELEASEDIR/iso, but do not contain additional content such
587 as the distribution sets.
589 Note that the mac68k port still uses an older method of
590 creating CD-ROM images. This requires the mkisofs(1) util-
591 ity, which is not part of NetBSD, but which can be
592 installed from pkgsrc/sysutils/cdrtools.
595 Create a NetBSD installation CD-ROM image in the
596 RELEASEDIR/iso directory. The CD-ROM file system will have
597 a layout as described in release(7). It will have top
598 level directories for the machine type and source.
600 For most machine types, the CD-ROM will be bootable, and
601 will automatically run the sysinst(8) menu-based installa-
602 tion program, which can be used to install or upgrade a
603 NetBSD system. Bootable CD-ROMs also contain tools that
604 may be useful in repairing a damaged NetBSD installation.
606 Before ``make iso-image-source'' is attempted, RELEASEDIR
607 must be populated by ``make sourcesets release'' or equiva-
610 Note that other, smaller, CD-ROM images may be created in
611 the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
612 tory by ``make release''. These smaller images usually
613 contain the same tools as the larger images in
614 RELEASEDIR/iso, but do not contain additional content such
615 as the distribution sets.
617 Note that the mac68k port still uses an older method of
618 creating CD-ROM images. This requires the mkisofs(1) util-
619 ity, which is not part of NetBSD, but which can be
620 installed from pkgsrc/sysutils/cdrtools.
623 Can only be run after building the regression tests in the
624 directory ``regress''. Runs those compiled regression
625 tests on the local host. Note that most tests are now man-
626 aged instead using atf(7); this target should probably run
627 those as well but currently does not.
629 The "build.sh" script
630 This script file is a Bourne shell script designed to build the entire
631 NetBSD system on any host with a Bourne shell in /bin/sh, including many
632 that are not POSIX compliant. Note that if a host system's /bin/sh is
633 unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
634 a usable alternative.
636 All cross-compile builds, and most native builds, of the entire system
637 should make use of build.sh rather than just running ``make''. This way,
638 the make(1) program will be bootstrapped properly, in case the host sys-
639 tem has an older or incompatible ``make'' program.
641 When compiling the entire system via build.sh, many make(1) variables are
642 set for you in order to help encapsulate the build process. In the list
643 of options below, variables that are automatically set by build.sh are
644 noted where applicable.
646 The following operations are supported by build.sh:
648 build Build the system as per ``make build''. Before the main
649 part of the build commences, this command runs the obj
650 operation (unless the -o option is given), ``make
651 cleandir'' (unless the -u option is given), and the tools
654 distribution Build a full distribution as per ``make distribution''.
655 This command first runs the build operation.
657 release Build a full release as per ``make release''. This command
658 first runs the distribution operation.
660 makewrapper Create the nbmake-MACHINE wrapper. This operation is auto-
661 matically performed for any of the other operations.
663 cleandir Perform ``make cleandir''.
665 obj Perform ``make obj''.
667 tools Build and install the host tools from src/tools. This com-
668 mand will first run ``make obj'' and ``make cleandir'' in
669 the tools subdirectory unless the -o or -u options (respec-
672 install=idir Install the contents of DESTDIR to idir, using ``make
673 installworld''. Note that files that are part of the
674 ``etc'' or ``xetc'' sets will not be installed.
676 kernel=kconf Build a new kernel. The kconf argument is the name of a
677 configuration file suitable for use by config(1). If kconf
678 does not contain any `/' characters, the configuration file
679 is expected to be found in the KERNCONFDIR directory, which
680 is typically sys/arch/MACHINE/conf. The new kernel will be
681 built in a subdirectory of KERNOBJDIR, which is typically
682 sys/arch/MACHINE/compile or an associated object directory.
684 This command does not imply the tools command; run the
685 tools command first unless it is certain that the tools
686 already exist and are up to date.
688 This command will run ``make cleandir'' on the kernel in
689 question first unless the -u option is given.
692 Install a gzip(1)ed copy of the kernel previously built by
694 RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
695 netbsd-kconf.gz, although the ``netbsd'' prefix is deter-
696 mined from the ``config'' directives in kconf.
698 sets Perform ``make sets''.
700 sourcesets Perform ``make sourcesets''.
702 syspkgs Perform ``make syspkgs''.
704 iso-image Perform ``make iso-image''.
707 Perform ``make iso-image-source''.
709 The following command line options alter the behaviour of the build.sh
710 operations described above:
712 -a arch Set the value of MACHINE_ARCH to arch.
715 Set the value of BUILDID to buildid. This will also append the
716 build identifier to the name of the ``make'' wrapper script so
717 that the resulting name is of the form
718 ``nbmake-MACHINE-BUILDID''.
721 Set the value of CDEXTRA to cdextras which is a space-separated
722 list of files or directories which will be added in order to
723 the CD-ROM image when used in conjunction with ``iso-image'' or
724 ``iso-image-source''. Files will be added to the root of the
725 CD-ROM image, whereas directories will be copied recursively.
726 If relative paths are specified, they will be converted to
727 absolute paths before being used.
729 -D dest Set the value of DESTDIR to dest. If a relative path is speci-
730 fied, it will be converted to an absolute path before being
733 -E Set `expert' mode. This overrides various sanity checks, and
734 allows: DESTDIR does not have to be set to a non-root path for
735 builds, and MKUNPRIVED=yes does not have to be set when build-
736 ing as a non-root user.
738 Note: It is highly recommended that you know what you are doing
739 when you use this option.
741 -h Print a help message.
743 -j njob Run up to njob make(1) subjobs in parallel; passed through to
744 make(1). If you see failures for reasons other than running
745 out of memory while using build.sh with -j, please save com-
746 plete build logs so the failures can be analyzed.
748 To achieve the fastest builds, -j values between (1 + the num-
749 ber of CPUs) and (2 * the number of CPUs) are recommended. Use
750 lower values on machines with limited memory or I/O bandwidth.
752 -M obj Set MAKEOBJDIRPREFIX to obj. For instance, if the source
753 directory is /usr/src, a setting of ``-M /usr/obj'' will place
754 build-time files under /usr/obj/usr/src/bin,
755 /usr/obj/usr/src/lib, /usr/obj/usr/src/usr.bin, and so forth.
756 If a relative path is specified, it will be converted to an
757 absolute path before being used. Unsets MAKEOBJDIR. See ``-O
758 -obj'' for more information.
760 -m mach Set the value of MACHINE to mach, except in some special cases
761 listed below. This will also override any value of
762 MACHINE_ARCH in the process environment with a value deduced
763 from mach, unless -a is specified. All cross builds require
764 -m, but if unset on a NetBSD host, the host's value of MACHINE
765 will be detected and used automatically.
767 Some machines support multiple values for MACHINE_ARCH. The
768 following special cases for the mach argument are defined to
769 set the listed values of MACHINE and MACHINE_ARCH:
771 mach MACHINE MACHINE_ARCH
772 evbarm evbarm (not set)
773 evbarm-eb evbarm armeb
775 evbmips evbmips (not set)
776 evbmips-eb evbmips mipseb
777 evbmips-el evbmips mipsel
778 evbsh3 evbsh3 (not set)
779 evbsh3-eb evbsh3 sh3eb
780 evbsh3-el evbsh3 sh3el
781 sbmips sbmips (not set)
782 sbmips-eb sbmips mipseb
783 sbmips-el sbmips mipsel
786 Set the ``noisyness'' level of the build, by setting
787 MAKEVERBOSE to noiselevel.
789 -n Show the commands that would be executed by build.sh, but do
790 not make any changes. This is similar in concept to ``make
793 -O obj Create an appropriate transform macro for MAKEOBJDIR that will
794 place the built object files under obj. For instance, a set-
795 ting of ``-O /usr/obj'' will place build-time files under
796 /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and so forth. If
797 a relative path is specified, it will be converted to an abso-
798 lute path before being used. Unsets MAKEOBJDIRPREFIX.
800 In normal use, exactly one of the -M or -O options should be
801 specified. If neither -M nor -O is specified, then a default
802 object directory will be chosen according to rules in
803 <bsd.obj.mk>. Relying on this default is not recommended
804 because it is determined by complex rules that are influenced
805 by the values of several variables and by the location of the
808 -o Set the value of MKOBJDIRS to ``no''. Otherwise, it will be
809 automatically set to ``yes''. This default is opposite to the
810 behaviour when not using build.sh.
812 -R rel Set the value of RELEASEDIR to rel. If a relative path is
813 specified, it will be converted to an absolute path before
816 -r Remove the contents of DESTDIR and TOOLDIR before building
817 (provides a clean starting point). This will skip deleting
818 DESTDIR if building on a native system to the root directory.
820 -S seed Change the value of BUILDSEED to seed. This should rarely be
823 -T tools Set the value of TOOLDIR to tools. If a relative path is spec-
824 ified, it will be converted to an absolute path before being
825 used. If set, the bootstrap ``make'' will only be rebuilt if
826 the source files for make(1) have changed.
828 -U Set MKUNPRIVED=yes.
833 Set the environment variable var to an optional value. This is
834 propagated to the nbmake wrapper.
837 Create the nbmake wrapper script (see below) in a custom loca-
838 tion, specified by wrapper. This allows, for instance, to
839 place the wrapper in PATH automatically. Note that wrapper is
840 the full name of the file, not just a directory name. If a
841 relative path is specified, it will be converted to an absolute
842 path before being used.
845 Set the value of X11SRCDIR to x11src. If a relative path is
846 specified, it will be converted to an absolute path before
851 -Z var Unset ("zap") the environment variable var. This is propagated
852 to the nbmake wrapper.
854 The "nbmake-MACHINE" wrapper script
855 If using the build.sh script to build NetBSD, a nbmake-MACHINE script
856 will be created in TOOLDIR/bin upon the first build to assist in building
857 subtrees on a cross-compile host.
859 nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
860 the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
861 eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
862 nbmake-MACHINE will also set variables specified with -V, and unset vari-
863 ables specified with -Z.
865 This script can be symlinked into a directory listed in PATH, or called
866 with an absolute path.
869 1. % ./build.sh [options] tools kernel=GENERIC
871 Build a new toolchain, and use the new toolchain to configure and
872 build a new GENERIC kernel.
874 2. % ./build.sh [options] -U distribution
876 Using unprivileged mode, build a complete distribution to a DESTDIR
877 directory that build.sh selects (and will display).
879 3. # ./build.sh [options] -U install=/
881 As root, install to / the distribution that was built by example 2.
882 Even though this is run as root, -U is required so that the permis-
883 sions stored in DESTDIR/METALOG are correctly applied to the files
884 as they're copied to /.
886 4. % ./build.sh [options] -U -u release
888 Using unprivileged mode, build a complete release to DESTDIR and
889 RELEASEDIR directories that build.sh selects (and will display).
890 MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that
891 if this is run after example 2, it doesn't need to redo that portion
892 of the release build.
895 NBUILDJOBS Use the make(1) option -j instead.
898 The new toolchain is now the default. To disable, use
899 TOOLCHAIN_MISSING=yes.
902 make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8),
903 pkgsrc/sysutils/cdrtools
906 The build.sh based build scheme was introduced for NetBSD 1.6 as
907 USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
909 NetBSD May 1, 2009 NetBSD