BUILDING revision 1.27
11.1StvBUILDING(8)             NetBSD System Manager's Manual             BUILDING(8)
21.1Stv
31.1StvNAME
41.1Stv     BUILDING - Procedure for building NetBSD from source code.
51.1Stv
61.1StvSTATUS
71.1Stv     This document is a work-in-progress.  As such, the information described
81.1Stv     here may not match the reality of the build system as of this writing.
91.1Stv     Once this document is completely in sync with reality, this paragraph
101.1Stv     will be removed.
111.1Stv
121.1Stv     Discrepancies between this documentation and the current reality of im-
131.1Stv     plementation are noted specially, as with the note below:
141.1Stv
151.1Stv     Note: This document applies only to platforms which use the new toolchain
161.15Slukem     as indicated by the default setting of TOOLCHAIN_MISSING in <bsd.own.mk>.
171.5Stv     Platforms which have not yet been switched to the new toolchain should
181.5Stv     continue building traditionally, using the notes specified in the file
191.5Stv     UPDATING.
201.1Stv
211.1StvREQUIREMENTS
221.1Stv     NetBSD is designed to be buildable on most POSIX-compliant host systems.
231.1Stv     The basic build procedure is the same whether compiling natively (on the
241.1Stv     same NetBSD architecture) or cross compiling (on another architecture or
251.1Stv     OS).
261.1Stv
271.1Stv     This source tree contains a special subtree, ``tools'', which uses the
281.1Stv     host system to create a build toolchain for the target architecture.  The
291.1Stv     host system must have at least C and C++ compilers in order to create the
301.1Stv     toolchain (make is not required); all other tools are created as part of
311.1Stv     the NetBSD build process.
321.1Stv
331.22Slukem           Note: A couple of host toolchain components are not yet available
341.22Slukem           in the tools directory.  Also, some tools use non-POSIX, non-ANSI C
351.1Stv           extensions and need to be standardized.  As a result, cross-compil-
361.1Stv           ing from systems other than NetBSD is not currently supported.
371.1Stv
381.1StvFILES
391.1Stv   Source tree layout
401.1Stv
411.17Swiz     doc/BUILDING.mdoc
421.17Swiz                    This document (in -mdoc troff format; the original copy).
431.1Stv
441.2Swiz     BUILDING       This document (in plaintext).
451.1Stv
461.1Stv     Makefile       The main Makefile for NetBSD; should only be run for na-
471.1Stv                    tive builds with an appropriately up-to-date version of
481.1Stv                    NetBSD make(1).  (For building from out-of-date systems or
491.1Stv                    on a non-native host, see the build.sh shell script.)
501.1Stv
511.1Stv     UPDATING       Special notes for updating from an earlier revision of
521.1Stv                    NetBSD.  It is important to read this file before every
531.1Stv                    build of an updated source tree.
541.1Stv
551.1Stv     build.sh       Bourne-compatible shell script used for building the host
561.1Stv                    build tools and the NetBSD system from scratch.  Can be
571.1Stv                    used for both native and cross builds, and should be used
581.1Stv                    instead of make(1) for any source tree that is updated and
591.1Stv                    recompiled regularly.
601.1Stv
611.1Stv     crypto/dist/, dist/, gnu/dist/
621.1Stv                    Sources imported verbatim from third parties, without man-
631.1Stv                    gling the existing build structure.  Other source trees in
641.1Stv                    bin through usr.sbin use the NetBSD make(1) ``reachover''
651.1Stv                    Makefile semantics when building these programs for a na-
661.1Stv                    tive host.
671.1Stv
681.1Stv     distrib/, etc/
691.1Stv                    Sources for items used when making a full release snap-
701.27Slukem                    shot, such as files installed in DESTDIR/etc on the desti-
711.27Slukem                    nation system, boot media, and release notes.
721.1Stv
731.1Stv     regress/       Regression test harness.  Can be cross-compiled, but only
741.1Stv                    run natively.
751.1Stv
761.1Stv     sys/           NetBSD kernel sources.
771.1Stv
781.1Stv     tools/         ``Reachover'' build structure for the host build tools.
791.1Stv                    This has a special method of determining out-of-date sta-
801.1Stv                    tus.
811.1Stv
821.1Stv     bin/ ... usr.sbin/
831.1Stv                    Sources to the NetBSD userland (non-kernel) programs.  If
841.1Stv                    any of these directories are missing, they will be skipped
851.1Stv                    during the build.
861.1Stv
871.1Stv   Build tree layout
881.1Stv     The NetBSD build tree is described in hier(7), and the release layout is
891.1Stv     described in release(7).
901.1Stv
911.1StvCONFIGURATION
921.8Slukem   Environment variables
931.8Slukem     Several environment variables control the behaviour of NetBSD builds.
941.8Slukem
951.8Slukem     MACHINE           Machine type.
961.8Slukem
971.8Slukem     MACHINE_ARCH      Machine architecture.
981.8Slukem
991.8Slukem     MAKE              Path name to invoke make(1) as.
1001.8Slukem
1011.8Slukem     MAKEFLAGS         Flags to invoke make(1) with.
1021.8Slukem
1031.8Slukem     MAKEOBJDIR        Directory to use as the .OBJDIR for the current direc-
1041.8Slukem                       tory.  Used only if MAKEOBJDIRPREFIX is not defined.
1051.8Slukem                       MAKEOBJDIR can only be provided in the environment.
1061.8Slukem
1071.8Slukem     MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  If
1081.8Slukem                       this is defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used
1091.8Slukem                       as the .OBJDIR for the current directory.  The current
1101.8Slukem                       directory may be read only.  MAKEOBJDIRPREFIX can only
1111.8Slukem                       be provided in the environment.
1121.8Slukem
1131.1Stv   "make" variables
1141.1Stv     Several variables control the behavior of NetBSD builds.  Unless other-
1151.1Stv     wise specified, these variables may be set in either the process environ-
1161.1Stv     ment or the make(1) configuration file specified by MAKECONF.
1171.1Stv
1181.9Sthorpej     BUILDID     Identifier for the build.  The identifier will be appended to
1191.9Sthorpej                 object directory names, and can be consulted in the make(1)
1201.9Sthorpej                 configuration file in order to set additional build parame-
1211.9Sthorpej                 ters, such as compiler flags.
1221.9Sthorpej
1231.1Stv     DESTDIR     Directory to contain the built NetBSD system.  If set, spe-
1241.1Stv                 cial options are passed to the compilation tools to prevent
1251.1Stv                 their default use of the host system's /usr/include,
1261.1Stv                 /usr/lib, and so forth.  This pathname should not end with a
1271.1Stv                 slash (/) character (for installation into the system's root
1281.7Slukem                 directory, set DESTDIR to an empty string).  The directory
1291.7Slukem                 must reside on a file system which supports long file names
1301.7Slukem                 and hard links.
1311.1Stv
1321.1Stv                 Default: Empty string if USETOOLS is ``yes''; unset other-
1331.1Stv                 wise.
1341.1Stv
1351.1Stv     MAKECONF    The name of the make(1) configuration file.  Only settable in
1361.1Stv                 the process environment.
1371.1Stv
1381.1Stv                 Default: ``/etc/mk.conf''
1391.1Stv
1401.1Stv     MKCATPAGES  Can be set to ``yes'' or ``no''.  Indicates whether prefor-
1411.1Stv                 matted plaintext manual pages will be created during a build.
1421.1Stv
1431.1Stv                 Default: ``yes''
1441.1Stv
1451.1Stv     MKCRYPTO    Can be set to ``yes'' or ``no''.  Indicates whether crypto-
1461.1Stv                 graphic code will be included in a build; provided for the
1471.1Stv                 benefit of countries that do not allow strong cryptography.
1481.1Stv                 Will not affect use of the standard low-security password en-
1491.1Stv                 cryption system, crypt(3).
1501.1Stv
1511.1Stv                 Default: ``yes''
1521.1Stv
1531.1Stv     MKDOC       Can be set to ``yes'' or ``no''.  Indicates whether system
1541.27Slukem                 documentation destined for DESTDIR/usr/share/doc will be in-
1551.27Slukem                 stalled during a build.
1561.1Stv
1571.1Stv                 Default: ``yes''
1581.1Stv
1591.4Stv     MKHOSTOBJ   Can be set to ``yes'' or ``no''.  If set to ``yes'', then for
1601.4Stv                 programs intended to be run on the compile host, the name,
1611.4Stv                 release, and architecture of the host operating system will
1621.4Stv                 be suffixed to the name of the object directory created by
1631.4Stv                 ``make obj''.  (This allows multiple host systems to compile
1641.4Stv                 NetBSD for a single target.)  If set to ``no'', then programs
1651.4Stv                 built to be run on the compile host will use the same object
1661.4Stv                 directory names as programs built to be run on the target.
1671.4Stv
1681.4Stv                 Default: ``no''
1691.4Stv
1701.1Stv     MKINFO      Can be set to ``yes'' or ``no''.  Indicates whether GNU Info
1711.1Stv                 files, used for the documentation for most of the compilation
1721.1Stv                 tools, will be created and installed during a build.
1731.1Stv
1741.1Stv                 Default: ``yes''
1751.1Stv
1761.1Stv     MKLINT      Can be set to ``yes'' or ``no''.  Indicates whether lint(1)
1771.1Stv                 will be run against portions of the NetBSD source code during
1781.1Stv                 the build, and whether lint libraries will be installed into
1791.27Slukem                 DESTDIR/usr/libdata/lint.
1801.1Stv
1811.1Stv                 Default: ``yes''
1821.1Stv
1831.1Stv     MKMAN       Can be set to ``yes'' or ``no''.  Indicates whether manual
1841.1Stv                 pages will be installed during a build.
1851.1Stv
1861.1Stv                 Default: ``yes''
1871.1Stv
1881.1Stv     MKNLS       Can be set to ``yes'' or ``no''.  Indicates whether Native
1891.1Stv                 Language System locale zone files will be compiled and in-
1901.1Stv                 stalled during a build.
1911.1Stv
1921.1Stv                 Default: ``yes''
1931.1Stv
1941.1Stv     MKOBJ       Can be set to ``yes'' or ``no''.  Indicates whether object
1951.1Stv                 directories will be created when running ``make obj''.  If
1961.1Stv                 set to ``no'', then all built files will be located inside
1971.1Stv                 the regular source tree.
1981.1Stv
1991.1Stv                 Default: ``yes''
2001.1Stv
2011.1Stv     MKPIC       Can be set to ``yes'' or ``no''.  Indicates whether shared
2021.1Stv                 objects and libraries will be created and installed during a
2031.1Stv                 build.  If set to ``no'', the entire built system will be
2041.1Stv                 statically linked.
2051.1Stv
2061.1Stv                 Default: Platform dependent.  As of this writing, all plat-
2071.1Stv                 forms except sh3 default to ``yes''.
2081.1Stv
2091.1Stv     MKPICINSTALL
2101.1Stv                 Can be set to ``yes'' or ``no''.  Indicates whether the ar(1)
2111.1Stv                 format libraries (lib*_pic.a), used to generate shared li-
2121.1Stv                 braries, are installed during a build.
2131.1Stv
2141.1Stv                 Default: ``yes''
2151.1Stv
2161.1Stv     MKPROFILE   Can be set to ``yes'' or ``no''.  Indicates whether profiled
2171.1Stv                 libraries (lib*_p.a) will be built and installed during a
2181.1Stv                 build.
2191.1Stv
2201.1Stv                 Default: ``yes''; however, some platforms turn off MKPROFILE
2211.1Stv                 by default at times due to toolchain problems with profiled
2221.1Stv                 code.
2231.1Stv
2241.1Stv     MKSHARE     Can be set to ``yes'' or ``no''.  Indicates whether files
2251.27Slukem                 destined to reside in DESTDIR/usr/share will be built and in-
2261.27Slukem                 stalled during a build.  If set to ``no'', then all of
2271.27Slukem                 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
2281.27Slukem                 ``no'' unconditionally.
2291.1Stv
2301.1Stv                 Default: ``yes''
2311.1Stv
2321.1Stv     TOOLDIR     Directory to hold the host tools, once built.  This directory
2331.1Stv                 should be unique to a given host system and NetBSD source
2341.1Stv                 tree.  (However, multiple targets may share the same TOOLDIR;
2351.1Stv                 the target-dependent files have unique names.)  If unset, a
2361.1Stv                 default based on the uname(1) information of the host plat-
2371.1Stv                 form will be created in the .OBJDIR of src/tools.
2381.1Stv
2391.1Stv                 Default: Unset.
2401.1Stv
2411.7Slukem     UNPRIVED    If set, then an unprivileged install will occur.  The user,
2421.7Slukem                 group, permissions, and file flags, will not be set on the
2431.7Slukem                 installed item; instead the information will be appended to a
2441.11Slukem                 file called METALOG in DESTDIR.  The contents of METALOG is
2451.11Slukem                 used during the generation of the distribution tar files to
2461.11Slukem                 ensure that the appropriate file ownership is stored.
2471.7Slukem
2481.7Slukem                 Default: Unset.
2491.7Slukem
2501.1Stv     UPDATE      If set, then all install operations intended to write to
2511.1Stv                 DESTDIR will compare file timestamps before installing, and
2521.1Stv                 skip the install phase if the destination files are up-to-
2531.1Stv                 date.  This also has implications on full builds (see next
2541.1Stv                 subsection).
2551.1Stv
2561.1Stv                 Default: Unset.
2571.1Stv
2581.1Stv     USETOOLS    Indicates whether the tools specified by TOOLDIR should be
2591.1Stv                 used as part of a build in progress.  Must be set to ``yes''
2601.1Stv                 if cross-compiling.
2611.1Stv
2621.1Stv                 yes    Use the tools from TOOLDIR.
2631.1Stv
2641.1Stv                 no     Do not use the tools from TOOLDIR, but refuse to build
2651.1Stv                        native compilation tool components that are version-
2661.1Stv                        specific for that tool.
2671.1Stv
2681.1Stv                 never  Do not use the tools from TOOLDIR, even when building
2691.1Stv                        native tool components.  This is similar to the tradi-
2701.1Stv                        tional NetBSD build method, but does not verify that
2711.1Stv                        the compilation tools in use are up-to-date enough in
2721.1Stv                        order to build the tree successfully.  This may cause
2731.1Stv                        build or runtime problems when building the whole
2741.1Stv                        NetBSD source tree.
2751.1Stv
2761.1Stv                 Default: ``yes'' if building all or part of a whole NetBSD
2771.1Stv                 source tree (detected automatically); ``no'' otherwise (to
2781.1Stv                 preserve traditional semantics of the <bsd.*.mk> make(1) in-
2791.1Stv                 clude files).
2801.1Stv
2811.1Stv   "make" variables for full builds
2821.7Slukem     These variables only affect the top level ``Makefile'' and do not affect
2831.7Slukem     manually building subtrees of the NetBSD source code.
2841.1Stv
2851.20Slukem     INSTALLWORLDDIR  Location for the ``make installworld'' target to install
2861.20Slukem                      to.
2871.1Stv
2881.20Slukem                      Default: ``/''
2891.1Stv
2901.20Slukem     MKOBJDIRS        Can be set to ``yes'' or ``no''.  Indicates whether ob-
2911.20Slukem                      ject directories will be created automatically (via a
2921.20Slukem                      ``make obj'' pass) at the start of a build.
2931.1Stv
2941.20Slukem                      Default: ``yes''
2951.1Stv
2961.20Slukem     NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead (see
2971.20Slukem                      below)
2981.1Stv
2991.20Slukem                      Default: Unset.
3001.1Stv
3011.20Slukem     NOCLEANDIR       If set, avoids the ``make cleandir'' phase of a full
3021.20Slukem                      build.  This has the effect of allowing only changed
3031.20Slukem                      files in a source tree to be recompiled.  This can speed
3041.20Slukem                      up builds when updating only a few files in the tree.
3051.1Stv
3061.20Slukem                      Default: Unset.
3071.1Stv
3081.20Slukem     NODISTRIBDIRS    If set, avoids the ``make distrib-dirs'' phase of a full
3091.20Slukem                      build.  This skips running mtree(8) on DESTDIR, useful
3101.20Slukem                      on systems where building as an unprivileged user, or
3111.20Slukem                      where it is known that the system-wide mtree files have
3121.20Slukem                      not changed.
3131.1Stv
3141.20Slukem                      Default: Unset.
3151.1Stv
3161.20Slukem     NOINCLUDES       If set, avoids the ``make includes'' phase of a full
3171.20Slukem                      build.  This has the effect of preventing make(1) from
3181.20Slukem                      thinking that some programs are out-of-date simply be-
3191.20Slukem                      cause the system include files have changed.  However,
3201.20Slukem                      this option should not be used when updating the entire
3211.20Slukem                      NetBSD source tree arbitrarily; it is suggested to use
3221.20Slukem                      UPDATE in that case.
3231.1Stv
3241.20Slukem                      Default: Unset.
3251.1Stv
3261.20Slukem     RELEASEDIR       If set, specifies the directory to which a release(7)
3271.20Slukem                      layout will be written at the end of a ``make release''.
3281.20Slukem
3291.20Slukem                      Default: Unset.
3301.20Slukem
3311.20Slukem     UPDATE           If set, then in addition to the effects described for
3321.20Slukem                      UPDATE above, this implies the effects of NOCLEANDIR.
3331.1Stv
3341.1StvBUILDING
3351.1Stv   "make" command line options
3361.1Stv     This is only a summary of options available to make(1); only the options
3371.1Stv     used most frequently with NetBSD builds are listed here.
3381.1Stv
3391.10Ssommerfe     -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
3401.10Ssommerfe                use .WAIT or have explicit dependancies as necessary to en-
3411.10Ssommerfe                force build ordering.  If you see build failures with -j,
3421.10Ssommerfe                please save complete build logs so the failures can be ana-
3431.10Ssommerfe                lyzed.
3441.10Ssommerfe
3451.1Stv     -m dir     Specify the default directory for searching for system Make-
3461.1Stv                file segments, mainly the <bsd.*.mk> files.  When building any
3471.1Stv                full NetBSD source tree, this should be set to the
3481.1Stv                ``share/mk'' directory in the source tree.  (This is set auto-
3491.1Stv                matically when building from the top level.)
3501.1Stv
3511.1Stv     -n         Display the commands that would have been executed, but do not
3521.1Stv                actually execute them.  This will still cause recursion to
3531.1Stv                take place.
3541.1Stv
3551.1Stv     -v var     Print make(1)'s idea of the value of var.  Does not build any
3561.1Stv                targets.
3571.1Stv
3581.1Stv     var=value  Set the variable var to value, overriding any setting speci-
3591.1Stv                fied by the process environment, the MAKECONF configuration
3601.1Stv                file, or the system Makefile segments.
3611.1Stv
3621.1Stv   "make" targets
3631.1Stv     These default targets may be built by running make(1) in any subtree of
3641.1Stv     the NetBSD source code.  It is recommended that none of these be used
3651.1Stv     from the top level Makefile; as a specific exception, ``make obj'' and
3661.1Stv     ``make cleandir'' are useful in that context.
3671.1Stv
3681.1Stv     all        Build programs, libraries, and preformatted documentation.
3691.1Stv
3701.1Stv     clean      Remove program and library object code files.
3711.1Stv
3721.1Stv     cleandir   Same as clean, but also remove preformatted documentation, de-
3731.1Stv                pendency files generated by ``make depend'', and any other
3741.1Stv                files known to be created at build time.  ``make distclean''
3751.1Stv                may be used as a synonym, for familiarity with a similar well-
3761.1Stv                known convention.
3771.1Stv
3781.1Stv     depend     Create dependency files (.depend) containing more detailed in-
3791.1Stv                formation about the dependencies of source code on header
3801.1Stv                files.  Allows programs to be recompiled automatically when a
3811.1Stv                dependency changes.
3821.1Stv
3831.1Stv     dependall  Does a ``make depend'' immediately followed by a ``make all''.
3841.10Ssommerfe                This improves cache locality of the build since both passes
3851.10Ssommerfe                read the source files in their entirety.
3861.1Stv
3871.1Stv     includes   Build and install system header files.  Typically needed be-
3881.1Stv                fore any system libraries or programs can be built.
3891.1Stv
3901.1Stv     install    Install programs, libraries, and documentation into DESTDIR.
3911.27Slukem                Few files will be installed to DESTDIR/dev, DESTDIR/etc,
3921.27Slukem                DESTDIR/root or DESTDIR/var in order to prevent user supplied
3931.27Slukem                configuration data from being overwritten.
3941.1Stv
3951.1Stv     lint       Run lint(1) against the C source code, where appropriate, and
3961.1Stv                generate system-installed lint libraries.
3971.1Stv
3981.1Stv     obj        Create object directories to be used for built files, instead
3991.1Stv                of building directly in the source tree.
4001.1Stv
4011.1Stv     tags       Create ctags(1) searchable function lists usable by the ex(1)
4021.1Stv                and vi(1) text editors.
4031.1Stv
4041.1Stv   "make" targets for the top level
4051.1Stv     Additional make(1) targets are usable specifically from the top source
4061.1Stv     level to facilitate building the entire NetBSD source tree.
4071.1Stv
4081.20Slukem     build         Build the entire NetBSD system.  This orders portions of
4091.20Slukem                   the source tree such that prerequisites will be built in
4101.20Slukem                   the proper order.
4111.20Slukem
4121.20Slukem     distribution  Do a ``make build'', and then install a full distribution
4131.27Slukem                   into DESTDIR, including files in DESTDIR/dev, DESTDIR/etc,
4141.27Slukem                   DESTDIR/root and DESTDIR/var.
4151.20Slukem
4161.20Slukem     buildworld    As per ``make distribution'', except that it ensures that
4171.20Slukem                   DESTDIR is not the root directory.
4181.20Slukem
4191.20Slukem     installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR
4201.20Slukem                   (which defaults to the root directory).  Ensures that
4211.20Slukem                   INSTALLWORLDDIR is the not root directory if cross compil-
4221.20Slukem                   ing.
4231.20Slukem
4241.20Slukem                   Note: It is highly recommended that you upgrade your kernel
4251.20Slukem                   and reboot before performing this operation.
4261.20Slukem
4271.25Slukem     sets          Create distribution sets from DESTDIR into
4281.25Slukem                   RELEASEDIR/MACHINE/binary/sets.  Should be run after ``make
4291.25Slukem                   distribution'' (as ``make build'' does not install all of
4301.25Slukem                   the required files).
4311.25Slukem
4321.22Slukem     release       Do a ``make distribution'', build kernels, distribution me-
4331.25Slukem                   dia, and install sets (this as per ``make sets''), and then
4341.25Slukem                   package the system into a standard release layout as de-
4351.25Slukem                   scribed by release(7).  This requires that RELEASEDIR be
4361.25Slukem                   set (see above).
4371.1Stv
4381.1Stv     regression-tests
4391.20Slukem                   Can only be run after building the regression tests in the
4401.20Slukem                   directory ``regress''.  Runs the compiled regression tests
4411.20Slukem                   on the local host.
4421.1Stv
4431.1Stv   The "build.sh" script
4441.1Stv     This script file is a Bourne shell script designed to build the entire
4451.1Stv     NetBSD system on any host with a Bourne shell in /bin/sh, including many
4461.1Stv     that are not POSIX compliant.  Note that if a host system's /bin/sh is
4471.1Stv     unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
4481.1Stv     a usable alternative.
4491.1Stv
4501.1Stv     All cross-compile builds, and most native builds, of the entire system
4511.1Stv     should make use of build.sh rather than just running ``make''.  This way,
4521.1Stv     the make(1) program will be bootstrapped properly, in case the host sys-
4531.1Stv     tem has an older or incompatible ``make'' program.
4541.1Stv
4551.1Stv     When compiling the entire system via build.sh, many make(1) variables are
4561.1Stv     set for you in order to help encapsulate the build process.  In the list
4571.1Stv     of options below, variables that are automatically set by build.sh are
4581.1Stv     noted where applicable.
4591.1Stv
4601.22Slukem     The following operations are supported by build.sh:
4611.22Slukem
4621.22Slukem     build         Build the system as per ``make build''.  This option im-
4631.22Slukem                   plies the obj and tools operations.
4641.22Slukem
4651.22Slukem     distribution  Build a full distribution as per ``make distribution''.
4661.22Slukem                   This option implies the build operation.
4671.22Slukem
4681.22Slukem     release       Build a full release as per ``make release''.  This option
4691.22Slukem                   implies the distribution operation.
4701.22Slukem
4711.23Slukem     makewrapper   Create the nbmake-MACHINE wrapper.  This operation is auto-
4721.23Slukem                   matically performed for any of the other operations.
4731.23Slukem
4741.22Slukem     obj           Perform ``make obj''.
4751.22Slukem
4761.22Slukem     tools         Build and install the host tools from src/tools.
4771.22Slukem
4781.22Slukem     kernel=kconf  Build a new kernel.  The kconf argument is the name of a
4791.22Slukem                   configuration file suitable for use by config(8).  If kconf
4801.22Slukem                   does not contain any `/' characters, the configuration file
4811.22Slukem                   is expected to be found in the KERNCONFDIR directory, which
4821.22Slukem                   is typically sys/arch/MACHINE/conf.  The new kernel will be
4831.22Slukem                   built in a subdirectory of KERNOBJDIR, which is typically
4841.22Slukem                   sys/arch/MACHINE/compile or an associated object directory.
4851.22Slukem                   In order to ensure that the kernel is built using up-to-
4861.22Slukem                   date tools, it is strongly recommended that the tools be
4871.22Slukem                   rebuilt (using the tools operation).
4881.22Slukem
4891.22Slukem     install=idir  Install the contents of DESTDIR to idir, using ``make
4901.22Slukem                   installworld''.
4911.24Slukem
4921.24Slukem     sets          Perform ``make sets''.
4931.22Slukem
4941.22Slukem     The following command line options alter the behaviour of the above oper-
4951.22Slukem     ations: The following command line options alter the behaviour of the
4961.22Slukem     build.sh operations described above:
4971.1Stv
4981.1Stv     -a arch   Set the value of MACHINE_ARCH to arch.
4991.9Sthorpej
5001.9Sthorpej     -B buildid
5011.9Sthorpej               Set the value of BUILDID to buildid.  This will also append the
5021.9Sthorpej               build idenfitier to the name of the ``make'' wrapper script so
5031.9Sthorpej               that the resulting name is of the form ``nbmake-MACHINE-
5041.9Sthorpej               BUILDID''.
5051.1Stv
5061.18Slukem     -D dest   Set the value of DESTDIR to dest.
5071.18Slukem
5081.23Slukem     -E        Set `expert' mode.  This overrides various sanity checks, and
5091.23Slukem               allows: DESTDIR does not have to be set to a non-root path for
5101.23Slukem               builds, and UNPRIVED does not have to be set when building as a
5111.23Slukem               non-root user.
5121.23Slukem
5131.23Slukem               Note: It is highly recommended that you know what you are doing
5141.23Slukem               when you use this option.
5151.19Slukem
5161.10Ssommerfe     -j njob   Passed through to make(1).  Makefiles should use .WAIT or have
5171.10Ssommerfe               explicit dependancies as necessary to enforce build ordering.
5181.10Ssommerfe               If you see build failures with -j, please save complete build
5191.10Ssommerfe               logs so the failures can be analyzed.
5201.1Stv
5211.18Slukem     -M obj    Set MAKEOBJDIRPREFIX to obj.
5221.18Slukem
5231.1Stv     -m mach   Set the value of MACHINE to mach.  This will also override any
5241.1Stv               value of MACHINE_ARCH in the process environment with a value
5251.1Stv               deduced from mach, unless -a is specified.  All cross builds
5261.1Stv               require -m, but if unset on a NetBSD host, the host's value of
5271.1Stv               MACHINE will be detected and used automatically.
5281.1Stv
5291.1Stv     -n        Show the commands that would be executed by build.sh, but do
5301.1Stv               not make any changes.  This is similar in concept to ``make
5311.1Stv               -n''.
5321.1Stv
5331.18Slukem     -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
5341.18Slukem               place the built object files under obj.  For instance, a set-
5351.18Slukem               ting of /usr/obj will place build-time files under
5361.18Slukem               /usr/obj/bin, /usr/obj/lib, and so forth.
5371.18Slukem
5381.1Stv     -o        Set the value of MKOBJDIRS to ``no''.
5391.1Stv
5401.22Slukem     -R rel    Set the value of RELEASEDIR to rel.
5411.18Slukem
5421.1Stv     -r        Remove the contents of DESTDIR and TOOLDIR before building
5431.1Stv               (provides a clean starting point).  This will skip deleting
5441.1Stv               DESTDIR if building on a native system to the root directory.
5451.1Stv
5461.18Slukem     -T tools  Set the value of TOOLDIR to tools.  If set, the bootstrap
5471.18Slukem               ``make'' will only be rebuilt as needed (when the source files
5481.18Slukem               for make(1) change).
5491.18Slukem
5501.18Slukem     -U        Set the UNPRIVED variable.
5511.18Slukem
5521.1Stv     -u        Set the UPDATE variable.
5531.1Stv
5541.21Slukem     -V var=[value]
5551.23Slukem               Set the variable var to value (which is optional).
5561.21Slukem
5571.1Stv     -w wrapper
5581.1Stv               Create the nbmake wrapper script (see below) in a custom loca-
5591.1Stv               tion, specified by wrapper.  This allows, for instance, to
5601.1Stv               place the wrapper in PATH automatically.  Note that wrapper is
5611.1Stv               the full name of the file, not just a directory name.
5621.1Stv
5631.1Stv   The "nbmake-MACHINE" wrapper script
5641.1Stv     If using the build.sh script to build NetBSD, a nbmake-MACHINE script
5651.1Stv     will be created in TOOLDIR/bin upon the first build to assist in building
5661.1Stv     subtrees on a cross-compile host.
5671.1Stv
5681.1Stv     nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
5691.1Stv     the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
5701.1Stv     eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
5711.1Stv     This script can be symlinked into a directory listed in PATH, or called
5721.1Stv     with an absolute path.
5731.1Stv
5741.16SlukemEXAMPLES
5751.22Slukem     ./build.sh tools kernel=GENERIC
5761.16Slukem               Build a new toolchain, and use the new toolchain to configure
5771.25Slukem               and build a new GENERIC kernel.
5781.16Slukem
5791.27Slukem     ./build.sh -U -D /path/to/destdir distribution
5801.16Slukem               Using unprivileged mode, build a complete distribution in
5811.27Slukem               /path/to/destdir.
5821.16Slukem
5831.27Slukem     # ./build.sh -U -D /path/to/destdir installworld=/
5841.22Slukem               As root, install the distribution that was built with unprivi-
5851.27Slukem               leged mode from /path/to/destdir to /.  (Even though this is
5861.25Slukem               run as root, -U is required so that the permissions stored in
5871.27Slukem               /path/to/destdir/METALOG are correctly applied to the files as
5881.23Slukem               they're copied to /).
5891.23Slukem
5901.27Slukem     ./build.sh -U -D /path/to/destdir -R /path/to/releasedir release
5911.23Slukem               Using unprivileged mode, build a complete release in
5921.27Slukem               /path/to/dir/releasedir.
5931.16Slukem
5941.10SsommerfeOBSOLETE VARIABLES
5951.15Slukem     NBUILDJOBS  Use the make(1) option -j, instead.
5961.15Slukem
5971.15Slukem     USE_NEW_TOOLCHAIN
5981.15Slukem                 The new toolchain is now the default.  To disable, use
5991.15Slukem                 TOOLCHAIN_MISSING=yes.
6001.10Ssommerfe
6011.1StvSEE ALSO
6021.1Stv     make(1), hier(7), release(7)
6031.1Stv
6041.1StvHISTORY
6051.15Slukem     The build.sh based build scheme was introduced for NetBSD 1.6 as
6061.15Slukem     USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
6071.1Stv
6081.1StvBUGS
6091.15Slukem     A few platforms are not yet using this build system.
6101.1Stv
6111.26SlukemNetBSD                         January 30, 2003                             10
612