BUILDING revision 1.143
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.142Sandvar                    NetBSD make(1).  Intended for expert use with knowledge 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.105Swiz   Build tree layout
871.1Stv     The NetBSD build tree is described in hier(7), and the release layout is
881.1Stv     described in release(7).
891.1Stv
901.105SwizCONFIGURATION
911.105Swiz   Environment variables
921.8Slukem     Several environment variables control the behaviour of NetBSD builds.
931.8Slukem
941.105Swiz     HOST_SH           Path name to a shell available on the host system and
951.96Sapb                       suitable for use during the build.  The NetBSD build
961.96Sapb                       system requires a modern Bourne-like shell with POSIX-
971.96Sapb                       compliant features, and also requires support for the
981.126Swiz                       "local" keyword to declare local variables in shell
991.104Swiz                       functions (which is a widely-implemented but non-
1001.104Swiz                       standardised feature).
1011.96Sapb
1021.96Sapb                       Depending on the host system, a suitable shell may be
1031.105Swiz                       /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a
1041.126Swiz                       variant of ksh that supports the "local" keyword, such
1051.126Swiz                       as ksh88, but not ksh93), or /usr/local/bin/bash.
1061.96Sapb
1071.105Swiz                       Most parts of the build require HOST_SH to be an
1081.105Swiz                       absolute path; however, build.sh allows it to be a
1091.104Swiz                       simple command name, which will be converted to an
1101.105Swiz                       absolute path by searching the PATH.
1111.58Sapb
1121.105Swiz     HOST_CC           Path name to C compiler used to create the toolchain.
1131.53Sreed
1141.137Suwe     HOST_CFLAGS       Flags passed to the host C compiler.
1151.137Suwe
1161.105Swiz     HOST_CXX          Path name to C++ compiler used to create the toolchain.
1171.53Sreed
1181.137Suwe     HOST_CXXFLAGS     Flags passed to the host C++ compiler.
1191.137Suwe
1201.126Swiz     MACHINE           Machine type, e.g., "macppc".
1211.8Slukem
1221.126Swiz     MACHINE_ARCH      Machine architecture, e.g., "powerpc".
1231.8Slukem
1241.105Swiz     MAKE              Path name to invoke make(1) as.
1251.8Slukem
1261.105Swiz     MAKEFLAGS         Flags to invoke make(1) with.  Note that build.sh
1271.105Swiz                       ignores the value of MAKEFLAGS passed in the
1281.105Swiz                       environment, but allows MAKEFLAGS to be set via the -V
1291.104Swiz                       option.
1301.8Slukem
1311.105Swiz     MAKEOBJDIR        Directory to use as the .OBJDIR for the current
1321.104Swiz                       directory.  The value is subjected to variable
1331.104Swiz                       expansion by make(1).  Typical usage is to set this
1341.104Swiz                       variable to a value involving the use of
1351.104Swiz                       `${.CURDIR:S...}' or `${.CURDIR:C...}', to derive the
1361.105Swiz                       value of .OBJDIR from the value of .CURDIR.  Used only
1371.105Swiz                       if MAKEOBJDIRPREFIX is not defined.  MAKEOBJDIR can be
1381.105Swiz                       provided only in the environment or via the -O flag of
1391.105Swiz                       build.sh; it cannot usefully be set inside a Makefile,
1401.105Swiz                       including mk.conf or ${MAKECONF}.
1411.8Slukem
1421.105Swiz     MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  The
1431.88Sapb                       value is subjected to variable expansion by make(1).
1441.105Swiz                       build.sh will create the ${MAKEOBJDIRPREFIX} directory
1451.105Swiz                       if necessary, but if make(1) is used without build.sh,
1461.88Sapb                       then rules in <bsd.obj.mk> will abort the build if the
1471.88Sapb                       ${MAKEOBJDIRPREFIX} directory does not exist.  If the
1481.104Swiz                       value is defined and valid, then
1491.105Swiz                       ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR
1501.104Swiz                       for the current directory.  The current directory may
1511.105Swiz                       be read only.  MAKEOBJDIRPREFIX can be provided only in
1521.105Swiz                       the environment or via the -M flag of build.sh; it
1531.104Swiz                       cannot usefully be set inside a Makefile, including
1541.105Swiz                       mk.conf or ${MAKECONF}.
1551.104Swiz
1561.105Swiz   "make" variables
1571.104Swiz     Several variables control the behavior of NetBSD builds.  Unless
1581.104Swiz     otherwise specified, these variables may be set in either the process
1591.105Swiz     environment or the make(1) configuration file specified by MAKECONF.
1601.1Stv
1611.107Sapb     BUILDID     Identifier for the build.  If set, this should be a short
1621.107Sapb                 string that is suitable for use as part of a file or
1631.107Sapb                 directory name.  The identifier will be appended to object
1641.107Sapb                 directory names, and can be consulted in the make(1)
1651.104Swiz                 configuration file in order to set additional build
1661.107Sapb                 parameters, such as compiler flags.  It will also be used as
1671.107Sapb                 part of the kernel version string, which can be printed by
1681.126Swiz                 "uname -v".
1691.107Sapb
1701.107Sapb                 Default: Unset.
1711.9Sthorpej
1721.108Sapb     BUILDINFO   This may be a multi-line string containing information about
1731.108Sapb                 the build.  This will appear in DESTDIR/etc/release, and it
1741.108Sapb                 will be stored in the buildinfo variable in any kernels that
1751.108Sapb                 are built.  When such kernels are booted, the sysctl(7)
1761.108Sapb                 kern.buildinfo variable will report this value.  The string
1771.126Swiz                 may contain backslash escape sequences, such as "\\"
1781.126Swiz                 (representing a backslash character) and "\n" (representing a
1791.126Swiz                 newline).
1801.108Sapb
1811.108Sapb                 Default: Unset.
1821.108Sapb
1831.105Swiz     BUILDSEED   GCC uses random numbers when compiling C++ code.  This
1841.104Swiz                 variable seeds the gcc random number generator using the
1851.104Swiz                 -frandom-seed flag with this value.  By default, it is set to
1861.104Swiz                 NetBSD-(majorversion).  Using a fixed value causes C++
1871.104Swiz                 binaries to be the same when built from the same sources,
1881.104Swiz                 resulting in identical (reproducible) builds.  Additional
1891.104Swiz                 information is available in the GCC documentation of
1901.104Swiz                 -frandom-seed.
1911.104Swiz
1921.138Sthorpej     CPUFLAGS    Additional flags to the compiler/assembler to select CPU
1931.138Sthorpej                 instruction set options, CPU tuning options, etc.
1941.138Sthorpej
1951.138Sthorpej                 Default: Unset.
1961.138Sthorpej
1971.105Swiz     DESTDIR     Directory to contain the built NetBSD system.  If set,
1981.104Swiz                 special options are passed to the compilation tools to
1991.105Swiz                 prevent their default use of the host system's /usr/include,
2001.105Swiz                 /usr/lib, and so forth.  This pathname must be an absolute
2011.105Swiz                 path, and should not end with a slash (/) character.  (For
2021.105Swiz                 installation into the system's root directory, set DESTDIR to
2031.126Swiz                 an empty string, not to "/").  The directory must reside on a
2041.126Swiz                 file system which supports long file names and hard links.
2051.1Stv
2061.126Swiz                 Default: Empty string if USETOOLS is "yes"; unset otherwise.
2071.1Stv
2081.105Swiz                 Note: build.sh will provide a default of destdir.MACHINE (in
2091.105Swiz                 the top-level .OBJDIR) unless run in `expert' mode.
2101.30Slukem
2111.105Swiz     MAKECONF    The name of the make(1) configuration file.  Only settable in
2121.105Swiz                 the process environment.
2131.1Stv
2141.126Swiz                 Default: "/etc/mk.conf"
2151.1Stv
2161.105Swiz     MAKEVERBOSE
2171.45Slukem                 Level of verbosity of status messages.  Supported values:
2181.45Slukem
2191.80Sapb                 0    No descriptive messages or commands executed by make(1)
2201.80Sapb                      are shown.
2211.45Slukem
2221.80Sapb                 1    Brief messages are shown describing what is being done,
2231.104Swiz                      but the actual commands executed by make(1) are not
2241.104Swiz                      displayed.
2251.80Sapb
2261.80Sapb                 2    Descriptive messages are shown as above (prefixed with a
2271.80Sapb                      `#'), and ordinary commands performed by make(1) are
2281.80Sapb                      displayed.
2291.80Sapb
2301.80Sapb                 3    In addition to the above, all commands performed by
2311.80Sapb                      make(1) are displayed, even if they would ordinarily
2321.126Swiz                      have been hidden through use of the "@" prefix in the
2331.80Sapb                      relevant makefile.
2341.45Slukem
2351.80Sapb                 4    In addition to the above, commands executed by make(1)
2361.126Swiz                      are traced through use of the sh(1) "-x" flag.
2371.45Slukem
2381.105Swiz                 Default: 2
2391.45Slukem
2401.140Skamil     MKCATPAGES  Can be set to "yes" or "no".  Indicates whether preformatted
2411.140Skamil                 plaintext manual pages will be created during a build.
2421.140Skamil
2431.140Skamil                 Default: "no"
2441.140Skamil
2451.126Swiz     MKCROSSGDB  Can be set to "yes" or "no".  Create a cross-gdb as a host
2461.126Swiz                 tool.
2471.106Swiz
2481.126Swiz                 Default: "no"
2491.106Swiz
2501.126Swiz     MKDEBUG     Can be set to "yes" or "no".  Indicates whether debug
2511.106Swiz                 information should be generated for all userland binaries
2521.106Swiz                 compiled.  The result is collected as an additional debug.tgz
2531.106Swiz                 and xdebug.tgz set and installed in /usr/libdata/debug.
2541.106Swiz
2551.126Swiz                 Default: "no"
2561.106Swiz
2571.126Swiz     MKDEBUGLIB  Can be set to "yes" or "no".  Indicates whether debug
2581.106Swiz                 information (see MKDEBUG) should also be generated for all
2591.134Ssevan                 libraries built.
2601.106Swiz
2611.126Swiz                 Default: "no"
2621.106Swiz
2631.126Swiz     MKDOC       Can be set to "yes" or "no".  Indicates whether system
2641.105Swiz                 documentation destined for DESTDIR/usr/share/doc will be
2651.44Slukem                 installed during a build.
2661.1Stv
2671.126Swiz                 Default: "yes"
2681.1Stv
2691.126Swiz     MKHTML      Can be set to "yes" or "no".  Indicates whether preformatted
2701.126Swiz                 HTML manual pages will be built and installed
2711.77Slukem
2721.126Swiz                 Default: "yes"
2731.77Slukem
2741.126Swiz     MKHOSTOBJ   Can be set to "yes" or "no".  If set to "yes", then for
2751.4Stv                 programs intended to be run on the compile host, the name,
2761.4Stv                 release, and architecture of the host operating system will
2771.4Stv                 be suffixed to the name of the object directory created by
2781.126Swiz                 "make obj".  (This allows multiple host systems to compile
2791.126Swiz                 NetBSD for a single target.)  If set to "no", then programs
2801.4Stv                 built to be run on the compile host will use the same object
2811.4Stv                 directory names as programs built to be run on the target.
2821.4Stv
2831.126Swiz                 Default: "no"
2841.4Stv
2851.126Swiz     MKINFO      Can be set to "yes" or "no".  Indicates whether GNU Info
2861.134Ssevan                 files will be created and installed during a build.  GNU Info
2871.134Ssevan                 files are used for providing documentation by most of the
2881.134Ssevan                 compilation tools.
2891.1Stv
2901.126Swiz                 Default: "yes"
2911.1Stv
2921.143Slukem     MKKDEBUG    Can be set to "yes" or "no".  Force generation of full-debug
2931.143Slukem                 symbol versions of all kernels compiled.  Alongside of the
2941.143Slukem                 netbsd kernel file, an unstripped version netbsd.gdb is
2951.143Slukem                 created.  This is useful if a cross-gdb is built as well (see
2961.143Slukem                 MKCROSSGDB).
2971.143Slukem
2981.143Slukem                 Default: "no"
2991.143Slukem
3001.126Swiz     MKKMOD      Can be set to "yes" or "no".  Indicates whether kernel
3011.95Sapb                 modules are built and installed.
3021.95Sapb
3031.126Swiz                 Default: "yes"
3041.95Sapb
3051.126Swiz     MKLINT      Can be set to "yes" or "no".  Indicates whether lint(1) will
3061.126Swiz                 be run against portions of the NetBSD source code during the
3071.126Swiz                 build, and whether lint libraries will be installed into
3081.105Swiz                 DESTDIR/usr/libdata/lint.
3091.1Stv
3101.126Swiz                 Default: "yes"
3111.1Stv
3121.126Swiz     MKMAN       Can be set to "yes" or "no".  Indicates whether manual pages
3131.126Swiz                 will be installed during a build.
3141.1Stv
3151.126Swiz                 Default: "yes"
3161.1Stv
3171.126Swiz     MKNLS       Can be set to "yes" or "no".  Indicates whether Native
3181.44Slukem                 Language System locale zone files will be compiled and
3191.44Slukem                 installed during a build.
3201.1Stv
3211.126Swiz                 Default: "yes"
3221.1Stv
3231.126Swiz     MKOBJ       Can be set to "yes" or "no".  Indicates whether object
3241.126Swiz                 directories will be created when running "make obj".  If set
3251.126Swiz                 to "no", then all built files will be located inside the
3261.126Swiz                 regular source tree.
3271.1Stv
3281.126Swiz                 Default: "yes"
3291.1Stv
3301.126Swiz                 Note that setting MKOBJ to "no" is not recommended and may
3311.70Sdholland                 cause problems when updating the tree with cvs(1).
3321.70Sdholland
3331.126Swiz     MKPIC       Can be set to "yes" or "no".  Indicates whether shared
3341.1Stv                 objects and libraries will be created and installed during a
3351.126Swiz                 build.  If set to "no", the entire built system will be
3361.1Stv                 statically linked.
3371.1Stv
3381.130Ssevan                 Default: Platform dependent.  As of this writing, all
3391.130Ssevan                 platforms except m68000 default to "yes".
3401.1Stv
3411.105Swiz     MKPICINSTALL
3421.126Swiz                 Can be set to "yes" or "no".  Indicates whether the ar(1)
3431.105Swiz                 format libraries (lib*_pic.a), used to generate shared
3441.44Slukem                 libraries, are installed during a build.
3451.1Stv
3461.126Swiz                 Default: "yes"
3471.1Stv
3481.126Swiz     MKPROFILE   Can be set to "yes" or "no".  Indicates whether profiled
3491.105Swiz                 libraries (lib*_p.a) will be built and installed during a
3501.1Stv                 build.
3511.1Stv
3521.126Swiz                 Default: "yes"; however, some platforms turn off MKPROFILE by
3531.126Swiz                 default at times due to toolchain problems with profiled
3541.1Stv                 code.
3551.1Stv
3561.126Swiz     MKREPRO     Can be set to "yes" or "no".  Create reproducible builds.
3571.100Swiz                 This enables different switches to make two builds from the
3581.100Swiz                 same source tree result in the same build results.
3591.100Swiz
3601.126Swiz                 Default: "no" This may be set to "yes" by giving build.sh the
3611.126Swiz                 -P option.
3621.100Swiz
3631.122Swiz     MKREPRO_TIMESTAMP
3641.122Swiz                 Unix timestamp.  When MKREPRO is set, the timestamp of all
3651.122Swiz                 files in the sets will be set to this value.
3661.122Swiz
3671.124Schristos                 Default: Unset.  This may be set automatically to the latest
3681.124Schristos                 source tree timestamp using cvslatest(1) by giving build.sh
3691.124Schristos                 the -P option.
3701.122Swiz
3711.126Swiz     MKSHARE     Can be set to "yes" or "no".  Indicates whether files
3721.105Swiz                 destined to reside in DESTDIR/usr/share will be built and
3731.140Skamil                 installed during a build.  If set to "no", then all of
3741.140Skamil                 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
3751.140Skamil                 "no" unconditionally.
3761.1Stv
3771.126Swiz                 Default: "yes"
3781.1Stv
3791.105Swiz     MKSTRIPIDENT
3801.126Swiz                 Can be set to "yes" or "no".  Indicates whether RCS IDs, for
3811.126Swiz                 use with ident(1), should be stripped from program binaries
3821.126Swiz                 and shared libraries.
3831.78Sapb
3841.126Swiz                 Default: "no"
3851.78Sapb
3861.126Swiz     MKSTRIPSYM  Can be set to "yes" or "no".  Indicates whether all local
3871.126Swiz                 symbols should be stripped from shared libraries.  If "yes",
3881.125Sozaki                 strip all local symbols from shared libraries; the affect is
3891.126Swiz                 equivalent to the -x option of ld(1).  If "no", strip only
3901.126Swiz                 temporary local symbols; the affect is equivalent to the -X
3911.126Swiz                 option of ld(1).  Keeping non-temporary local symbols such as
3921.125Sozaki                 static function names is useful on using DTrace for userland
3931.125Sozaki                 libraries and getting a backtrace from a rump kernel loading
3941.125Sozaki                 shared libraries.
3951.125Sozaki
3961.126Swiz                 Default: "yes"
3971.125Sozaki
3981.126Swiz     MKUNPRIVED  Can be set to "yes" or "no".  Indicates whether an
3991.104Swiz                 unprivileged install will occur.  The user, group,
4001.104Swiz                 permissions, and file flags, will not be set on the installed
4011.52Sjmc                 items; instead the information will be appended to a file
4021.105Swiz                 called METALOG in DESTDIR.  The contents of METALOG are used
4031.52Sjmc                 during the generation of the distribution tar files to ensure
4041.52Sjmc                 that the appropriate file ownership is stored.
4051.38Slukem
4061.126Swiz                 Default: "no"
4071.38Slukem
4081.126Swiz     MKUPDATE    Can be set to "yes" or "no".  Indicates whether all install
4091.126Swiz                 operations intended to write to DESTDIR will compare file
4101.126Swiz                 timestamps before installing, and skip the install phase if
4111.126Swiz                 the destination files are up-to-date.  This also has
4121.44Slukem                 implications on full builds (see next subsection).
4131.38Slukem
4141.126Swiz                 Default: "no"
4151.38Slukem
4161.126Swiz     MKX11       Can be set to "yes" or "no".  Indicates whether X11 is built
4171.126Swiz                 from X11SRCDIR.
4181.49Slukem
4191.126Swiz                 Default: "no"
4201.49Slukem
4211.105Swiz     TOOLDIR     Directory to hold the host tools, once built.  If specified,
4221.59Sapb                 must be an absolute path.  This directory should be unique to
4231.104Swiz                 a given host system and NetBSD source tree.  (However,
4241.105Swiz                 multiple targets may share the same TOOLDIR; the target-
4251.104Swiz                 dependent files have unique names.)  If unset, a default
4261.104Swiz                 based on the uname(1) information of the host platform will
4271.105Swiz                 be created in the .OBJDIR of src.
4281.1Stv
4291.105Swiz                 Default: Unset.
4301.1Stv
4311.105Swiz     USETOOLS    Indicates whether the tools specified by TOOLDIR should be
4321.126Swiz                 used as part of a build in progress.  Must be set to "yes" if
4331.126Swiz                 cross-compiling.
4341.1Stv
4351.105Swiz                 yes    Use the tools from TOOLDIR.
4361.1Stv
4371.105Swiz                 no     Do not use the tools from TOOLDIR, but refuse to build
4381.1Stv                        native compilation tool components that are version-
4391.1Stv                        specific for that tool.
4401.1Stv
4411.105Swiz                 never  Do not use the tools from TOOLDIR, even when building
4421.104Swiz                        native tool components.  This is similar to the
4431.105Swiz                        traditional NetBSD build method, but does not verify
4441.104Swiz                        that the compilation tools in use are up-to-date
4451.104Swiz                        enough in order to build the tree successfully.  This
4461.104Swiz                        may cause build or runtime problems when building the
4471.104Swiz                        whole NetBSD source tree.
4481.1Stv
4491.126Swiz                 Default: "yes", unless TOOLCHAIN_MISSING is set to "yes".
4501.71Sdholland
4511.126Swiz                 USETOOLS is also set to "no" when using <bsd.*.mk> outside
4521.71Sdholland                 the NetBSD source tree.
4531.1Stv
4541.121Smrg     X11SRCDIR   Directory containing the modular Xorg source.  If specified,
4551.121Smrg                 must be an absolute path.  The main modular Xorg source is
4561.121Smrg                 found in X11SRCDIR/external/mit.
4571.49Slukem
4581.135Sleot                 Default: NETBSDSRCDIR/../xsrc, if that exists; otherwise
4591.105Swiz                 /usr/xsrc.
4601.49Slukem
4611.105Swiz   "make" variables for full builds
4621.126Swiz     These variables only affect the top level "Makefile" and do not affect
4631.7Slukem     manually building subtrees of the NetBSD source code.
4641.1Stv
4651.126Swiz     INSTALLWORLDDIR  Location for the "make installworld" target to install
4661.59Sapb                      to.  If specified, must be an absolute path.
4671.1Stv
4681.126Swiz                      Default: "/"
4691.1Stv
4701.126Swiz     MKOBJDIRS        Can be set to "yes" or "no".  Indicates whether object
4711.126Swiz                      directories will be created automatically (via a "make
4721.126Swiz                      obj" pass) at the start of a build.
4731.1Stv
4741.126Swiz                      Default: "no"
4751.1Stv
4761.126Swiz                      If using build.sh, the default is "yes".  This may be
4771.126Swiz                      set back to "no" by giving build.sh the -o option.
4781.70Sdholland
4791.126Swiz     MKUPDATE         Can be set to "yes" or "no".  If set, then in addition
4801.126Swiz                      to the effects described for MKUPDATE=yes above, this
4811.126Swiz                      implies the effects of NOCLEANDIR (i.e., "make cleandir"
4821.126Swiz                      is avoided).
4831.38Slukem
4841.126Swiz                      Default: "no"
4851.38Slukem
4861.105Swiz                      If using build.sh, this may be set by giving the -u
4871.70Sdholland                      option.
4881.70Sdholland
4891.105Swiz     NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead.  See
4901.70Sdholland                      below.
4911.1Stv
4921.105Swiz                      Default: Unset.
4931.1Stv
4941.126Swiz     NOCLEANDIR       If set, avoids the "make cleandir" phase of a full
4951.20Slukem                      build.  This has the effect of allowing only changed
4961.20Slukem                      files in a source tree to be recompiled.  This can speed
4971.20Slukem                      up builds when updating only a few files in the tree.
4981.1Stv
4991.105Swiz                      Default: Unset.
5001.1Stv
5011.105Swiz                      See also MKUPDATE.
5021.70Sdholland
5031.126Swiz     NODISTRIBDIRS    If set, avoids the "make distrib-dirs" phase of a full
5041.105Swiz                      build.  This skips running mtree(8) on DESTDIR, useful
5051.20Slukem                      on systems where building as an unprivileged user, or
5061.20Slukem                      where it is known that the system-wide mtree files have
5071.20Slukem                      not changed.
5081.1Stv
5091.105Swiz                      Default: Unset.
5101.1Stv
5111.126Swiz     NOINCLUDES       If set, avoids the "make includes" phase of a full
5121.20Slukem                      build.  This has the effect of preventing make(1) from
5131.44Slukem                      thinking that some programs are out-of-date simply
5141.44Slukem                      because the system include files have changed.  However,
5151.20Slukem                      this option should not be used when updating the entire
5161.20Slukem                      NetBSD source tree arbitrarily; it is suggested to use
5171.105Swiz                      MKUPDATE=yes instead in that case.
5181.1Stv
5191.105Swiz                      Default: Unset.
5201.1Stv
5211.105Swiz     RELEASEDIR       If set, specifies the directory to which a release(7)
5221.126Swiz                      layout will be written at the end of a "make release".
5231.59Sapb                      If specified, must be an absolute path.
5241.20Slukem
5251.105Swiz                      Default: Unset.
5261.20Slukem
5271.105Swiz                      Note: build.sh will provide a default of releasedir (in
5281.105Swiz                      the top-level .OBJDIR) unless run in `expert' mode.
5291.30Slukem
5301.105SwizBUILDING
5311.105Swiz   "make" command line options
5321.52Sjmc     This is not a summary of all the options available to make(1); only the
5331.52Sjmc     options used most frequently with NetBSD builds are listed here.
5341.1Stv
5351.105Swiz     -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
5361.52Sjmc                use .WAIT or have explicit dependencies as necessary to
5371.74Sapb                enforce build ordering.
5381.10Ssommerfe
5391.105Swiz     -m dir     Specify the default directory for searching for system
5401.104Swiz                Makefile segments, mainly the <bsd.*.mk> files.  When building
5411.104Swiz                any full NetBSD source tree, this should be set to the
5421.126Swiz                "share/mk" directory in the source tree.  This is set
5431.104Swiz                automatically when building from the top level, or when using
5441.105Swiz                build.sh.
5451.1Stv
5461.105Swiz     -n         Display the commands that would have been executed, but do not
5471.1Stv                actually execute them.  This will still cause recursion to
5481.1Stv                take place.
5491.1Stv
5501.105Swiz     -V var     Print make(1)'s idea of the value of var.  Does not build any
5511.1Stv                targets.
5521.1Stv
5531.105Swiz     var=value  Set the variable var to value, overriding any setting
5541.105Swiz                specified by the process environment, the MAKECONF
5551.104Swiz                configuration file, or the system Makefile segments.
5561.1Stv
5571.105Swiz   "make" targets
5581.1Stv     These default targets may be built by running make(1) in any subtree of
5591.1Stv     the NetBSD source code.  It is recommended that none of these be used
5601.126Swiz     from the top level Makefile; as a specific exception, "make obj" and
5611.126Swiz     "make cleandir" are useful in that context.
5621.1Stv
5631.105Swiz     all        Build programs, libraries, and preformatted documentation.
5641.1Stv
5651.105Swiz     clean      Remove program and library object code files.
5661.1Stv
5671.105Swiz     cleandir   Same as clean, but also remove preformatted documentation,
5681.126Swiz                dependency files generated by "make depend", and any other
5691.49Slukem                files known to be created at build time.
5701.1Stv
5711.105Swiz     depend     Create dependency files (.depend) containing more detailed
5721.44Slukem                information about the dependencies of source code on header
5731.1Stv                files.  Allows programs to be recompiled automatically when a
5741.1Stv                dependency changes.
5751.1Stv
5761.126Swiz     dependall  Does a "make depend" immediately followed by a "make all".
5771.10Ssommerfe                This improves cache locality of the build since both passes
5781.10Ssommerfe                read the source files in their entirety.
5791.1Stv
5801.105Swiz     distclean  Synonym for cleandir.
5811.49Slukem
5821.105Swiz     includes   Build and install system header files.  Typically needed
5831.44Slukem                before any system libraries or programs can be built.
5841.1Stv
5851.105Swiz     install    Install programs, libraries, and documentation into DESTDIR.
5861.105Swiz                Few files will be installed to DESTDIR/dev, DESTDIR/etc,
5871.105Swiz                DESTDIR/root or DESTDIR/var in order to prevent user supplied
5881.27Slukem                configuration data from being overwritten.
5891.1Stv
5901.105Swiz     lint       Run lint(1) against the C source code, where appropriate, and
5911.1Stv                generate system-installed lint libraries.
5921.1Stv
5931.105Swiz     obj        Create object directories to be used for built files, instead
5941.1Stv                of building directly in the source tree.
5951.1Stv
5961.105Swiz     tags       Create ctags(1) searchable function lists usable by the ex(1)
5971.1Stv                and vi(1) text editors.
5981.1Stv
5991.105Swiz   "make" targets for the top level
6001.1Stv     Additional make(1) targets are usable specifically from the top source
6011.1Stv     level to facilitate building the entire NetBSD source tree.
6021.1Stv
6031.105Swiz     build         Build the entire NetBSD system (except the kernel).  This
6041.68Sreed                   orders portions of the source tree such that prerequisites
6051.68Sreed                   will be built in the proper order.
6061.20Slukem
6071.126Swiz     distribution  Do a "make build", and then install a full distribution
6081.105Swiz                   (which does not include a kernel) into DESTDIR, including
6091.105Swiz                   files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
6101.105Swiz                   DESTDIR/var.
6111.20Slukem
6121.126Swiz     buildworld    As per "make distribution", except that it ensures that
6131.105Swiz                   DESTDIR is not the root directory.
6141.20Slukem
6151.105Swiz     installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR,
6161.70Sdholland                   which defaults to the root directory.  Ensures that
6171.105Swiz                   INSTALLWORLDDIR is not the root directory if cross
6181.104Swiz                   compiling.
6191.20Slukem
6201.105Swiz                   The INSTALLSETS environment variable may be set to a space-
6211.95Sapb                   separated list of distribution sets to be installed.  By
6221.126Swiz                   default, all sets except "etc" and "xetc" are installed, so
6231.126Swiz                   most files in INSTALLWORLDDIR/etc will not be installed or
6241.126Swiz                   modified.
6251.61Sapb
6261.105Swiz                   Note: Before performing this operation with
6271.105Swiz                   INSTALLWORLDDIR=/, it is highly recommended that you
6281.61Sapb                   upgrade your kernel and reboot.  After performing this
6291.61Sapb                   operation, it is recommended that you use etcupdate(8) to
6301.105Swiz                   update files in INSTALLWORLDDIR/etc, and postinstall(8) to
6311.102Sabs                   check for or fix inconsistencies.
6321.20Slukem
6331.105Swiz     sets          Create distribution sets from DESTDIR into
6341.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/sets.  Should be run
6351.126Swiz                   after "make distribution", as "make build" alone does not
6361.126Swiz                   install all of the required files.
6371.25Slukem
6381.105Swiz     sourcesets    Create source sets of the source tree into
6391.105Swiz                   RELEASEDIR/source/sets.
6401.31Slukem
6411.105Swiz     syspkgs       Create syspkgs from DESTDIR into
6421.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.  Should be run
6431.126Swiz                   after "make distribution", as "make build" alone does not
6441.126Swiz                   install all of the required files.
6451.54Sapb
6461.126Swiz     release       Do a "make distribution", build kernels, distribution
6471.126Swiz                   media, and install sets (this as per "make sets"), and then
6481.126Swiz                   package the system into a standard release layout as
6491.105Swiz                   described by release(7).  This requires that RELEASEDIR be
6501.25Slukem                   set (see above).
6511.1Stv
6521.105Swiz     iso-image     Create a NetBSD installation CD-ROM image in the
6531.114Ssnj                   RELEASEDIR/images directory.  The CD-ROM file system will
6541.114Ssnj                   have a layout as described in release(7).
6551.62Sapb
6561.62Sapb                   For most machine types, the CD-ROM will be bootable, and
6571.104Swiz                   will automatically run the sysinst(8) menu-based
6581.104Swiz                   installation program, which can be used to install or
6591.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
6601.104Swiz                   tools that may be useful in repairing a damaged NetBSD
6611.104Swiz                   installation.
6621.62Sapb
6631.126Swiz                   Before "make iso-image" is attempted, RELEASEDIR must be
6641.126Swiz                   populated by "make release" or equivalent.
6651.62Sapb
6661.62Sapb                   Note that other, smaller, CD-ROM images may be created in
6671.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
6681.126Swiz                   directory by "make release".  These smaller images usually
6691.126Swiz                   contain the same tools as the larger images in
6701.114Ssnj                   RELEASEDIR/images, but do not contain additional content
6711.114Ssnj                   such as the distribution sets.
6721.62Sapb
6731.62Sapb                   Note that the mac68k port still uses an older method of
6741.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
6751.104Swiz                   utility, which is not part of NetBSD, but which can be
6761.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
6771.56Sapb
6781.105Swiz     iso-image-source
6791.64Sjnemeth                   Create a NetBSD installation CD-ROM image in the
6801.114Ssnj                   RELEASEDIR/images directory.  The CD-ROM file system will
6811.114Ssnj                   have a layout as described in release(7).  It will have top
6821.64Sjnemeth                   level directories for the machine type and source.
6831.64Sjnemeth
6841.64Sjnemeth                   For most machine types, the CD-ROM will be bootable, and
6851.104Swiz                   will automatically run the sysinst(8) menu-based
6861.104Swiz                   installation program, which can be used to install or
6871.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
6881.104Swiz                   tools that may be useful in repairing a damaged NetBSD
6891.104Swiz                   installation.
6901.64Sjnemeth
6911.126Swiz                   Before "make iso-image-source" is attempted, RELEASEDIR
6921.126Swiz                   must be populated by "make sourcesets release" or
6931.104Swiz                   equivalent.
6941.64Sjnemeth
6951.64Sjnemeth                   Note that other, smaller, CD-ROM images may be created in
6961.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
6971.126Swiz                   directory by "make release".  These smaller images usually
6981.126Swiz                   contain the same tools as the larger images in
6991.114Ssnj                   RELEASEDIR/images, but do not contain additional content
7001.114Ssnj                   such as the distribution sets.
7011.64Sjnemeth
7021.64Sjnemeth                   Note that the mac68k port still uses an older method of
7031.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
7041.104Swiz                   utility, which is not part of NetBSD, but which can be
7051.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
7061.64Sjnemeth
7071.105Swiz     install-image
7081.98Sapb                   Create a bootable NetBSD installation disk image in the
7091.127Splunky                   RELEASEDIR/images directory.  The installation disk image
7101.127Splunky                   is suitable for copying to bootable USB flash memory
7111.127Splunky                   sticks, etc., for machines which are able to boot from such
7121.127Splunky                   devices.  The file system in the bootable disk image will
7131.127Splunky                   have a layout as described in release(7).
7141.97Stsutsui
7151.97Stsutsui                   The installation image is bootable, and will automatically
7161.97Stsutsui                   run the sysinst(8) menu-based installation program, which
7171.98Sapb                   can be used to install or upgrade a NetBSD system.  The
7181.98Sapb                   image also contains tools that may be useful in repairing a
7191.98Sapb                   damaged NetBSD installation.
7201.97Stsutsui
7211.126Swiz                   Before "make install-image" is attempted, RELEASEDIR must
7221.126Swiz                   be populated by "make release" or equivalent.  The build
7231.126Swiz                   must have been performed with MKUNPRIVED=yes because "make
7241.126Swiz                   install-image" relies on information in DESTDIR/METALOG.
7251.97Stsutsui
7261.120Spgoyette     live-image    Create NetBSD live images in the RELEASEDIR/images
7271.104Swiz                   directory.  The live image contains all necessary files to
7281.104Swiz                   boot NetBSD up to multi-user mode, including all files
7291.104Swiz                   which should be extracted during installation, NetBSD
7301.104Swiz                   disklabel, bootloaders, etc.
7311.104Swiz
7321.104Swiz                   The live image is suitable for use as a disk image in
7331.104Swiz                   virtual machine environments such as QEMU, and also useful
7341.104Swiz                   to boot NetBSD from a USB flash memory stick on a real
7351.98Sapb                   machine, without the need for installation.
7361.97Stsutsui
7371.126Swiz                   Before "make live-image" is attempted, RELEASEDIR must be
7381.126Swiz                   populated by "make release" or equivalent.  The build must
7391.126Swiz                   have been performed with MKUNPRIVED=yes because "make
7401.126Swiz                   install-image" relies on information in DESTDIR/METALOG.
7411.97Stsutsui
7421.105Swiz     regression-tests
7431.20Slukem                   Can only be run after building the regression tests in the
7441.126Swiz                   directory "regress".  Runs those compiled regression tests
7451.126Swiz                   on the local host.  Note that most tests are now managed
7461.126Swiz                   instead using atf(7); this target should probably run those
7471.126Swiz                   as well but currently does not.
7481.1Stv
7491.105Swiz   The "build.sh" script
7501.96Sapb     This script file is a shell script designed to build the entire NetBSD
7511.104Swiz     system on any host with a suitable modern shell and some common
7521.105Swiz     utilities.  The required shell features are described under the HOST_SH
7531.104Swiz     variable.
7541.96Sapb
7551.96Sapb     If a host system's default shell does support the required features, then
7561.96Sapb     we suggest that you explicitly specify a suitable shell using a command
7571.96Sapb     like
7581.96Sapb
7591.105Swiz           /path/to/suitable/shell build.sh [options]
7601.96Sapb
7611.105Swiz     The above command will usually enable build.sh to automatically set
7621.105Swiz     HOST_SH=/path/to/suitable/shell, but if that fails, then the following
7631.96Sapb     set of commands may be used instead:
7641.96Sapb
7651.105Swiz           HOST_SH=/path/to/suitable/shell
7661.96Sapb           export HOST_SH
7671.105Swiz           ${HOST_SH} build.sh [options]
7681.96Sapb
7691.105Swiz     If build.sh detects that it is being executed under an unsuitable shell,
7701.96Sapb     it attempts to exec a suitable shell instead, or prints an error message.
7711.105Swiz     If HOST_SH is not set explicitly, then build.sh sets a default using
7721.96Sapb     heuristics dependent on the host platform, or from the shell under which
7731.105Swiz     build.sh is executed (if that can be determined), or using the first copy
7741.105Swiz     of sh found in PATH.
7751.1Stv
7761.1Stv     All cross-compile builds, and most native builds, of the entire system
7771.126Swiz     should make use of build.sh rather than just running "make".  This way,
7781.104Swiz     the make(1) program will be bootstrapped properly, in case the host
7791.126Swiz     system has an older or incompatible "make" program.
7801.1Stv
7811.105Swiz     When compiling the entire system via build.sh, many make(1) variables are
7821.1Stv     set for you in order to help encapsulate the build process.  In the list
7831.105Swiz     of options below, variables that are automatically set by build.sh are
7841.1Stv     noted where applicable.
7851.1Stv
7861.105Swiz     The following operations are supported by build.sh:
7871.22Slukem
7881.126Swiz     build         Build the system as per "make build".  Before the main part
7891.126Swiz                   of the build commences, this command runs the obj operation
7901.126Swiz                   (unless the -o option is given), "make cleandir" (unless
7911.126Swiz                   the -u option is given), and the tools operation.
7921.22Slukem
7931.126Swiz     distribution  Build a full distribution as per "make distribution".  This
7941.126Swiz                   command first runs the build operation.
7951.22Slukem
7961.126Swiz     release       Build a full release as per "make release".  This command
7971.105Swiz                   first runs the distribution operation.
7981.22Slukem
7991.105Swiz     makewrapper   Create the nbmake-MACHINE wrapper.  This operation is
8001.104Swiz                   automatically performed for any of the other operations.
8011.23Slukem
8021.126Swiz     cleandir      Perform "make cleandir".
8031.75Slukem
8041.126Swiz     obj           Perform "make obj".
8051.22Slukem
8061.105Swiz     tools         Build and install the host tools from src/tools.  This
8071.126Swiz                   command will first run "make obj" and "make cleandir" in
8081.126Swiz                   the tools subdirectory unless the -o or -u options
8091.104Swiz                   (respectively) are given.
8101.22Slukem
8111.126Swiz     install=idir  Install the contents of DESTDIR to idir, using "make
8121.126Swiz                   installworld".  Note that files that are part of the "etc"
8131.126Swiz                   or "xetc" sets will not be installed, unless overridden by
8141.126Swiz                   the INSTALLSETS environment variable.
8151.35Slukem
8161.105Swiz     kernel=kconf  Build a new kernel.  The kconf argument is the name of a
8171.105Swiz                   configuration file suitable for use by config(1).  If kconf
8181.22Slukem                   does not contain any `/' characters, the configuration file
8191.105Swiz                   is expected to be found in the KERNCONFDIR directory, which
8201.105Swiz                   is typically sys/arch/MACHINE/conf.  The new kernel will be
8211.105Swiz                   built in a subdirectory of KERNOBJDIR, which is typically
8221.105Swiz                   sys/arch/MACHINE/compile or an associated object directory.
8231.70Sdholland
8241.105Swiz                   This command does not imply the tools command; run the
8251.105Swiz                   tools command first unless it is certain that the tools
8261.70Sdholland                   already exist and are up to date.
8271.70Sdholland
8281.126Swiz                   This command will run "make cleandir" on the kernel in
8291.105Swiz                   question first unless the -u option is given.
8301.22Slukem
8311.106Swiz     kernel.gdb=kconf
8321.106Swiz                   Build a new kernel with debug information.  Similar to the
8331.106Swiz                   above kernel=kconf operation, but creates a netbsd.gdb file
8341.106Swiz                   alongside of the kernel netbsd, which contains a full
8351.106Swiz                   symbol table and can be used for debugging (for example
8361.106Swiz                   with a cross-gdb built by MKCROSSGDB).
8371.106Swiz
8381.113Suebayasi     kernels       This command will build all kernels defined in port
8391.113Suebayasi                   specific release build procedure.
8401.111Suebayasi
8411.112Suebayasi                   This command internally calls the kernel=kconf operation
8421.112Suebayasi                   for each found kernel configuration file.
8431.111Suebayasi
8441.105Swiz     modules       This command will build kernel modules and install them
8451.105Swiz                   into DESTDIR.
8461.86Sjnemeth
8471.105Swiz     releasekernel=kconf
8481.70Sdholland                   Install a gzip(1)ed copy of the kernel previously built by
8491.105Swiz                   kernel=kconf into
8501.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
8511.126Swiz                   netbsd-kconf.gz, although the "netbsd" prefix is determined
8521.126Swiz                   from the "config" directives in kconf.
8531.24Slukem
8541.126Swiz     sets          Perform "make sets".
8551.31Slukem
8561.126Swiz     sourcesets    Perform "make sourcesets".
8571.22Slukem
8581.126Swiz     syspkgs       Perform "make syspkgs".
8591.54Sapb
8601.126Swiz     iso-image     Perform "make iso-image".
8611.56Sapb
8621.105Swiz     iso-image-source
8631.126Swiz                   Perform "make iso-image-source".
8641.65Sjnemeth
8651.105Swiz     install-image
8661.126Swiz                   Perform "make install-image".
8671.97Stsutsui
8681.126Swiz     live-image    Perform "make live-image".
8691.97Stsutsui
8701.109Sapb     list-arch     Prints a list of valid MACHINE and MACHINE_ARCH settings,
8711.109Sapb                   the default MACHINE_ARCH for each MACHINE, and aliases for
8721.109Sapb                   MACHINE/MACHINE_ARCH pairs, and then exits.  The -m or -a
8731.109Sapb                   options (or both) may be used to specify glob patterns that
8741.109Sapb                   will be used to narrow the list of results; for example,
8751.131Sleot                   "build.sh -m 'evb*' -a '*arm*' list-arch" will list all
8761.109Sapb                   known MACHINE/MACHINE_ARCH values in which either MACHINE
8771.109Sapb                   or ALIAS matches the pattern `evb*', and MACHINE_ARCH
8781.109Sapb                   matches the pattern `*arm*'.
8791.109Sapb
8801.105Swiz     The following command line options alter the behaviour of the build.sh
8811.51Swiz     operations described above:
8821.1Stv
8831.109Sapb     -a arch   Set the value of MACHINE_ARCH to arch.  See the -m option for
8841.109Sapb               more information.
8851.9Sthorpej
8861.105Swiz     -B buildid
8871.105Swiz               Set the value of BUILDID to buildid.  This will also append the
8881.126Swiz               build identifier to the name of the "make" wrapper script so
8891.37Slukem               that the resulting name is of the form
8901.126Swiz               "nbmake-MACHINE-BUILDID".
8911.1Stv
8921.105Swiz     -C cdextras
8931.105Swiz               Append cdextras to the CDEXTRA variable, which is a space-
8941.104Swiz               separated list of files or directories that will be added to
8951.126Swiz               the CD-ROM image that may be create by the "iso-image" or
8961.126Swiz               "iso-image-source" operations.  Files will be added to the root
8971.126Swiz               of the CD-ROM image, whereas directories will be copied
8981.87Sapb               recursively.  If relative paths are specified, they will be
8991.87Sapb               converted to absolute paths before being used.  Multiple paths
9001.105Swiz               may be specified via multiple -C options, or via a single
9011.87Sapb               option whose argument contains multiple space-separated paths.
9021.66Sjnemeth
9031.136Suwe     -c compiler
9041.136Suwe               Select the compiler for the toolchain to build NetBSD and for
9051.136Suwe               inclusion in the NetBSD distribution.  Supported choices:
9061.136Suwe
9071.136Suwe                     clang
9081.136Suwe
9091.136Suwe                     gcc [default]
9101.136Suwe
9111.136Suwe               The compiler used to build the toolchain can be different; see
9121.136Suwe               HOST_CC and HOST_CXX.
9131.136Suwe
9141.105Swiz     -D dest   Set the value of DESTDIR to dest.  If a relative path is
9151.104Swiz               specified, it will be converted to an absolute path before
9161.104Swiz               being used.
9171.104Swiz
9181.105Swiz     -E        Set `expert' mode.  This overrides various sanity checks, and
9191.105Swiz               allows: DESTDIR does not have to be set to a non-root path for
9201.105Swiz               builds, and MKUNPRIVED=yes does not have to be set when
9211.104Swiz               building as a non-root user.
9221.23Slukem
9231.105Swiz               Note: It is highly recommended that you know what you are doing
9241.23Slukem               when you use this option.
9251.19Slukem
9261.105Swiz     -h        Print a help message.
9271.51Swiz
9281.105Swiz     -j njob   Run up to njob make(1) subjobs in parallel; passed through to
9291.74Sapb               make(1).  If you see failures for reasons other than running
9301.105Swiz               out of memory while using build.sh with -j, please save
9311.104Swiz               complete build logs so the failures can be analyzed.
9321.74Sapb
9331.105Swiz               To achieve the fastest builds, -j values between (1 + the
9341.104Swiz               number of CPUs) and (2 * the number of CPUs) are recommended.
9351.104Swiz               Use lower values on machines with limited memory or I/O
9361.104Swiz               bandwidth.
9371.104Swiz
9381.126Swiz     -M obj    Set MAKEOBJDIRPREFIX to obj.  Unsets MAKEOBJDIR.  See "-O obj"
9391.126Swiz               for more information.
9401.104Swiz
9411.105Swiz               For instance, if the source directory is /usr/src, a setting of
9421.126Swiz               "-M /usr/obj" will place build-time files under
9431.105Swiz               /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
9441.105Swiz               /usr/obj/usr/src/usr.bin, and so forth.
9451.88Sapb
9461.73Sapb               If a relative path is specified, it will be converted to an
9471.105Swiz               absolute path before being used.  build.sh imposes the
9481.105Swiz               restriction that the argument to the -M option must not begin
9491.126Swiz               with a "$" (dollar sign) character; otherwise it would be too
9501.104Swiz               difficult to determine whether the value is an absolute or a
9511.104Swiz               relative path.  If the directory does not already exist,
9521.105Swiz               build.sh will create it.
9531.18Slukem
9541.109Sapb     -m mach   Set the value of MACHINE to mach, unless the mach argument is
9551.109Sapb               an alias that refers to a MACHINE/MACHINE_ARCH pair, in which
9561.109Sapb               case both MACHINE and MACHINE_ARCH are set from the alias.
9571.109Sapb               Such aliases are interpreted entirely by build.sh; they are not
9581.109Sapb               used by any other part of the build system.  The MACHINE_ARCH
9591.109Sapb               setting implied by mach will override any value of MACHINE_ARCH
9601.109Sapb               in the process environment, but will not override a value set
9611.109Sapb               by the -a option.  All cross builds require -m, but if unset on
9621.109Sapb               a NetBSD host, the host's value of MACHINE will be detected and
9631.109Sapb               used automatically.
9641.109Sapb
9651.109Sapb               See the list-arch operation for a way to get a list of valid
9661.109Sapb               MACHINE and MACHINE_ARCH settings.
9671.1Stv
9681.105Swiz     -N noiselevel
9691.126Swiz               Set the "noisyness" level of the build, by setting MAKEVERBOSE
9701.126Swiz               to noiselevel.
9711.45Slukem
9721.105Swiz     -n        Show the commands that would be executed by build.sh, but do
9731.126Swiz               not make any changes.  This is similar in concept to "make -n".
9741.1Stv
9751.105Swiz     -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
9761.105Swiz               place the built object files under obj.  Unsets
9771.105Swiz               MAKEOBJDIRPREFIX.
9781.88Sapb
9791.126Swiz               For instance, a setting of "-O /usr/obj" will place build-time
9801.126Swiz               files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and
9811.126Swiz               so forth.
9821.88Sapb
9831.88Sapb               If a relative path is specified, it will be converted to an
9841.105Swiz               absolute path before being used.  build.sh imposes the
9851.105Swiz               restriction that the argument to the -O option must not contain
9861.126Swiz               a "$" (dollar sign) character.  If the directory does not
9871.105Swiz               already exist, build.sh will create it.
9881.73Sapb
9891.105Swiz               In normal use, exactly one of the -M or -O options should be
9901.105Swiz               specified.  If neither -M nor -O is specified, then a default
9911.78Sapb               object directory will be chosen according to rules in
9921.78Sapb               <bsd.obj.mk>.  Relying on this default is not recommended
9931.78Sapb               because it is determined by complex rules that are influenced
9941.78Sapb               by the values of several variables and by the location of the
9951.78Sapb               source directory.
9961.18Slukem
9971.109Sapb               Note that placing the obj directory location outside of the
9981.109Sapb               default source tree hierarchy makes it easier to manually clear
9991.126Swiz               out old files in the event the "make cleandir" operation is
10001.109Sapb               unable to do so.  (See CAVEATS below.)
10011.109Sapb
10021.109Sapb               Note also that use of one of -M or -O is the only means of
10031.109Sapb               building multiple machine architecture userlands from the same
10041.109Sapb               source tree without cleaning between builds (in which case, one
10051.109Sapb               would specify distinct obj locations for each).
10061.109Sapb
10071.126Swiz     -o        Set the value of MKOBJDIRS to "no".  Otherwise, it will be
10081.126Swiz               automatically set to "yes".  This default is opposite to the
10091.105Swiz               behaviour when not using build.sh.
10101.1Stv
10111.105Swiz     -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
10121.59Sapb               specified, it will be converted to an absolute path before
10131.59Sapb               being used.
10141.18Slukem
10151.105Swiz     -r        Remove the contents of DESTDIR and TOOLDIR before building
10161.1Stv               (provides a clean starting point).  This will skip deleting
10171.105Swiz               DESTDIR if building on a native system to the root directory.
10181.1Stv
10191.105Swiz     -S seed   Change the value of BUILDSEED to seed.  This should rarely be
10201.72Sperry               necessary.
10211.72Sperry
10221.105Swiz     -T tools  Set the value of TOOLDIR to tools.  If a relative path is
10231.104Swiz               specified, it will be converted to an absolute path before
10241.126Swiz               being used.  If set, the bootstrap "make" will only be rebuilt
10251.126Swiz               if the source files for make(1) have changed.
10261.104Swiz
10271.105Swiz     -U        Set MKUNPRIVED=yes.
10281.104Swiz
10291.105Swiz     -u        Set MKUPDATE=yes.
10301.104Swiz
10311.105Swiz     -V var=[value]
10321.105Swiz               Set the environment variable var to an optional value.  This is
10331.105Swiz               propagated to the nbmake wrapper.
10341.105Swiz
10351.105Swiz     -w wrapper
10361.105Swiz               Create the nbmake wrapper script (see below) in a custom
10371.105Swiz               location, specified by wrapper.  This allows, for instance, to
10381.105Swiz               place the wrapper in PATH automatically.  Note that wrapper is
10391.59Sapb               the full name of the file, not just a directory name.  If a
10401.59Sapb               relative path is specified, it will be converted to an absolute
10411.59Sapb               path before being used.
10421.1Stv
10431.105Swiz     -X x11src
10441.105Swiz               Set the value of X11SRCDIR to x11src.  If a relative path is
10451.59Sapb               specified, it will be converted to an absolute path before
10461.59Sapb               being used.
10471.49Slukem
10481.105Swiz     -x        Set MKX11=yes.
10491.49Slukem
10501.105Swiz     -Z var    Unset ("zap") the environment variable var.  This is propagated
10511.105Swiz               to the nbmake wrapper.
10521.40Slukem
10531.105Swiz   The "nbmake-MACHINE" wrapper script
10541.105Swiz     If using the build.sh script to build NetBSD, a nbmake-MACHINE script
10551.105Swiz     will be created in TOOLDIR/bin upon the first build to assist in building
10561.1Stv     subtrees on a cross-compile host.
10571.1Stv
10581.105Swiz     nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
10591.126Swiz     the up-to-date version of "nbmake" installed into TOOLDIR/bin with
10601.105Swiz     several key variables pre-set, including MACHINE, MACHINE_ARCH, and
10611.105Swiz     TOOLDIR.  nbmake-MACHINE will also set variables specified with -V, and
10621.105Swiz     unset variables specified with -Z.
10631.40Slukem
10641.105Swiz     This script can be symlinked into a directory listed in PATH, or called
10651.1Stv     with an absolute path.
10661.1Stv
10671.105SwizEXAMPLES
10681.78Sapb     1.   % ./build.sh [options] tools kernel=GENERIC
10691.28Slukem
10701.28Slukem          Build a new toolchain, and use the new toolchain to configure and
10711.28Slukem          build a new GENERIC kernel.
10721.28Slukem
10731.78Sapb     2.   % ./build.sh [options] -U distribution
10741.28Slukem
10751.105Swiz          Using unprivileged mode, build a complete distribution to a DESTDIR
10761.105Swiz          directory that build.sh selects (and will display).
10771.28Slukem
10781.78Sapb     3.   # ./build.sh [options] -U install=/
10791.28Slukem
10801.105Swiz          As root, install to / the distribution that was built by example 2.
10811.105Swiz          Even though this is run as root, -U is required so that the
10821.105Swiz          permissions stored in DESTDIR/METALOG are correctly applied to the
10831.105Swiz          files as they're copied to /.
10841.28Slukem
10851.78Sapb     4.   % ./build.sh [options] -U -u release
10861.28Slukem
10871.105Swiz          Using unprivileged mode, build a complete release to DESTDIR and
10881.105Swiz          RELEASEDIR directories that build.sh selects (and will display).
10891.126Swiz          MKUPDATE=yes (-u) is set to prevent the "make cleandir", so that if
10901.126Swiz          this is run after example 2, it doesn't need to redo that portion of
10911.126Swiz          the release build.
10921.16Slukem
10931.105SwizOBSOLETE VARIABLES
10941.105Swiz     NBUILDJOBS  Use the make(1) option -j instead.
10951.15Slukem
10961.105Swiz     USE_NEW_TOOLCHAIN
10971.15Slukem                 The new toolchain is now the default.  To disable, use
10981.105Swiz                 TOOLCHAIN_MISSING=yes.
10991.10Ssommerfe
11001.105SwizSEE ALSO
11011.62Sapb     make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8),
11021.105Swiz     pkgsrc/sysutils/cdrtools
11031.1Stv
11041.105SwizHISTORY
11051.105Swiz     The build.sh based build scheme was introduced for NetBSD 1.6 as
11061.105Swiz     USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
11071.1Stv
11081.109SapbCAVEATS
11091.109Sapb     After significant updates to third-party components in the source tree,
11101.126Swiz     the "make cleandir" operation may be insufficient to clean out old files
11111.126Swiz     in object directories.  Instead, one may have to manually remove the
11121.126Swiz     files.  Consult the UPDATING file for notices concerning this.
11131.109Sapb
11141.137SuweNetBSD                         October 13, 2020                         NetBSD
1115