BUILDING revision 1.150
11.104SwizBUILDING(8)                 System Manager's Manual                BUILDING(8)
21.1Stv
31.105SwizNAME
41.150Slukem     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.147Slukem     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.147Slukem     INSTALLBOOT_UBOOT_PATHS
1211.147Slukem                       A colon-separated list of search paths used by
1221.147Slukem                       installboot(8) to find U-Boot packages.
1231.147Slukem
1241.126Swiz     MACHINE           Machine type, e.g., "macppc".
1251.8Slukem
1261.126Swiz     MACHINE_ARCH      Machine architecture, e.g., "powerpc".
1271.8Slukem
1281.105Swiz     MAKE              Path name to invoke make(1) as.
1291.8Slukem
1301.150Slukem     MAKECONF          The name of the make(1) configuration file.  See "make"
1311.150Slukem                       variables and mk.conf(5).
1321.150Slukem
1331.150Slukem                       Note: Only settable in the process environment.
1341.150Slukem
1351.150Slukem                       Default: "/etc/mk.conf"
1361.150Slukem
1371.105Swiz     MAKEFLAGS         Flags to invoke make(1) with.  Note that build.sh
1381.105Swiz                       ignores the value of MAKEFLAGS passed in the
1391.105Swiz                       environment, but allows MAKEFLAGS to be set via the -V
1401.104Swiz                       option.
1411.8Slukem
1421.105Swiz     MAKEOBJDIR        Directory to use as the .OBJDIR for the current
1431.104Swiz                       directory.  The value is subjected to variable
1441.104Swiz                       expansion by make(1).  Typical usage is to set this
1451.104Swiz                       variable to a value involving the use of
1461.104Swiz                       `${.CURDIR:S...}' or `${.CURDIR:C...}', to derive the
1471.105Swiz                       value of .OBJDIR from the value of .CURDIR.  Used only
1481.150Slukem                       if MAKEOBJDIRPREFIX is not defined.
1491.150Slukem
1501.150Slukem                       Note: MAKEOBJDIR can be provided only in the
1511.150Slukem                       environment or via the -O flag of build.sh; it cannot
1521.150Slukem                       usefully be set inside a Makefile, including in
1531.150Slukem                       mk.conf(5) or MAKECONF.
1541.8Slukem
1551.105Swiz     MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  The
1561.88Sapb                       value is subjected to variable expansion by make(1).
1571.105Swiz                       build.sh will create the ${MAKEOBJDIRPREFIX} directory
1581.105Swiz                       if necessary, but if make(1) is used without build.sh,
1591.88Sapb                       then rules in <bsd.obj.mk> will abort the build if the
1601.88Sapb                       ${MAKEOBJDIRPREFIX} directory does not exist.  If the
1611.104Swiz                       value is defined and valid, then
1621.105Swiz                       ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR
1631.104Swiz                       for the current directory.  The current directory may
1641.150Slukem                       be read only.
1651.150Slukem
1661.150Slukem                       Note: MAKEOBJDIRPREFIX can be provided only in the
1671.150Slukem                       environment or via the -M flag of build.sh; it cannot
1681.150Slukem                       usefully be set inside a Makefile, including in
1691.150Slukem                       mk.conf(5) or MAKECONF.
1701.104Swiz
1711.149Slukem     TMPDIR            Top-level directory to store temporary directories used
1721.149Slukem                       by build.sh before paths to other directories such as
1731.149Slukem                       .OBJDIR can be determined.
1741.149Slukem
1751.149Slukem                       Note: Must support execution of binaries.  I.e.,
1761.149Slukem                       without mount(8)'s -o noexec option.
1771.149Slukem
1781.149Slukem                       Default: "/tmp".
1791.149Slukem
1801.105Swiz   "make" variables
1811.104Swiz     Several variables control the behavior of NetBSD builds.  Unless
1821.104Swiz     otherwise specified, these variables may be set in either the process
1831.150Slukem     environment or the make(1) configuration file mk.conf(5) specified by
1841.150Slukem     MAKECONF.  This list is not comprehensive; all supported variables and
1851.150Slukem     their defaults are documented in mk.conf(5).
1861.1Stv
1871.107Sapb     BUILDID     Identifier for the build.  If set, this should be a short
1881.107Sapb                 string that is suitable for use as part of a file or
1891.107Sapb                 directory name.  The identifier will be appended to object
1901.107Sapb                 directory names, and can be consulted in the make(1)
1911.104Swiz                 configuration file in order to set additional build
1921.107Sapb                 parameters, such as compiler flags.  It will also be used as
1931.148Slukem                 part of the kernel version string, which can be shown by
1941.126Swiz                 "uname -v".
1951.107Sapb
1961.107Sapb                 Default: Unset.
1971.9Sthorpej
1981.108Sapb     BUILDINFO   This may be a multi-line string containing information about
1991.108Sapb                 the build.  This will appear in DESTDIR/etc/release, and it
2001.108Sapb                 will be stored in the buildinfo variable in any kernels that
2011.108Sapb                 are built.  When such kernels are booted, the sysctl(7)
2021.108Sapb                 kern.buildinfo variable will report this value.  The string
2031.126Swiz                 may contain backslash escape sequences, such as "\\"
2041.126Swiz                 (representing a backslash character) and "\n" (representing a
2051.126Swiz                 newline).
2061.108Sapb
2071.108Sapb                 Default: Unset.
2081.108Sapb
2091.105Swiz     BUILDSEED   GCC uses random numbers when compiling C++ code.  This
2101.104Swiz                 variable seeds the gcc random number generator using the
2111.104Swiz                 -frandom-seed flag with this value.  By default, it is set to
2121.104Swiz                 NetBSD-(majorversion).  Using a fixed value causes C++
2131.104Swiz                 binaries to be the same when built from the same sources,
2141.104Swiz                 resulting in identical (reproducible) builds.  Additional
2151.104Swiz                 information is available in the GCC documentation of
2161.104Swiz                 -frandom-seed.
2171.104Swiz
2181.138Sthorpej     CPUFLAGS    Additional flags to the compiler/assembler to select CPU
2191.138Sthorpej                 instruction set options, CPU tuning options, etc.
2201.138Sthorpej
2211.138Sthorpej                 Default: Unset.
2221.138Sthorpej
2231.105Swiz     DESTDIR     Directory to contain the built NetBSD system.  If set,
2241.104Swiz                 special options are passed to the compilation tools to
2251.105Swiz                 prevent their default use of the host system's /usr/include,
2261.105Swiz                 /usr/lib, and so forth.  This pathname must be an absolute
2271.105Swiz                 path, and should not end with a slash (/) character.  (For
2281.105Swiz                 installation into the system's root directory, set DESTDIR to
2291.126Swiz                 an empty string, not to "/").  The directory must reside on a
2301.126Swiz                 file system which supports long file names and hard links.
2311.1Stv
2321.126Swiz                 Default: Empty string if USETOOLS is "yes"; unset otherwise.
2331.1Stv
2341.105Swiz                 Note: build.sh will provide a default of destdir.MACHINE (in
2351.105Swiz                 the top-level .OBJDIR) unless run in `expert' mode.
2361.30Slukem
2371.105Swiz     MAKEVERBOSE
2381.45Slukem                 Level of verbosity of status messages.  Supported values:
2391.45Slukem
2401.80Sapb                 0    No descriptive messages or commands executed by make(1)
2411.80Sapb                      are shown.
2421.45Slukem
2431.80Sapb                 1    Brief messages are shown describing what is being done,
2441.104Swiz                      but the actual commands executed by make(1) are not
2451.148Slukem                      shown.
2461.80Sapb
2471.80Sapb                 2    Descriptive messages are shown as above (prefixed with a
2481.80Sapb                      `#'), and ordinary commands performed by make(1) are
2491.148Slukem                      shown.
2501.80Sapb
2511.80Sapb                 3    In addition to the above, all commands performed by
2521.148Slukem                      make(1) are shown, even if they would ordinarily have
2531.148Slukem                      been hidden through use of the "@" prefix in the
2541.80Sapb                      relevant makefile.
2551.45Slukem
2561.80Sapb                 4    In addition to the above, commands executed by make(1)
2571.126Swiz                      are traced through use of the sh(1) "-x" flag.
2581.45Slukem
2591.105Swiz                 Default: 2
2601.45Slukem
2611.140Skamil     MKCATPAGES  Can be set to "yes" or "no".  Indicates whether preformatted
2621.140Skamil                 plaintext manual pages will be created during a build.
2631.140Skamil
2641.140Skamil                 Default: "no"
2651.140Skamil
2661.126Swiz     MKCROSSGDB  Can be set to "yes" or "no".  Create a cross-gdb as a host
2671.126Swiz                 tool.
2681.106Swiz
2691.126Swiz                 Default: "no"
2701.106Swiz
2711.126Swiz     MKDEBUG     Can be set to "yes" or "no".  Indicates whether debug
2721.106Swiz                 information should be generated for all userland binaries
2731.106Swiz                 compiled.  The result is collected as an additional debug.tgz
2741.106Swiz                 and xdebug.tgz set and installed in /usr/libdata/debug.
2751.106Swiz
2761.126Swiz                 Default: "no"
2771.106Swiz
2781.126Swiz     MKDEBUGLIB  Can be set to "yes" or "no".  Indicates whether debug
2791.106Swiz                 information (see MKDEBUG) should also be generated for all
2801.134Ssevan                 libraries built.
2811.106Swiz
2821.126Swiz                 Default: "no"
2831.106Swiz
2841.126Swiz     MKDOC       Can be set to "yes" or "no".  Indicates whether system
2851.105Swiz                 documentation destined for DESTDIR/usr/share/doc will be
2861.44Slukem                 installed during a build.
2871.1Stv
2881.126Swiz                 Default: "yes"
2891.1Stv
2901.126Swiz     MKHTML      Can be set to "yes" or "no".  Indicates whether preformatted
2911.126Swiz                 HTML manual pages will be built and installed
2921.77Slukem
2931.126Swiz                 Default: "yes"
2941.77Slukem
2951.126Swiz     MKHOSTOBJ   Can be set to "yes" or "no".  If set to "yes", then for
2961.4Stv                 programs intended to be run on the compile host, the name,
2971.4Stv                 release, and architecture of the host operating system will
2981.4Stv                 be suffixed to the name of the object directory created by
2991.126Swiz                 "make obj".  (This allows multiple host systems to compile
3001.126Swiz                 NetBSD for a single target.)  If set to "no", then programs
3011.4Stv                 built to be run on the compile host will use the same object
3021.4Stv                 directory names as programs built to be run on the target.
3031.4Stv
3041.126Swiz                 Default: "no"
3051.4Stv
3061.126Swiz     MKINFO      Can be set to "yes" or "no".  Indicates whether GNU Info
3071.134Ssevan                 files will be created and installed during a build.  GNU Info
3081.134Ssevan                 files are used for providing documentation by most of the
3091.134Ssevan                 compilation tools.
3101.1Stv
3111.126Swiz                 Default: "yes"
3121.1Stv
3131.143Slukem     MKKDEBUG    Can be set to "yes" or "no".  Force generation of full-debug
3141.143Slukem                 symbol versions of all kernels compiled.  Alongside of the
3151.143Slukem                 netbsd kernel file, an unstripped version netbsd.gdb is
3161.143Slukem                 created.  This is useful if a cross-gdb is built as well (see
3171.143Slukem                 MKCROSSGDB).
3181.143Slukem
3191.143Slukem                 Default: "no"
3201.143Slukem
3211.126Swiz     MKKMOD      Can be set to "yes" or "no".  Indicates whether kernel
3221.95Sapb                 modules are built and installed.
3231.95Sapb
3241.126Swiz                 Default: "yes"
3251.95Sapb
3261.126Swiz     MKLINT      Can be set to "yes" or "no".  Indicates whether lint(1) will
3271.126Swiz                 be run against portions of the NetBSD source code during the
3281.126Swiz                 build, and whether lint libraries will be installed into
3291.105Swiz                 DESTDIR/usr/libdata/lint.
3301.1Stv
3311.146Srillig                 Default: "no"
3321.1Stv
3331.126Swiz     MKMAN       Can be set to "yes" or "no".  Indicates whether manual pages
3341.126Swiz                 will be installed during a build.
3351.1Stv
3361.126Swiz                 Default: "yes"
3371.1Stv
3381.126Swiz     MKNLS       Can be set to "yes" or "no".  Indicates whether Native
3391.44Slukem                 Language System locale zone files will be compiled and
3401.44Slukem                 installed during a build.
3411.1Stv
3421.126Swiz                 Default: "yes"
3431.1Stv
3441.126Swiz     MKOBJ       Can be set to "yes" or "no".  Indicates whether object
3451.126Swiz                 directories will be created when running "make obj".  If set
3461.126Swiz                 to "no", then all built files will be located inside the
3471.126Swiz                 regular source tree.
3481.1Stv
3491.126Swiz                 Default: "yes"
3501.1Stv
3511.126Swiz                 Note that setting MKOBJ to "no" is not recommended and may
3521.70Sdholland                 cause problems when updating the tree with cvs(1).
3531.70Sdholland
3541.126Swiz     MKPIC       Can be set to "yes" or "no".  Indicates whether shared
3551.1Stv                 objects and libraries will be created and installed during a
3561.126Swiz                 build.  If set to "no", the entire built system will be
3571.1Stv                 statically linked.
3581.1Stv
3591.130Ssevan                 Default: Platform dependent.  As of this writing, all
3601.130Ssevan                 platforms except m68000 default to "yes".
3611.1Stv
3621.105Swiz     MKPICINSTALL
3631.126Swiz                 Can be set to "yes" or "no".  Indicates whether the ar(1)
3641.105Swiz                 format libraries (lib*_pic.a), used to generate shared
3651.44Slukem                 libraries, are installed during a build.
3661.1Stv
3671.126Swiz                 Default: "yes"
3681.1Stv
3691.126Swiz     MKPROFILE   Can be set to "yes" or "no".  Indicates whether profiled
3701.105Swiz                 libraries (lib*_p.a) will be built and installed during a
3711.1Stv                 build.
3721.1Stv
3731.126Swiz                 Default: "yes"; however, some platforms turn off MKPROFILE by
3741.126Swiz                 default at times due to toolchain problems with profiled
3751.1Stv                 code.
3761.1Stv
3771.126Swiz     MKREPRO     Can be set to "yes" or "no".  Create reproducible builds.
3781.100Swiz                 This enables different switches to make two builds from the
3791.100Swiz                 same source tree result in the same build results.
3801.100Swiz
3811.126Swiz                 Default: "no" This may be set to "yes" by giving build.sh the
3821.126Swiz                 -P option.
3831.100Swiz
3841.122Swiz     MKREPRO_TIMESTAMP
3851.122Swiz                 Unix timestamp.  When MKREPRO is set, the timestamp of all
3861.122Swiz                 files in the sets will be set to this value.
3871.122Swiz
3881.124Schristos                 Default: Unset.  This may be set automatically to the latest
3891.124Schristos                 source tree timestamp using cvslatest(1) by giving build.sh
3901.124Schristos                 the -P option.
3911.122Swiz
3921.126Swiz     MKSHARE     Can be set to "yes" or "no".  Indicates whether files
3931.105Swiz                 destined to reside in DESTDIR/usr/share will be built and
3941.140Skamil                 installed during a build.  If set to "no", then all of
3951.140Skamil                 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
3961.140Skamil                 "no" unconditionally.
3971.1Stv
3981.126Swiz                 Default: "yes"
3991.1Stv
4001.105Swiz     MKSTRIPIDENT
4011.126Swiz                 Can be set to "yes" or "no".  Indicates whether RCS IDs, for
4021.126Swiz                 use with ident(1), should be stripped from program binaries
4031.126Swiz                 and shared libraries.
4041.78Sapb
4051.126Swiz                 Default: "no"
4061.78Sapb
4071.126Swiz     MKSTRIPSYM  Can be set to "yes" or "no".  Indicates whether all local
4081.126Swiz                 symbols should be stripped from shared libraries.  If "yes",
4091.125Sozaki                 strip all local symbols from shared libraries; the affect is
4101.126Swiz                 equivalent to the -x option of ld(1).  If "no", strip only
4111.126Swiz                 temporary local symbols; the affect is equivalent to the -X
4121.126Swiz                 option of ld(1).  Keeping non-temporary local symbols such as
4131.125Sozaki                 static function names is useful on using DTrace for userland
4141.125Sozaki                 libraries and getting a backtrace from a rump kernel loading
4151.125Sozaki                 shared libraries.
4161.125Sozaki
4171.126Swiz                 Default: "yes"
4181.125Sozaki
4191.126Swiz     MKUNPRIVED  Can be set to "yes" or "no".  Indicates whether an
4201.104Swiz                 unprivileged install will occur.  The user, group,
4211.104Swiz                 permissions, and file flags, will not be set on the installed
4221.52Sjmc                 items; instead the information will be appended to a file
4231.105Swiz                 called METALOG in DESTDIR.  The contents of METALOG are used
4241.52Sjmc                 during the generation of the distribution tar files to ensure
4251.52Sjmc                 that the appropriate file ownership is stored.
4261.38Slukem
4271.126Swiz                 Default: "no"
4281.38Slukem
4291.126Swiz     MKUPDATE    Can be set to "yes" or "no".  Indicates whether all install
4301.126Swiz                 operations intended to write to DESTDIR will compare file
4311.126Swiz                 timestamps before installing, and skip the install phase if
4321.126Swiz                 the destination files are up-to-date.  This also has
4331.44Slukem                 implications on full builds (see next subsection).
4341.38Slukem
4351.126Swiz                 Default: "no"
4361.38Slukem
4371.126Swiz     MKX11       Can be set to "yes" or "no".  Indicates whether X11 is built
4381.126Swiz                 from X11SRCDIR.
4391.49Slukem
4401.126Swiz                 Default: "no"
4411.49Slukem
4421.105Swiz     TOOLDIR     Directory to hold the host tools, once built.  If specified,
4431.59Sapb                 must be an absolute path.  This directory should be unique to
4441.104Swiz                 a given host system and NetBSD source tree.  (However,
4451.105Swiz                 multiple targets may share the same TOOLDIR; the target-
4461.104Swiz                 dependent files have unique names.)  If unset, a default
4471.104Swiz                 based on the uname(1) information of the host platform will
4481.105Swiz                 be created in the .OBJDIR of src.
4491.1Stv
4501.105Swiz                 Default: Unset.
4511.1Stv
4521.105Swiz     USETOOLS    Indicates whether the tools specified by TOOLDIR should be
4531.126Swiz                 used as part of a build in progress.  Must be set to "yes" if
4541.126Swiz                 cross-compiling.
4551.1Stv
4561.105Swiz                 yes    Use the tools from TOOLDIR.
4571.1Stv
4581.105Swiz                 no     Do not use the tools from TOOLDIR, but refuse to build
4591.1Stv                        native compilation tool components that are version-
4601.1Stv                        specific for that tool.
4611.1Stv
4621.105Swiz                 never  Do not use the tools from TOOLDIR, even when building
4631.104Swiz                        native tool components.  This is similar to the
4641.105Swiz                        traditional NetBSD build method, but does not verify
4651.104Swiz                        that the compilation tools in use are up-to-date
4661.104Swiz                        enough in order to build the tree successfully.  This
4671.104Swiz                        may cause build or runtime problems when building the
4681.104Swiz                        whole NetBSD source tree.
4691.1Stv
4701.126Swiz                 Default: "yes", unless TOOLCHAIN_MISSING is set to "yes".
4711.71Sdholland
4721.126Swiz                 USETOOLS is also set to "no" when using <bsd.*.mk> outside
4731.71Sdholland                 the NetBSD source tree.
4741.1Stv
4751.121Smrg     X11SRCDIR   Directory containing the modular Xorg source.  If specified,
4761.121Smrg                 must be an absolute path.  The main modular Xorg source is
4771.121Smrg                 found in X11SRCDIR/external/mit.
4781.49Slukem
4791.135Sleot                 Default: NETBSDSRCDIR/../xsrc, if that exists; otherwise
4801.105Swiz                 /usr/xsrc.
4811.49Slukem
4821.105Swiz   "make" variables for full builds
4831.126Swiz     These variables only affect the top level "Makefile" and do not affect
4841.7Slukem     manually building subtrees of the NetBSD source code.
4851.1Stv
4861.147Slukem     INSTALLBOOT_BOARDS
4871.147Slukem                      A list of boards to create bootable images for.  If
4881.147Slukem                      corresponding U-Boot packages are installed, bootable
4891.147Slukem                      images are created as part of a release.  See the
4901.147Slukem                      -o board=name option of installboot(8).
4911.147Slukem
4921.126Swiz     INSTALLWORLDDIR  Location for the "make installworld" target to install
4931.59Sapb                      to.  If specified, must be an absolute path.
4941.1Stv
4951.126Swiz                      Default: "/"
4961.1Stv
4971.126Swiz     MKOBJDIRS        Can be set to "yes" or "no".  Indicates whether object
4981.126Swiz                      directories will be created automatically (via a "make
4991.126Swiz                      obj" pass) at the start of a build.
5001.1Stv
5011.126Swiz                      Default: "no"
5021.1Stv
5031.126Swiz                      If using build.sh, the default is "yes".  This may be
5041.126Swiz                      set back to "no" by giving build.sh the -o option.
5051.70Sdholland
5061.126Swiz     MKUPDATE         Can be set to "yes" or "no".  If set, then in addition
5071.126Swiz                      to the effects described for MKUPDATE=yes above, this
5081.126Swiz                      implies the effects of NOCLEANDIR (i.e., "make cleandir"
5091.126Swiz                      is avoided).
5101.38Slukem
5111.126Swiz                      Default: "no"
5121.38Slukem
5131.105Swiz                      If using build.sh, this may be set by giving the -u
5141.70Sdholland                      option.
5151.70Sdholland
5161.105Swiz     NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead.  See
5171.70Sdholland                      below.
5181.1Stv
5191.105Swiz                      Default: Unset.
5201.1Stv
5211.126Swiz     NOCLEANDIR       If set, avoids the "make cleandir" phase of a full
5221.20Slukem                      build.  This has the effect of allowing only changed
5231.20Slukem                      files in a source tree to be recompiled.  This can speed
5241.20Slukem                      up builds when updating only a few files in the tree.
5251.1Stv
5261.105Swiz                      Default: Unset.
5271.1Stv
5281.105Swiz                      See also MKUPDATE.
5291.70Sdholland
5301.126Swiz     NODISTRIBDIRS    If set, avoids the "make distrib-dirs" phase of a full
5311.105Swiz                      build.  This skips running mtree(8) on DESTDIR, useful
5321.20Slukem                      on systems where building as an unprivileged user, or
5331.20Slukem                      where it is known that the system-wide mtree files have
5341.20Slukem                      not changed.
5351.1Stv
5361.105Swiz                      Default: Unset.
5371.1Stv
5381.126Swiz     NOINCLUDES       If set, avoids the "make includes" phase of a full
5391.20Slukem                      build.  This has the effect of preventing make(1) from
5401.44Slukem                      thinking that some programs are out-of-date simply
5411.44Slukem                      because the system include files have changed.  However,
5421.20Slukem                      this option should not be used when updating the entire
5431.20Slukem                      NetBSD source tree arbitrarily; it is suggested to use
5441.105Swiz                      MKUPDATE=yes instead in that case.
5451.1Stv
5461.105Swiz                      Default: Unset.
5471.1Stv
5481.105Swiz     RELEASEDIR       If set, specifies the directory to which a release(7)
5491.126Swiz                      layout will be written at the end of a "make release".
5501.59Sapb                      If specified, must be an absolute path.
5511.20Slukem
5521.105Swiz                      Default: Unset.
5531.20Slukem
5541.105Swiz                      Note: build.sh will provide a default of releasedir (in
5551.105Swiz                      the top-level .OBJDIR) unless run in `expert' mode.
5561.30Slukem
5571.105SwizBUILDING
5581.105Swiz   "make" command line options
5591.52Sjmc     This is not a summary of all the options available to make(1); only the
5601.52Sjmc     options used most frequently with NetBSD builds are listed here.
5611.1Stv
5621.105Swiz     -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
5631.52Sjmc                use .WAIT or have explicit dependencies as necessary to
5641.74Sapb                enforce build ordering.
5651.10Ssommerfe
5661.105Swiz     -m dir     Specify the default directory for searching for system
5671.104Swiz                Makefile segments, mainly the <bsd.*.mk> files.  When building
5681.104Swiz                any full NetBSD source tree, this should be set to the
5691.126Swiz                "share/mk" directory in the source tree.  This is set
5701.104Swiz                automatically when building from the top level, or when using
5711.105Swiz                build.sh.
5721.1Stv
5731.148Slukem     -n         Show the commands that would have been executed, but do not
5741.1Stv                actually execute them.  This will still cause recursion to
5751.1Stv                take place.
5761.1Stv
5771.148Slukem     -V var     Show make(1)'s idea of the value of var.  Does not build any
5781.1Stv                targets.
5791.1Stv
5801.105Swiz     var=value  Set the variable var to value, overriding any setting
5811.105Swiz                specified by the process environment, the MAKECONF
5821.104Swiz                configuration file, or the system Makefile segments.
5831.1Stv
5841.105Swiz   "make" targets
5851.1Stv     These default targets may be built by running make(1) in any subtree of
5861.1Stv     the NetBSD source code.  It is recommended that none of these be used
5871.126Swiz     from the top level Makefile; as a specific exception, "make obj" and
5881.126Swiz     "make cleandir" are useful in that context.
5891.1Stv
5901.105Swiz     all        Build programs, libraries, and preformatted documentation.
5911.1Stv
5921.105Swiz     clean      Remove program and library object code files.
5931.1Stv
5941.105Swiz     cleandir   Same as clean, but also remove preformatted documentation,
5951.126Swiz                dependency files generated by "make depend", and any other
5961.49Slukem                files known to be created at build time.
5971.1Stv
5981.105Swiz     depend     Create dependency files (.depend) containing more detailed
5991.44Slukem                information about the dependencies of source code on header
6001.1Stv                files.  Allows programs to be recompiled automatically when a
6011.1Stv                dependency changes.
6021.1Stv
6031.126Swiz     dependall  Does a "make depend" immediately followed by a "make all".
6041.10Ssommerfe                This improves cache locality of the build since both passes
6051.10Ssommerfe                read the source files in their entirety.
6061.1Stv
6071.105Swiz     distclean  Synonym for cleandir.
6081.49Slukem
6091.105Swiz     includes   Build and install system header files.  Typically needed
6101.44Slukem                before any system libraries or programs can be built.
6111.1Stv
6121.105Swiz     install    Install programs, libraries, and documentation into DESTDIR.
6131.105Swiz                Few files will be installed to DESTDIR/dev, DESTDIR/etc,
6141.105Swiz                DESTDIR/root or DESTDIR/var in order to prevent user supplied
6151.27Slukem                configuration data from being overwritten.
6161.1Stv
6171.105Swiz     lint       Run lint(1) against the C source code, where appropriate, and
6181.1Stv                generate system-installed lint libraries.
6191.1Stv
6201.105Swiz     obj        Create object directories to be used for built files, instead
6211.1Stv                of building directly in the source tree.
6221.1Stv
6231.105Swiz     tags       Create ctags(1) searchable function lists usable by the ex(1)
6241.1Stv                and vi(1) text editors.
6251.1Stv
6261.105Swiz   "make" targets for the top level
6271.1Stv     Additional make(1) targets are usable specifically from the top source
6281.1Stv     level to facilitate building the entire NetBSD source tree.
6291.1Stv
6301.105Swiz     build         Build the entire NetBSD system (except the kernel).  This
6311.68Sreed                   orders portions of the source tree such that prerequisites
6321.68Sreed                   will be built in the proper order.
6331.20Slukem
6341.126Swiz     distribution  Do a "make build", and then install a full distribution
6351.105Swiz                   (which does not include a kernel) into DESTDIR, including
6361.105Swiz                   files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
6371.105Swiz                   DESTDIR/var.
6381.20Slukem
6391.126Swiz     buildworld    As per "make distribution", except that it ensures that
6401.105Swiz                   DESTDIR is not the root directory.
6411.20Slukem
6421.105Swiz     installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR,
6431.70Sdholland                   which defaults to the root directory.  Ensures that
6441.105Swiz                   INSTALLWORLDDIR is not the root directory if cross
6451.104Swiz                   compiling.
6461.20Slukem
6471.105Swiz                   The INSTALLSETS environment variable may be set to a space-
6481.95Sapb                   separated list of distribution sets to be installed.  By
6491.126Swiz                   default, all sets except "etc" and "xetc" are installed, so
6501.126Swiz                   most files in INSTALLWORLDDIR/etc will not be installed or
6511.126Swiz                   modified.
6521.61Sapb
6531.105Swiz                   Note: Before performing this operation with
6541.105Swiz                   INSTALLWORLDDIR=/, it is highly recommended that you
6551.61Sapb                   upgrade your kernel and reboot.  After performing this
6561.61Sapb                   operation, it is recommended that you use etcupdate(8) to
6571.105Swiz                   update files in INSTALLWORLDDIR/etc, and postinstall(8) to
6581.102Sabs                   check for or fix inconsistencies.
6591.20Slukem
6601.105Swiz     sets          Create distribution sets from DESTDIR into
6611.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/sets.  Should be run
6621.126Swiz                   after "make distribution", as "make build" alone does not
6631.126Swiz                   install all of the required files.
6641.25Slukem
6651.105Swiz     sourcesets    Create source sets of the source tree into
6661.105Swiz                   RELEASEDIR/source/sets.
6671.31Slukem
6681.105Swiz     syspkgs       Create syspkgs from DESTDIR into
6691.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.  Should be run
6701.126Swiz                   after "make distribution", as "make build" alone does not
6711.126Swiz                   install all of the required files.
6721.54Sapb
6731.126Swiz     release       Do a "make distribution", build kernels, distribution
6741.126Swiz                   media, and install sets (this as per "make sets"), and then
6751.126Swiz                   package the system into a standard release layout as
6761.105Swiz                   described by release(7).  This requires that RELEASEDIR be
6771.25Slukem                   set (see above).
6781.1Stv
6791.105Swiz     iso-image     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).
6821.62Sapb
6831.62Sapb                   For most machine types, the CD-ROM will be bootable, and
6841.104Swiz                   will automatically run the sysinst(8) menu-based
6851.104Swiz                   installation program, which can be used to install or
6861.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
6871.104Swiz                   tools that may be useful in repairing a damaged NetBSD
6881.104Swiz                   installation.
6891.62Sapb
6901.126Swiz                   Before "make iso-image" is attempted, RELEASEDIR must be
6911.126Swiz                   populated by "make release" or equivalent.
6921.62Sapb
6931.62Sapb                   Note that other, smaller, CD-ROM images may be created in
6941.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
6951.126Swiz                   directory by "make release".  These smaller images usually
6961.126Swiz                   contain the same tools as the larger images in
6971.114Ssnj                   RELEASEDIR/images, but do not contain additional content
6981.114Ssnj                   such as the distribution sets.
6991.62Sapb
7001.62Sapb                   Note that the mac68k port still uses an older method of
7011.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
7021.104Swiz                   utility, which is not part of NetBSD, but which can be
7031.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
7041.56Sapb
7051.105Swiz     iso-image-source
7061.64Sjnemeth                   Create a NetBSD installation CD-ROM image in the
7071.114Ssnj                   RELEASEDIR/images directory.  The CD-ROM file system will
7081.114Ssnj                   have a layout as described in release(7).  It will have top
7091.64Sjnemeth                   level directories for the machine type and source.
7101.64Sjnemeth
7111.64Sjnemeth                   For most machine types, the CD-ROM will be bootable, and
7121.104Swiz                   will automatically run the sysinst(8) menu-based
7131.104Swiz                   installation program, which can be used to install or
7141.104Swiz                   upgrade a NetBSD system.  Bootable CD-ROMs also contain
7151.104Swiz                   tools that may be useful in repairing a damaged NetBSD
7161.104Swiz                   installation.
7171.64Sjnemeth
7181.126Swiz                   Before "make iso-image-source" is attempted, RELEASEDIR
7191.126Swiz                   must be populated by "make sourcesets release" or
7201.104Swiz                   equivalent.
7211.64Sjnemeth
7221.64Sjnemeth                   Note that other, smaller, CD-ROM images may be created in
7231.105Swiz                   the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom
7241.126Swiz                   directory by "make release".  These smaller images usually
7251.126Swiz                   contain the same tools as the larger images in
7261.114Ssnj                   RELEASEDIR/images, but do not contain additional content
7271.114Ssnj                   such as the distribution sets.
7281.64Sjnemeth
7291.64Sjnemeth                   Note that the mac68k port still uses an older method of
7301.104Swiz                   creating CD-ROM images.  This requires the mkisofs(1)
7311.104Swiz                   utility, which is not part of NetBSD, but which can be
7321.105Swiz                   installed from pkgsrc/sysutils/cdrtools.
7331.64Sjnemeth
7341.105Swiz     install-image
7351.98Sapb                   Create a bootable NetBSD installation disk image in the
7361.127Splunky                   RELEASEDIR/images directory.  The installation disk image
7371.127Splunky                   is suitable for copying to bootable USB flash memory
7381.127Splunky                   sticks, etc., for machines which are able to boot from such
7391.127Splunky                   devices.  The file system in the bootable disk image will
7401.127Splunky                   have a layout as described in release(7).
7411.97Stsutsui
7421.97Stsutsui                   The installation image is bootable, and will automatically
7431.97Stsutsui                   run the sysinst(8) menu-based installation program, which
7441.98Sapb                   can be used to install or upgrade a NetBSD system.  The
7451.98Sapb                   image also contains tools that may be useful in repairing a
7461.98Sapb                   damaged NetBSD installation.
7471.97Stsutsui
7481.126Swiz                   Before "make install-image" is attempted, RELEASEDIR must
7491.126Swiz                   be populated by "make release" or equivalent.  The build
7501.126Swiz                   must have been performed with MKUNPRIVED=yes because "make
7511.126Swiz                   install-image" relies on information in DESTDIR/METALOG.
7521.97Stsutsui
7531.120Spgoyette     live-image    Create NetBSD live images in the RELEASEDIR/images
7541.104Swiz                   directory.  The live image contains all necessary files to
7551.104Swiz                   boot NetBSD up to multi-user mode, including all files
7561.104Swiz                   which should be extracted during installation, NetBSD
7571.104Swiz                   disklabel, bootloaders, etc.
7581.104Swiz
7591.104Swiz                   The live image is suitable for use as a disk image in
7601.104Swiz                   virtual machine environments such as QEMU, and also useful
7611.104Swiz                   to boot NetBSD from a USB flash memory stick on a real
7621.98Sapb                   machine, without the need for installation.
7631.97Stsutsui
7641.126Swiz                   Before "make live-image" is attempted, RELEASEDIR must be
7651.126Swiz                   populated by "make release" or equivalent.  The build must
7661.126Swiz                   have been performed with MKUNPRIVED=yes because "make
7671.126Swiz                   install-image" relies on information in DESTDIR/METALOG.
7681.97Stsutsui
7691.105Swiz     regression-tests
7701.20Slukem                   Can only be run after building the regression tests in the
7711.126Swiz                   directory "regress".  Runs those compiled regression tests
7721.126Swiz                   on the local host.  Note that most tests are now managed
7731.126Swiz                   instead using atf(7); this target should probably run those
7741.126Swiz                   as well but currently does not.
7751.1Stv
7761.105Swiz   The "build.sh" script
7771.96Sapb     This script file is a shell script designed to build the entire NetBSD
7781.104Swiz     system on any host with a suitable modern shell and some common
7791.105Swiz     utilities.  The required shell features are described under the HOST_SH
7801.104Swiz     variable.
7811.96Sapb
7821.96Sapb     If a host system's default shell does support the required features, then
7831.96Sapb     we suggest that you explicitly specify a suitable shell using a command
7841.96Sapb     like
7851.96Sapb
7861.105Swiz           /path/to/suitable/shell build.sh [options]
7871.96Sapb
7881.105Swiz     The above command will usually enable build.sh to automatically set
7891.105Swiz     HOST_SH=/path/to/suitable/shell, but if that fails, then the following
7901.96Sapb     set of commands may be used instead:
7911.96Sapb
7921.105Swiz           HOST_SH=/path/to/suitable/shell
7931.96Sapb           export HOST_SH
7941.105Swiz           ${HOST_SH} build.sh [options]
7951.96Sapb
7961.105Swiz     If build.sh detects that it is being executed under an unsuitable shell,
7971.148Slukem     it attempts to exec a suitable shell instead, or shows an error message.
7981.105Swiz     If HOST_SH is not set explicitly, then build.sh sets a default using
7991.96Sapb     heuristics dependent on the host platform, or from the shell under which
8001.105Swiz     build.sh is executed (if that can be determined), or using the first copy
8011.105Swiz     of sh found in PATH.
8021.1Stv
8031.1Stv     All cross-compile builds, and most native builds, of the entire system
8041.126Swiz     should make use of build.sh rather than just running "make".  This way,
8051.104Swiz     the make(1) program will be bootstrapped properly, in case the host
8061.126Swiz     system has an older or incompatible "make" program.
8071.1Stv
8081.105Swiz     When compiling the entire system via build.sh, many make(1) variables are
8091.1Stv     set for you in order to help encapsulate the build process.  In the list
8101.105Swiz     of options below, variables that are automatically set by build.sh are
8111.1Stv     noted where applicable.
8121.1Stv
8131.105Swiz     The following operations are supported by build.sh:
8141.22Slukem
8151.126Swiz     build         Build the system as per "make build".  Before the main part
8161.126Swiz                   of the build commences, this command runs the obj operation
8171.126Swiz                   (unless the -o option is given), "make cleandir" (unless
8181.126Swiz                   the -u option is given), and the tools operation.
8191.22Slukem
8201.126Swiz     distribution  Build a full distribution as per "make distribution".  This
8211.126Swiz                   command first runs the build operation.
8221.22Slukem
8231.126Swiz     release       Build a full release as per "make release".  This command
8241.105Swiz                   first runs the distribution operation.
8251.22Slukem
8261.148Slukem     help          Show a help message, and exit.
8271.148Slukem
8281.105Swiz     makewrapper   Create the nbmake-MACHINE wrapper.  This operation is
8291.104Swiz                   automatically performed for any of the other operations.
8301.23Slukem
8311.126Swiz     cleandir      Perform "make cleandir".
8321.75Slukem
8331.126Swiz     obj           Perform "make obj".
8341.22Slukem
8351.105Swiz     tools         Build and install the host tools from src/tools.  This
8361.126Swiz                   command will first run "make obj" and "make cleandir" in
8371.126Swiz                   the tools subdirectory unless the -o or -u options
8381.104Swiz                   (respectively) are given.
8391.22Slukem
8401.126Swiz     install=idir  Install the contents of DESTDIR to idir, using "make
8411.126Swiz                   installworld".  Note that files that are part of the "etc"
8421.126Swiz                   or "xetc" sets will not be installed, unless overridden by
8431.126Swiz                   the INSTALLSETS environment variable.
8441.35Slukem
8451.105Swiz     kernel=kconf  Build a new kernel.  The kconf argument is the name of a
8461.105Swiz                   configuration file suitable for use by config(1).  If kconf
8471.22Slukem                   does not contain any `/' characters, the configuration file
8481.105Swiz                   is expected to be found in the KERNCONFDIR directory, which
8491.105Swiz                   is typically sys/arch/MACHINE/conf.  The new kernel will be
8501.105Swiz                   built in a subdirectory of KERNOBJDIR, which is typically
8511.105Swiz                   sys/arch/MACHINE/compile or an associated object directory.
8521.70Sdholland
8531.105Swiz                   This command does not imply the tools command; run the
8541.105Swiz                   tools command first unless it is certain that the tools
8551.70Sdholland                   already exist and are up to date.
8561.70Sdholland
8571.126Swiz                   This command will run "make cleandir" on the kernel in
8581.105Swiz                   question first unless the -u option is given.
8591.22Slukem
8601.106Swiz     kernel.gdb=kconf
8611.106Swiz                   Build a new kernel with debug information.  Similar to the
8621.106Swiz                   above kernel=kconf operation, but creates a netbsd.gdb file
8631.106Swiz                   alongside of the kernel netbsd, which contains a full
8641.106Swiz                   symbol table and can be used for debugging (for example
8651.106Swiz                   with a cross-gdb built by MKCROSSGDB).
8661.106Swiz
8671.113Suebayasi     kernels       This command will build all kernels defined in port
8681.113Suebayasi                   specific release build procedure.
8691.111Suebayasi
8701.112Suebayasi                   This command internally calls the kernel=kconf operation
8711.112Suebayasi                   for each found kernel configuration file.
8721.111Suebayasi
8731.105Swiz     modules       This command will build kernel modules and install them
8741.105Swiz                   into DESTDIR.
8751.86Sjnemeth
8761.105Swiz     releasekernel=kconf
8771.70Sdholland                   Install a gzip(1)ed copy of the kernel previously built by
8781.105Swiz                   kernel=kconf into
8791.105Swiz                   RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
8801.126Swiz                   netbsd-kconf.gz, although the "netbsd" prefix is determined
8811.126Swiz                   from the "config" directives in kconf.
8821.24Slukem
8831.126Swiz     sets          Perform "make sets".
8841.31Slukem
8851.126Swiz     sourcesets    Perform "make sourcesets".
8861.22Slukem
8871.126Swiz     syspkgs       Perform "make syspkgs".
8881.54Sapb
8891.126Swiz     iso-image     Perform "make iso-image".
8901.56Sapb
8911.105Swiz     iso-image-source
8921.126Swiz                   Perform "make iso-image-source".
8931.65Sjnemeth
8941.105Swiz     install-image
8951.126Swiz                   Perform "make install-image".
8961.97Stsutsui
8971.126Swiz     live-image    Perform "make live-image".
8981.97Stsutsui
8991.148Slukem     list-arch     Show a list of valid MACHINE and MACHINE_ARCH settings, the
9001.148Slukem                   default MACHINE_ARCH for each MACHINE, and aliases for
9011.109Sapb                   MACHINE/MACHINE_ARCH pairs, and then exits.  The -m or -a
9021.109Sapb                   options (or both) may be used to specify glob patterns that
9031.109Sapb                   will be used to narrow the list of results; for example,
9041.131Sleot                   "build.sh -m 'evb*' -a '*arm*' list-arch" will list all
9051.109Sapb                   known MACHINE/MACHINE_ARCH values in which either MACHINE
9061.109Sapb                   or ALIAS matches the pattern `evb*', and MACHINE_ARCH
9071.109Sapb                   matches the pattern `*arm*'.
9081.109Sapb
9091.105Swiz     The following command line options alter the behaviour of the build.sh
9101.51Swiz     operations described above:
9111.1Stv
9121.109Sapb     -a arch   Set the value of MACHINE_ARCH to arch.  See the -m option for
9131.109Sapb               more information.
9141.9Sthorpej
9151.105Swiz     -B buildid
9161.105Swiz               Set the value of BUILDID to buildid.  This will also append the
9171.126Swiz               build identifier to the name of the "make" wrapper script so
9181.37Slukem               that the resulting name is of the form
9191.126Swiz               "nbmake-MACHINE-BUILDID".
9201.1Stv
9211.105Swiz     -C cdextras
9221.105Swiz               Append cdextras to the CDEXTRA variable, which is a space-
9231.104Swiz               separated list of files or directories that will be added to
9241.126Swiz               the CD-ROM image that may be create by the "iso-image" or
9251.126Swiz               "iso-image-source" operations.  Files will be added to the root
9261.126Swiz               of the CD-ROM image, whereas directories will be copied
9271.87Sapb               recursively.  If relative paths are specified, they will be
9281.87Sapb               converted to absolute paths before being used.  Multiple paths
9291.105Swiz               may be specified via multiple -C options, or via a single
9301.87Sapb               option whose argument contains multiple space-separated paths.
9311.66Sjnemeth
9321.136Suwe     -c compiler
9331.136Suwe               Select the compiler for the toolchain to build NetBSD and for
9341.136Suwe               inclusion in the NetBSD distribution.  Supported choices:
9351.136Suwe
9361.136Suwe                     clang
9371.136Suwe
9381.136Suwe                     gcc [default]
9391.136Suwe
9401.136Suwe               The compiler used to build the toolchain can be different; see
9411.136Suwe               HOST_CC and HOST_CXX.
9421.136Suwe
9431.105Swiz     -D dest   Set the value of DESTDIR to dest.  If a relative path is
9441.104Swiz               specified, it will be converted to an absolute path before
9451.104Swiz               being used.
9461.104Swiz
9471.105Swiz     -E        Set `expert' mode.  This overrides various sanity checks, and
9481.105Swiz               allows: DESTDIR does not have to be set to a non-root path for
9491.105Swiz               builds, and MKUNPRIVED=yes does not have to be set when
9501.104Swiz               building as a non-root user.
9511.23Slukem
9521.105Swiz               Note: It is highly recommended that you know what you are doing
9531.23Slukem               when you use this option.
9541.19Slukem
9551.148Slukem     -h        Show a help message, and exit.
9561.51Swiz
9571.105Swiz     -j njob   Run up to njob make(1) subjobs in parallel; passed through to
9581.74Sapb               make(1).  If you see failures for reasons other than running
9591.105Swiz               out of memory while using build.sh with -j, please save
9601.104Swiz               complete build logs so the failures can be analyzed.
9611.74Sapb
9621.105Swiz               To achieve the fastest builds, -j values between (1 + the
9631.104Swiz               number of CPUs) and (2 * the number of CPUs) are recommended.
9641.104Swiz               Use lower values on machines with limited memory or I/O
9651.104Swiz               bandwidth.
9661.104Swiz
9671.126Swiz     -M obj    Set MAKEOBJDIRPREFIX to obj.  Unsets MAKEOBJDIR.  See "-O obj"
9681.126Swiz               for more information.
9691.104Swiz
9701.105Swiz               For instance, if the source directory is /usr/src, a setting of
9711.126Swiz               "-M /usr/obj" will place build-time files under
9721.105Swiz               /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
9731.105Swiz               /usr/obj/usr/src/usr.bin, and so forth.
9741.88Sapb
9751.73Sapb               If a relative path is specified, it will be converted to an
9761.105Swiz               absolute path before being used.  build.sh imposes the
9771.105Swiz               restriction that the argument to the -M option must not begin
9781.126Swiz               with a "$" (dollar sign) character; otherwise it would be too
9791.104Swiz               difficult to determine whether the value is an absolute or a
9801.104Swiz               relative path.  If the directory does not already exist,
9811.105Swiz               build.sh will create it.
9821.18Slukem
9831.109Sapb     -m mach   Set the value of MACHINE to mach, unless the mach argument is
9841.109Sapb               an alias that refers to a MACHINE/MACHINE_ARCH pair, in which
9851.109Sapb               case both MACHINE and MACHINE_ARCH are set from the alias.
9861.109Sapb               Such aliases are interpreted entirely by build.sh; they are not
9871.109Sapb               used by any other part of the build system.  The MACHINE_ARCH
9881.109Sapb               setting implied by mach will override any value of MACHINE_ARCH
9891.109Sapb               in the process environment, but will not override a value set
9901.109Sapb               by the -a option.  All cross builds require -m, but if unset on
9911.109Sapb               a NetBSD host, the host's value of MACHINE will be detected and
9921.109Sapb               used automatically.
9931.109Sapb
9941.109Sapb               See the list-arch operation for a way to get a list of valid
9951.109Sapb               MACHINE and MACHINE_ARCH settings.
9961.1Stv
9971.105Swiz     -N noiselevel
9981.126Swiz               Set the "noisyness" level of the build, by setting MAKEVERBOSE
9991.126Swiz               to noiselevel.
10001.45Slukem
10011.105Swiz     -n        Show the commands that would be executed by build.sh, but do
10021.126Swiz               not make any changes.  This is similar in concept to "make -n".
10031.1Stv
10041.105Swiz     -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
10051.105Swiz               place the built object files under obj.  Unsets
10061.105Swiz               MAKEOBJDIRPREFIX.
10071.88Sapb
10081.126Swiz               For instance, a setting of "-O /usr/obj" will place build-time
10091.126Swiz               files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and
10101.126Swiz               so forth.
10111.88Sapb
10121.88Sapb               If a relative path is specified, it will be converted to an
10131.105Swiz               absolute path before being used.  build.sh imposes the
10141.105Swiz               restriction that the argument to the -O option must not contain
10151.126Swiz               a "$" (dollar sign) character.  If the directory does not
10161.105Swiz               already exist, build.sh will create it.
10171.73Sapb
10181.105Swiz               In normal use, exactly one of the -M or -O options should be
10191.105Swiz               specified.  If neither -M nor -O is specified, then a default
10201.78Sapb               object directory will be chosen according to rules in
10211.78Sapb               <bsd.obj.mk>.  Relying on this default is not recommended
10221.78Sapb               because it is determined by complex rules that are influenced
10231.78Sapb               by the values of several variables and by the location of the
10241.78Sapb               source directory.
10251.18Slukem
10261.109Sapb               Note that placing the obj directory location outside of the
10271.109Sapb               default source tree hierarchy makes it easier to manually clear
10281.126Swiz               out old files in the event the "make cleandir" operation is
10291.109Sapb               unable to do so.  (See CAVEATS below.)
10301.109Sapb
10311.109Sapb               Note also that use of one of -M or -O is the only means of
10321.109Sapb               building multiple machine architecture userlands from the same
10331.109Sapb               source tree without cleaning between builds (in which case, one
10341.109Sapb               would specify distinct obj locations for each).
10351.109Sapb
10361.126Swiz     -o        Set the value of MKOBJDIRS to "no".  Otherwise, it will be
10371.126Swiz               automatically set to "yes".  This default is opposite to the
10381.105Swiz               behaviour when not using build.sh.
10391.1Stv
10401.148Slukem     -P        Set the value of MKREPRO and MKREPRO_TIMESTAMP to the latest
10411.148Slukem               source CVS timestamp for reproducible builds.
10421.148Slukem
10431.105Swiz     -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
10441.59Sapb               specified, it will be converted to an absolute path before
10451.59Sapb               being used.
10461.18Slukem
10471.105Swiz     -r        Remove the contents of DESTDIR and TOOLDIR before building
10481.1Stv               (provides a clean starting point).  This will skip deleting
10491.105Swiz               DESTDIR if building on a native system to the root directory.
10501.1Stv
10511.105Swiz     -S seed   Change the value of BUILDSEED to seed.  This should rarely be
10521.72Sperry               necessary.
10531.72Sperry
10541.105Swiz     -T tools  Set the value of TOOLDIR to tools.  If a relative path is
10551.104Swiz               specified, it will be converted to an absolute path before
10561.126Swiz               being used.  If set, the bootstrap "make" will only be rebuilt
10571.126Swiz               if the source files for make(1) have changed.
10581.104Swiz
10591.105Swiz     -U        Set MKUNPRIVED=yes.
10601.104Swiz
10611.105Swiz     -u        Set MKUPDATE=yes.
10621.104Swiz
10631.105Swiz     -V var=[value]
10641.105Swiz               Set the environment variable var to an optional value.  This is
10651.105Swiz               propagated to the nbmake wrapper.
10661.105Swiz
10671.105Swiz     -w wrapper
10681.105Swiz               Create the nbmake wrapper script (see below) in a custom
10691.105Swiz               location, specified by wrapper.  This allows, for instance, to
10701.105Swiz               place the wrapper in PATH automatically.  Note that wrapper is
10711.59Sapb               the full name of the file, not just a directory name.  If a
10721.59Sapb               relative path is specified, it will be converted to an absolute
10731.59Sapb               path before being used.
10741.1Stv
10751.105Swiz     -X x11src
10761.105Swiz               Set the value of X11SRCDIR to x11src.  If a relative path is
10771.59Sapb               specified, it will be converted to an absolute path before
10781.59Sapb               being used.
10791.49Slukem
10801.105Swiz     -x        Set MKX11=yes.
10811.49Slukem
10821.105Swiz     -Z var    Unset ("zap") the environment variable var.  This is propagated
10831.105Swiz               to the nbmake wrapper.
10841.40Slukem
10851.148Slukem     -?        Show a help message, and exit.
10861.148Slukem
10871.105Swiz   The "nbmake-MACHINE" wrapper script
10881.105Swiz     If using the build.sh script to build NetBSD, a nbmake-MACHINE script
10891.105Swiz     will be created in TOOLDIR/bin upon the first build to assist in building
10901.1Stv     subtrees on a cross-compile host.
10911.1Stv
10921.105Swiz     nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
10931.126Swiz     the up-to-date version of "nbmake" installed into TOOLDIR/bin with
10941.105Swiz     several key variables pre-set, including MACHINE, MACHINE_ARCH, and
10951.105Swiz     TOOLDIR.  nbmake-MACHINE will also set variables specified with -V, and
10961.105Swiz     unset variables specified with -Z.
10971.40Slukem
10981.105Swiz     This script can be symlinked into a directory listed in PATH, or called
10991.1Stv     with an absolute path.
11001.1Stv
11011.105SwizEXAMPLES
11021.78Sapb     1.   % ./build.sh [options] tools kernel=GENERIC
11031.28Slukem
11041.28Slukem          Build a new toolchain, and use the new toolchain to configure and
11051.28Slukem          build a new GENERIC kernel.
11061.28Slukem
11071.78Sapb     2.   % ./build.sh [options] -U distribution
11081.28Slukem
11091.105Swiz          Using unprivileged mode, build a complete distribution to a DESTDIR
11101.148Slukem          directory that build.sh selects (and will show).
11111.28Slukem
11121.78Sapb     3.   # ./build.sh [options] -U install=/
11131.28Slukem
11141.105Swiz          As root, install to / the distribution that was built by example 2.
11151.105Swiz          Even though this is run as root, -U is required so that the
11161.105Swiz          permissions stored in DESTDIR/METALOG are correctly applied to the
11171.105Swiz          files as they're copied to /.
11181.28Slukem
11191.78Sapb     4.   % ./build.sh [options] -U -u release
11201.28Slukem
11211.105Swiz          Using unprivileged mode, build a complete release to DESTDIR and
11221.148Slukem          RELEASEDIR directories that build.sh selects (and will show).
11231.126Swiz          MKUPDATE=yes (-u) is set to prevent the "make cleandir", so that if
11241.126Swiz          this is run after example 2, it doesn't need to redo that portion of
11251.126Swiz          the release build.
11261.16Slukem
11271.105SwizOBSOLETE VARIABLES
11281.105Swiz     NBUILDJOBS  Use the make(1) option -j instead.
11291.15Slukem
11301.105Swiz     USE_NEW_TOOLCHAIN
11311.15Slukem                 The new toolchain is now the default.  To disable, use
11321.105Swiz                 TOOLCHAIN_MISSING=yes.
11331.10Ssommerfe
11341.105SwizSEE ALSO
11351.150Slukem     make(1), mk.conf(5), hier(7), release(7), etcupdate(8), installboot(8),
11361.150Slukem     mount(8), postinstall(8), sysinst(8), pkgsrc/sysutils/cdrtools
11371.1Stv
11381.105SwizHISTORY
11391.105Swiz     The build.sh based build scheme was introduced for NetBSD 1.6 as
11401.105Swiz     USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
11411.1Stv
11421.109SapbCAVEATS
11431.109Sapb     After significant updates to third-party components in the source tree,
11441.126Swiz     the "make cleandir" operation may be insufficient to clean out old files
11451.126Swiz     in object directories.  Instead, one may have to manually remove the
11461.126Swiz     files.  Consult the UPDATING file for notices concerning this.
11471.109Sapb
11481.149SlukemNetBSD                           May 18, 2023                           NetBSD
1149