BUILDING revision 1.130
11.104SwizBUILDING(8)                 System Manager's Manual                BUILDING(8)
21.1Stv
31.105SwizNAME
41.122Swiz     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.126Swiz     This source tree contains a special subtree, "tools", which uses the host
131.126Swiz     system to create a build toolchain for the target architecture.  The host
141.126Swiz     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.129Ssevan                    NetBSD make(1).  Intended for expert use with knowlege of
331.129Ssevan                    its shortcomings, it has been superseded by the build.sh
341.129Ssevan                    shell script as the recommended means for building NetBSD.
351.1Stv
361.105Swiz     UPDATING       Special notes for updating from an earlier revision of
371.1Stv                    NetBSD.  It is important to read this file before every
381.1Stv                    build of an updated source tree.
391.1Stv
401.105Swiz     build.sh       Bourne-compatible shell script used for building the host
411.1Stv                    build tools and the NetBSD system from scratch.  Can be
421.1Stv                    used for both native and cross builds, and should be used
431.129Ssevan                    instead of make(1) as it performs additional checks to
441.129Ssevan                    prevent common issues going undetected, such as building
451.129Ssevan                    with an outdated version of make(1).
461.1Stv
471.105Swiz     crypto/dist/, dist/, gnu/dist/
481.104Swiz                    Sources imported verbatim from third parties, without
491.104Swiz                    mangling the existing build structure.  Other source trees
501.126Swiz                    in bin through usr.sbin use the NetBSD make(1) "reachover"
511.126Swiz                    Makefile semantics when building these programs for a
521.126Swiz                    native host.
531.104Swiz
541.106Swiz     external, sys/external
551.106Swiz                    Sources and build infrastructure for components imported
561.106Swiz                    (mostly) unchanged from upstream maintainers, sorted by
571.106Swiz                    applicable license.  This is (slowly) replacing the
581.106Swiz                    crypto/dist, dist, and gnu/dist directories.
591.106Swiz
601.105Swiz     distrib/, etc/
611.104Swiz                    Sources for items used when making a full release
621.105Swiz                    snapshot, such as files installed in DESTDIR/etc on the
631.104Swiz                    destination system, boot media, and release notes.
641.1Stv
651.105Swiz     tests/, regress/
661.70Sdholland                    Regression test harness.  Can be cross-compiled, but only
671.105Swiz                    run natively.  tests/ uses the atf(7) test framework;
681.105Swiz                    regress/ contains older tests that have not yet been
691.70Sdholland                    migrated to atf(7).
701.1Stv
711.105Swiz     sys/           NetBSD kernel sources.
721.1Stv
731.126Swiz     tools/         "Reachover" build structure for the host build tools.
741.104Swiz                    This has a special method of determining out-of-date
751.104Swiz                    status.
761.1Stv
771.105Swiz     bin/ ... usr.sbin/
781.1Stv                    Sources to the NetBSD userland (non-kernel) programs.  If
791.1Stv                    any of these directories are missing, they will be skipped
801.1Stv                    during the build.
811.1Stv
821.121Smrg     external/mit/xorg/
831.126Swiz                    "Reachover" build structure for modular Xorg; the source
841.121Smrg                    is in X11SRCDIR.
851.49Slukem
861.126Swiz     extsrc/        "Reachover" build structure for externally added programs
871.126Swiz                    and libraries; the source is in EXTSRCSRCDIR.
881.115Sapb
891.105Swiz   Build tree layout
901.1Stv     The NetBSD build tree is described in hier(7), and the release layout is
911.1Stv     described in release(7).
921.1Stv
931.105SwizCONFIGURATION
941.105Swiz   Environment variables
951.8Slukem     Several environment variables control the behaviour of NetBSD builds.
961.8Slukem
971.105Swiz     HOST_SH           Path name to a shell available on the host system and
981.96Sapb                       suitable for use during the build.  The NetBSD build
991.96Sapb                       system requires a modern Bourne-like shell with POSIX-
1001.96Sapb                       compliant features, and also requires support for the
1011.126Swiz                       "local" keyword to declare local variables in shell
1021.104Swiz                       functions (which is a widely-implemented but non-
1031.104Swiz                       standardised feature).
1041.96Sapb
1051.96Sapb                       Depending on the host system, a suitable shell may be
1061.105Swiz                       /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a
1071.126Swiz                       variant of ksh that supports the "local" keyword, such
1081.126Swiz                       as ksh88, but not ksh93), or /usr/local/bin/bash.
1091.96Sapb
1101.105Swiz                       Most parts of the build require HOST_SH to be an
1111.105Swiz                       absolute path; however, build.sh allows it to be a
1121.104Swiz                       simple command name, which will be converted to an
1131.105Swiz                       absolute path by searching the PATH.
1141.58Sapb
1151.105Swiz     HOST_CC           Path name to C compiler used to create the toolchain.
1161.53Sreed
1171.105Swiz     HOST_CXX          Path name to C++ compiler used to create the toolchain.
1181.53Sreed
1191.126Swiz     MACHINE           Machine type, e.g., "macppc".
1201.8Slukem
1211.126Swiz     MACHINE_ARCH      Machine architecture, e.g., "powerpc".
1221.8Slukem
1231.105Swiz     MAKE              Path name to invoke make(1) as.
1241.8Slukem
1251.105Swiz     MAKEFLAGS         Flags to invoke make(1) with.  Note that build.sh
1261.105Swiz                       ignores the value of MAKEFLAGS passed in the
1271.105Swiz                       environment, but allows MAKEFLAGS to be set via the -V
1281.104Swiz                       option.
1291.8Slukem
1301.105Swiz     MAKEOBJDIR        Directory to use as the .OBJDIR for the current
1311.104Swiz                       directory.  The value is subjected to variable
1321.104Swiz                       expansion by make(1).  Typical usage is to set this
1331.104Swiz                       variable to a value involving the use of
1341.104Swiz                       `${.CURDIR:S...}' or `${.CURDIR:C...}', to derive the
1351.105Swiz                       value of .OBJDIR from the value of .CURDIR.  Used only
1361.105Swiz                       if MAKEOBJDIRPREFIX is not defined.  MAKEOBJDIR can be
1371.105Swiz                       provided only in the environment or via the -O flag of
1381.105Swiz                       build.sh; it cannot usefully be set inside a Makefile,
1391.105Swiz                       including mk.conf or ${MAKECONF}.
1401.8Slukem
1411.105Swiz     MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  The
1421.88Sapb                       value is subjected to variable expansion by make(1).
1431.105Swiz                       build.sh will create the ${MAKEOBJDIRPREFIX} directory
1441.105Swiz                       if necessary, but if make(1) is used without build.sh,
1451.88Sapb                       then rules in <bsd.obj.mk> will abort the build if the
1461.88Sapb                       ${MAKEOBJDIRPREFIX} directory does not exist.  If the
1471.104Swiz                       value is defined and valid, then
1481.105Swiz                       ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR
1491.104Swiz                       for the current directory.  The current directory may
1501.105Swiz                       be read only.  MAKEOBJDIRPREFIX can be provided only in
1511.105Swiz                       the environment or via the -M flag of build.sh; it
1521.104Swiz                       cannot usefully be set inside a Makefile, including
1531.105Swiz                       mk.conf or ${MAKECONF}.
1541.104Swiz
1551.105Swiz   "make" variables
1561.104Swiz     Several variables control the behavior of NetBSD builds.  Unless
1571.104Swiz     otherwise specified, these variables may be set in either the process
1581.105Swiz     environment or the make(1) configuration file specified by MAKECONF.
1591.1Stv
1601.107Sapb     BUILDID     Identifier for the build.  If set, this should be a short
1611.107Sapb                 string that is suitable for use as part of a file or
1621.107Sapb                 directory name.  The identifier will be appended to object
1631.107Sapb                 directory names, and can be consulted in the make(1)
1641.104Swiz                 configuration file in order to set additional build
1651.107Sapb                 parameters, such as compiler flags.  It will also be used as
1661.107Sapb                 part of the kernel version string, which can be printed by
1671.126Swiz                 "uname -v".
1681.107Sapb
1691.107Sapb                 Default: Unset.
1701.9Sthorpej
1711.108Sapb     BUILDINFO   This may be a multi-line string containing information about
1721.108Sapb                 the build.  This will appear in DESTDIR/etc/release, and it
1731.108Sapb                 will be stored in the buildinfo variable in any kernels that
1741.108Sapb                 are built.  When such kernels are booted, the sysctl(7)
1751.108Sapb                 kern.buildinfo variable will report this value.  The string
1761.126Swiz                 may contain backslash escape sequences, such as "\\"
1771.126Swiz                 (representing a backslash character) and "\n" (representing a
1781.126Swiz                 newline).
1791.108Sapb
1801.108Sapb                 Default: Unset.
1811.108Sapb
1821.105Swiz     BUILDSEED   GCC uses random numbers when compiling C++ code.  This
1831.104Swiz                 variable seeds the gcc random number generator using the
1841.104Swiz                 -frandom-seed flag with this value.  By default, it is set to
1851.104Swiz                 NetBSD-(majorversion).  Using a fixed value causes C++
1861.104Swiz                 binaries to be the same when built from the same sources,
1871.104Swiz                 resulting in identical (reproducible) builds.  Additional
1881.104Swiz                 information is available in the GCC documentation of
1891.104Swiz                 -frandom-seed.
1901.104Swiz
1911.105Swiz     DESTDIR     Directory to contain the built NetBSD system.  If set,
1921.104Swiz                 special options are passed to the compilation tools to
1931.105Swiz                 prevent their default use of the host system's /usr/include,
1941.105Swiz                 /usr/lib, and so forth.  This pathname must be an absolute
1951.105Swiz                 path, and should not end with a slash (/) character.  (For
1961.105Swiz                 installation into the system's root directory, set DESTDIR to
1971.126Swiz                 an empty string, not to "/").  The directory must reside on a
1981.126Swiz                 file system which supports long file names and hard links.
1991.1Stv
2001.126Swiz                 Default: Empty string if USETOOLS is "yes"; unset otherwise.
2011.1Stv
2021.105Swiz                 Note: build.sh will provide a default of destdir.MACHINE (in
2031.105Swiz                 the top-level .OBJDIR) unless run in `expert' mode.
2041.30Slukem
2051.115Sapb     EXTSRCSRCDIR
2061.115Sapb                 Directory containing sources of externally added programs and
2071.115Sapb                 libraries.  If specified, must be an absolute path.
2081.115Sapb
2091.115Sapb                 Default: NETBSDRCDIR/../extsrc, if that exists; otherwise
2101.115Sapb                 /usr/extsrc.
2111.115Sapb
2121.105Swiz     MAKECONF    The name of the make(1) configuration file.  Only settable in
2131.105Swiz                 the process environment.
2141.1Stv
2151.126Swiz                 Default: "/etc/mk.conf"
2161.1Stv
2171.105Swiz     MAKEVERBOSE
2181.45Slukem                 Level of verbosity of status messages.  Supported values:
2191.45Slukem
2201.80Sapb                 0    No descriptive messages or commands executed by make(1)
2211.80Sapb                      are shown.
2221.45Slukem
2231.80Sapb                 1    Brief messages are shown describing what is being done,
2241.104Swiz                      but the actual commands executed by make(1) are not
2251.104Swiz                      displayed.
2261.80Sapb
2271.80Sapb                 2    Descriptive messages are shown as above (prefixed with a
2281.80Sapb                      `#'), and ordinary commands performed by make(1) are
2291.80Sapb                      displayed.
2301.80Sapb
2311.80Sapb                 3    In addition to the above, all commands performed by
2321.80Sapb                      make(1) are displayed, even if they would ordinarily
2331.126Swiz                      have been hidden through use of the "@" prefix in the
2341.80Sapb                      relevant makefile.
2351.45Slukem
2361.80Sapb                 4    In addition to the above, commands executed by make(1)
2371.126Swiz                      are traced through use of the sh(1) "-x" flag.
2381.45Slukem
2391.105Swiz                 Default: 2
2401.45Slukem
2411.126Swiz     MKCATPAGES  Can be set to "yes" or "no".  Indicates whether preformatted
2421.126Swiz                 plaintext manual pages will be created during a build.
2431.1Stv
2441.126Swiz                 Default: "no"
2451.1Stv
2461.126Swiz     MKCROSSGDB  Can be set to "yes" or "no".  Create a cross-gdb as a host
2471.126Swiz                 tool.
2481.106Swiz
2491.126Swiz                 Default: "no"
2501.106Swiz
2511.126Swiz     MKDEBUG     Can be set to "yes" or "no".  Indicates whether debug
2521.106Swiz                 information should be generated for all userland binaries
2531.106Swiz                 compiled.  The result is collected as an additional debug.tgz
2541.106Swiz                 and xdebug.tgz set and installed in /usr/libdata/debug.
2551.106Swiz
2561.126Swiz                 Default: "no"
2571.106Swiz
2581.126Swiz     MKDEBUGLIB  Can be set to "yes" or "no".  Indicates whether debug
2591.106Swiz                 information (see MKDEBUG) should also be generated for all
2601.106Swiz                 libraries build.
2611.106Swiz
2621.126Swiz                 Default: "no"
2631.106Swiz
2641.126Swiz     MKDOC       Can be set to "yes" or "no".  Indicates whether system
2651.105Swiz                 documentation destined for DESTDIR/usr/share/doc will be
2661.44Slukem                 installed during a build.
2671.1Stv
2681.126Swiz                 Default: "yes"
2691.1Stv
2701.126Swiz     MKEXTSRC    Can be set to "yes" or "no".  Indicates whether extsrc is
2711.115Sapb                 built from EXTSRCSRCDIR.
2721.115Sapb
2731.126Swiz                 Default: "no"
2741.115Sapb
2751.126Swiz     MKHTML      Can be set to "yes" or "no".  Indicates whether preformatted
2761.126Swiz                 HTML manual pages will be built and installed
2771.77Slukem
2781.126Swiz                 Default: "yes"
2791.77Slukem
2801.126Swiz     MKHOSTOBJ   Can be set to "yes" or "no".  If set to "yes", then for
2811.4Stv                 programs intended to be run on the compile host, the name,
2821.4Stv                 release, and architecture of the host operating system will
2831.4Stv                 be suffixed to the name of the object directory created by
2841.126Swiz                 "make obj".  (This allows multiple host systems to compile
2851.126Swiz                 NetBSD for a single target.)  If set to "no", then programs
2861.4Stv                 built to be run on the compile host will use the same object
2871.4Stv                 directory names as programs built to be run on the target.
2881.4Stv
2891.126Swiz                 Default: "no"
2901.4Stv
2911.126Swiz     MKINFO      Can be set to "yes" or "no".  Indicates whether GNU Info
2921.1Stv                 files, used for the documentation for most of the compilation
2931.1Stv                 tools, will be created and installed during a build.
2941.1Stv
2951.126Swiz                 Default: "yes"
2961.1Stv
2971.126Swiz     MKKDEBUG    Can be set to "yes" or "no".  Force generation of full-debug
2981.126Swiz                 symbol versions of all kernels compiled.  Alongside of the
2991.126Swiz                 netbsd kernel file, an unstripped version netbsd.gdb is
3001.106Swiz                 created.  This is useful if a cross-gdb is built as well (see
3011.106Swiz                 MKCROSSGDB).
3021.106Swiz
3031.126Swiz                 Default: "no"
3041.106Swiz
3051.126Swiz     MKKMOD      Can be set to "yes" or "no".  Indicates whether kernel
3061.95Sapb                 modules are built and installed.
3071.95Sapb
3081.126Swiz                 Default: "yes"
3091.95Sapb
3101.126Swiz     MKLINT      Can be set to "yes" or "no".  Indicates whether lint(1) will
3111.126Swiz                 be run against portions of the NetBSD source code during the
3121.126Swiz                 build, and whether lint libraries will be installed into
3131.105Swiz                 DESTDIR/usr/libdata/lint.
3141.1Stv
3151.126Swiz                 Default: "yes"
3161.1Stv
3171.126Swiz     MKMAN       Can be set to "yes" or "no".  Indicates whether manual pages
3181.126Swiz                 will be installed during a build.
3191.1Stv
3201.126Swiz                 Default: "yes"
3211.1Stv
3221.126Swiz     MKNLS       Can be set to "yes" or "no".  Indicates whether Native
3231.44Slukem                 Language System locale zone files will be compiled and
3241.44Slukem                 installed during a build.
3251.1Stv
3261.126Swiz                 Default: "yes"
3271.1Stv
3281.126Swiz     MKOBJ       Can be set to "yes" or "no".  Indicates whether object
3291.126Swiz                 directories will be created when running "make obj".  If set
3301.126Swiz                 to "no", then all built files will be located inside the
3311.126Swiz                 regular source tree.
3321.1Stv
3331.126Swiz                 Default: "yes"
3341.1Stv
3351.126Swiz                 Note that setting MKOBJ to "no" is not recommended and may
3361.70Sdholland                 cause problems when updating the tree with cvs(1).
3371.70Sdholland
3381.126Swiz     MKPIC       Can be set to "yes" or "no".  Indicates whether shared
3391.1Stv                 objects and libraries will be created and installed during a
3401.126Swiz                 build.  If set to "no", the entire built system will be
3411.1Stv                 statically linked.
3421.1Stv
3431.130Ssevan                 Default: Platform dependent.  As of this writing, all
3441.130Ssevan                 platforms except m68000 default to "yes".
3451.1Stv
3461.105Swiz     MKPICINSTALL
3471.126Swiz                 Can be set to "yes" or "no".  Indicates whether the ar(1)
3481.105Swiz                 format libraries (lib*_pic.a), used to generate shared
3491.44Slukem                 libraries, are installed during a build.
3501.1Stv
3511.126Swiz                 Default: "yes"
3521.1Stv
3531.126Swiz     MKPROFILE   Can be set to "yes" or "no".  Indicates whether profiled
3541.105Swiz                 libraries (lib*_p.a) will be built and installed during a
3551.1Stv                 build.
3561.1Stv
3571.126Swiz                 Default: "yes"; however, some platforms turn off MKPROFILE by
3581.126Swiz                 default at times due to toolchain problems with profiled
3591.1Stv                 code.
3601.1Stv
3611.126Swiz     MKREPRO     Can be set to "yes" or "no".  Create reproducible builds.
3621.100Swiz                 This enables different switches to make two builds from the
3631.100Swiz                 same source tree result in the same build results.
3641.100Swiz
3651.126Swiz                 Default: "no" This may be set to "yes" by giving build.sh the
3661.126Swiz                 -P option.
3671.100Swiz
3681.122Swiz     MKREPRO_TIMESTAMP
3691.122Swiz                 Unix timestamp.  When MKREPRO is set, the timestamp of all
3701.122Swiz                 files in the sets will be set to this value.
3711.122Swiz
3721.124Schristos                 Default: Unset.  This may be set automatically to the latest
3731.124Schristos                 source tree timestamp using cvslatest(1) by giving build.sh
3741.124Schristos                 the -P option.
3751.122Swiz
3761.126Swiz     MKSHARE     Can be set to "yes" or "no".  Indicates whether files
3771.105Swiz                 destined to reside in DESTDIR/usr/share will be built and
3781.126Swiz                 installed during a build.  If set to "no", then all of
3791.105Swiz                 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
3801.126Swiz                 "no" unconditionally.
3811.1Stv
3821.126Swiz                 Default: "yes"
3831.1Stv
3841.105Swiz     MKSTRIPIDENT
3851.126Swiz                 Can be set to "yes" or "no".  Indicates whether RCS IDs, for
3861.126Swiz                 use with ident(1), should be stripped from program binaries
3871.126Swiz                 and shared libraries.
3881.78Sapb
3891.126Swiz                 Default: "no"
3901.78Sapb
3911.126Swiz     MKSTRIPSYM  Can be set to "yes" or "no".  Indicates whether all local
3921.126Swiz                 symbols should be stripped from shared libraries.  If "yes",
3931.125Sozaki                 strip all local symbols from shared libraries; the affect is
3941.126Swiz                 equivalent to the -x option of ld(1).  If "no", strip only
3951.126Swiz                 temporary local symbols; the affect is equivalent to the -X
3961.126Swiz                 option of ld(1).  Keeping non-temporary local symbols such as
3971.125Sozaki                 static function names is useful on using DTrace for userland
3981.125Sozaki                 libraries and getting a backtrace from a rump kernel loading
3991.125Sozaki                 shared libraries.
4001.125Sozaki
4011.126Swiz                 Default: "yes"
4021.125Sozaki
4031.126Swiz     MKUNPRIVED  Can be set to "yes" or "no".  Indicates whether an
4041.104Swiz                 unprivileged install will occur.  The user, group,
4051.104Swiz                 permissions, and file flags, will not be set on the installed
4061.52Sjmc                 items; instead the information will be appended to a file
4071.105Swiz                 called METALOG in DESTDIR.  The contents of METALOG are used
4081.52Sjmc                 during the generation of the distribution tar files to ensure
4091.52Sjmc                 that the appropriate file ownership is stored.
4101.38Slukem
4111.126Swiz                 Default: "no"
4121.38Slukem
4131.126Swiz     MKUPDATE    Can be set to "yes" or "no".  Indicates whether all install
4141.126Swiz                 operations intended to write to DESTDIR will compare file
4151.126Swiz                 timestamps before installing, and skip the install phase if
4161.126Swiz                 the destination files are up-to-date.  This also has
4171.44Slukem                 implications on full builds (see next subsection).
4181.38Slukem
4191.126Swiz                 Default: "no"
4201.38Slukem
4211.126Swiz     MKX11       Can be set to "yes" or "no".  Indicates whether X11 is built
4221.126Swiz                 from X11SRCDIR.
4231.49Slukem
4241.126Swiz                 Default: "no"
4251.49Slukem
4261.105Swiz     TOOLDIR     Directory to hold the host tools, once built.  If specified,
4271.59Sapb                 must be an absolute path.  This directory should be unique to
4281.104Swiz                 a given host system and NetBSD source tree.  (However,
4291.105Swiz                 multiple targets may share the same TOOLDIR; the target-
4301.104Swiz                 dependent files have unique names.)  If unset, a default
4311.104Swiz                 based on the uname(1) information of the host platform will
4321.105Swiz                 be created in the .OBJDIR of src.
4331.1Stv
4341.105Swiz                 Default: Unset.
4351.1Stv
4361.105Swiz     USETOOLS    Indicates whether the tools specified by TOOLDIR should be
4371.126Swiz                 used as part of a build in progress.  Must be set to "yes" if
4381.126Swiz                 cross-compiling.
4391.1Stv
4401.105Swiz                 yes    Use the tools from TOOLDIR.
4411.1Stv
4421.105Swiz                 no     Do not use the tools from TOOLDIR, but refuse to build
4431.1Stv                        native compilation tool components that are version-
4441.1Stv                        specific for that tool.
4451.1Stv
4461.105Swiz                 never  Do not use the tools from TOOLDIR, even when building
4471.104Swiz                        native tool components.  This is similar to the
4481.105Swiz                        traditional NetBSD build method, but does not verify
4491.104Swiz                        that the compilation tools in use are up-to-date
4501.104Swiz                        enough in order to build the tree successfully.  This
4511.104Swiz                        may cause build or runtime problems when building the
4521.104Swiz                        whole NetBSD source tree.
4531.1Stv
4541.126Swiz                 Default: "yes", unless TOOLCHAIN_MISSING is set to "yes".
4551.71Sdholland
4561.126Swiz                 USETOOLS is also set to "no" when using <bsd.*.mk> outside
4571.71Sdholland                 the NetBSD source tree.
4581.1Stv
4591.121Smrg     X11SRCDIR   Directory containing the modular Xorg source.  If specified,
4601.121Smrg                 must be an absolute path.  The main modular Xorg source is
4611.121Smrg                 found in X11SRCDIR/external/mit.
4621.49Slukem
4631.105Swiz                 Default: NETBSDRCDIR/../xsrc, if that exists; otherwise
4641.105Swiz                 /usr/xsrc.
4651.49Slukem
4661.105Swiz   "make" variables for full builds
4671.126Swiz     These variables only affect the top level "Makefile" and do not affect
4681.7Slukem     manually building subtrees of the NetBSD source code.
4691.1Stv
4701.126Swiz     INSTALLWORLDDIR  Location for the "make installworld" target to install
4711.59Sapb                      to.  If specified, must be an absolute path.
4721.1Stv
4731.126Swiz                      Default: "/"
4741.1Stv
4751.126Swiz     MKOBJDIRS        Can be set to "yes" or "no".  Indicates whether object
4761.126Swiz                      directories will be created automatically (via a "make
4771.126Swiz                      obj" pass) at the start of a build.
4781.1Stv
4791.126Swiz                      Default: "no"
4801.1Stv
4811.126Swiz                      If using build.sh, the default is "yes".  This may be
4821.126Swiz                      set back to "no" by giving build.sh the -o option.
4831.70Sdholland
4841.126Swiz     MKUPDATE         Can be set to "yes" or "no".  If set, then in addition
4851.126Swiz                      to the effects described for MKUPDATE=yes above, this
4861.126Swiz                      implies the effects of NOCLEANDIR (i.e., "make cleandir"
4871.126Swiz                      is avoided).
4881.38Slukem
4891.126Swiz                      Default: "no"
4901.38Slukem
4911.105Swiz                      If using build.sh, this may be set by giving the -u
4921.70Sdholland                      option.
4931.70Sdholland
4941.105Swiz     NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead.  See
4951.70Sdholland                      below.
4961.1Stv
4971.105Swiz                      Default: Unset.
4981.1Stv
4991.126Swiz     NOCLEANDIR       If set, avoids the "make cleandir" phase of a full
5001.20Slukem                      build.  This has the effect of allowing only changed
5011.20Slukem                      files in a source tree to be recompiled.  This can speed
5021.20Slukem                      up builds when updating only a few files in the tree.
5031.1Stv
5041.105Swiz                      Default: Unset.
5051.1Stv
5061.105Swiz                      See also MKUPDATE.
5071.70Sdholland
5081.126Swiz     NODISTRIBDIRS    If set, avoids the "make distrib-dirs" phase of a full
5091.105Swiz                      build.  This skips running mtree(8) on DESTDIR, useful
5101.20Slukem                      on systems where building as an unprivileged user, or
5111.20Slukem                      where it is known that the system-wide mtree files have
5121.20Slukem                      not changed.
5131.1Stv
5141.105Swiz                      Default: Unset.
5151.1Stv
5161.126Swiz     NOINCLUDES       If set, avoids the "make includes" phase of a full
5171.20Slukem                      build.  This has the effect of preventing make(1) from
5181.44Slukem                      thinking that some programs are out-of-date simply
5191.44Slukem                      because the system include files have changed.  However,
5201.20Slukem                      this option should not be used when updating the entire
5211.20Slukem                      NetBSD source tree arbitrarily; it is suggested to use
5221.105Swiz                      MKUPDATE=yes instead in that case.
5231.1Stv
5241.105Swiz                      Default: Unset.
5251.1Stv
5261.105Swiz     RELEASEDIR       If set, specifies the directory to which a release(7)
5271.126Swiz                      layout will be written at the end of a "make release".
5281.59Sapb                      If specified, must be an absolute path.
5291.20Slukem
5301.105Swiz                      Default: Unset.
5311.20Slukem
5321.105Swiz                      Note: build.sh will provide a default of releasedir (in
5331.105Swiz                      the top-level .OBJDIR) unless run in `expert' mode.
5341.30Slukem
5351.105SwizBUILDING
5361.105Swiz   "make" command line options
5371.52Sjmc     This is not a summary of all the options available to make(1); only the
5381.52Sjmc     options used most frequently with NetBSD builds are listed here.
5391.1Stv
5401.105Swiz     -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
5411.52Sjmc                use .WAIT or have explicit dependencies as necessary to
5421.74Sapb                enforce build ordering.
5431.10Ssommerfe
5441.105Swiz     -m dir     Specify the default directory for searching for system
5451.104Swiz                Makefile segments, mainly the <bsd.*.mk> files.  When building
5461.104Swiz                any full NetBSD source tree, this should be set to the
5471.126Swiz                "share/mk" directory in the source tree.  This is set
5481.104Swiz                automatically when building from the top level, or when using
5491.105Swiz                build.sh.
5501.1Stv
5511.105Swiz     -n         Display the commands that would have been executed, but do not
5521.1Stv                actually execute them.  This will still cause recursion to
5531.1Stv                take place.
5541.1Stv
5551.105Swiz     -V var     Print make(1)'s idea of the value of var.  Does not build any
5561.1Stv                targets.
5571.1Stv
5581.105Swiz     var=value  Set the variable var to value, overriding any setting
5591.105Swiz                specified by the process environment, the MAKECONF
5601.104Swiz                configuration file, or the system Makefile segments.
5611.1Stv
5621.105Swiz   "make" targets
5631.1Stv     These default targets may be built by running make(1) in any subtree of
5641.1Stv     the NetBSD source code.  It is recommended that none of these be used
5651.126Swiz     from the top level Makefile; as a specific exception, "make obj" and
5661.126Swiz     "make cleandir" are useful in that context.
5671.1Stv
5681.105Swiz     all        Build programs, libraries, and preformatted documentation.
5691.1Stv
5701.105Swiz     clean      Remove program and library object code files.
5711.1Stv
5721.105Swiz     cleandir   Same as clean, but also remove preformatted documentation,
5731.126Swiz                dependency files generated by "make depend", and any other
5741.49Slukem                files known to be created at build time.
5751.1Stv
5761.105Swiz     depend     Create dependency files (.depend) containing more detailed
5771.44Slukem                information about the dependencies of source code on header
5781.1Stv                files.  Allows programs to be recompiled automatically when a
5791.1Stv                dependency changes.
5801.1Stv
5811.126Swiz     dependall  Does a "make depend" immediately followed by a "make all".
5821.10Ssommerfe                This improves cache locality of the build since both passes
5831.10Ssommerfe                read the source files in their entirety.
5841.1Stv
5851.105Swiz     distclean  Synonym for cleandir.
5861.49Slukem
5871.105Swiz     includes   Build and install system header files.  Typically needed
5881.44Slukem                before any system libraries or programs can be built.
5891.1Stv
5901.105Swiz     install    Install programs, libraries, and documentation into DESTDIR.
5911.105Swiz                Few files will be installed to DESTDIR/dev, DESTDIR/etc,
5921.105Swiz                DESTDIR/root or DESTDIR/var in order to prevent user supplied
5931.27Slukem                configuration data from being overwritten.
5941.1Stv
5951.105Swiz     lint       Run lint(1) against the C source code, where appropriate, and
5961.1Stv                generate system-installed lint libraries.
5971.1Stv
5981.105Swiz     obj        Create object directories to be used for built files, instead
5991.1Stv                of building directly in the source tree.
6001.1Stv
6011.105Swiz     tags       Create ctags(1) searchable function lists usable by the ex(1)
6021.1Stv                and vi(1) text editors.
6031.1Stv
6041.105Swiz   "make" targets for the top level
6051.1Stv     Additional make(1) targets are usable specifically from the top source
6061.1Stv     level to facilitate building the entire NetBSD source tree.
6071.1Stv
6081.105Swiz     build         Build the entire NetBSD system (except the kernel).  This
6091.68Sreed                   orders portions of the source tree such that prerequisites
6101.68Sreed                   will be built in the proper order.
6111.20Slukem
6121.126Swiz     distribution  Do a "make build", and then install a full distribution
6131.105Swiz                   (which does not include a kernel) into DESTDIR, including
6141.105Swiz                   files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
6151.105Swiz                   DESTDIR/var.
6161.20Slukem
6171.126Swiz     buildworld    As per "make distribution", except that it ensures that
6181.105Swiz                   DESTDIR is not the root directory.
6191.20Slukem
6201.105Swiz     installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR,
6211.70Sdholland                   which defaults to the root directory.  Ensures that
6221.105Swiz                   INSTALLWORLDDIR is not the root directory if cross
6231.104Swiz                   compiling.
6241.20Slukem
6251.105Swiz                   The INSTALLSETS environment variable may be set to a space-
6261.95Sapb                   separated list of distribution sets to be installed.  By
6271.126Swiz                   default, all sets except "etc" and "xetc" are installed, so
6281.126Swiz                   most files in INSTALLWORLDDIR/etc will not be installed or
6291.126Swiz                   modified.
6301.61Sapb
6311.105Swiz                   Note: Before performing this operation with
6321.105Swiz                   INSTALLWORLDDIR=/, it is highly recommended that you
6331.61Sapb                   upgrade your kernel and reboot.  After performing this
6341.61Sapb                   operation, it is recommended that you use etcupdate(8) to
6351.105Swiz                   update files in INSTALLWORLDDIR/etc, and postinstall(8) to
6361.102Sabs                   check for or fix inconsistencies.
6371.20Slukem
6381.105Swiz     sets          Create distribution sets from DESTDIR into
6391.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/sets.  Should be run
6401.126Swiz                   after "make distribution", as "make build" alone does not
6411.126Swiz                   install all of the required files.
6421.25Slukem
6431.105Swiz     sourcesets    Create source sets of the source tree into
6441.105Swiz                   RELEASEDIR/source/sets.
6451.31Slukem
6461.105Swiz     syspkgs       Create syspkgs from DESTDIR into
6471.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.  Should be run
6481.126Swiz                   after "make distribution", as "make build" alone does not
6491.126Swiz                   install all of the required files.
6501.54Sapb
6511.126Swiz     release       Do a "make distribution", build kernels, distribution
6521.126Swiz                   media, and install sets (this as per "make sets"), and then
6531.126Swiz                   package the system into a standard release layout as
6541.105Swiz                   described by release(7).  This requires that RELEASEDIR be
6551.25Slukem                   set (see above).
6561.1Stv
6571.105Swiz     iso-image     Create a NetBSD installation CD-ROM image in the
6581.114Ssnj                   RELEASEDIR/images directory.  The CD-ROM file system will
6591.114Ssnj                   have a layout as described in release(7).
6601.62Sapb
6611.62Sapb                   For most machine types, the CD-ROM will be bootable, and
6621.104Swiz                   will automatically run the sysinst(8) menu-based
6631.104Swiz                   installation program, which can be used to install or
6641.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
6651.104Swiz                   tools that may be useful in repairing a damaged NetBSD
6661.104Swiz                   installation.
6671.62Sapb
6681.126Swiz                   Before "make iso-image" is attempted, RELEASEDIR must be
6691.126Swiz                   populated by "make release" or equivalent.
6701.62Sapb
6711.62Sapb                   Note that other, smaller, CD-ROM images may be created in
6721.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
6731.126Swiz                   directory by "make release".  These smaller images usually
6741.126Swiz                   contain the same tools as the larger images in
6751.114Ssnj                   RELEASEDIR/images, but do not contain additional content
6761.114Ssnj                   such as the distribution sets.
6771.62Sapb
6781.62Sapb                   Note that the mac68k port still uses an older method of
6791.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
6801.104Swiz                   utility, which is not part of NetBSD, but which can be
6811.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
6821.56Sapb
6831.105Swiz     iso-image-source
6841.64Sjnemeth                   Create a NetBSD installation CD-ROM image in the
6851.114Ssnj                   RELEASEDIR/images directory.  The CD-ROM file system will
6861.114Ssnj                   have a layout as described in release(7).  It will have top
6871.64Sjnemeth                   level directories for the machine type and source.
6881.64Sjnemeth
6891.64Sjnemeth                   For most machine types, the CD-ROM will be bootable, and
6901.104Swiz                   will automatically run the sysinst(8) menu-based
6911.104Swiz                   installation program, which can be used to install or
6921.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
6931.104Swiz                   tools that may be useful in repairing a damaged NetBSD
6941.104Swiz                   installation.
6951.64Sjnemeth
6961.126Swiz                   Before "make iso-image-source" is attempted, RELEASEDIR
6971.126Swiz                   must be populated by "make sourcesets release" or
6981.104Swiz                   equivalent.
6991.64Sjnemeth
7001.64Sjnemeth                   Note that other, smaller, CD-ROM images may be created in
7011.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
7021.126Swiz                   directory by "make release".  These smaller images usually
7031.126Swiz                   contain the same tools as the larger images in
7041.114Ssnj                   RELEASEDIR/images, but do not contain additional content
7051.114Ssnj                   such as the distribution sets.
7061.64Sjnemeth
7071.64Sjnemeth                   Note that the mac68k port still uses an older method of
7081.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
7091.104Swiz                   utility, which is not part of NetBSD, but which can be
7101.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
7111.64Sjnemeth
7121.105Swiz     install-image
7131.98Sapb                   Create a bootable NetBSD installation disk image in the
7141.127Splunky                   RELEASEDIR/images directory.  The installation disk image
7151.127Splunky                   is suitable for copying to bootable USB flash memory
7161.127Splunky                   sticks, etc., for machines which are able to boot from such
7171.127Splunky                   devices.  The file system in the bootable disk image will
7181.127Splunky                   have a layout as described in release(7).
7191.97Stsutsui
7201.97Stsutsui                   The installation image is bootable, and will automatically
7211.97Stsutsui                   run the sysinst(8) menu-based installation program, which
7221.98Sapb                   can be used to install or upgrade a NetBSD system.  The
7231.98Sapb                   image also contains tools that may be useful in repairing a
7241.98Sapb                   damaged NetBSD installation.
7251.97Stsutsui
7261.126Swiz                   Before "make install-image" is attempted, RELEASEDIR must
7271.126Swiz                   be populated by "make release" or equivalent.  The build
7281.126Swiz                   must have been performed with MKUNPRIVED=yes because "make
7291.126Swiz                   install-image" relies on information in DESTDIR/METALOG.
7301.97Stsutsui
7311.120Spgoyette     live-image    Create NetBSD live images in the RELEASEDIR/images
7321.104Swiz                   directory.  The live image contains all necessary files to
7331.104Swiz                   boot NetBSD up to multi-user mode, including all files
7341.104Swiz                   which should be extracted during installation, NetBSD
7351.104Swiz                   disklabel, bootloaders, etc.
7361.104Swiz
7371.104Swiz                   The live image is suitable for use as a disk image in
7381.104Swiz                   virtual machine environments such as QEMU, and also useful
7391.104Swiz                   to boot NetBSD from a USB flash memory stick on a real
7401.98Sapb                   machine, without the need for installation.
7411.97Stsutsui
7421.126Swiz                   Before "make live-image" is attempted, RELEASEDIR must be
7431.126Swiz                   populated by "make release" or equivalent.  The build must
7441.126Swiz                   have been performed with MKUNPRIVED=yes because "make
7451.126Swiz                   install-image" relies on information in DESTDIR/METALOG.
7461.97Stsutsui
7471.105Swiz     regression-tests
7481.20Slukem                   Can only be run after building the regression tests in the
7491.126Swiz                   directory "regress".  Runs those compiled regression tests
7501.126Swiz                   on the local host.  Note that most tests are now managed
7511.126Swiz                   instead using atf(7); this target should probably run those
7521.126Swiz                   as well but currently does not.
7531.1Stv
7541.105Swiz   The "build.sh" script
7551.96Sapb     This script file is a shell script designed to build the entire NetBSD
7561.104Swiz     system on any host with a suitable modern shell and some common
7571.105Swiz     utilities.  The required shell features are described under the HOST_SH
7581.104Swiz     variable.
7591.96Sapb
7601.96Sapb     If a host system's default shell does support the required features, then
7611.96Sapb     we suggest that you explicitly specify a suitable shell using a command
7621.96Sapb     like
7631.96Sapb
7641.105Swiz           /path/to/suitable/shell build.sh [options]
7651.96Sapb
7661.105Swiz     The above command will usually enable build.sh to automatically set
7671.105Swiz     HOST_SH=/path/to/suitable/shell, but if that fails, then the following
7681.96Sapb     set of commands may be used instead:
7691.96Sapb
7701.105Swiz           HOST_SH=/path/to/suitable/shell
7711.96Sapb           export HOST_SH
7721.105Swiz           ${HOST_SH} build.sh [options]
7731.96Sapb
7741.105Swiz     If build.sh detects that it is being executed under an unsuitable shell,
7751.96Sapb     it attempts to exec a suitable shell instead, or prints an error message.
7761.105Swiz     If HOST_SH is not set explicitly, then build.sh sets a default using
7771.96Sapb     heuristics dependent on the host platform, or from the shell under which
7781.105Swiz     build.sh is executed (if that can be determined), or using the first copy
7791.105Swiz     of sh found in PATH.
7801.1Stv
7811.1Stv     All cross-compile builds, and most native builds, of the entire system
7821.126Swiz     should make use of build.sh rather than just running "make".  This way,
7831.104Swiz     the make(1) program will be bootstrapped properly, in case the host
7841.126Swiz     system has an older or incompatible "make" program.
7851.1Stv
7861.105Swiz     When compiling the entire system via build.sh, many make(1) variables are
7871.1Stv     set for you in order to help encapsulate the build process.  In the list
7881.105Swiz     of options below, variables that are automatically set by build.sh are
7891.1Stv     noted where applicable.
7901.1Stv
7911.105Swiz     The following operations are supported by build.sh:
7921.22Slukem
7931.126Swiz     build         Build the system as per "make build".  Before the main part
7941.126Swiz                   of the build commences, this command runs the obj operation
7951.126Swiz                   (unless the -o option is given), "make cleandir" (unless
7961.126Swiz                   the -u option is given), and the tools operation.
7971.22Slukem
7981.126Swiz     distribution  Build a full distribution as per "make distribution".  This
7991.126Swiz                   command first runs the build operation.
8001.22Slukem
8011.126Swiz     release       Build a full release as per "make release".  This command
8021.105Swiz                   first runs the distribution operation.
8031.22Slukem
8041.105Swiz     makewrapper   Create the nbmake-MACHINE wrapper.  This operation is
8051.104Swiz                   automatically performed for any of the other operations.
8061.23Slukem
8071.126Swiz     cleandir      Perform "make cleandir".
8081.75Slukem
8091.126Swiz     obj           Perform "make obj".
8101.22Slukem
8111.105Swiz     tools         Build and install the host tools from src/tools.  This
8121.126Swiz                   command will first run "make obj" and "make cleandir" in
8131.126Swiz                   the tools subdirectory unless the -o or -u options
8141.104Swiz                   (respectively) are given.
8151.22Slukem
8161.126Swiz     install=idir  Install the contents of DESTDIR to idir, using "make
8171.126Swiz                   installworld".  Note that files that are part of the "etc"
8181.126Swiz                   or "xetc" sets will not be installed, unless overridden by
8191.126Swiz                   the INSTALLSETS environment variable.
8201.35Slukem
8211.105Swiz     kernel=kconf  Build a new kernel.  The kconf argument is the name of a
8221.105Swiz                   configuration file suitable for use by config(1).  If kconf
8231.22Slukem                   does not contain any `/' characters, the configuration file
8241.105Swiz                   is expected to be found in the KERNCONFDIR directory, which
8251.105Swiz                   is typically sys/arch/MACHINE/conf.  The new kernel will be
8261.105Swiz                   built in a subdirectory of KERNOBJDIR, which is typically
8271.105Swiz                   sys/arch/MACHINE/compile or an associated object directory.
8281.70Sdholland
8291.105Swiz                   This command does not imply the tools command; run the
8301.105Swiz                   tools command first unless it is certain that the tools
8311.70Sdholland                   already exist and are up to date.
8321.70Sdholland
8331.126Swiz                   This command will run "make cleandir" on the kernel in
8341.105Swiz                   question first unless the -u option is given.
8351.22Slukem
8361.106Swiz     kernel.gdb=kconf
8371.106Swiz                   Build a new kernel with debug information.  Similar to the
8381.106Swiz                   above kernel=kconf operation, but creates a netbsd.gdb file
8391.106Swiz                   alongside of the kernel netbsd, which contains a full
8401.106Swiz                   symbol table and can be used for debugging (for example
8411.106Swiz                   with a cross-gdb built by MKCROSSGDB).
8421.106Swiz
8431.113Suebayasi     kernels       This command will build all kernels defined in port
8441.113Suebayasi                   specific release build procedure.
8451.111Suebayasi
8461.112Suebayasi                   This command internally calls the kernel=kconf operation
8471.112Suebayasi                   for each found kernel configuration file.
8481.111Suebayasi
8491.105Swiz     modules       This command will build kernel modules and install them
8501.105Swiz                   into DESTDIR.
8511.86Sjnemeth
8521.105Swiz     releasekernel=kconf
8531.70Sdholland                   Install a gzip(1)ed copy of the kernel previously built by
8541.105Swiz                   kernel=kconf into
8551.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
8561.126Swiz                   netbsd-kconf.gz, although the "netbsd" prefix is determined
8571.126Swiz                   from the "config" directives in kconf.
8581.24Slukem
8591.126Swiz     sets          Perform "make sets".
8601.31Slukem
8611.126Swiz     sourcesets    Perform "make sourcesets".
8621.22Slukem
8631.126Swiz     syspkgs       Perform "make syspkgs".
8641.54Sapb
8651.126Swiz     iso-image     Perform "make iso-image".
8661.56Sapb
8671.105Swiz     iso-image-source
8681.126Swiz                   Perform "make iso-image-source".
8691.65Sjnemeth
8701.105Swiz     install-image
8711.126Swiz                   Perform "make install-image".
8721.97Stsutsui
8731.126Swiz     live-image    Perform "make live-image".
8741.97Stsutsui
8751.109Sapb     list-arch     Prints a list of valid MACHINE and MACHINE_ARCH settings,
8761.109Sapb                   the default MACHINE_ARCH for each MACHINE, and aliases for
8771.109Sapb                   MACHINE/MACHINE_ARCH pairs, and then exits.  The -m or -a
8781.109Sapb                   options (or both) may be used to specify glob patterns that
8791.109Sapb                   will be used to narrow the list of results; for example,
8801.126Swiz                   "build.sh -m 'evm*' -a '*arm*' list-arch" will list all
8811.109Sapb                   known MACHINE/MACHINE_ARCH values in which either MACHINE
8821.109Sapb                   or ALIAS matches the pattern `evb*', and MACHINE_ARCH
8831.109Sapb                   matches the pattern `*arm*'.
8841.109Sapb
8851.105Swiz     The following command line options alter the behaviour of the build.sh
8861.51Swiz     operations described above:
8871.1Stv
8881.109Sapb     -a arch   Set the value of MACHINE_ARCH to arch.  See the -m option for
8891.109Sapb               more information.
8901.9Sthorpej
8911.105Swiz     -B buildid
8921.105Swiz               Set the value of BUILDID to buildid.  This will also append the
8931.126Swiz               build identifier to the name of the "make" wrapper script so
8941.37Slukem               that the resulting name is of the form
8951.126Swiz               "nbmake-MACHINE-BUILDID".
8961.1Stv
8971.105Swiz     -C cdextras
8981.105Swiz               Append cdextras to the CDEXTRA variable, which is a space-
8991.104Swiz               separated list of files or directories that will be added to
9001.126Swiz               the CD-ROM image that may be create by the "iso-image" or
9011.126Swiz               "iso-image-source" operations.  Files will be added to the root
9021.126Swiz               of the CD-ROM image, whereas directories will be copied
9031.87Sapb               recursively.  If relative paths are specified, they will be
9041.87Sapb               converted to absolute paths before being used.  Multiple paths
9051.105Swiz               may be specified via multiple -C options, or via a single
9061.87Sapb               option whose argument contains multiple space-separated paths.
9071.66Sjnemeth
9081.105Swiz     -D dest   Set the value of DESTDIR to dest.  If a relative path is
9091.104Swiz               specified, it will be converted to an absolute path before
9101.104Swiz               being used.
9111.104Swiz
9121.105Swiz     -E        Set `expert' mode.  This overrides various sanity checks, and
9131.105Swiz               allows: DESTDIR does not have to be set to a non-root path for
9141.105Swiz               builds, and MKUNPRIVED=yes does not have to be set when
9151.104Swiz               building as a non-root user.
9161.23Slukem
9171.105Swiz               Note: It is highly recommended that you know what you are doing
9181.23Slukem               when you use this option.
9191.19Slukem
9201.105Swiz     -h        Print a help message.
9211.51Swiz
9221.105Swiz     -j njob   Run up to njob make(1) subjobs in parallel; passed through to
9231.74Sapb               make(1).  If you see failures for reasons other than running
9241.105Swiz               out of memory while using build.sh with -j, please save
9251.104Swiz               complete build logs so the failures can be analyzed.
9261.74Sapb
9271.105Swiz               To achieve the fastest builds, -j values between (1 + the
9281.104Swiz               number of CPUs) and (2 * the number of CPUs) are recommended.
9291.104Swiz               Use lower values on machines with limited memory or I/O
9301.104Swiz               bandwidth.
9311.104Swiz
9321.126Swiz     -M obj    Set MAKEOBJDIRPREFIX to obj.  Unsets MAKEOBJDIR.  See "-O obj"
9331.126Swiz               for more information.
9341.104Swiz
9351.105Swiz               For instance, if the source directory is /usr/src, a setting of
9361.126Swiz               "-M /usr/obj" will place build-time files under
9371.105Swiz               /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
9381.105Swiz               /usr/obj/usr/src/usr.bin, and so forth.
9391.88Sapb
9401.73Sapb               If a relative path is specified, it will be converted to an
9411.105Swiz               absolute path before being used.  build.sh imposes the
9421.105Swiz               restriction that the argument to the -M option must not begin
9431.126Swiz               with a "$" (dollar sign) character; otherwise it would be too
9441.104Swiz               difficult to determine whether the value is an absolute or a
9451.104Swiz               relative path.  If the directory does not already exist,
9461.105Swiz               build.sh will create it.
9471.18Slukem
9481.109Sapb     -m mach   Set the value of MACHINE to mach, unless the mach argument is
9491.109Sapb               an alias that refers to a MACHINE/MACHINE_ARCH pair, in which
9501.109Sapb               case both MACHINE and MACHINE_ARCH are set from the alias.
9511.109Sapb               Such aliases are interpreted entirely by build.sh; they are not
9521.109Sapb               used by any other part of the build system.  The MACHINE_ARCH
9531.109Sapb               setting implied by mach will override any value of MACHINE_ARCH
9541.109Sapb               in the process environment, but will not override a value set
9551.109Sapb               by the -a option.  All cross builds require -m, but if unset on
9561.109Sapb               a NetBSD host, the host's value of MACHINE will be detected and
9571.109Sapb               used automatically.
9581.109Sapb
9591.109Sapb               See the list-arch operation for a way to get a list of valid
9601.109Sapb               MACHINE and MACHINE_ARCH settings.
9611.1Stv
9621.105Swiz     -N noiselevel
9631.126Swiz               Set the "noisyness" level of the build, by setting MAKEVERBOSE
9641.126Swiz               to noiselevel.
9651.45Slukem
9661.105Swiz     -n        Show the commands that would be executed by build.sh, but do
9671.126Swiz               not make any changes.  This is similar in concept to "make -n".
9681.1Stv
9691.105Swiz     -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
9701.105Swiz               place the built object files under obj.  Unsets
9711.105Swiz               MAKEOBJDIRPREFIX.
9721.88Sapb
9731.126Swiz               For instance, a setting of "-O /usr/obj" will place build-time
9741.126Swiz               files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and
9751.126Swiz               so forth.
9761.88Sapb
9771.88Sapb               If a relative path is specified, it will be converted to an
9781.105Swiz               absolute path before being used.  build.sh imposes the
9791.105Swiz               restriction that the argument to the -O option must not contain
9801.126Swiz               a "$" (dollar sign) character.  If the directory does not
9811.105Swiz               already exist, build.sh will create it.
9821.73Sapb
9831.105Swiz               In normal use, exactly one of the -M or -O options should be
9841.105Swiz               specified.  If neither -M nor -O is specified, then a default
9851.78Sapb               object directory will be chosen according to rules in
9861.78Sapb               <bsd.obj.mk>.  Relying on this default is not recommended
9871.78Sapb               because it is determined by complex rules that are influenced
9881.78Sapb               by the values of several variables and by the location of the
9891.78Sapb               source directory.
9901.18Slukem
9911.109Sapb               Note that placing the obj directory location outside of the
9921.109Sapb               default source tree hierarchy makes it easier to manually clear
9931.126Swiz               out old files in the event the "make cleandir" operation is
9941.109Sapb               unable to do so.  (See CAVEATS below.)
9951.109Sapb
9961.109Sapb               Note also that use of one of -M or -O is the only means of
9971.109Sapb               building multiple machine architecture userlands from the same
9981.109Sapb               source tree without cleaning between builds (in which case, one
9991.109Sapb               would specify distinct obj locations for each).
10001.109Sapb
10011.126Swiz     -o        Set the value of MKOBJDIRS to "no".  Otherwise, it will be
10021.126Swiz               automatically set to "yes".  This default is opposite to the
10031.105Swiz               behaviour when not using build.sh.
10041.1Stv
10051.105Swiz     -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
10061.59Sapb               specified, it will be converted to an absolute path before
10071.59Sapb               being used.
10081.18Slukem
10091.105Swiz     -r        Remove the contents of DESTDIR and TOOLDIR before building
10101.1Stv               (provides a clean starting point).  This will skip deleting
10111.105Swiz               DESTDIR if building on a native system to the root directory.
10121.1Stv
10131.105Swiz     -S seed   Change the value of BUILDSEED to seed.  This should rarely be
10141.72Sperry               necessary.
10151.72Sperry
10161.105Swiz     -T tools  Set the value of TOOLDIR to tools.  If a relative path is
10171.104Swiz               specified, it will be converted to an absolute path before
10181.126Swiz               being used.  If set, the bootstrap "make" will only be rebuilt
10191.126Swiz               if the source files for make(1) have changed.
10201.104Swiz
10211.105Swiz     -U        Set MKUNPRIVED=yes.
10221.104Swiz
10231.105Swiz     -u        Set MKUPDATE=yes.
10241.104Swiz
10251.105Swiz     -V var=[value]
10261.105Swiz               Set the environment variable var to an optional value.  This is
10271.105Swiz               propagated to the nbmake wrapper.
10281.105Swiz
10291.105Swiz     -w wrapper
10301.105Swiz               Create the nbmake wrapper script (see below) in a custom
10311.105Swiz               location, specified by wrapper.  This allows, for instance, to
10321.105Swiz               place the wrapper in PATH automatically.  Note that wrapper is
10331.59Sapb               the full name of the file, not just a directory name.  If a
10341.59Sapb               relative path is specified, it will be converted to an absolute
10351.59Sapb               path before being used.
10361.1Stv
10371.105Swiz     -X x11src
10381.105Swiz               Set the value of X11SRCDIR to x11src.  If a relative path is
10391.59Sapb               specified, it will be converted to an absolute path before
10401.59Sapb               being used.
10411.49Slukem
10421.105Swiz     -x        Set MKX11=yes.
10431.49Slukem
10441.115Sapb     -Y extsrcdir
10451.115Sapb               Set the value of EXTSRCSRCDIR to extsrcdir.  If a relative path
10461.115Sapb               is specified, it will be converted to an absolute path before
10471.115Sapb               being used.
10481.115Sapb
10491.115Sapb     -y        Set MKEXTSRC=yes.
10501.115Sapb
10511.105Swiz     -Z var    Unset ("zap") the environment variable var.  This is propagated
10521.105Swiz               to the nbmake wrapper.
10531.40Slukem
10541.105Swiz   The "nbmake-MACHINE" wrapper script
10551.105Swiz     If using the build.sh script to build NetBSD, a nbmake-MACHINE script
10561.105Swiz     will be created in TOOLDIR/bin upon the first build to assist in building
10571.1Stv     subtrees on a cross-compile host.
10581.1Stv
10591.105Swiz     nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
10601.126Swiz     the up-to-date version of "nbmake" installed into TOOLDIR/bin with
10611.105Swiz     several key variables pre-set, including MACHINE, MACHINE_ARCH, and
10621.105Swiz     TOOLDIR.  nbmake-MACHINE will also set variables specified with -V, and
10631.105Swiz     unset variables specified with -Z.
10641.40Slukem
10651.105Swiz     This script can be symlinked into a directory listed in PATH, or called
10661.1Stv     with an absolute path.
10671.1Stv
10681.105SwizEXAMPLES
10691.78Sapb     1.   % ./build.sh [options] tools kernel=GENERIC
10701.28Slukem
10711.28Slukem          Build a new toolchain, and use the new toolchain to configure and
10721.28Slukem          build a new GENERIC kernel.
10731.28Slukem
10741.78Sapb     2.   % ./build.sh [options] -U distribution
10751.28Slukem
10761.105Swiz          Using unprivileged mode, build a complete distribution to a DESTDIR
10771.105Swiz          directory that build.sh selects (and will display).
10781.28Slukem
10791.78Sapb     3.   # ./build.sh [options] -U install=/
10801.28Slukem
10811.105Swiz          As root, install to / the distribution that was built by example 2.
10821.105Swiz          Even though this is run as root, -U is required so that the
10831.105Swiz          permissions stored in DESTDIR/METALOG are correctly applied to the
10841.105Swiz          files as they're copied to /.
10851.28Slukem
10861.78Sapb     4.   % ./build.sh [options] -U -u release
10871.28Slukem
10881.105Swiz          Using unprivileged mode, build a complete release to DESTDIR and
10891.105Swiz          RELEASEDIR directories that build.sh selects (and will display).
10901.126Swiz          MKUPDATE=yes (-u) is set to prevent the "make cleandir", so that if
10911.126Swiz          this is run after example 2, it doesn't need to redo that portion of
10921.126Swiz          the release build.
10931.16Slukem
10941.105SwizOBSOLETE VARIABLES
10951.105Swiz     NBUILDJOBS  Use the make(1) option -j instead.
10961.15Slukem
10971.105Swiz     USE_NEW_TOOLCHAIN
10981.15Slukem                 The new toolchain is now the default.  To disable, use
10991.105Swiz                 TOOLCHAIN_MISSING=yes.
11001.10Ssommerfe
11011.105SwizSEE ALSO
11021.62Sapb     make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8),
11031.105Swiz     pkgsrc/sysutils/cdrtools
11041.1Stv
11051.105SwizHISTORY
11061.105Swiz     The build.sh based build scheme was introduced for NetBSD 1.6 as
11071.105Swiz     USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
11081.1Stv
11091.109SapbCAVEATS
11101.109Sapb     After significant updates to third-party components in the source tree,
11111.126Swiz     the "make cleandir" operation may be insufficient to clean out old files
11121.126Swiz     in object directories.  Instead, one may have to manually remove the
11131.126Swiz     files.  Consult the UPDATING file for notices concerning this.
11141.109Sapb
11151.129SsevanNetBSD                         October 21, 2017                         NetBSD
1116