BUILDING revision 1.109
11.104SwizBUILDING(8)                 System Manager's Manual                BUILDING(8)
21.1Stv
31.105SwizNAME
41.105Swiz     BUILDING -- Procedure for building NetBSD from source code.
51.1Stv
61.105SwizREQUIREMENTS
71.1Stv     NetBSD is designed to be buildable on most POSIX-compliant host systems.
81.105Swiz     The basic build procedure is the same whether compiling natively (on the
91.105Swiz     same NetBSD architecture) or cross compiling (on another architecture or
101.1Stv     OS).
111.1Stv
121.1Stv     This source tree contains a special subtree, ``tools'', which uses the
131.1Stv     host system to create a build toolchain for the target architecture.  The
141.1Stv     host system must have at least C and C++ compilers in order to create the
151.105Swiz     toolchain (make is not required); all other tools are created as part of
161.53Sreed     the NetBSD build process.  (See the environment variables section below
171.53Sreed     if you need to override or manually select your compilers.)
181.1Stv
191.105SwizFILES
201.105Swiz   Source tree layout
211.105Swiz     doc/BUILDING.mdoc
221.17Swiz                    This document (in -mdoc troff format; the original copy).
231.1Stv
241.105Swiz     BUILDING       This document (in plaintext).
251.1Stv
261.105Swiz     tools/compat/README
271.48Sjmc                    Special notes for cross-hosting a NetBSD build on non-
281.48Sjmc                    NetBSD platforms.
291.48Sjmc
301.105Swiz     Makefile       The main Makefile for NetBSD; should only be run for
311.44Slukem                    native builds with an appropriately up-to-date version of
321.1Stv                    NetBSD make(1).  (For building from out-of-date systems or
331.105Swiz                    on a non-native host, see the build.sh shell script.)
341.1Stv
351.105Swiz     UPDATING       Special notes for updating from an earlier revision of
361.1Stv                    NetBSD.  It is important to read this file before every
371.1Stv                    build of an updated source tree.
381.1Stv
391.105Swiz     build.sh       Bourne-compatible shell script used for building the host
401.1Stv                    build tools and the NetBSD system from scratch.  Can be
411.1Stv                    used for both native and cross builds, and should be used
421.1Stv                    instead of make(1) for any source tree that is updated and
431.1Stv                    recompiled regularly.
441.1Stv
451.105Swiz     crypto/dist/, dist/, gnu/dist/
461.104Swiz                    Sources imported verbatim from third parties, without
471.104Swiz                    mangling the existing build structure.  Other source trees
481.105Swiz                    in bin through usr.sbin use the NetBSD make(1)
491.104Swiz                    ``reachover'' Makefile semantics when building these
501.104Swiz                    programs for a native host.
511.104Swiz
521.106Swiz     external, sys/external
531.106Swiz                    Sources and build infrastructure for components imported
541.106Swiz                    (mostly) unchanged from upstream maintainers, sorted by
551.106Swiz                    applicable license.  This is (slowly) replacing the
561.106Swiz                    crypto/dist, dist, and gnu/dist directories.
571.106Swiz
581.105Swiz     distrib/, etc/
591.104Swiz                    Sources for items used when making a full release
601.105Swiz                    snapshot, such as files installed in DESTDIR/etc on the
611.104Swiz                    destination system, boot media, and release notes.
621.1Stv
631.105Swiz     tests/, regress/
641.70Sdholland                    Regression test harness.  Can be cross-compiled, but only
651.105Swiz                    run natively.  tests/ uses the atf(7) test framework;
661.105Swiz                    regress/ contains older tests that have not yet been
671.70Sdholland                    migrated to atf(7).
681.1Stv
691.105Swiz     sys/           NetBSD kernel sources.
701.1Stv
711.105Swiz     tools/         ``Reachover'' build structure for the host build tools.
721.104Swiz                    This has a special method of determining out-of-date
731.104Swiz                    status.
741.1Stv
751.105Swiz     bin/ ... usr.sbin/
761.1Stv                    Sources to the NetBSD userland (non-kernel) programs.  If
771.1Stv                    any of these directories are missing, they will be skipped
781.1Stv                    during the build.
791.1Stv
801.105Swiz     x11/           ``Reachover'' build structure for X11R6; the source is in
811.105Swiz                    X11SRCDIR.
821.49Slukem
831.105Swiz   Build tree layout
841.1Stv     The NetBSD build tree is described in hier(7), and the release layout is
851.1Stv     described in release(7).
861.1Stv
871.105SwizCONFIGURATION
881.105Swiz   Environment variables
891.8Slukem     Several environment variables control the behaviour of NetBSD builds.
901.8Slukem
911.105Swiz     HOST_SH           Path name to a shell available on the host system and
921.96Sapb                       suitable for use during the build.  The NetBSD build
931.96Sapb                       system requires a modern Bourne-like shell with POSIX-
941.96Sapb                       compliant features, and also requires support for the
951.96Sapb                       ``local'' keyword to declare local variables in shell
961.104Swiz                       functions (which is a widely-implemented but non-
971.104Swiz                       standardised feature).
981.96Sapb
991.96Sapb                       Depending on the host system, a suitable shell may be
1001.105Swiz                       /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a
1011.96Sapb                       variant of ksh that supports the ``local'' keyword,
1021.105Swiz                       such as ksh88, but not ksh93), or /usr/local/bin/bash.
1031.96Sapb
1041.105Swiz                       Most parts of the build require HOST_SH to be an
1051.105Swiz                       absolute path; however, build.sh allows it to be a
1061.104Swiz                       simple command name, which will be converted to an
1071.105Swiz                       absolute path by searching the PATH.
1081.58Sapb
1091.105Swiz     HOST_CC           Path name to C compiler used to create the toolchain.
1101.53Sreed
1111.105Swiz     HOST_CXX          Path name to C++ compiler used to create the toolchain.
1121.53Sreed
1131.105Swiz     MACHINE           Machine type, e.g., ``macppc''.
1141.8Slukem
1151.105Swiz     MACHINE_ARCH      Machine architecture, e.g., ``powerpc''.
1161.8Slukem
1171.105Swiz     MAKE              Path name to invoke make(1) as.
1181.8Slukem
1191.105Swiz     MAKEFLAGS         Flags to invoke make(1) with.  Note that build.sh
1201.105Swiz                       ignores the value of MAKEFLAGS passed in the
1211.105Swiz                       environment, but allows MAKEFLAGS to be set via the -V
1221.104Swiz                       option.
1231.8Slukem
1241.105Swiz     MAKEOBJDIR        Directory to use as the .OBJDIR for the current
1251.104Swiz                       directory.  The value is subjected to variable
1261.104Swiz                       expansion by make(1).  Typical usage is to set this
1271.104Swiz                       variable to a value involving the use of
1281.104Swiz                       `${.CURDIR:S...}' or `${.CURDIR:C...}', to derive the
1291.105Swiz                       value of .OBJDIR from the value of .CURDIR.  Used only
1301.105Swiz                       if MAKEOBJDIRPREFIX is not defined.  MAKEOBJDIR can be
1311.105Swiz                       provided only in the environment or via the -O flag of
1321.105Swiz                       build.sh; it cannot usefully be set inside a Makefile,
1331.105Swiz                       including mk.conf or ${MAKECONF}.
1341.8Slukem
1351.105Swiz     MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  The
1361.88Sapb                       value is subjected to variable expansion by make(1).
1371.105Swiz                       build.sh will create the ${MAKEOBJDIRPREFIX} directory
1381.105Swiz                       if necessary, but if make(1) is used without build.sh,
1391.88Sapb                       then rules in <bsd.obj.mk> will abort the build if the
1401.88Sapb                       ${MAKEOBJDIRPREFIX} directory does not exist.  If the
1411.104Swiz                       value is defined and valid, then
1421.105Swiz                       ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR
1431.104Swiz                       for the current directory.  The current directory may
1441.105Swiz                       be read only.  MAKEOBJDIRPREFIX can be provided only in
1451.105Swiz                       the environment or via the -M flag of build.sh; it
1461.104Swiz                       cannot usefully be set inside a Makefile, including
1471.105Swiz                       mk.conf or ${MAKECONF}.
1481.104Swiz
1491.105Swiz   "make" variables
1501.104Swiz     Several variables control the behavior of NetBSD builds.  Unless
1511.104Swiz     otherwise specified, these variables may be set in either the process
1521.105Swiz     environment or the make(1) configuration file specified by MAKECONF.
1531.1Stv
1541.107Sapb     BUILDID     Identifier for the build.  If set, this should be a short
1551.107Sapb                 string that is suitable for use as part of a file or
1561.107Sapb                 directory name.  The identifier will be appended to object
1571.107Sapb                 directory names, and can be consulted in the make(1)
1581.104Swiz                 configuration file in order to set additional build
1591.107Sapb                 parameters, such as compiler flags.  It will also be used as
1601.107Sapb                 part of the kernel version string, which can be printed by
1611.107Sapb                 ``uname -v''.
1621.107Sapb
1631.107Sapb                 Default: Unset.
1641.9Sthorpej
1651.108Sapb     BUILDINFO   This may be a multi-line string containing information about
1661.108Sapb                 the build.  This will appear in DESTDIR/etc/release, and it
1671.108Sapb                 will be stored in the buildinfo variable in any kernels that
1681.108Sapb                 are built.  When such kernels are booted, the sysctl(7)
1691.108Sapb                 kern.buildinfo variable will report this value.  The string
1701.108Sapb                 may contain backslash escape sequences, such as ``\\''
1711.108Sapb                 (representing a backslash character) and ``\n'' (representing
1721.108Sapb                 a newline).
1731.108Sapb
1741.108Sapb                 Default: Unset.
1751.108Sapb
1761.105Swiz     BUILDSEED   GCC uses random numbers when compiling C++ code.  This
1771.104Swiz                 variable seeds the gcc random number generator using the
1781.104Swiz                 -frandom-seed flag with this value.  By default, it is set to
1791.104Swiz                 NetBSD-(majorversion).  Using a fixed value causes C++
1801.104Swiz                 binaries to be the same when built from the same sources,
1811.104Swiz                 resulting in identical (reproducible) builds.  Additional
1821.104Swiz                 information is available in the GCC documentation of
1831.104Swiz                 -frandom-seed.
1841.104Swiz
1851.105Swiz     DESTDIR     Directory to contain the built NetBSD system.  If set,
1861.104Swiz                 special options are passed to the compilation tools to
1871.105Swiz                 prevent their default use of the host system's /usr/include,
1881.105Swiz                 /usr/lib, and so forth.  This pathname must be an absolute
1891.105Swiz                 path, and should not end with a slash (/) character.  (For
1901.105Swiz                 installation into the system's root directory, set DESTDIR to
1911.59Sapb                 an empty string, not to ``/'').  The directory must reside on
1921.59Sapb                 a file system which supports long file names and hard links.
1931.1Stv
1941.105Swiz                 Default: Empty string if USETOOLS is ``yes''; unset
1951.104Swiz                 otherwise.
1961.1Stv
1971.105Swiz                 Note: build.sh will provide a default of destdir.MACHINE (in
1981.105Swiz                 the top-level .OBJDIR) unless run in `expert' mode.
1991.30Slukem
2001.105Swiz     MAKECONF    The name of the make(1) configuration file.  Only settable in
2011.105Swiz                 the process environment.
2021.1Stv
2031.105Swiz                 Default: ``/etc/mk.conf''
2041.1Stv
2051.105Swiz     MAKEVERBOSE
2061.45Slukem                 Level of verbosity of status messages.  Supported values:
2071.45Slukem
2081.80Sapb                 0    No descriptive messages or commands executed by make(1)
2091.80Sapb                      are shown.
2101.45Slukem
2111.80Sapb                 1    Brief messages are shown describing what is being done,
2121.104Swiz                      but the actual commands executed by make(1) are not
2131.104Swiz                      displayed.
2141.80Sapb
2151.80Sapb                 2    Descriptive messages are shown as above (prefixed with a
2161.80Sapb                      `#'), and ordinary commands performed by make(1) are
2171.80Sapb                      displayed.
2181.80Sapb
2191.80Sapb                 3    In addition to the above, all commands performed by
2201.80Sapb                      make(1) are displayed, even if they would ordinarily
2211.80Sapb                      have been hidden through use of the ``@'' prefix in the
2221.80Sapb                      relevant makefile.
2231.45Slukem
2241.80Sapb                 4    In addition to the above, commands executed by make(1)
2251.105Swiz                      are traced through use of the sh(1) ``-x'' flag.
2261.45Slukem
2271.105Swiz                 Default: 2
2281.45Slukem
2291.105Swiz     MKCATPAGES  Can be set to ``yes'' or ``no''.  Indicates whether
2301.104Swiz                 preformatted plaintext manual pages will be created during a
2311.104Swiz                 build.
2321.1Stv
2331.105Swiz                 Default: ``no''
2341.1Stv
2351.106Swiz     MKCROSSGDB  Can be set to ``yes'' or ``no''.  Create a cross-gdb as a
2361.106Swiz                 host tool.
2371.106Swiz
2381.106Swiz                 Default: ``no''
2391.106Swiz
2401.105Swiz     MKCRYPTO    Can be set to ``yes'' or ``no''.  Indicates whether
2411.104Swiz                 cryptographic code will be included in a build; provided for
2421.104Swiz                 the benefit of countries that do not allow strong
2431.104Swiz                 cryptography.  Will not affect use of the standard low-
2441.104Swiz                 security password encryption system, crypt(3).
2451.1Stv
2461.105Swiz                 Default: ``yes''
2471.1Stv
2481.106Swiz     MKDEBUG     Can be set to ``yes'' or ``no''.  Indicates whether debug
2491.106Swiz                 information should be generated for all userland binaries
2501.106Swiz                 compiled.  The result is collected as an additional debug.tgz
2511.106Swiz                 and xdebug.tgz set and installed in /usr/libdata/debug.
2521.106Swiz
2531.106Swiz                 Default: ``no''
2541.106Swiz
2551.106Swiz     MKDEBUGLIB  Can be set to ``yes'' or ``no''.  Indicates whether debug
2561.106Swiz                 information (see MKDEBUG) should also be generated for all
2571.106Swiz                 libraries build.
2581.106Swiz
2591.106Swiz                 Default: ``no''
2601.106Swiz
2611.105Swiz     MKDOC       Can be set to ``yes'' or ``no''.  Indicates whether system
2621.105Swiz                 documentation destined for DESTDIR/usr/share/doc will be
2631.44Slukem                 installed during a build.
2641.1Stv
2651.105Swiz                 Default: ``yes''
2661.1Stv
2671.105Swiz     MKHTML      Can be set to ``yes'' or ``no''.  Indicates whether
2681.104Swiz                 preformatted HTML manual pages will be built and installed
2691.77Slukem
2701.105Swiz                 Default: ``yes''
2711.77Slukem
2721.105Swiz     MKHOSTOBJ   Can be set to ``yes'' or ``no''.  If set to ``yes'', then for
2731.4Stv                 programs intended to be run on the compile host, the name,
2741.4Stv                 release, and architecture of the host operating system will
2751.4Stv                 be suffixed to the name of the object directory created by
2761.4Stv                 ``make obj''.  (This allows multiple host systems to compile
2771.4Stv                 NetBSD for a single target.)  If set to ``no'', then programs
2781.4Stv                 built to be run on the compile host will use the same object
2791.4Stv                 directory names as programs built to be run on the target.
2801.4Stv
2811.105Swiz                 Default: ``no''
2821.4Stv
2831.105Swiz     MKINFO      Can be set to ``yes'' or ``no''.  Indicates whether GNU Info
2841.1Stv                 files, used for the documentation for most of the compilation
2851.1Stv                 tools, will be created and installed during a build.
2861.1Stv
2871.105Swiz                 Default: ``yes''
2881.1Stv
2891.106Swiz     MKKDEBUG    Can be set to ``yes'' or ``no''.  Force generation of full-
2901.106Swiz                 debug symbol versions of all kernels compiled.  Alongside of
2911.106Swiz                 the netbsd kernel file, an unstripped version netbsd.gdb is
2921.106Swiz                 created.  This is useful if a cross-gdb is built as well (see
2931.106Swiz                 MKCROSSGDB).
2941.106Swiz
2951.106Swiz                 Default: ``no''
2961.106Swiz
2971.105Swiz     MKKMOD      Can be set to ``yes'' or ``no''.  Indicates whether kernel
2981.95Sapb                 modules are built and installed.
2991.95Sapb
3001.105Swiz                 Default: ``yes''
3011.95Sapb
3021.105Swiz     MKLINT      Can be set to ``yes'' or ``no''.  Indicates whether lint(1)
3031.1Stv                 will be run against portions of the NetBSD source code during
3041.1Stv                 the build, and whether lint libraries will be installed into
3051.105Swiz                 DESTDIR/usr/libdata/lint.
3061.1Stv
3071.105Swiz                 Default: ``yes''
3081.1Stv
3091.105Swiz     MKMAN       Can be set to ``yes'' or ``no''.  Indicates whether manual
3101.1Stv                 pages will be installed during a build.
3111.1Stv
3121.105Swiz                 Default: ``yes''
3131.1Stv
3141.105Swiz     MKNLS       Can be set to ``yes'' or ``no''.  Indicates whether Native
3151.44Slukem                 Language System locale zone files will be compiled and
3161.44Slukem                 installed during a build.
3171.1Stv
3181.105Swiz                 Default: ``yes''
3191.1Stv
3201.105Swiz     MKOBJ       Can be set to ``yes'' or ``no''.  Indicates whether object
3211.1Stv                 directories will be created when running ``make obj''.  If
3221.1Stv                 set to ``no'', then all built files will be located inside
3231.1Stv                 the regular source tree.
3241.1Stv
3251.105Swiz                 Default: ``yes''
3261.1Stv
3271.105Swiz                 Note that setting MKOBJ to ``no'' is not recommended and may
3281.70Sdholland                 cause problems when updating the tree with cvs(1).
3291.70Sdholland
3301.105Swiz     MKPIC       Can be set to ``yes'' or ``no''.  Indicates whether shared
3311.1Stv                 objects and libraries will be created and installed during a
3321.1Stv                 build.  If set to ``no'', the entire built system will be
3331.1Stv                 statically linked.
3341.1Stv
3351.105Swiz                 Default: Platform dependent.  As of this writing, all
3361.105Swiz                 platforms except sh3 default to ``yes''.
3371.1Stv
3381.105Swiz     MKPICINSTALL
3391.1Stv                 Can be set to ``yes'' or ``no''.  Indicates whether the ar(1)
3401.105Swiz                 format libraries (lib*_pic.a), used to generate shared
3411.44Slukem                 libraries, are installed during a build.
3421.1Stv
3431.105Swiz                 Default: ``yes''
3441.1Stv
3451.105Swiz     MKPROFILE   Can be set to ``yes'' or ``no''.  Indicates whether profiled
3461.105Swiz                 libraries (lib*_p.a) will be built and installed during a
3471.1Stv                 build.
3481.1Stv
3491.105Swiz                 Default: ``yes''; however, some platforms turn off MKPROFILE
3501.1Stv                 by default at times due to toolchain problems with profiled
3511.1Stv                 code.
3521.1Stv
3531.105Swiz     MKREPRO     Can be set to ``yes'' or ``no''.  Create reproducable builds.
3541.100Swiz                 This enables different switches to make two builds from the
3551.100Swiz                 same source tree result in the same build results.
3561.100Swiz
3571.105Swiz                 Default: ``no''
3581.100Swiz
3591.105Swiz     MKSHARE     Can be set to ``yes'' or ``no''.  Indicates whether files
3601.105Swiz                 destined to reside in DESTDIR/usr/share will be built and
3611.44Slukem                 installed during a build.  If set to ``no'', then all of
3621.105Swiz                 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
3631.27Slukem                 ``no'' unconditionally.
3641.1Stv
3651.105Swiz                 Default: ``yes''
3661.1Stv
3671.105Swiz     MKSTRIPIDENT
3681.102Sabs                 Can be set to ``yes'' or ``no''.  Indicates whether RCS IDs,
3691.104Swiz                 for use with ident(1), should be stripped from program
3701.104Swiz                 binaries and shared libraries.
3711.78Sapb
3721.105Swiz                 Default: ``no''
3731.78Sapb
3741.105Swiz     MKUNPRIVED  Can be set to ``yes'' or ``no''.  Indicates whether an
3751.104Swiz                 unprivileged install will occur.  The user, group,
3761.104Swiz                 permissions, and file flags, will not be set on the installed
3771.52Sjmc                 items; instead the information will be appended to a file
3781.105Swiz                 called METALOG in DESTDIR.  The contents of METALOG are used
3791.52Sjmc                 during the generation of the distribution tar files to ensure
3801.52Sjmc                 that the appropriate file ownership is stored.
3811.38Slukem
3821.105Swiz                 Default: ``no''
3831.38Slukem
3841.105Swiz     MKUPDATE    Can be set to ``yes'' or ``no''.  Indicates whether all
3851.105Swiz                 install operations intended to write to DESTDIR will compare
3861.38Slukem                 file timestamps before installing, and skip the install phase
3871.44Slukem                 if the destination files are up-to-date.  This also has
3881.44Slukem                 implications on full builds (see next subsection).
3891.38Slukem
3901.105Swiz                 Default: ``no''
3911.38Slukem
3921.105Swiz     MKX11       Can be set to ``yes'' or ``no''.  Indicates whether X11 is
3931.105Swiz                 built from X11SRCDIR.
3941.49Slukem
3951.105Swiz                 Default: ``no''
3961.49Slukem
3971.105Swiz     TOOLDIR     Directory to hold the host tools, once built.  If specified,
3981.59Sapb                 must be an absolute path.  This directory should be unique to
3991.104Swiz                 a given host system and NetBSD source tree.  (However,
4001.105Swiz                 multiple targets may share the same TOOLDIR; the target-
4011.104Swiz                 dependent files have unique names.)  If unset, a default
4021.104Swiz                 based on the uname(1) information of the host platform will
4031.105Swiz                 be created in the .OBJDIR of src.
4041.1Stv
4051.105Swiz                 Default: Unset.
4061.1Stv
4071.105Swiz     USETOOLS    Indicates whether the tools specified by TOOLDIR should be
4081.1Stv                 used as part of a build in progress.  Must be set to ``yes''
4091.1Stv                 if cross-compiling.
4101.1Stv
4111.105Swiz                 yes    Use the tools from TOOLDIR.
4121.1Stv
4131.105Swiz                 no     Do not use the tools from TOOLDIR, but refuse to build
4141.1Stv                        native compilation tool components that are version-
4151.1Stv                        specific for that tool.
4161.1Stv
4171.105Swiz                 never  Do not use the tools from TOOLDIR, even when building
4181.104Swiz                        native tool components.  This is similar to the
4191.105Swiz                        traditional NetBSD build method, but does not verify
4201.104Swiz                        that the compilation tools in use are up-to-date
4211.104Swiz                        enough in order to build the tree successfully.  This
4221.104Swiz                        may cause build or runtime problems when building the
4231.104Swiz                        whole NetBSD source tree.
4241.1Stv
4251.105Swiz                 Default: ``yes'', unless TOOLCHAIN_MISSING is set to ``yes''.
4261.71Sdholland
4271.105Swiz                 USETOOLS is also set to ``no'' when using <bsd.*.mk> outside
4281.71Sdholland                 the NetBSD source tree.
4291.1Stv
4301.105Swiz     X11SRCDIR   Directory containing the X11R6 source.  If specified, must be
4311.59Sapb                 an absolute path.  The main X11R6 source is found in
4321.105Swiz                 X11SRCDIR/xfree/xc.
4331.49Slukem
4341.105Swiz                 Default: NETBSDRCDIR/../xsrc, if that exists; otherwise
4351.105Swiz                 /usr/xsrc.
4361.49Slukem
4371.105Swiz     X11FLAVOUR  The style of X11 cross-built, set to either ``Xorg'' or
4381.79Smrg                 ``XFree86''.
4391.79Smrg
4401.105Swiz                 Default: ``Xorg'' on amd64, i386, macppc, shark and sparc64
4411.81Smrg                 platforms, ``XFree86'' on everything else.
4421.79Smrg
4431.105Swiz   "make" variables for full builds
4441.7Slukem     These variables only affect the top level ``Makefile'' and do not affect
4451.7Slukem     manually building subtrees of the NetBSD source code.
4461.1Stv
4471.105Swiz     INSTALLWORLDDIR  Location for the ``make installworld'' target to install
4481.59Sapb                      to.  If specified, must be an absolute path.
4491.1Stv
4501.105Swiz                      Default: ``/''
4511.1Stv
4521.105Swiz     MKOBJDIRS        Can be set to ``yes'' or ``no''.  Indicates whether
4531.44Slukem                      object directories will be created automatically (via a
4541.20Slukem                      ``make obj'' pass) at the start of a build.
4551.1Stv
4561.105Swiz                      Default: ``no''
4571.1Stv
4581.105Swiz                      If using build.sh, the default is ``yes''.  This may be
4591.105Swiz                      set back to ``no'' by giving build.sh the -o option.
4601.70Sdholland
4611.105Swiz     MKUPDATE         Can be set to ``yes'' or ``no''.  If set, then in
4621.105Swiz                      addition to the effects described for MKUPDATE=yes
4631.105Swiz                      above, this implies the effects of NOCLEANDIR (i.e.,
4641.104Swiz                      ``make cleandir'' is avoided).
4651.38Slukem
4661.105Swiz                      Default: ``no''
4671.38Slukem
4681.105Swiz                      If using build.sh, this may be set by giving the -u
4691.70Sdholland                      option.
4701.70Sdholland
4711.105Swiz     NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead.  See
4721.70Sdholland                      below.
4731.1Stv
4741.105Swiz                      Default: Unset.
4751.1Stv
4761.105Swiz     NOCLEANDIR       If set, avoids the ``make cleandir'' phase of a full
4771.20Slukem                      build.  This has the effect of allowing only changed
4781.20Slukem                      files in a source tree to be recompiled.  This can speed
4791.20Slukem                      up builds when updating only a few files in the tree.
4801.1Stv
4811.105Swiz                      Default: Unset.
4821.1Stv
4831.105Swiz                      See also MKUPDATE.
4841.70Sdholland
4851.105Swiz     NODISTRIBDIRS    If set, avoids the ``make distrib-dirs'' phase of a full
4861.105Swiz                      build.  This skips running mtree(8) on DESTDIR, useful
4871.20Slukem                      on systems where building as an unprivileged user, or
4881.20Slukem                      where it is known that the system-wide mtree files have
4891.20Slukem                      not changed.
4901.1Stv
4911.105Swiz                      Default: Unset.
4921.1Stv
4931.105Swiz     NOINCLUDES       If set, avoids the ``make includes'' phase of a full
4941.20Slukem                      build.  This has the effect of preventing make(1) from
4951.44Slukem                      thinking that some programs are out-of-date simply
4961.44Slukem                      because the system include files have changed.  However,
4971.20Slukem                      this option should not be used when updating the entire
4981.20Slukem                      NetBSD source tree arbitrarily; it is suggested to use
4991.105Swiz                      MKUPDATE=yes instead in that case.
5001.1Stv
5011.105Swiz                      Default: Unset.
5021.1Stv
5031.105Swiz     RELEASEDIR       If set, specifies the directory to which a release(7)
5041.20Slukem                      layout will be written at the end of a ``make release''.
5051.59Sapb                      If specified, must be an absolute path.
5061.20Slukem
5071.105Swiz                      Default: Unset.
5081.20Slukem
5091.105Swiz                      Note: build.sh will provide a default of releasedir (in
5101.105Swiz                      the top-level .OBJDIR) unless run in `expert' mode.
5111.30Slukem
5121.105SwizBUILDING
5131.105Swiz   "make" command line options
5141.52Sjmc     This is not a summary of all the options available to make(1); only the
5151.52Sjmc     options used most frequently with NetBSD builds are listed here.
5161.1Stv
5171.105Swiz     -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
5181.52Sjmc                use .WAIT or have explicit dependencies as necessary to
5191.74Sapb                enforce build ordering.
5201.10Ssommerfe
5211.105Swiz     -m dir     Specify the default directory for searching for system
5221.104Swiz                Makefile segments, mainly the <bsd.*.mk> files.  When building
5231.104Swiz                any full NetBSD source tree, this should be set to the
5241.104Swiz                ``share/mk'' directory in the source tree.  This is set
5251.104Swiz                automatically when building from the top level, or when using
5261.105Swiz                build.sh.
5271.1Stv
5281.105Swiz     -n         Display the commands that would have been executed, but do not
5291.1Stv                actually execute them.  This will still cause recursion to
5301.1Stv                take place.
5311.1Stv
5321.105Swiz     -V var     Print make(1)'s idea of the value of var.  Does not build any
5331.1Stv                targets.
5341.1Stv
5351.105Swiz     var=value  Set the variable var to value, overriding any setting
5361.105Swiz                specified by the process environment, the MAKECONF
5371.104Swiz                configuration file, or the system Makefile segments.
5381.1Stv
5391.105Swiz   "make" targets
5401.1Stv     These default targets may be built by running make(1) in any subtree of
5411.1Stv     the NetBSD source code.  It is recommended that none of these be used
5421.1Stv     from the top level Makefile; as a specific exception, ``make obj'' and
5431.1Stv     ``make cleandir'' are useful in that context.
5441.1Stv
5451.105Swiz     all        Build programs, libraries, and preformatted documentation.
5461.1Stv
5471.105Swiz     clean      Remove program and library object code files.
5481.1Stv
5491.105Swiz     cleandir   Same as clean, but also remove preformatted documentation,
5501.44Slukem                dependency files generated by ``make depend'', and any other
5511.49Slukem                files known to be created at build time.
5521.1Stv
5531.105Swiz     depend     Create dependency files (.depend) containing more detailed
5541.44Slukem                information about the dependencies of source code on header
5551.1Stv                files.  Allows programs to be recompiled automatically when a
5561.1Stv                dependency changes.
5571.1Stv
5581.105Swiz     dependall  Does a ``make depend'' immediately followed by a ``make all''.
5591.10Ssommerfe                This improves cache locality of the build since both passes
5601.10Ssommerfe                read the source files in their entirety.
5611.1Stv
5621.105Swiz     distclean  Synonym for cleandir.
5631.49Slukem
5641.105Swiz     includes   Build and install system header files.  Typically needed
5651.44Slukem                before any system libraries or programs can be built.
5661.1Stv
5671.105Swiz     install    Install programs, libraries, and documentation into DESTDIR.
5681.105Swiz                Few files will be installed to DESTDIR/dev, DESTDIR/etc,
5691.105Swiz                DESTDIR/root or DESTDIR/var in order to prevent user supplied
5701.27Slukem                configuration data from being overwritten.
5711.1Stv
5721.105Swiz     lint       Run lint(1) against the C source code, where appropriate, and
5731.1Stv                generate system-installed lint libraries.
5741.1Stv
5751.105Swiz     obj        Create object directories to be used for built files, instead
5761.1Stv                of building directly in the source tree.
5771.1Stv
5781.105Swiz     tags       Create ctags(1) searchable function lists usable by the ex(1)
5791.1Stv                and vi(1) text editors.
5801.1Stv
5811.105Swiz   "make" targets for the top level
5821.1Stv     Additional make(1) targets are usable specifically from the top source
5831.1Stv     level to facilitate building the entire NetBSD source tree.
5841.1Stv
5851.105Swiz     build         Build the entire NetBSD system (except the kernel).  This
5861.68Sreed                   orders portions of the source tree such that prerequisites
5871.68Sreed                   will be built in the proper order.
5881.20Slukem
5891.105Swiz     distribution  Do a ``make build'', and then install a full distribution
5901.105Swiz                   (which does not include a kernel) into DESTDIR, including
5911.105Swiz                   files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
5921.105Swiz                   DESTDIR/var.
5931.20Slukem
5941.105Swiz     buildworld    As per ``make distribution'', except that it ensures that
5951.105Swiz                   DESTDIR is not the root directory.
5961.20Slukem
5971.105Swiz     installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR,
5981.70Sdholland                   which defaults to the root directory.  Ensures that
5991.105Swiz                   INSTALLWORLDDIR is not the root directory if cross
6001.104Swiz                   compiling.
6011.20Slukem
6021.105Swiz                   The INSTALLSETS environment variable may be set to a space-
6031.95Sapb                   separated list of distribution sets to be installed.  By
6041.95Sapb                   default, all sets except ``etc'' and ``xetc'' are
6051.105Swiz                   installed, so most files in INSTALLWORLDDIR/etc will not be
6061.95Sapb                   installed or modified.
6071.61Sapb
6081.105Swiz                   Note: Before performing this operation with
6091.105Swiz                   INSTALLWORLDDIR=/, it is highly recommended that you
6101.61Sapb                   upgrade your kernel and reboot.  After performing this
6111.61Sapb                   operation, it is recommended that you use etcupdate(8) to
6121.105Swiz                   update files in INSTALLWORLDDIR/etc, and postinstall(8) to
6131.102Sabs                   check for or fix inconsistencies.
6141.20Slukem
6151.105Swiz     sets          Create distribution sets from DESTDIR into
6161.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/sets.  Should be run
6171.70Sdholland                   after ``make distribution'', as ``make build'' alone does
6181.70Sdholland                   not install all of the required files.
6191.25Slukem
6201.105Swiz     sourcesets    Create source sets of the source tree into
6211.105Swiz                   RELEASEDIR/source/sets.
6221.31Slukem
6231.105Swiz     syspkgs       Create syspkgs from DESTDIR into
6241.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.  Should be run
6251.70Sdholland                   after ``make distribution'', as ``make build'' alone does
6261.70Sdholland                   not install all of the required files.
6271.54Sapb
6281.105Swiz     release       Do a ``make distribution'', build kernels, distribution
6291.44Slukem                   media, and install sets (this as per ``make sets''), and
6301.44Slukem                   then package the system into a standard release layout as
6311.105Swiz                   described by release(7).  This requires that RELEASEDIR be
6321.25Slukem                   set (see above).
6331.1Stv
6341.105Swiz     iso-image     Create a NetBSD installation CD-ROM image in the
6351.105Swiz                   RELEASEDIR/iso directory.  The CD-ROM file system will have
6361.62Sapb                   a layout as described in release(7).
6371.62Sapb
6381.62Sapb                   For most machine types, the CD-ROM will be bootable, and
6391.104Swiz                   will automatically run the sysinst(8) menu-based
6401.104Swiz                   installation program, which can be used to install or
6411.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
6421.104Swiz                   tools that may be useful in repairing a damaged NetBSD
6431.104Swiz                   installation.
6441.62Sapb
6451.62Sapb                   Before ``make iso-image'' is attempted, RELEASEDIR must be
6461.62Sapb                   populated by ``make release'' or equivalent.
6471.62Sapb
6481.62Sapb                   Note that other, smaller, CD-ROM images may be created in
6491.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
6501.104Swiz                   directory by ``make release''.  These smaller images
6511.104Swiz                   usually contain the same tools as the larger images in
6521.105Swiz                   RELEASEDIR/iso, but do not contain additional content such
6531.69Slukem                   as the distribution sets.
6541.62Sapb
6551.62Sapb                   Note that the mac68k port still uses an older method of
6561.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
6571.104Swiz                   utility, which is not part of NetBSD, but which can be
6581.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
6591.56Sapb
6601.105Swiz     iso-image-source
6611.64Sjnemeth                   Create a NetBSD installation CD-ROM image in the
6621.105Swiz                   RELEASEDIR/iso directory.  The CD-ROM file system will have
6631.64Sjnemeth                   a layout as described in release(7).  It will have top
6641.64Sjnemeth                   level directories for the machine type and source.
6651.64Sjnemeth
6661.64Sjnemeth                   For most machine types, the CD-ROM will be bootable, and
6671.104Swiz                   will automatically run the sysinst(8) menu-based
6681.104Swiz                   installation program, which can be used to install or
6691.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
6701.104Swiz                   tools that may be useful in repairing a damaged NetBSD
6711.104Swiz                   installation.
6721.64Sjnemeth
6731.64Sjnemeth                   Before ``make iso-image-source'' is attempted, RELEASEDIR
6741.104Swiz                   must be populated by ``make sourcesets release'' or
6751.104Swiz                   equivalent.
6761.64Sjnemeth
6771.64Sjnemeth                   Note that other, smaller, CD-ROM images may be created in
6781.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
6791.104Swiz                   directory by ``make release''.  These smaller images
6801.104Swiz                   usually contain the same tools as the larger images in
6811.105Swiz                   RELEASEDIR/iso, but do not contain additional content such
6821.69Slukem                   as the distribution sets.
6831.64Sjnemeth
6841.64Sjnemeth                   Note that the mac68k port still uses an older method of
6851.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
6861.104Swiz                   utility, which is not part of NetBSD, but which can be
6871.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
6881.64Sjnemeth
6891.105Swiz     install-image
6901.98Sapb                   Create a bootable NetBSD installation disk image in the
6911.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/installation/installimage
6921.98Sapb                   directory.  The installation disk image is suitable for
6931.98Sapb                   copying to bootable USB flash memory sticks, etc., for
6941.98Sapb                   machines which are able to boot from such devices.  The
6951.98Sapb                   file system in the bootable disk image will have a layout
6961.98Sapb                   as described in release(7).
6971.97Stsutsui
6981.97Stsutsui                   The installation image is bootable, and will automatically
6991.97Stsutsui                   run the sysinst(8) menu-based installation program, which
7001.98Sapb                   can be used to install or upgrade a NetBSD system.  The
7011.98Sapb                   image also contains tools that may be useful in repairing a
7021.98Sapb                   damaged NetBSD installation.
7031.97Stsutsui
7041.105Swiz                   Before ``make install-image'' is attempted, RELEASEDIR must
7051.98Sapb                   be populated by ``make release'' or equivalent.  The build
7061.105Swiz                   must have been performed with MKUNPRIVED=yes because ``make
7071.105Swiz                   install-image'' relies on information in DESTDIR/METALOG.
7081.97Stsutsui
7091.97Stsutsui     live-image    Create NetBSD live images in the
7101.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage
7111.104Swiz                   directory.  The live image contains all necessary files to
7121.104Swiz                   boot NetBSD up to multi-user mode, including all files
7131.104Swiz                   which should be extracted during installation, NetBSD
7141.104Swiz                   disklabel, bootloaders, etc.
7151.104Swiz
7161.104Swiz                   The live image is suitable for use as a disk image in
7171.104Swiz                   virtual machine environments such as QEMU, and also useful
7181.104Swiz                   to boot NetBSD from a USB flash memory stick on a real
7191.98Sapb                   machine, without the need for installation.
7201.97Stsutsui
7211.97Stsutsui                   Before ``make live-image'' is attempted, RELEASEDIR must be
7221.99Stsutsui                   populated by ``make release'' or equivalent.  The build
7231.105Swiz                   must have been performed with MKUNPRIVED=yes because ``make
7241.105Swiz                   install-image'' relies on information in DESTDIR/METALOG.
7251.97Stsutsui
7261.105Swiz     regression-tests
7271.20Slukem                   Can only be run after building the regression tests in the
7281.70Sdholland                   directory ``regress''.  Runs those compiled regression
7291.104Swiz                   tests on the local host.  Note that most tests are now
7301.104Swiz                   managed instead using atf(7); this target should probably
7311.104Swiz                   run those as well but currently does not.
7321.1Stv
7331.105Swiz   The "build.sh" script
7341.96Sapb     This script file is a shell script designed to build the entire NetBSD
7351.104Swiz     system on any host with a suitable modern shell and some common
7361.105Swiz     utilities.  The required shell features are described under the HOST_SH
7371.104Swiz     variable.
7381.96Sapb
7391.96Sapb     If a host system's default shell does support the required features, then
7401.96Sapb     we suggest that you explicitly specify a suitable shell using a command
7411.96Sapb     like
7421.96Sapb
7431.105Swiz           /path/to/suitable/shell build.sh [options]
7441.96Sapb
7451.105Swiz     The above command will usually enable build.sh to automatically set
7461.105Swiz     HOST_SH=/path/to/suitable/shell, but if that fails, then the following
7471.96Sapb     set of commands may be used instead:
7481.96Sapb
7491.105Swiz           HOST_SH=/path/to/suitable/shell
7501.96Sapb           export HOST_SH
7511.105Swiz           ${HOST_SH} build.sh [options]
7521.96Sapb
7531.105Swiz     If build.sh detects that it is being executed under an unsuitable shell,
7541.96Sapb     it attempts to exec a suitable shell instead, or prints an error message.
7551.105Swiz     If HOST_SH is not set explicitly, then build.sh sets a default using
7561.96Sapb     heuristics dependent on the host platform, or from the shell under which
7571.105Swiz     build.sh is executed (if that can be determined), or using the first copy
7581.105Swiz     of sh found in PATH.
7591.1Stv
7601.1Stv     All cross-compile builds, and most native builds, of the entire system
7611.105Swiz     should make use of build.sh rather than just running ``make''.  This way,
7621.104Swiz     the make(1) program will be bootstrapped properly, in case the host
7631.104Swiz     system has an older or incompatible ``make'' program.
7641.1Stv
7651.105Swiz     When compiling the entire system via build.sh, many make(1) variables are
7661.1Stv     set for you in order to help encapsulate the build process.  In the list
7671.105Swiz     of options below, variables that are automatically set by build.sh are
7681.1Stv     noted where applicable.
7691.1Stv
7701.105Swiz     The following operations are supported by build.sh:
7711.22Slukem
7721.105Swiz     build         Build the system as per ``make build''.  Before the main
7731.105Swiz                   part of the build commences, this command runs the obj
7741.105Swiz                   operation (unless the -o option is given), ``make
7751.105Swiz                   cleandir'' (unless the -u option is given), and the tools
7761.70Sdholland                   operation.
7771.22Slukem
7781.105Swiz     distribution  Build a full distribution as per ``make distribution''.
7791.105Swiz                   This command first runs the build operation.
7801.22Slukem
7811.105Swiz     release       Build a full release as per ``make release''.  This command
7821.105Swiz                   first runs the distribution operation.
7831.22Slukem
7841.105Swiz     makewrapper   Create the nbmake-MACHINE wrapper.  This operation is
7851.104Swiz                   automatically performed for any of the other operations.
7861.23Slukem
7871.105Swiz     cleandir      Perform ``make cleandir''.
7881.75Slukem
7891.105Swiz     obj           Perform ``make obj''.
7901.22Slukem
7911.105Swiz     tools         Build and install the host tools from src/tools.  This
7921.104Swiz                   command will first run ``make obj'' and ``make cleandir''
7931.105Swiz                   in the tools subdirectory unless the -o or -u options
7941.104Swiz                   (respectively) are given.
7951.22Slukem
7961.105Swiz     install=idir  Install the contents of DESTDIR to idir, using ``make
7971.61Sapb                   installworld''.  Note that files that are part of the
7981.95Sapb                   ``etc'' or ``xetc'' sets will not be installed, unless
7991.95Sapb                   overridden by the INSTALLSETS environment variable.
8001.35Slukem
8011.105Swiz     kernel=kconf  Build a new kernel.  The kconf argument is the name of a
8021.105Swiz                   configuration file suitable for use by config(1).  If kconf
8031.22Slukem                   does not contain any `/' characters, the configuration file
8041.105Swiz                   is expected to be found in the KERNCONFDIR directory, which
8051.105Swiz                   is typically sys/arch/MACHINE/conf.  The new kernel will be
8061.105Swiz                   built in a subdirectory of KERNOBJDIR, which is typically
8071.105Swiz                   sys/arch/MACHINE/compile or an associated object directory.
8081.70Sdholland
8091.105Swiz                   This command does not imply the tools command; run the
8101.105Swiz                   tools command first unless it is certain that the tools
8111.70Sdholland                   already exist and are up to date.
8121.70Sdholland
8131.70Sdholland                   This command will run ``make cleandir'' on the kernel in
8141.105Swiz                   question first unless the -u option is given.
8151.22Slukem
8161.106Swiz     kernel.gdb=kconf
8171.106Swiz                   Build a new kernel with debug information.  Similar to the
8181.106Swiz                   above kernel=kconf operation, but creates a netbsd.gdb file
8191.106Swiz                   alongside of the kernel netbsd, which contains a full
8201.106Swiz                   symbol table and can be used for debugging (for example
8211.106Swiz                   with a cross-gdb built by MKCROSSGDB).
8221.106Swiz
8231.105Swiz     modules       This command will build kernel modules and install them
8241.105Swiz                   into DESTDIR.
8251.86Sjnemeth
8261.105Swiz     releasekernel=kconf
8271.70Sdholland                   Install a gzip(1)ed copy of the kernel previously built by
8281.105Swiz                   kernel=kconf into
8291.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
8301.105Swiz                   netbsd-kconf.gz, although the ``netbsd'' prefix is
8311.105Swiz                   determined from the ``config'' directives in kconf.
8321.24Slukem
8331.105Swiz     sets          Perform ``make sets''.
8341.31Slukem
8351.105Swiz     sourcesets    Perform ``make sourcesets''.
8361.22Slukem
8371.105Swiz     syspkgs       Perform ``make syspkgs''.
8381.54Sapb
8391.105Swiz     iso-image     Perform ``make iso-image''.
8401.56Sapb
8411.105Swiz     iso-image-source
8421.65Sjnemeth                   Perform ``make iso-image-source''.
8431.65Sjnemeth
8441.105Swiz     install-image
8451.98Sapb                   Perform ``make install-image''.
8461.97Stsutsui
8471.105Swiz     live-image    Perform ``make live-image''.
8481.97Stsutsui
8491.109Sapb     list-arch     Prints a list of valid MACHINE and MACHINE_ARCH settings,
8501.109Sapb                   the default MACHINE_ARCH for each MACHINE, and aliases for
8511.109Sapb                   MACHINE/MACHINE_ARCH pairs, and then exits.  The -m or -a
8521.109Sapb                   options (or both) may be used to specify glob patterns that
8531.109Sapb                   will be used to narrow the list of results; for example,
8541.109Sapb                   ``build.sh -m 'evm*' -a '*arm*' list-arch'' will list all
8551.109Sapb                   known MACHINE/MACHINE_ARCH values in which either MACHINE
8561.109Sapb                   or ALIAS matches the pattern `evb*', and MACHINE_ARCH
8571.109Sapb                   matches the pattern `*arm*'.
8581.109Sapb
8591.105Swiz     The following command line options alter the behaviour of the build.sh
8601.51Swiz     operations described above:
8611.1Stv
8621.109Sapb     -a arch   Set the value of MACHINE_ARCH to arch.  See the -m option for
8631.109Sapb               more information.
8641.9Sthorpej
8651.105Swiz     -B buildid
8661.105Swiz               Set the value of BUILDID to buildid.  This will also append the
8671.67Ssborrill               build identifier to the name of the ``make'' wrapper script so
8681.37Slukem               that the resulting name is of the form
8691.105Swiz               ``nbmake-MACHINE-BUILDID''.
8701.1Stv
8711.105Swiz     -C cdextras
8721.105Swiz               Append cdextras to the CDEXTRA variable, which is a space-
8731.104Swiz               separated list of files or directories that will be added to
8741.104Swiz               the CD-ROM image that may be create by the ``iso-image'' or
8751.87Sapb               ``iso-image-source'' operations.  Files will be added to the
8761.87Sapb               root of the CD-ROM image, whereas directories will be copied
8771.87Sapb               recursively.  If relative paths are specified, they will be
8781.87Sapb               converted to absolute paths before being used.  Multiple paths
8791.105Swiz               may be specified via multiple -C options, or via a single
8801.87Sapb               option whose argument contains multiple space-separated paths.
8811.66Sjnemeth
8821.105Swiz     -D dest   Set the value of DESTDIR to dest.  If a relative path is
8831.104Swiz               specified, it will be converted to an absolute path before
8841.104Swiz               being used.
8851.104Swiz
8861.105Swiz     -E        Set `expert' mode.  This overrides various sanity checks, and
8871.105Swiz               allows: DESTDIR does not have to be set to a non-root path for
8881.105Swiz               builds, and MKUNPRIVED=yes does not have to be set when
8891.104Swiz               building as a non-root user.
8901.23Slukem
8911.105Swiz               Note: It is highly recommended that you know what you are doing
8921.23Slukem               when you use this option.
8931.19Slukem
8941.105Swiz     -h        Print a help message.
8951.51Swiz
8961.105Swiz     -j njob   Run up to njob make(1) subjobs in parallel; passed through to
8971.74Sapb               make(1).  If you see failures for reasons other than running
8981.105Swiz               out of memory while using build.sh with -j, please save
8991.104Swiz               complete build logs so the failures can be analyzed.
9001.74Sapb
9011.105Swiz               To achieve the fastest builds, -j values between (1 + the
9021.104Swiz               number of CPUs) and (2 * the number of CPUs) are recommended.
9031.104Swiz               Use lower values on machines with limited memory or I/O
9041.104Swiz               bandwidth.
9051.104Swiz
9061.105Swiz     -M obj    Set MAKEOBJDIRPREFIX to obj.  Unsets MAKEOBJDIR.  See ``-O
9071.106Swiz               obj'' for more information.
9081.104Swiz
9091.105Swiz               For instance, if the source directory is /usr/src, a setting of
9101.105Swiz               ``-M /usr/obj'' will place build-time files under
9111.105Swiz               /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
9121.105Swiz               /usr/obj/usr/src/usr.bin, and so forth.
9131.88Sapb
9141.73Sapb               If a relative path is specified, it will be converted to an
9151.105Swiz               absolute path before being used.  build.sh imposes the
9161.105Swiz               restriction that the argument to the -M option must not begin
9171.104Swiz               with a ``$'' (dollar sign) character; otherwise it would be too
9181.104Swiz               difficult to determine whether the value is an absolute or a
9191.104Swiz               relative path.  If the directory does not already exist,
9201.105Swiz               build.sh will create it.
9211.18Slukem
9221.109Sapb     -m mach   Set the value of MACHINE to mach, unless the mach argument is
9231.109Sapb               an alias that refers to a MACHINE/MACHINE_ARCH pair, in which
9241.109Sapb               case both MACHINE and MACHINE_ARCH are set from the alias.
9251.109Sapb               Such aliases are interpreted entirely by build.sh; they are not
9261.109Sapb               used by any other part of the build system.  The MACHINE_ARCH
9271.109Sapb               setting implied by mach will override any value of MACHINE_ARCH
9281.109Sapb               in the process environment, but will not override a value set
9291.109Sapb               by the -a option.  All cross builds require -m, but if unset on
9301.109Sapb               a NetBSD host, the host's value of MACHINE will be detected and
9311.109Sapb               used automatically.
9321.109Sapb
9331.109Sapb               See the list-arch operation for a way to get a list of valid
9341.109Sapb               MACHINE and MACHINE_ARCH settings.
9351.1Stv
9361.105Swiz     -N noiselevel
9371.46Slukem               Set the ``noisyness'' level of the build, by setting
9381.105Swiz               MAKEVERBOSE to noiselevel.
9391.45Slukem
9401.105Swiz     -n        Show the commands that would be executed by build.sh, but do
9411.1Stv               not make any changes.  This is similar in concept to ``make
9421.1Stv               -n''.
9431.1Stv
9441.105Swiz     -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
9451.105Swiz               place the built object files under obj.  Unsets
9461.105Swiz               MAKEOBJDIRPREFIX.
9471.88Sapb
9481.105Swiz               For instance, a setting of ``-O /usr/obj'' will place build-
9491.105Swiz               time files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin,
9501.88Sapb               and so forth.
9511.88Sapb
9521.88Sapb               If a relative path is specified, it will be converted to an
9531.105Swiz               absolute path before being used.  build.sh imposes the
9541.105Swiz               restriction that the argument to the -O option must not contain
9551.104Swiz               a ``$'' (dollar sign) character.  If the directory does not
9561.105Swiz               already exist, build.sh will create it.
9571.73Sapb
9581.105Swiz               In normal use, exactly one of the -M or -O options should be
9591.105Swiz               specified.  If neither -M nor -O is specified, then a default
9601.78Sapb               object directory will be chosen according to rules in
9611.78Sapb               <bsd.obj.mk>.  Relying on this default is not recommended
9621.78Sapb               because it is determined by complex rules that are influenced
9631.78Sapb               by the values of several variables and by the location of the
9641.78Sapb               source directory.
9651.18Slukem
9661.109Sapb               Note that placing the obj directory location outside of the
9671.109Sapb               default source tree hierarchy makes it easier to manually clear
9681.109Sapb               out old files in the event the ``make cleandir'' operation is
9691.109Sapb               unable to do so.  (See CAVEATS below.)
9701.109Sapb
9711.109Sapb               Note also that use of one of -M or -O is the only means of
9721.109Sapb               building multiple machine architecture userlands from the same
9731.109Sapb               source tree without cleaning between builds (in which case, one
9741.109Sapb               would specify distinct obj locations for each).
9751.109Sapb
9761.105Swiz     -o        Set the value of MKOBJDIRS to ``no''.  Otherwise, it will be
9771.70Sdholland               automatically set to ``yes''.  This default is opposite to the
9781.105Swiz               behaviour when not using build.sh.
9791.1Stv
9801.105Swiz     -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
9811.59Sapb               specified, it will be converted to an absolute path before
9821.59Sapb               being used.
9831.18Slukem
9841.105Swiz     -r        Remove the contents of DESTDIR and TOOLDIR before building
9851.1Stv               (provides a clean starting point).  This will skip deleting
9861.105Swiz               DESTDIR if building on a native system to the root directory.
9871.1Stv
9881.105Swiz     -S seed   Change the value of BUILDSEED to seed.  This should rarely be
9891.72Sperry               necessary.
9901.72Sperry
9911.105Swiz     -T tools  Set the value of TOOLDIR to tools.  If a relative path is
9921.104Swiz               specified, it will be converted to an absolute path before
9931.104Swiz               being used.  If set, the bootstrap ``make'' will only be
9941.104Swiz               rebuilt if the source files for make(1) have changed.
9951.104Swiz
9961.105Swiz     -U        Set MKUNPRIVED=yes.
9971.104Swiz
9981.105Swiz     -u        Set MKUPDATE=yes.
9991.104Swiz
10001.105Swiz     -V var=[value]
10011.105Swiz               Set the environment variable var to an optional value.  This is
10021.105Swiz               propagated to the nbmake wrapper.
10031.105Swiz
10041.105Swiz     -w wrapper
10051.105Swiz               Create the nbmake wrapper script (see below) in a custom
10061.105Swiz               location, specified by wrapper.  This allows, for instance, to
10071.105Swiz               place the wrapper in PATH automatically.  Note that wrapper is
10081.59Sapb               the full name of the file, not just a directory name.  If a
10091.59Sapb               relative path is specified, it will be converted to an absolute
10101.59Sapb               path before being used.
10111.1Stv
10121.105Swiz     -X x11src
10131.105Swiz               Set the value of X11SRCDIR to x11src.  If a relative path is
10141.59Sapb               specified, it will be converted to an absolute path before
10151.59Sapb               being used.
10161.49Slukem
10171.105Swiz     -x        Set MKX11=yes.
10181.49Slukem
10191.105Swiz     -Z var    Unset ("zap") the environment variable var.  This is propagated
10201.105Swiz               to the nbmake wrapper.
10211.40Slukem
10221.105Swiz   The "nbmake-MACHINE" wrapper script
10231.105Swiz     If using the build.sh script to build NetBSD, a nbmake-MACHINE script
10241.105Swiz     will be created in TOOLDIR/bin upon the first build to assist in building
10251.1Stv     subtrees on a cross-compile host.
10261.1Stv
10271.105Swiz     nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
10281.105Swiz     the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with
10291.105Swiz     several key variables pre-set, including MACHINE, MACHINE_ARCH, and
10301.105Swiz     TOOLDIR.  nbmake-MACHINE will also set variables specified with -V, and
10311.105Swiz     unset variables specified with -Z.
10321.40Slukem
10331.105Swiz     This script can be symlinked into a directory listed in PATH, or called
10341.1Stv     with an absolute path.
10351.1Stv
10361.105SwizEXAMPLES
10371.78Sapb     1.   % ./build.sh [options] tools kernel=GENERIC
10381.28Slukem
10391.28Slukem          Build a new toolchain, and use the new toolchain to configure and
10401.28Slukem          build a new GENERIC kernel.
10411.28Slukem
10421.78Sapb     2.   % ./build.sh [options] -U distribution
10431.28Slukem
10441.105Swiz          Using unprivileged mode, build a complete distribution to a DESTDIR
10451.105Swiz          directory that build.sh selects (and will display).
10461.28Slukem
10471.78Sapb     3.   # ./build.sh [options] -U install=/
10481.28Slukem
10491.105Swiz          As root, install to / the distribution that was built by example 2.
10501.105Swiz          Even though this is run as root, -U is required so that the
10511.105Swiz          permissions stored in DESTDIR/METALOG are correctly applied to the
10521.105Swiz          files as they're copied to /.
10531.28Slukem
10541.78Sapb     4.   % ./build.sh [options] -U -u release
10551.28Slukem
10561.105Swiz          Using unprivileged mode, build a complete release to DESTDIR and
10571.105Swiz          RELEASEDIR directories that build.sh selects (and will display).
10581.105Swiz          MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that
10591.38Slukem          if this is run after example 2, it doesn't need to redo that portion
10601.38Slukem          of the release build.
10611.16Slukem
10621.105SwizOBSOLETE VARIABLES
10631.105Swiz     NBUILDJOBS  Use the make(1) option -j instead.
10641.15Slukem
10651.105Swiz     USE_NEW_TOOLCHAIN
10661.15Slukem                 The new toolchain is now the default.  To disable, use
10671.105Swiz                 TOOLCHAIN_MISSING=yes.
10681.10Ssommerfe
10691.105SwizSEE ALSO
10701.62Sapb     make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8),
10711.105Swiz     pkgsrc/sysutils/cdrtools
10721.1Stv
10731.105SwizHISTORY
10741.105Swiz     The build.sh based build scheme was introduced for NetBSD 1.6 as
10751.105Swiz     USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
10761.1Stv
10771.109SapbCAVEATS
10781.109Sapb     After significant updates to third-party components in the source tree,
10791.109Sapb     the ``make cleandir'' operation may be insufficient to clean out old
10801.109Sapb     files in object directories.  Instead, one may have to manually remove
10811.109Sapb     the files.  Consult the UPDATING file for notices concerning this.
10821.109Sapb
10831.109SapbNetBSD                          August 7, 2014                          NetBSD
1084