Home | History | Annotate | Line # | Download | only in src
BUILDING revision 1.151
      1 BUILDING(8)                 System Manager's Manual                BUILDING(8)
      2 
      3 NAME
      4      BUILDING - Procedure for building NetBSD from source code
      5 
      6 REQUIREMENTS
      7      NetBSD is designed to be buildable on most POSIX-compliant host systems.
      8      The basic build procedure is the same whether compiling natively (on the
      9      same NetBSD architecture) or cross compiling (on another architecture or
     10      OS).
     11 
     12      This source tree contains a special subtree, "tools", which uses the host
     13      system to create a build toolchain for the target architecture.  The host
     14      system must have at least C and C++ compilers in order to create the
     15      toolchain (make is not required); all other tools are created as part of
     16      the NetBSD build process.  (See the Environment variables section below
     17      if you need to override or manually select your compilers.)
     18 
     19 FILES
     20    Source tree layout
     21      BUILDING       This document (in plaintext).  Generated from
     22                     doc/BUILDING.mdoc.
     23 
     24      Makefile       The main Makefile for NetBSD; should only be run for
     25                     native builds with an appropriately up-to-date version of
     26                     NetBSD make(1).  Intended for expert use with knowledge of
     27                     its shortcomings, it has been superseded by the build.sh
     28                     shell script as the recommended means for building NetBSD.
     29 
     30      UPDATING       Special notes for updating from an earlier revision of
     31                     NetBSD.  It is important to read this file before every
     32                     build of an updated source tree.
     33 
     34      build.sh       Bourne-compatible shell script used for building the host
     35                     build tools and the NetBSD system from scratch.  Can be
     36                     used for both native and cross builds, and should be used
     37                     instead of make(1) as it performs additional checks to
     38                     prevent common issues going undetected, such as building
     39                     with an outdated version of make(1).
     40 
     41      crypto/dist/, dist/, gnu/dist/
     42                     Sources imported verbatim from third parties, without
     43                     mangling the existing build structure.  Other source trees
     44                     in bin through usr.sbin use the NetBSD make(1) "reachover"
     45                     Makefile semantics when building these programs for a
     46                     native host.
     47 
     48      distrib/, etc/
     49                     Sources for items used when making a full release
     50                     snapshot, such as files installed in DESTDIR/etc on the
     51                     destination system, boot media, and release notes.
     52 
     53      doc/BUILDING.mdoc
     54                     This document, in -mdoc troff format; the original copy.
     55                     Used to generate BUILDING.
     56 
     57      external, sys/external
     58                     Sources and build infrastructure for components imported
     59                     (mostly) unchanged from upstream maintainers, sorted by
     60                     applicable license.  This is (slowly) replacing the
     61                     crypto/dist, dist, and gnu/dist directories.
     62 
     63      external/mit/xorg/
     64                     "Reachover" build structure for modular Xorg; the source
     65                     is in X11SRCDIR.
     66 
     67      regress/, tests/
     68                     Regression test harness.  Can be cross-compiled, but only
     69                     run natively.  tests/ uses the atf(7) test framework;
     70                     regress/ contains older tests that have not yet been
     71                     migrated to atf(7).
     72 
     73      sys/           NetBSD kernel sources.
     74 
     75      tools/         "Reachover" build structure for the host build tools.
     76                     This has a special method of determining out-of-date
     77                     status.
     78 
     79      tools/compat/README
     80                     Special notes for cross-hosting a NetBSD build on non-
     81                     NetBSD platforms.
     82 
     83      Other directories including bin/ ... usr.sbin/
     84                     Sources to the NetBSD userland (non-kernel) programs.  If
     85                     any of these directories are missing, they will be skipped
     86                     during the build.
     87 
     88    Build tree layout
     89      The NetBSD build tree is described in hier(7), and the release layout is
     90      described in release(7).
     91 
     92 CONFIGURATION
     93    Environment variables
     94      Several environment variables control the behaviour of NetBSD builds.
     95 
     96      HOST_CC          Path name to C compiler used to create the toolchain.
     97 
     98      HOST_CFLAGS      Flags passed to the host C compiler.
     99 
    100      HOST_CXX         Path name to C++ compiler used to create the toolchain.
    101 
    102      HOST_CXXFLAGS    Flags passed to the host C++ compiler.
    103 
    104      HOST_SH          Path name to a shell available on the host system and
    105                       suitable for use during the build.  The NetBSD build
    106                       system requires a modern Bourne-like shell with POSIX-
    107                       compliant features, and also requires support for the
    108                       "local" keyword to declare local variables in shell
    109                       functions (which is a widely-implemented but non-
    110                       standardised feature).
    111 
    112                       Depending on the host system, a suitable shell may be
    113                       /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a
    114                       variant of ksh that supports the "local" keyword, such
    115                       as ksh88, but not ksh93), or /usr/local/bin/bash.
    116 
    117                       Most parts of the build require HOST_SH to be an
    118                       absolute path; however, build.sh allows it to be a
    119                       simple command name, which will be converted to an
    120                       absolute path by searching the PATH.
    121 
    122      INSTALLBOOT_UBOOT_PATHS
    123                       A colon-separated list of search paths used by
    124                       installboot(8) to find U-Boot packages.
    125 
    126      MACHINE          Machine type, e.g., "macppc".
    127 
    128      MACHINE_ARCH     Machine architecture, e.g., "powerpc".
    129 
    130      MAKE             Path name to invoke make(1) as.
    131 
    132      MAKECONF         The name of the make(1) configuration file.  See "make"
    133                       variables and mk.conf(5).
    134 
    135                       Note: Only settable in the process environment.
    136 
    137                       Default: "/etc/mk.conf"
    138 
    139      MAKEFLAGS        Flags to invoke make(1) with.
    140 
    141                       Note: build.sh ignores the value of MAKEFLAGS passed in
    142                       the environment, but allows MAKEFLAGS to be set via the
    143                       -V option.
    144 
    145      MAKEOBJDIR       Directory to use as the .OBJDIR for the current
    146                       directory.  The value is subjected to variable expansion
    147                       by make(1).  Typical usage is to set this variable to a
    148                       value involving the use of `${.CURDIR:S...}' or
    149                       `${.CURDIR:C...}', to derive the value of .OBJDIR from
    150                       the value of .CURDIR.  Used only if MAKEOBJDIRPREFIX is
    151                       not defined.
    152 
    153                       Note: MAKEOBJDIR can be provided only in the environment
    154                       or via the -O flag of build.sh; it cannot usefully be
    155                       set inside a Makefile, including in mk.conf(5) or
    156                       MAKECONF.
    157 
    158      MAKEOBJDIRPREFIX
    159                       Top level directory of the object directory tree.  The
    160                       value is subjected to variable expansion by make(1).
    161                       build.sh will create the ${MAKEOBJDIRPREFIX} directory
    162                       if necessary, but if make(1) is used without build.sh,
    163                       then rules in <bsd.obj.mk> will abort the build if the
    164                       ${MAKEOBJDIRPREFIX} directory does not exist.  If the
    165                       value is defined and valid, then
    166                       ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR
    167                       for the current directory.  The current directory may be
    168                       read only.
    169 
    170                       Note: MAKEOBJDIRPREFIX can be provided only in the
    171                       environment or via the -M flag of build.sh; it cannot
    172                       usefully be set inside a Makefile, including in
    173                       mk.conf(5) or MAKECONF.
    174 
    175      TMPDIR           Top-level directory to store temporary directories used
    176                       by build.sh before paths to other directories such as
    177                       .OBJDIR can be determined.
    178 
    179                       Note: Must support execution of binaries.  I.e., without
    180                       mount(8)'s -o noexec option.
    181 
    182                       Default: "/tmp".
    183 
    184    "make" variables
    185      Several variables control the behavior of NetBSD builds.  Unless
    186      otherwise specified, these variables may be set in either the process
    187      environment or the make(1) configuration file mk.conf(5) specified by
    188      MAKECONF.
    189 
    190      This list is not comprehensive; all supported variables and their
    191      defaults are documented in mk.conf(5).
    192 
    193      BSDOBJDIR        The real path to the object directory tree for the
    194                       NetBSD source tree.
    195 
    196                       Default: "/usr/obj"
    197 
    198      BSDSRCDIR        The real path to the NetBSD source tree, if NETBSDSRCDIR
    199                       isn't defined.
    200 
    201                       Default: "/usr/src"
    202 
    203      BUILDID          Identifier for the build.  If set, this should be a
    204                       short string that is suitable for use as part of a file
    205                       or directory name.  The identifier will be appended to
    206                       object directory names, and can be consulted in the
    207                       make(1) configuration file in order to set additional
    208                       build parameters, such as compiler flags.  It will also
    209                       be used as part of the kernel version string, which can
    210                       be shown by "uname -v".
    211 
    212                       Default: Unset.
    213 
    214      BUILDINFO        Optional multi-line string containing information about
    215                       the build.  This will appear in DESTDIR/etc/release, and
    216                       it will be stored in the buildinfo variable in any
    217                       kernels that are built.  When such kernels are booted,
    218                       the sysctl(7) kern.buildinfo variable will report this
    219                       value.  The string may contain backslash escape
    220                       sequences, such as "\\" (representing a backslash
    221                       character) and "\n" (representing a newline).
    222 
    223                       Default: Unset.
    224 
    225      BUILDSEED        g++(1) uses random numbers when compiling C++ code.
    226                       This variable seeds the g++(1) random number generator
    227                       using -frandom-seed with this value.  By default, it is
    228                       set to "NetBSD-(majorversion)".  Using a fixed value
    229                       causes C++ binaries to be the same when built from the
    230                       same sources, resulting in identical (reproducible)
    231                       builds.  Additional information is available in the
    232                       g++(1) documentation of -frandom-seed.
    233 
    234                       Default: Unset.
    235 
    236      CPUFLAGS         Additional flags to the compiler/assembler to select CPU
    237                       instruction set options, CPU tuning options, etc.
    238 
    239                       Default: Unset.
    240 
    241      DESTDIR          Directory to contain the built NetBSD system.  If set,
    242                       special options are passed to the compilation tools to
    243                       prevent their default use of the host system's
    244                       /usr/include, /usr/lib, and so forth.  This pathname
    245                       must be an absolute path, and should not end with a
    246                       slash (/) character.  (For installation into the
    247                       system's root directory, set DESTDIR to an empty string,
    248                       not to "/").  The directory must reside on a file system
    249                       which supports long file names and hard links.
    250 
    251                       Note: build.sh will provide a default of destdir.MACHINE
    252                       (in the top-level .OBJDIR) unless run in `expert' mode.
    253 
    254                       Default: Empty string if USETOOLS is "yes"; unset
    255                       otherwise.
    256 
    257      EXTERNAL_TOOLCHAIN
    258                       If defined, this variable indicates the root directory
    259                       of an external toolchain which will be used to build the
    260                       tree.  For example, if a platform is a TOOLCHAIN_MISSING
    261                       platform, EXTERNAL_TOOLCHAIN can be used to re-enable
    262                       the cross-compile framework.
    263 
    264                       If EXTERNAL_TOOLCHAIN is defined, act as MKGCC=no, since
    265                       the external version of the compiler may not be able to
    266                       build the library components of the in-tree compiler.
    267 
    268                       This variable should be used in conjunction with an
    269                       appropriate HAVE_GCC or HAVE_LLVM setting to control the
    270                       compiler flags.
    271 
    272                       Note: This variable is not yet used in as many places as
    273                       it should be.  Expect the exact semantics of this
    274                       variable to change in the short term as parts of the
    275                       cross-compile framework continue to be cleaned up.
    276 
    277                       Default: Unset.
    278 
    279      MAKEVERBOSE      Level of verbosity of status messages.  Supported
    280                       values:
    281 
    282                       0   No descriptive messages or commands executed by
    283                           make(1) are shown.
    284 
    285                       1   Brief messages are shown describing what is being
    286                           done, but the actual commands executed by make(1)
    287                           are not shown.
    288 
    289                       2   Descriptive messages are shown as above (prefixed
    290                           with a `#'), and ordinary commands performed by
    291                           make(1) are shown.
    292 
    293                       3   In addition to the above, all commands performed by
    294                           make(1) are shown, even if they would ordinarily
    295                           have been hidden through use of the "@" prefix in
    296                           the relevant makefile.
    297 
    298                       4   In addition to the above, commands executed by
    299                           make(1) are traced through use of the sh(1) "-x"
    300                           flag.
    301 
    302                       Default: 2
    303 
    304      MKCATPAGES       Can be set to "yes" or "no".  Indicates whether
    305                       preformatted plaintext manual pages will be created and
    306                       installed.
    307 
    308                       Forced to "no" if MKMAN=no or MKSHARE=no.
    309 
    310                       Default: "no"
    311 
    312      MKCROSSGDB       Can be set to "yes" or "no".  Create a cross-gdb as a
    313                       host tool.
    314 
    315                       Default: "no"
    316 
    317      MKDEBUG          Can be set to "yes" or "no".  Indicates whether debug
    318                       information should be generated for all userland
    319                       binaries.  The result is collected as an additional
    320                       debug.tgz and xdebug.tgz set and installed in
    321                       DESTDIR/usr/libdata/debug.
    322 
    323                       Forced to "no" if NODEBUG is defined, usually in the
    324                       Makefile before any make(1) .include directives.
    325 
    326                       Default: "no"
    327 
    328      MKDEBUGKERNEL    Can be set to "yes" or "no".  Indicates whether
    329                       debugging symbols will be built for kernels by default;
    330                       pretend as if makeoptions DEBUG="-g" is specified in
    331                       kernel configuration files.  This will also put the
    332                       debug kernel netbsd.gdb in the kernel sets.  See
    333                       options(4) for details.  This is useful if a cross-gdb
    334                       is built as well (see MKCROSSGDB).
    335 
    336                       Default: "no"
    337 
    338      MKDEBUGLIB       Can be set to "yes" or "no".  Indicates whether debug
    339                       libraries (lib*_g.a) will be built and installed.  Debug
    340                       libraries are compiled with "-g -DDEBUG".
    341 
    342                       Forced to "no" if NODEBUGLIB is defined, usually in the
    343                       Makefile before any make(1) .include directives.
    344 
    345                       Default: "no"
    346 
    347      MKDEBUGTOOLS     Can be set to "yes" or "no".  Indicates whether debug
    348                       information (lib*_g.a) will be included in the build
    349                       toolchain.
    350 
    351                       Default: "no"
    352 
    353      MKDOC            Can be set to "yes" or "no".  Indicates whether system
    354                       documentation destined for DESTDIR/usr/share/doc will be
    355                       installed.
    356 
    357                       Forced to "no" if NODOC is defined, usually in the
    358                       Makefile before any make(1) .include directives.
    359 
    360                       Forced to "no" if MKSHARE=no.
    361 
    362                       Default: "yes"
    363 
    364      MKHOSTOBJ        Can be set to "yes" or "no".  If set to "yes", then for
    365                       programs intended to be run on the compile host, the
    366                       name, release, and architecture of the host operating
    367                       system will be suffixed to the name of the object
    368                       directory created by "make obj".  (This allows multiple
    369                       host systems to compile NetBSD for a single target.)  If
    370                       set to "no", then programs built to be run on the
    371                       compile host will use the same object directory names as
    372                       programs built to be run on the target.
    373 
    374                       Default: "no"
    375 
    376      MKHTML           Can be set to "yes" or "no".  Indicates whether the HTML
    377                       manual pages are created and installed.  and installed
    378 
    379                       Forced to "no" if NOHTML is defined, usually in the
    380                       Makefile before any make(1) .include directives.
    381 
    382                       Forced to "no" if MKMAN=no or MKSHARE=no.
    383 
    384                       Default: "yes"
    385 
    386      MKINFO           Can be set to "yes" or "no".  Indicates whether GNU Info
    387                       files, used for the documentation for most of the
    388                       compilation tools, will be built and installed.
    389 
    390                       Forced to "no" if NOINFO is defined, usually in the
    391                       Makefile before any make(1) .include directives.
    392 
    393                       Forced to "no" if MKSHARE=no.
    394 
    395                       Default: "yes"
    396 
    397      MKKDEBUG         Deprecated, use MKDEBUGKERNEL.
    398 
    399      MKKMOD           Can be set to "yes" or "no".  Indicates whether kernel
    400                       modules are built and installed.
    401 
    402                       Default: "no" on or1k; "yes" on other platforms.
    403 
    404      MKLINKLIB        Can be set to "yes" or "no".  Indicates whether all of
    405                       the shared library infrastructure will be built and
    406                       installed.  If "no", prevents: installation of the *.a
    407                       libraries, installation of the *_pic.a libraries on PIC
    408                       systems, building of *.a libraries on PIC systems, or
    409                       installation of .so symlinks on ELF systems.
    410 
    411                       Forced to "no" if NOLINKLIB is defined, usually in the
    412                       Makefile before any make(1) .include directives.
    413 
    414                       If "no", acts as MKLINT=no MKPICINSTALL=no MKPROFILE=no.
    415 
    416                       Default: "yes"
    417 
    418      MKLINT           Can be set to "yes" or "no".  Indicates whether lint(1)
    419                       will be run against portions of the NetBSD source code
    420                       during the build, and whether lint libraries will be
    421                       installed into DESTDIR/usr/libdata/lint.
    422 
    423                       Forced to "no" if NOLINT is defined, usually in the
    424                       Makefile before any make(1) .include directives.
    425 
    426                       Forced to "no" if MKLINKLIB=no.
    427 
    428                       Default: "no"
    429 
    430      MKMAN            Can be set to "yes" or "no".  Indicates whether manual
    431                       pages will be installed.
    432 
    433                       Forced to "no" if NOMAN is defined, usually in the
    434                       Makefile before any make(1) .include directives.
    435 
    436                       Forced to "no" if MKSHARE=no.
    437 
    438                       If "no", acts as MKCATPAGES=no MKHTML=no.
    439 
    440                       Default: "yes"
    441 
    442      MKNLS            Can be set to "yes" or "no".  Indicates whether Native
    443                       Language System (NLS) locale zone files will be built
    444                       and installed.
    445 
    446                       Forced to "no" if NONLS is defined, usually in the
    447                       Makefile before any make(1) .include directives.
    448 
    449                       Forced to "no" if MKSHARE=no.
    450 
    451                       Default: "yes"
    452 
    453      MKOBJ            Can be set to "yes" or "no".  Indicates whether object
    454                       directories will be created when running "make obj".  If
    455                       set to "no", then all built files will be located inside
    456                       the regular source tree.
    457 
    458                       Forced to "no" if NOOBJ is defined, usually in the
    459                       Makefile before any make(1) .include directives.
    460 
    461                       If "no", acts as MKOBJDIRS=no.
    462 
    463                       Note: Setting MKOBJ to "no" is not recommended and may
    464                       cause problems when updating the tree with cvs(1).
    465 
    466                       Default: "yes"
    467 
    468      MKOBJDIRS        Can be set to "yes" or "no".  Indicates whether object
    469                       directories will be created automatically (via a "make
    470                       obj" pass) at the start of a build.
    471 
    472                       Forced to "no" if MKOBJ=no.
    473 
    474                       Default: "no"
    475 
    476      MKPIC            Can be set to "yes" or "no".  Indicates whether shared
    477                       objects and libraries will be created and installed.  If
    478                       "no", the entire built system will be statically linked.
    479 
    480                       Forced to "no" if NOPIC is defined, usually in the
    481                       Makefile before any make(1) .include directives.
    482 
    483                       If "no", acts as MKPICLIB=no.
    484 
    485                       Default: "no" on m68000; "yes" on other platforms.
    486 
    487      MKPICINSTALL     Can be set to "yes" or "no".  Indicates whether the
    488                       ar(1) format libraries (lib*_pic.a), used to generate
    489                       shared libraries, are installed.
    490 
    491                       Forced to "no" if NOPICINSTALL is defined, usually in
    492                       the Makefile before any make(1) .include directives.
    493 
    494                       Forced to "no" if MKLINKLIB=no.
    495 
    496                       Default: "no"
    497 
    498      MKPROFILE        Can be set to "yes" or "no".  Indicates whether profiled
    499                       libraries (lib*_p.a) will be built and installed.
    500 
    501                       Forced to "no" if NOPROFILE is defined, usually in the
    502                       Makefile before any make(1) .include directives.
    503 
    504                       Forced to "no" if MKLINKLIB=no.
    505 
    506                       Default: "no" on or1k, riscv32, and riscv64 (due to
    507                       toolchain problems with profiled code); "yes" on other
    508                       platforms.
    509 
    510      MKREPRO          Can be set to "yes" or "no".  Indicates whether builds
    511                       are to be reproducible.  If "yes", two builds from the
    512                       same source tree will produce the same build results.
    513 
    514                       Used as the default for MKARZERO.
    515 
    516                       This may be set to "yes" by giving build.sh the -P
    517                       option.
    518 
    519                       Default: "no" Can be set to "yes" or "no".
    520 
    521      MKREPRO_TIMESTAMP
    522                       Unix timestamp.  When MKREPRO is set, the timestamp of
    523                       all files in the sets will be set to this value.
    524 
    525                       This may be set automatically to the latest source tree
    526                       timestamp using cvslatest(1) by giving build.sh the -P
    527                       option.
    528 
    529                       Default: Unset.
    530 
    531      MKSHARE          Can be set to "yes" or "no".  Indicates whether files
    532                       destined to reside in DESTDIR/usr/share will be built
    533                       and installed.
    534 
    535                       Forced to "no" if NOSHARE is defined, usually in the
    536                       Makefile before any make(1) .include directives.
    537 
    538                       If "no", acts as MKCATPAGES=no MKDOC=no MKINFO=no
    539                       MKHTML=no MKMAN=no MKNLS=no.
    540 
    541                       Default: "yes"
    542 
    543      MKSTRIPIDENT     Can be set to "yes" or "no".  Indicates whether RCS IDs,
    544                       for use with ident(1), should be stripped from program
    545                       binaries and shared libraries.
    546 
    547                       Default: "no"
    548 
    549      MKSTRIPSYM       Can be set to "yes" or "no".  Indicates whether all
    550                       local symbols should be stripped from shared libraries.
    551                       If "yes", strip all local symbols from shared libraries;
    552                       the affect is equivalent to the -x option of ld(1).  If
    553                       "no", strip only temporary local symbols; the affect is
    554                       equivalent to the -X option of ld(1).  Keeping non-
    555                       temporary local symbols such as static function names is
    556                       useful on using DTrace for userland libraries and
    557                       getting a backtrace from a rump kernel loading shared
    558                       libraries.
    559 
    560                       Default: "yes"
    561 
    562      MKUNPRIVED       Can be set to "yes" or "no".  Indicates whether an
    563                       unprivileged install will occur.  The user, group,
    564                       permissions, and file flags, will not be set on the
    565                       installed items; instead the information will be
    566                       appended to a file called METALOG in DESTDIR.  The
    567                       contents of METALOG are used during the generation of
    568                       the distribution tar files to ensure that the
    569                       appropriate file ownership is stored.
    570 
    571                       Default: "no"
    572 
    573      MKUPDATE         Can be set to "yes" or "no".  Indicates whether all
    574                       install operations intended to write to DESTDIR will
    575                       compare file timestamps before installing, and skip the
    576                       install phase if the destination files are up-to-date.
    577 
    578                       Note: This also has implications on full builds (see
    579                       next subsection).
    580 
    581                       Default: "no"
    582 
    583      MKX11            Can be set to "yes" or "no".  Indicates whether X11 is
    584                       built and installed from X11SRCDIR.
    585 
    586                       Default: "no"
    587 
    588      NETBSDSRCDIR     The path to the top level of the NetBSD sources.
    589 
    590                       Default: Top level of the NetBSD source tree (as
    591                       determined by the presence of build.sh and tools/) if
    592                       make(1) is run from within that tree; otherwise
    593                       BSDSRCDIR will be used.
    594 
    595      TOOLCHAIN_MISSING
    596                       Can be set to "yes" or "no".  If not "no", this
    597                       indicates that the platform "MACHINE_ARCH" being built
    598                       does not have a working in-tree toolchain.
    599 
    600                       If not "no", acts as MKBINUTILS=no MKGCC=no MKGDB=no.
    601 
    602                       Default: "no"
    603 
    604      TOOLDIR          Directory to hold the host tools, once built.  If
    605                       specified, must be an absolute path.  This directory
    606                       should be unique to a given host system and NetBSD
    607                       source tree.  (However, multiple targets may share the
    608                       same TOOLDIR; the target-dependent files have unique
    609                       names.)  If unset, a default based on the uname(1)
    610                       information of the host platform will be created in the
    611                       .OBJDIR of src.
    612 
    613                       Default: Unset.
    614 
    615      USETOOLS         Can be set to "yes" or "no".  Indicates whether the
    616                       tools specified by TOOLDIR should be used as part of a
    617                       build in progress.  Must be set to "yes" if cross-
    618                       compiling.
    619 
    620                       yes    Use the tools from TOOLDIR.
    621 
    622                       no     Do not use the tools from TOOLDIR, but refuse to
    623                              build native compilation tool components that are
    624                              version-specific for that tool.
    625 
    626                       never  Do not use the tools from TOOLDIR, even when
    627                              building native tool components.  This is similar
    628                              to the traditional NetBSD build method, but does
    629                              not verify that the compilation tools in use are
    630                              up-to-date enough in order to build the tree
    631                              successfully.  This may cause build or runtime
    632                              problems when building the whole NetBSD source
    633                              tree.
    634 
    635                       Default: "no" when using <bsd.*.mk> outside the NetBSD
    636                       source tree (detected automatically) or if
    637                       TOOLCHAIN_MISSING=yes; "yes" otherwise.
    638 
    639      X11SRCDIR        Directory containing the modular Xorg source.  If
    640                       specified, must be an absolute path.  The main modular
    641                       Xorg source is found in X11SRCDIR/external/mit.
    642 
    643                       Default: NETBSDSRCDIR/../xsrc, if that exists; otherwise
    644                       /usr/xsrc.
    645 
    646    "make" variables for full builds
    647      These variables only affect the top level "Makefile" and do not affect
    648      manually building subtrees of the NetBSD source code.
    649 
    650      INSTALLBOOT_BOARDS
    651                       A list of boards to create bootable images for.  If
    652                       corresponding U-Boot packages are installed, bootable
    653                       images are created as part of a release.  See the
    654                       -o board=name option of installboot(8).
    655 
    656      INSTALLWORLDDIR  Location for the "make installworld" target to install
    657                       to.  If specified, must be an absolute path.
    658 
    659                       Default: "/"
    660 
    661      MKOBJDIRS        Can be set to "yes" or "no".  Indicates whether object
    662                       directories will be created automatically (via a "make
    663                       obj" pass) at the start of a build.
    664 
    665                       Default: "no"
    666 
    667                       If using build.sh, the default is "yes".  This may be
    668                       set back to "no" by giving build.sh the -o option.
    669 
    670      MKUPDATE         Can be set to "yes" or "no".  If set, then in addition
    671                       to the effects described for MKUPDATE=yes above, this
    672                       implies the effects of NOCLEANDIR (i.e., "make cleandir"
    673                       is avoided).
    674 
    675                       Default: "no"
    676 
    677                       If using build.sh, this may be set by giving the -u
    678                       option.
    679 
    680      NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead.  See
    681                       below.
    682 
    683                       Default: Unset.
    684 
    685      NOCLEANDIR       If set, avoids the "make cleandir" phase of a full
    686                       build.  This has the effect of allowing only changed
    687                       files in a source tree to be recompiled.  This can speed
    688                       up builds when updating only a few files in the tree.
    689 
    690                       Default: Unset.
    691 
    692                       See also MKUPDATE.
    693 
    694      NODISTRIBDIRS    If set, avoids the "make distrib-dirs" phase of a full
    695                       build.  This skips running mtree(8) on DESTDIR, useful
    696                       on systems where building as an unprivileged user, or
    697                       where it is known that the system-wide mtree files have
    698                       not changed.
    699 
    700                       Default: Unset.
    701 
    702      NOINCLUDES       If set, avoids the "make includes" phase of a full
    703                       build.  This has the effect of preventing make(1) from
    704                       thinking that some programs are out-of-date simply
    705                       because the system include files have changed.  However,
    706                       this option should not be used when updating the entire
    707                       NetBSD source tree arbitrarily; it is suggested to use
    708                       MKUPDATE=yes instead in that case.
    709 
    710                       Default: Unset.
    711 
    712      RELEASEDIR       If set, specifies the directory to which a release(7)
    713                       layout will be written at the end of a "make release".
    714                       If specified, must be an absolute path.
    715 
    716                       Note: build.sh will provide a default of releasedir (in
    717                       the top-level .OBJDIR) unless run in `expert' mode.
    718 
    719                       Default: Unset.
    720 
    721 BUILDING
    722    "make" command line options
    723      This is not a summary of all the options available to make(1); only the
    724      options used most frequently with NetBSD builds are listed here.
    725 
    726      -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
    727                 use .WAIT or have explicit dependencies as necessary to
    728                 enforce build ordering.
    729 
    730      -m dir     Specify the default directory for searching for system
    731                 Makefile segments, mainly the <bsd.*.mk> files.  When building
    732                 any full NetBSD source tree, this should be set to the
    733                 "share/mk" directory in the source tree.  This is set
    734                 automatically when building from the top level, or when using
    735                 build.sh.
    736 
    737      -n         Show the commands that would have been executed, but do not
    738                 actually execute them.  This will still cause recursion to
    739                 take place.
    740 
    741      -V var     Show make(1)'s idea of the value of var.  Does not build any
    742                 targets.
    743 
    744      var=value  Set the variable var to value, overriding any setting
    745                 specified by the process environment, the MAKECONF
    746                 configuration file, or the system Makefile segments.
    747 
    748    "make" targets
    749      These default targets may be built by running make(1) in any subtree of
    750      the NetBSD source code.  It is recommended that none of these be used
    751      from the top level Makefile; as a specific exception, "make obj" and
    752      "make cleandir" are useful in that context.
    753 
    754      all        Build programs, libraries, and preformatted documentation.
    755 
    756      clean      Remove program and library object code files.
    757 
    758      cleandir   Same as clean, but also remove preformatted documentation,
    759                 dependency files generated by "make depend", and any other
    760                 files known to be created at build time.
    761 
    762      depend     Create dependency files (.depend) containing more detailed
    763                 information about the dependencies of source code on header
    764                 files.  Allows programs to be recompiled automatically when a
    765                 dependency changes.
    766 
    767      dependall  Does a "make depend" immediately followed by a "make all".
    768                 This improves cache locality of the build since both passes
    769                 read the source files in their entirety.
    770 
    771      distclean  Synonym for cleandir.
    772 
    773      includes   Build and install system header files.  Typically needed
    774                 before any system libraries or programs can be built.
    775 
    776      install    Install programs, libraries, and documentation into DESTDIR.
    777                 Few files will be installed to DESTDIR/dev, DESTDIR/etc,
    778                 DESTDIR/root or DESTDIR/var in order to prevent user supplied
    779                 configuration data from being overwritten.
    780 
    781      lint       Run lint(1) against the C source code, where appropriate, and
    782                 generate system-installed lint libraries.
    783 
    784      obj        Create object directories to be used for built files, instead
    785                 of building directly in the source tree.
    786 
    787      tags       Create ctags(1) searchable function lists usable by the ex(1)
    788                 and vi(1) text editors.
    789 
    790    "make" targets for the top level
    791      Additional make(1) targets are usable specifically from the top source
    792      level to facilitate building the entire NetBSD source tree.
    793 
    794      build         Build the entire NetBSD system (except the kernel).  This
    795                    orders portions of the source tree such that prerequisites
    796                    will be built in the proper order.
    797 
    798      distribution  Do a "make build", and then install a full distribution
    799                    (which does not include a kernel) into DESTDIR, including
    800                    files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
    801                    DESTDIR/var.
    802 
    803      buildworld    As per "make distribution", except that it ensures that
    804                    DESTDIR is not the root directory.
    805 
    806      installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR,
    807                    which defaults to the root directory.  Ensures that
    808                    INSTALLWORLDDIR is not the root directory if cross
    809                    compiling.
    810 
    811                    The INSTALLSETS environment variable may be set to a space-
    812                    separated list of distribution sets to be installed.  By
    813                    default, all sets except "etc" and "xetc" are installed, so
    814                    most files in INSTALLWORLDDIR/etc will not be installed or
    815                    modified.
    816 
    817                    Note: Before performing this operation with
    818                    INSTALLWORLDDIR=/, it is highly recommended that you
    819                    upgrade your kernel and reboot.  After performing this
    820                    operation, it is recommended that you use etcupdate(8) to
    821                    update files in INSTALLWORLDDIR/etc, and postinstall(8) to
    822                    check for or fix inconsistencies.
    823 
    824      sets          Create distribution sets from DESTDIR into
    825                    RELEASEDIR/RELEASEMACHINEDIR/binary/sets.  Should be run
    826                    after "make distribution", as "make build" alone does not
    827                    install all of the required files.
    828 
    829      sourcesets    Create source sets of the source tree into
    830                    RELEASEDIR/source/sets.
    831 
    832      syspkgs       Create syspkgs from DESTDIR into
    833                    RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.  Should be run
    834                    after "make distribution", as "make build" alone does not
    835                    install all of the required files.
    836 
    837      release       Do a "make distribution", build kernels, distribution
    838                    media, and install sets (this as per "make sets"), and then
    839                    package the system into a standard release layout as
    840                    described by release(7).  This requires that RELEASEDIR be
    841                    set (see above).
    842 
    843      iso-image     Create a NetBSD installation CD-ROM image in the
    844                    RELEASEDIR/images directory.  The CD-ROM file system will
    845                    have a layout as described in release(7).
    846 
    847                    For most machine types, the CD-ROM will be bootable, and
    848                    will automatically run the sysinst(8) menu-based
    849                    installation program, which can be used to install or
    850                    upgrade a NetBSD system.  Bootable CD-ROMs also contain
    851                    tools that may be useful in repairing a damaged NetBSD
    852                    installation.
    853 
    854                    Before "make iso-image" is attempted, RELEASEDIR must be
    855                    populated by "make release" or equivalent.
    856 
    857                    Note: Other, smaller, CD-ROM images may be created in the
    858                    RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom directory
    859                    by "make release".  These smaller images usually contain
    860                    the same tools as the larger images in RELEASEDIR/images,
    861                    but do not contain additional content such as the
    862                    distribution sets.
    863 
    864                    Note: The mac68k port still uses an older method of
    865                    creating CD-ROM images.  This requires the mkisofs(1)
    866                    utility, which is not part of NetBSD, but which can be
    867                    installed from pkgsrc/sysutils/cdrtools.
    868 
    869      iso-image-source
    870                    Create a NetBSD installation CD-ROM image in the
    871                    RELEASEDIR/images directory.  The CD-ROM file system will
    872                    have a layout as described in release(7).  It will have top
    873                    level directories for the machine type and source.
    874 
    875                    For most machine types, the CD-ROM will be bootable, and
    876                    will automatically run the sysinst(8) menu-based
    877                    installation program, which can be used to install or
    878                    upgrade a NetBSD system.  Bootable CD-ROMs also contain
    879                    tools that may be useful in repairing a damaged NetBSD
    880                    installation.
    881 
    882                    Before "make iso-image-source" is attempted, RELEASEDIR
    883                    must be populated by "make sourcesets release" or
    884                    equivalent.
    885 
    886                    Note: Other, smaller, CD-ROM images may be created in the
    887                    RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom directory
    888                    by "make release".  These smaller images usually contain
    889                    the same tools as the larger images in RELEASEDIR/images,
    890                    but do not contain additional content such as the
    891                    distribution sets.
    892 
    893                    Note: The mac68k port still uses an older method of
    894                    creating CD-ROM images.  This requires the mkisofs(1)
    895                    utility, which is not part of NetBSD, but which can be
    896                    installed from pkgsrc/sysutils/cdrtools.
    897 
    898      install-image
    899                    Create a bootable NetBSD installation disk image in the
    900                    RELEASEDIR/images directory.  The installation disk image
    901                    is suitable for copying to bootable USB flash memory
    902                    sticks, etc., for machines which are able to boot from such
    903                    devices.  The file system in the bootable disk image will
    904                    have a layout as described in release(7).
    905 
    906                    The installation image is bootable, and will automatically
    907                    run the sysinst(8) menu-based installation program, which
    908                    can be used to install or upgrade a NetBSD system.  The
    909                    image also contains tools that may be useful in repairing a
    910                    damaged NetBSD installation.
    911 
    912                    Before "make install-image" is attempted, RELEASEDIR must
    913                    be populated by "make release" or equivalent.  The build
    914                    must have been performed with MKUNPRIVED=yes because "make
    915                    install-image" relies on information in DESTDIR/METALOG.
    916 
    917      live-image    Create NetBSD live images in the RELEASEDIR/images
    918                    directory.  The live image contains all necessary files to
    919                    boot NetBSD up to multi-user mode, including all files
    920                    which should be extracted during installation, NetBSD
    921                    disklabel, bootloaders, etc.
    922 
    923                    The live image is suitable for use as a disk image in
    924                    virtual machine environments such as QEMU, and also useful
    925                    to boot NetBSD from a USB flash memory stick on a real
    926                    machine, without the need for installation.
    927 
    928                    Before "make live-image" is attempted, RELEASEDIR must be
    929                    populated by "make release" or equivalent.  The build must
    930                    have been performed with MKUNPRIVED=yes because "make
    931                    install-image" relies on information in DESTDIR/METALOG.
    932 
    933      regression-tests
    934                    Can only be run after building the regression tests in the
    935                    directory "regress".  Runs those compiled regression tests
    936                    on the local host.
    937 
    938                    Note: Most tests are now managed instead using atf(7); this
    939                    target should probably run those as well but currently does
    940                    not.
    941 
    942    The "build.sh" script
    943      This script file is a shell script designed to build the entire NetBSD
    944      system on any host with a suitable modern shell and some common
    945      utilities.  The required shell features are described under the HOST_SH
    946      variable.
    947 
    948      If a host system's default shell does support the required features, then
    949      we suggest that you explicitly specify a suitable shell using a command
    950      like
    951 
    952            /path/to/suitable/shell build.sh [options]
    953 
    954      The above command will usually enable build.sh to automatically set
    955      HOST_SH=/path/to/suitable/shell, but if that fails, then the following
    956      set of commands may be used instead:
    957 
    958            HOST_SH=/path/to/suitable/shell
    959            export HOST_SH
    960            ${HOST_SH} build.sh [options]
    961 
    962      If build.sh detects that it is being executed under an unsuitable shell,
    963      it attempts to exec a suitable shell instead, or shows an error message.
    964      If HOST_SH is not set explicitly, then build.sh sets a default using
    965      heuristics dependent on the host platform, or from the shell under which
    966      build.sh is executed (if that can be determined), or using the first copy
    967      of sh found in PATH.
    968 
    969      All cross-compile builds, and most native builds, of the entire system
    970      should make use of build.sh rather than just running "make".  This way,
    971      the make(1) program will be bootstrapped properly, in case the host
    972      system has an older or incompatible "make" program.
    973 
    974      When compiling the entire system via build.sh, many make(1) variables are
    975      set for you in order to help encapsulate the build process.  In the list
    976      of options below, variables that are automatically set by build.sh are
    977      noted where applicable.
    978 
    979      The following operations are supported by build.sh:
    980 
    981      build         Build the system as per "make build".  Before the main part
    982                    of the build commences, this command runs the obj operation
    983                    (unless the -o option is given), "make cleandir" (unless
    984                    the -u option is given), and the tools operation.
    985 
    986      distribution  Build a full distribution as per "make distribution".  This
    987                    command first runs the build operation.
    988 
    989      release       Build a full release as per "make release".  This command
    990                    first runs the distribution operation.
    991 
    992      help          Show a help message, and exit.
    993 
    994      makewrapper   Create the nbmake-MACHINE wrapper.  This operation is
    995                    automatically performed for any of the other operations.
    996 
    997      cleandir      Perform "make cleandir".
    998 
    999      obj           Perform "make obj".
   1000 
   1001      tools         Build and install the host tools from src/tools.  This
   1002                    command will first run "make obj" and "make cleandir" in
   1003                    the tools subdirectory unless the -o or -u options
   1004                    (respectively) are given.
   1005 
   1006      install=idir  Install the contents of DESTDIR to idir, using "make
   1007                    installworld".
   1008 
   1009                    Note: Files that are part of the "etc" or "xetc" sets will
   1010                    not be installed, unless overridden by the INSTALLSETS
   1011                    environment variable.
   1012 
   1013      kernel=kconf  Build a new kernel.  The kconf argument is the name of a
   1014                    configuration file suitable for use by config(1).  If kconf
   1015                    does not contain any `/' characters, the configuration file
   1016                    is expected to be found in the KERNCONFDIR directory, which
   1017                    is typically sys/arch/MACHINE/conf.  The new kernel will be
   1018                    built in a subdirectory of KERNOBJDIR, which is typically
   1019                    sys/arch/MACHINE/compile or an associated object directory.
   1020 
   1021                    This command does not imply the tools command; run the
   1022                    tools command first unless it is certain that the tools
   1023                    already exist and are up to date.
   1024 
   1025                    This command will run "make cleandir" on the kernel in
   1026                    question first unless the -u option is given.
   1027 
   1028      kernel.gdb=kconf
   1029                    Build a new kernel with debug information.  Similar to the
   1030                    above kernel=kconf operation, but creates a netbsd.gdb file
   1031                    alongside of the kernel netbsd, which contains a full
   1032                    symbol table and can be used for debugging (for example
   1033                    with a cross-gdb built by MKCROSSGDB).
   1034 
   1035      kernels       This command will build all kernels defined in port
   1036                    specific release build procedure.
   1037 
   1038                    This command internally calls the kernel=kconf operation
   1039                    for each found kernel configuration file.
   1040 
   1041      modules       This command will build kernel modules and install them
   1042                    into DESTDIR.
   1043 
   1044      releasekernel=kconf
   1045                    Install a gzip(1)ed copy of the kernel previously built by
   1046                    kernel=kconf into
   1047                    RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
   1048                    netbsd-kconf.gz, although the "netbsd" prefix is determined
   1049                    from the "config" directives in kconf.
   1050 
   1051      sets          Perform "make sets".
   1052 
   1053      sourcesets    Perform "make sourcesets".
   1054 
   1055      syspkgs       Perform "make syspkgs".
   1056 
   1057      iso-image     Perform "make iso-image".
   1058 
   1059      iso-image-source
   1060                    Perform "make iso-image-source".
   1061 
   1062      install-image
   1063                    Perform "make install-image".
   1064 
   1065      live-image    Perform "make live-image".
   1066 
   1067      list-arch     Show a list of valid MACHINE and MACHINE_ARCH settings, the
   1068                    default MACHINE_ARCH for each MACHINE, and aliases for
   1069                    MACHINE/MACHINE_ARCH pairs, and then exits.  The -m or -a
   1070                    options (or both) may be used to specify glob patterns that
   1071                    will be used to narrow the list of results; for example,
   1072                    "build.sh -m 'evb*' -a '*arm*' list-arch" will list all
   1073                    known MACHINE/MACHINE_ARCH values in which either MACHINE
   1074                    or ALIAS matches the pattern `evb*', and MACHINE_ARCH
   1075                    matches the pattern `*arm*'.
   1076 
   1077      The following command line options alter the behaviour of the build.sh
   1078      operations described above:
   1079 
   1080      -a arch   Set the value of MACHINE_ARCH to arch.  See the -m option for
   1081                more information.
   1082 
   1083      -B buildid
   1084                Set the value of BUILDID to buildid.  This will also append the
   1085                build identifier to the name of the "make" wrapper script so
   1086                that the resulting name is of the form
   1087                "nbmake-MACHINE-BUILDID".
   1088 
   1089      -C cdextras
   1090                Append cdextras to the CDEXTRA variable, which is a space-
   1091                separated list of files or directories that will be added to
   1092                the CD-ROM image that may be create by the "iso-image" or
   1093                "iso-image-source" operations.  Files will be added to the root
   1094                of the CD-ROM image, whereas directories will be copied
   1095                recursively.  If relative paths are specified, they will be
   1096                converted to absolute paths before being used.  Multiple paths
   1097                may be specified via multiple -C options, or via a single
   1098                option whose argument contains multiple space-separated paths.
   1099 
   1100      -c compiler
   1101                Select the compiler for the toolchain to build NetBSD and for
   1102                inclusion in the NetBSD distribution.  Supported choices:
   1103 
   1104                      clang
   1105 
   1106                      gcc [default]
   1107 
   1108                The compiler used to build the toolchain can be different; see
   1109                HOST_CC and HOST_CXX.
   1110 
   1111      -D dest   Set the value of DESTDIR to dest.  If a relative path is
   1112                specified, it will be converted to an absolute path before
   1113                being used.
   1114 
   1115      -E        Set `expert' mode.  This overrides various sanity checks, and
   1116                allows: DESTDIR does not have to be set to a non-root path for
   1117                builds, and MKUNPRIVED=yes does not have to be set when
   1118                building as a non-root user.
   1119 
   1120                Note: It is highly recommended that you know what you are doing
   1121                when you use this option.
   1122 
   1123      -h        Show a help message, and exit.
   1124 
   1125      -j njob   Run up to njob make(1) subjobs in parallel; passed through to
   1126                make(1).  If you see failures for reasons other than running
   1127                out of memory while using build.sh with -j, please save
   1128                complete build logs so the failures can be analyzed.
   1129 
   1130                To achieve the fastest builds, -j values between (1 + the
   1131                number of CPUs) and (2 * the number of CPUs) are recommended.
   1132                Use lower values on machines with limited memory or I/O
   1133                bandwidth.
   1134 
   1135      -M obj    Set MAKEOBJDIRPREFIX to obj.  Unsets MAKEOBJDIR.  See "-O obj"
   1136                for more information.
   1137 
   1138                For instance, if the source directory is /usr/src, a setting of
   1139                "-M /usr/obj" will place build-time files under
   1140                /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
   1141                /usr/obj/usr/src/usr.bin, and so forth.
   1142 
   1143                If a relative path is specified, it will be converted to an
   1144                absolute path before being used.  build.sh imposes the
   1145                restriction that the argument to the -M option must not begin
   1146                with a "$" (dollar sign) character; otherwise it would be too
   1147                difficult to determine whether the value is an absolute or a
   1148                relative path.  If the directory does not already exist,
   1149                build.sh will create it.
   1150 
   1151      -m mach   Set the value of MACHINE to mach, unless the mach argument is
   1152                an alias that refers to a MACHINE/MACHINE_ARCH pair, in which
   1153                case both MACHINE and MACHINE_ARCH are set from the alias.
   1154                Such aliases are interpreted entirely by build.sh; they are not
   1155                used by any other part of the build system.  The MACHINE_ARCH
   1156                setting implied by mach will override any value of MACHINE_ARCH
   1157                in the process environment, but will not override a value set
   1158                by the -a option.  All cross builds require -m, but if unset on
   1159                a NetBSD host, the host's value of MACHINE will be detected and
   1160                used automatically.
   1161 
   1162                See the list-arch operation for a way to get a list of valid
   1163                MACHINE and MACHINE_ARCH settings.
   1164 
   1165      -N noiselevel
   1166                Set the "noisyness" level of the build, by setting MAKEVERBOSE
   1167                to noiselevel.
   1168 
   1169      -n        Show the commands that would be executed by build.sh, but do
   1170                not make any changes.  This is similar in concept to "make -n".
   1171 
   1172      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
   1173                place the built object files under obj.  Unsets
   1174                MAKEOBJDIRPREFIX.
   1175 
   1176                For instance, a setting of "-O /usr/obj" will place build-time
   1177                files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and
   1178                so forth.
   1179 
   1180                If a relative path is specified, it will be converted to an
   1181                absolute path before being used.  build.sh imposes the
   1182                restriction that the argument to the -O option must not contain
   1183                a "$" (dollar sign) character.  If the directory does not
   1184                already exist, build.sh will create it.
   1185 
   1186                In normal use, exactly one of the -M or -O options should be
   1187                specified.  If neither -M nor -O is specified, then a default
   1188                object directory will be chosen according to rules in
   1189                <bsd.obj.mk>.  Relying on this default is not recommended
   1190                because it is determined by complex rules that are influenced
   1191                by the values of several variables and by the location of the
   1192                source directory.
   1193 
   1194                Note: Placing the obj directory location outside of the default
   1195                source tree hierarchy makes it easier to manually clear out old
   1196                files in the event the "make cleandir" operation is unable to
   1197                do so.  (See CAVEATS below.)
   1198 
   1199                Note: The use of one of -M or -O is the only means of building
   1200                multiple machine architecture userlands from the same source
   1201                tree without cleaning between builds (in which case, one would
   1202                specify distinct obj locations for each).
   1203 
   1204      -o        Set the value of MKOBJDIRS to "no".  Otherwise, it will be
   1205                automatically set to "yes".  This default is opposite to the
   1206                behaviour when not using build.sh.
   1207 
   1208      -P        Set the value of MKREPRO and MKREPRO_TIMESTAMP to the latest
   1209                source CVS timestamp for reproducible builds.
   1210 
   1211      -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
   1212                specified, it will be converted to an absolute path before
   1213                being used.
   1214 
   1215      -r        Remove the contents of DESTDIR and TOOLDIR before building
   1216                (provides a clean starting point).  This will skip deleting
   1217                DESTDIR if building on a native system to the root directory.
   1218 
   1219      -S seed   Change the value of BUILDSEED to seed.  This should rarely be
   1220                necessary.
   1221 
   1222      -T tools  Set the value of TOOLDIR to tools.  If a relative path is
   1223                specified, it will be converted to an absolute path before
   1224                being used.  If set, the bootstrap "make" will only be rebuilt
   1225                if the source files for make(1) have changed.
   1226 
   1227      -U        Set MKUNPRIVED=yes.
   1228 
   1229      -u        Set MKUPDATE=yes.
   1230 
   1231      -V var=[value]
   1232                Set the environment variable var to an optional value.  This is
   1233                propagated to the nbmake wrapper.
   1234 
   1235      -w wrapper
   1236                Create the nbmake wrapper script (see below) in a custom
   1237                location, specified by wrapper.  This allows, for instance, to
   1238                place the wrapper in PATH automatically.
   1239 
   1240                Note: wrapper is the full name of the file, not just a
   1241                directory name.  If a relative path is specified, it will be
   1242                converted to an absolute path before being used.
   1243 
   1244      -X x11src
   1245                Set the value of X11SRCDIR to x11src.  If a relative path is
   1246                specified, it will be converted to an absolute path before
   1247                being used.
   1248 
   1249      -x        Set MKX11=yes.
   1250 
   1251      -Z var    Unset ("zap") the environment variable var.  This is propagated
   1252                to the nbmake wrapper.
   1253 
   1254      -?        Show a help message, and exit.
   1255 
   1256    The "nbmake-MACHINE" wrapper script
   1257      If using the build.sh script to build NetBSD, a nbmake-MACHINE script
   1258      will be created in TOOLDIR/bin upon the first build to assist in building
   1259      subtrees on a cross-compile host.
   1260 
   1261      nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
   1262      the up-to-date version of "nbmake" installed into TOOLDIR/bin with
   1263      several key variables pre-set, including MACHINE, MACHINE_ARCH, and
   1264      TOOLDIR.  nbmake-MACHINE will also set variables specified with -V, and
   1265      unset variables specified with -Z.
   1266 
   1267      This script can be symlinked into a directory listed in PATH, or called
   1268      with an absolute path.
   1269 
   1270 EXAMPLES
   1271      1.   % ./build.sh [OPTIONS] tools kernel=GENERIC
   1272 
   1273           Build a new toolchain, and use the new toolchain to configure and
   1274           build a new GENERIC kernel.
   1275 
   1276      2.   % ./build.sh [OPTIONS] -U distribution
   1277 
   1278           Using unprivileged mode, build a complete distribution to a DESTDIR
   1279           directory that build.sh selects (and will show).
   1280 
   1281      3.   # ./build.sh [OPTIONS] -U install=/
   1282 
   1283           As root, install to / the distribution that was built by example 2.
   1284           Even though this is run as root, -U is required so that the
   1285           permissions stored in DESTDIR/METALOG are correctly applied to the
   1286           files as they're copied to /.
   1287 
   1288      4.   % ./build.sh [OPTIONS] -U -u release
   1289 
   1290           Using unprivileged mode, build a complete release to DESTDIR and
   1291           RELEASEDIR directories that build.sh selects (and will show).
   1292           MKUPDATE=yes (-u) is set to prevent the "make cleandir", so that if
   1293           this is run after example 2, it doesn't need to redo that portion of
   1294           the release build.
   1295 
   1296 OBSOLETE VARIABLES
   1297      NBUILDJOBS  Use the make(1) option -j instead.
   1298 
   1299      USE_NEW_TOOLCHAIN
   1300                  The new toolchain is now the default.  To disable, use
   1301                  TOOLCHAIN_MISSING=yes.
   1302 
   1303 SEE ALSO
   1304      ar(1), config(1), ctags(1), cvs(1), cvslatest(1), ex(1), g++(1), gzip(1),
   1305      ident(1), ld(1), lint(1), make(1), mkisofs(1), sh(1), uname(1), vi(1),
   1306      options(4), mk.conf(5), atf(7), hier(7), release(7), sysctl(7),
   1307      etcupdate(8), installboot(8), mount(8), mtree(8), postinstall(8),
   1308      sysinst(8), pkgsrc/sysutils/cdrtools
   1309 
   1310 HISTORY
   1311      The build.sh based build scheme was introduced for NetBSD 1.6 as
   1312      USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
   1313 
   1314 CAVEATS
   1315      After significant updates to third-party components in the source tree,
   1316      the "make cleandir" operation may be insufficient to clean out old files
   1317      in object directories.  Instead, one may have to manually remove the
   1318      files.  Consult the UPDATING file for notices concerning this.
   1319 
   1320 NetBSD                           June 4, 2023                           NetBSD
   1321