Home | History | Annotate | Line # | Download | only in src
BUILDING revision 1.59
      1 BUILDING(8)             NetBSD System Manager's Manual             BUILDING(8)
      2 
      3 NAME
      4      BUILDING -- Procedure for building NetBSD from source code.
      5 
      6 STATUS
      7      This document is a work-in-progress.  As such, the information described
      8      here may not match the reality of the build system as of this writing.
      9      Once this document is completely in sync with reality, this paragraph
     10      will be removed.
     11 
     12      Discrepancies between this documentation and the current reality of
     13      implementation are noted specially, as with the note below:
     14 
     15      Note: This document applies only to platforms which use the new toolchain
     16      as indicated by the default setting of TOOLCHAIN_MISSING in <bsd.own.mk>.
     17      Platforms which have not yet been switched to the new toolchain should
     18      continue building traditionally, using the notes specified in the file
     19      UPDATING.
     20 
     21 REQUIREMENTS
     22      NetBSD is designed to be buildable on most POSIX-compliant host systems.
     23      The basic build procedure is the same whether compiling natively (on the
     24      same NetBSD architecture) or cross compiling (on another architecture or
     25      OS).
     26 
     27      This source tree contains a special subtree, ``tools'', which uses the
     28      host system to create a build toolchain for the target architecture.  The
     29      host system must have at least C and C++ compilers in order to create the
     30      toolchain (make is not required); all other tools are created as part of
     31      the NetBSD build process.  (See the environment variables section below
     32      if you need to override or manually select your compilers.)
     33 
     34 FILES
     35    Source tree layout
     36      doc/BUILDING.mdoc
     37                     This document (in -mdoc troff format; the original copy).
     38 
     39      BUILDING       This document (in plaintext).
     40 
     41      tools/compat/README
     42                     Special notes for cross-hosting a NetBSD build on non-
     43                     NetBSD platforms.
     44 
     45      Makefile       The main Makefile for NetBSD; should only be run for
     46                     native builds with an appropriately up-to-date version of
     47                     NetBSD make(1).  (For building from out-of-date systems or
     48                     on a non-native host, see the build.sh shell script.)
     49 
     50      UPDATING       Special notes for updating from an earlier revision of
     51                     NetBSD.  It is important to read this file before every
     52                     build of an updated source tree.
     53 
     54      build.sh       Bourne-compatible shell script used for building the host
     55                     build tools and the NetBSD system from scratch.  Can be
     56                     used for both native and cross builds, and should be used
     57                     instead of make(1) for any source tree that is updated and
     58                     recompiled regularly.
     59 
     60      crypto/dist/, dist/, gnu/dist/
     61                     Sources imported verbatim from third parties, without man-
     62                     gling the existing build structure.  Other source trees in
     63                     bin through usr.sbin use the NetBSD make(1) ``reachover''
     64                     Makefile semantics when building these programs for a
     65                     native host.
     66 
     67      distrib/, etc/
     68                     Sources for items used when making a full release snap-
     69                     shot, such as files installed in DESTDIR/etc on the desti-
     70                     nation system, boot media, and release notes.
     71 
     72      regress/       Regression test harness.  Can be cross-compiled, but only
     73                     run natively.
     74 
     75      sys/           NetBSD kernel sources.
     76 
     77      tools/         ``Reachover'' build structure for the host build tools.
     78                     This has a special method of determining out-of-date sta-
     79                     tus.
     80 
     81      bin/ ... usr.sbin/
     82                     Sources to the NetBSD userland (non-kernel) programs.  If
     83                     any of these directories are missing, they will be skipped
     84                     during the build.
     85 
     86      x11/           ``Reachover'' build structure for X11R6; the source is in
     87                     X11SRCDIR.
     88 
     89    Build tree layout
     90      The NetBSD build tree is described in hier(7), and the release layout is
     91      described in release(7).
     92 
     93 CONFIGURATION
     94    Environment variables
     95      Several environment variables control the behaviour of NetBSD builds.
     96 
     97      HOST_SH           Path name to a POSIX-compliant shell.  If this is not
     98                        set explicitly, then the default is set using heuris-
     99                        tics dependent on the host platform, or from the shell
    100                        under which build.sh is executed (if that can be deter-
    101                        mined), or using the first copy of sh found in PATH.
    102                        If the host system's /bin/sh is not POSIX-compliant, we
    103                        suggest that you build using commands like
    104 
    105                              HOST_SH=/path/to/working/shell
    106                              export HOST_SH
    107                              ${HOST_SH} build.sh [options]
    108 
    109      HOST_CC           Path name to C compiler used to create the toolchain.
    110 
    111      HOST_CXX          Path name to C++ compiler used to create the toolchain.
    112 
    113      MACHINE           Machine type.
    114 
    115      MACHINE_ARCH      Machine architecture.
    116 
    117      MAKE              Path name to invoke make(1) as.
    118 
    119      MAKEFLAGS         Flags to invoke make(1) with.
    120 
    121      MAKEOBJDIR        Directory to use as the .OBJDIR for the current direc-
    122                        tory.  The value is subjected to variable expansion by
    123                        make(1).  Used only if MAKEOBJDIRPREFIX is not defined.
    124                        MAKEOBJDIR can only be provided in the environment or
    125                        via the -O flag of build.sh.
    126 
    127      MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  If
    128                        specified, must be an absolute path.  If this is
    129                        defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the
    130                        .OBJDIR for the current directory.  The current direc-
    131                        tory may be read only.  MAKEOBJDIRPREFIX can only be
    132                        provided in the environment or via the -M flag of
    133                        build.sh.
    134 
    135    "make" variables
    136      Several variables control the behavior of NetBSD builds.  Unless other-
    137      wise specified, these variables may be set in either the process environ-
    138      ment or the make(1) configuration file specified by MAKECONF.
    139 
    140      BUILDID     Identifier for the build.  The identifier will be appended to
    141                  object directory names, and can be consulted in the make(1)
    142                  configuration file in order to set additional build parame-
    143                  ters, such as compiler flags.
    144 
    145      DESTDIR     Directory to contain the built NetBSD system.  If set, spe-
    146                  cial options are passed to the compilation tools to prevent
    147                  their default use of the host system's /usr/include,
    148                  /usr/lib, and so forth.  This pathname must be an absolute
    149                  path, and should not end with a slash (/) character.  (For
    150                  installation into the system's root directory, set DESTDIR to
    151                  an empty string, not to ``/'').  The directory must reside on
    152                  a file system which supports long file names and hard links.
    153 
    154                  Default: Empty string if USETOOLS is ``yes''; unset other-
    155                  wise.
    156 
    157                  Note: build.sh will provide a default of destdir.MACHINE (in
    158                  the top-level .OBJDIR) unless run in `expert' mode
    159 
    160      MAKECONF    The name of the make(1) configuration file.  Only settable in
    161                  the process environment.
    162 
    163                  Default: ``/etc/mk.conf''
    164 
    165      MAKEVERBOSE
    166                  Level of verbosity of status messages.  Supported values:
    167 
    168                  0    No descriptive messages are shown.
    169 
    170                  1    Descriptive messages are shown.
    171 
    172                  2    Descriptive messages (prefixed with a `#') and command
    173                       output is not suppressed.
    174 
    175                  Default: 2
    176 
    177      MKCATPAGES  Can be set to ``yes'' or ``no''.  Indicates whether prefor-
    178                  matted plaintext manual pages will be created during a build.
    179 
    180                  Default: ``yes''
    181 
    182      MKCRYPTO    Can be set to ``yes'' or ``no''.  Indicates whether crypto-
    183                  graphic code will be included in a build; provided for the
    184                  benefit of countries that do not allow strong cryptography.
    185                  Will not affect use of the standard low-security password
    186                  encryption system, crypt(3).
    187 
    188                  Default: ``yes''
    189 
    190      MKDOC       Can be set to ``yes'' or ``no''.  Indicates whether system
    191                  documentation destined for DESTDIR/usr/share/doc will be
    192                  installed during a build.
    193 
    194                  Default: ``yes''
    195 
    196      MKHOSTOBJ   Can be set to ``yes'' or ``no''.  If set to ``yes'', then for
    197                  programs intended to be run on the compile host, the name,
    198                  release, and architecture of the host operating system will
    199                  be suffixed to the name of the object directory created by
    200                  ``make obj''.  (This allows multiple host systems to compile
    201                  NetBSD for a single target.)  If set to ``no'', then programs
    202                  built to be run on the compile host will use the same object
    203                  directory names as programs built to be run on the target.
    204 
    205                  Default: ``no''
    206 
    207      MKINFO      Can be set to ``yes'' or ``no''.  Indicates whether GNU Info
    208                  files, used for the documentation for most of the compilation
    209                  tools, will be created and installed during a build.
    210 
    211                  Default: ``yes''
    212 
    213      MKLINT      Can be set to ``yes'' or ``no''.  Indicates whether lint(1)
    214                  will be run against portions of the NetBSD source code during
    215                  the build, and whether lint libraries will be installed into
    216                  DESTDIR/usr/libdata/lint.
    217 
    218                  Default: ``yes''
    219 
    220      MKMAN       Can be set to ``yes'' or ``no''.  Indicates whether manual
    221                  pages will be installed during a build.
    222 
    223                  Default: ``yes''
    224 
    225      MKNLS       Can be set to ``yes'' or ``no''.  Indicates whether Native
    226                  Language System locale zone files will be compiled and
    227                  installed during a build.
    228 
    229                  Default: ``yes''
    230 
    231      MKOBJ       Can be set to ``yes'' or ``no''.  Indicates whether object
    232                  directories will be created when running ``make obj''.  If
    233                  set to ``no'', then all built files will be located inside
    234                  the regular source tree.
    235 
    236                  Default: ``yes''
    237 
    238      MKPIC       Can be set to ``yes'' or ``no''.  Indicates whether shared
    239                  objects and libraries will be created and installed during a
    240                  build.  If set to ``no'', the entire built system will be
    241                  statically linked.
    242 
    243                  Default: Platform dependent.  As of this writing, all plat-
    244                  forms except sh3 default to ``yes''.
    245 
    246      MKPICINSTALL
    247                  Can be set to ``yes'' or ``no''.  Indicates whether the ar(1)
    248                  format libraries (lib*_pic.a), used to generate shared
    249                  libraries, are installed during a build.
    250 
    251                  Default: ``yes''
    252 
    253      MKPROFILE   Can be set to ``yes'' or ``no''.  Indicates whether profiled
    254                  libraries (lib*_p.a) will be built and installed during a
    255                  build.
    256 
    257                  Default: ``yes''; however, some platforms turn off MKPROFILE
    258                  by default at times due to toolchain problems with profiled
    259                  code.
    260 
    261      MKSHARE     Can be set to ``yes'' or ``no''.  Indicates whether files
    262                  destined to reside in DESTDIR/usr/share will be built and
    263                  installed during a build.  If set to ``no'', then all of
    264                  MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
    265                  ``no'' unconditionally.
    266 
    267                  Default: ``yes''
    268 
    269      MKTTINTERP  Can be set to ``yes'' or ``no''.  For X builds, decides if
    270                  the TrueType bytecode interpreter is turned on.  See
    271                  http://www.freetype.org/patents.html for details.
    272 
    273                  Default: ``no''
    274 
    275      MKUNPRIVED  Can be set to ``yes'' or ``no''.  Indicates whether an
    276                  unprivileged install will occur.  The user, group, permis-
    277                  sions, and file flags, will not be set on the installed
    278                  items; instead the information will be appended to a file
    279                  called METALOG in DESTDIR.  The contents of METALOG are used
    280                  during the generation of the distribution tar files to ensure
    281                  that the appropriate file ownership is stored.
    282 
    283                  Default: ``no''
    284 
    285      MKUPDATE    Can be set to ``yes'' or ``no''.  Indicates whether all
    286                  install operations intended to write to DESTDIR will compare
    287                  file timestamps before installing, and skip the install phase
    288                  if the destination files are up-to-date.  This also has
    289                  implications on full builds (see next subsection).
    290 
    291                  Default: ``no''
    292 
    293      MKX11       Can be set to ``yes'' or ``no''.  Indicates whether X11R6 is
    294                  built from X11SRCDIR.
    295 
    296                  Default: ``no''
    297 
    298      TOOLDIR     Directory to hold the host tools, once built.  If specified,
    299                  must be an absolute path.  This directory should be unique to
    300                  a given host system and NetBSD source tree.  (However, multi-
    301                  ple targets may share the same TOOLDIR; the target-dependent
    302                  files have unique names.)  If unset, a default based on the
    303                  uname(1) information of the host platform will be created in
    304                  the .OBJDIR of src.
    305 
    306                  Default: Unset.
    307 
    308      USETOOLS    Indicates whether the tools specified by TOOLDIR should be
    309                  used as part of a build in progress.  Must be set to ``yes''
    310                  if cross-compiling.
    311 
    312                  yes    Use the tools from TOOLDIR.
    313 
    314                  no     Do not use the tools from TOOLDIR, but refuse to build
    315                         native compilation tool components that are version-
    316                         specific for that tool.
    317 
    318                  never  Do not use the tools from TOOLDIR, even when building
    319                         native tool components.  This is similar to the tradi-
    320                         tional NetBSD build method, but does not verify that
    321                         the compilation tools in use are up-to-date enough in
    322                         order to build the tree successfully.  This may cause
    323                         build or runtime problems when building the whole
    324                         NetBSD source tree.
    325 
    326                  Default: ``yes'' if building all or part of a whole NetBSD
    327                  source tree (detected automatically); ``no'' otherwise (to
    328                  preserve traditional semantics of the <bsd.*.mk> make(1)
    329                  include files).
    330 
    331      X11SRCDIR   Directory containing the X11R6 source.  If specified, must be
    332                  an absolute path.  The main X11R6 source is found in
    333                  X11SRCDIR/xfree/xc.
    334 
    335                  Default: ``/usr/xsrc''
    336 
    337    "make" variables for full builds
    338      These variables only affect the top level ``Makefile'' and do not affect
    339      manually building subtrees of the NetBSD source code.
    340 
    341      INSTALLWORLDDIR  Location for the ``make installworld'' target to install
    342                       to.  If specified, must be an absolute path.
    343 
    344                       Default: ``/''
    345 
    346      MKOBJDIRS        Can be set to ``yes'' or ``no''.  Indicates whether
    347                       object directories will be created automatically (via a
    348                       ``make obj'' pass) at the start of a build.
    349 
    350                       Default: ``no''
    351 
    352      MKUPDATE         Can be set to ``yes'' or ``no''.  If set, then in addi-
    353                       tion to the effects described for MKUPDATE=yes above,
    354                       this implies the effects of NOCLEANDIR (i.e., ``make
    355                       cleandir'' is avoided).
    356 
    357                       Default: ``no''
    358 
    359      NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead (see
    360                       below)
    361 
    362                       Default: Unset.
    363 
    364      NOCLEANDIR       If set, avoids the ``make cleandir'' phase of a full
    365                       build.  This has the effect of allowing only changed
    366                       files in a source tree to be recompiled.  This can speed
    367                       up builds when updating only a few files in the tree.
    368 
    369                       Default: Unset.
    370 
    371      NODISTRIBDIRS    If set, avoids the ``make distrib-dirs'' phase of a full
    372                       build.  This skips running mtree(8) on DESTDIR, useful
    373                       on systems where building as an unprivileged user, or
    374                       where it is known that the system-wide mtree files have
    375                       not changed.
    376 
    377                       Default: Unset.
    378 
    379      NOINCLUDES       If set, avoids the ``make includes'' phase of a full
    380                       build.  This has the effect of preventing make(1) from
    381                       thinking that some programs are out-of-date simply
    382                       because the system include files have changed.  However,
    383                       this option should not be used when updating the entire
    384                       NetBSD source tree arbitrarily; it is suggested to use
    385                       MKUPDATE=yes in that case.
    386 
    387                       Default: Unset.
    388 
    389      RELEASEDIR       If set, specifies the directory to which a release(7)
    390                       layout will be written at the end of a ``make release''.
    391                       If specified, must be an absolute path.
    392 
    393                       Default: Unset.
    394 
    395                       Note: build.sh will provide a default of releasedir (in
    396                       the top-level .OBJDIR) unless run in `expert' mode
    397 
    398 BUILDING
    399    "make" command line options
    400      This is not a summary of all the options available to make(1); only the
    401      options used most frequently with NetBSD builds are listed here.
    402 
    403      -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
    404                 use .WAIT or have explicit dependencies as necessary to
    405                 enforce build ordering.  If you see build failures with -j,
    406                 please save complete build logs so the failures can be ana-
    407                 lyzed.
    408 
    409      -m dir     Specify the default directory for searching for system Make-
    410                 file segments, mainly the <bsd.*.mk> files.  When building any
    411                 full NetBSD source tree, this should be set to the
    412                 ``share/mk'' directory in the source tree.  (This is set auto-
    413                 matically when building from the top level.)
    414 
    415      -n         Display the commands that would have been executed, but do not
    416                 actually execute them.  This will still cause recursion to
    417                 take place.
    418 
    419      -V var     Print make(1)'s idea of the value of var.  Does not build any
    420                 targets.
    421 
    422      var=value  Set the variable var to value, overriding any setting speci-
    423                 fied by the process environment, the MAKECONF configuration
    424                 file, or the system Makefile segments.
    425 
    426    "make" targets
    427      These default targets may be built by running make(1) in any subtree of
    428      the NetBSD source code.  It is recommended that none of these be used
    429      from the top level Makefile; as a specific exception, ``make obj'' and
    430      ``make cleandir'' are useful in that context.
    431 
    432      all        Build programs, libraries, and preformatted documentation.
    433 
    434      clean      Remove program and library object code files.
    435 
    436      cleandir   Same as clean, but also remove preformatted documentation,
    437                 dependency files generated by ``make depend'', and any other
    438                 files known to be created at build time.
    439 
    440      depend     Create dependency files (.depend) containing more detailed
    441                 information about the dependencies of source code on header
    442                 files.  Allows programs to be recompiled automatically when a
    443                 dependency changes.
    444 
    445      dependall  Does a ``make depend'' immediately followed by a ``make all''.
    446                 This improves cache locality of the build since both passes
    447                 read the source files in their entirety.
    448 
    449      distclean  Synonym for cleandir.
    450 
    451      includes   Build and install system header files.  Typically needed
    452                 before any system libraries or programs can be built.
    453 
    454      install    Install programs, libraries, and documentation into DESTDIR.
    455                 Few files will be installed to DESTDIR/dev, DESTDIR/etc,
    456                 DESTDIR/root or DESTDIR/var in order to prevent user supplied
    457                 configuration data from being overwritten.
    458 
    459      lint       Run lint(1) against the C source code, where appropriate, and
    460                 generate system-installed lint libraries.
    461 
    462      obj        Create object directories to be used for built files, instead
    463                 of building directly in the source tree.
    464 
    465      tags       Create ctags(1) searchable function lists usable by the ex(1)
    466                 and vi(1) text editors.
    467 
    468    "make" targets for the top level
    469      Additional make(1) targets are usable specifically from the top source
    470      level to facilitate building the entire NetBSD source tree.
    471 
    472      build         Build the entire NetBSD system.  This orders portions of
    473                    the source tree such that prerequisites will be built in
    474                    the proper order.
    475 
    476      distribution  Do a ``make build'', and then install a full distribution
    477                    into DESTDIR, including files in DESTDIR/dev, DESTDIR/etc,
    478                    DESTDIR/root and DESTDIR/var.
    479 
    480      buildworld    As per ``make distribution'', except that it ensures that
    481                    DESTDIR is not the root directory.
    482 
    483      installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR
    484                    (which defaults to the root directory).  Ensures that
    485                    INSTALLWORLDDIR is not the root directory if cross compil-
    486                    ing.
    487 
    488                    Note: It is highly recommended that you upgrade your kernel
    489                    and reboot before performing this operation.
    490 
    491      sets          Create distribution sets from DESTDIR into
    492                    RELEASEDIR/MACHINE/binary/sets.  Should be run after ``make
    493                    distribution'' (as ``make build'' does not install all of
    494                    the required files).
    495 
    496      sourcesets    Create source sets of the source tree into
    497                    RELEASEDIR/source/sets.
    498 
    499      syspkgs       Create syspkgs from DESTDIR into
    500                    RELEASEDIR/MACHINE/binary/syspkgs.  Should be run after
    501                    ``make distribution'' (as ``make build'' does not install
    502                    all of the required files).
    503 
    504      release       Do a ``make distribution'', build kernels, distribution
    505                    media, and install sets (this as per ``make sets''), and
    506                    then package the system into a standard release layout as
    507                    described by release(7).  This requires that RELEASEDIR be
    508                    set (see above).
    509 
    510      iso-image     Create a CD-ROM image in
    511                    RELEASEDIR/MACHINE/installation/cdrom.  RELEASEDIR must
    512                    already have been populated by ``make release'' or equiva-
    513                    lent.  This requires the mkisofs(1) utility, which is not
    514                    part of NetBSD, but which can be installed from
    515                    pkgsrc/sysutils/cdrtools.
    516 
    517      regression-tests
    518                    Can only be run after building the regression tests in the
    519                    directory ``regress''.  Runs the compiled regression tests
    520                    on the local host.
    521 
    522    The "build.sh" script
    523      This script file is a Bourne shell script designed to build the entire
    524      NetBSD system on any host with a Bourne shell in /bin/sh, including many
    525      that are not POSIX compliant.  Note that if a host system's /bin/sh is
    526      unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
    527      a usable alternative.
    528 
    529      All cross-compile builds, and most native builds, of the entire system
    530      should make use of build.sh rather than just running ``make''.  This way,
    531      the make(1) program will be bootstrapped properly, in case the host sys-
    532      tem has an older or incompatible ``make'' program.
    533 
    534      When compiling the entire system via build.sh, many make(1) variables are
    535      set for you in order to help encapsulate the build process.  In the list
    536      of options below, variables that are automatically set by build.sh are
    537      noted where applicable.
    538 
    539      The following operations are supported by build.sh:
    540 
    541      build         Build the system as per ``make build''.  This option
    542                    implies the obj and tools operations.
    543 
    544      distribution  Build a full distribution as per ``make distribution''.
    545                    This option implies the build operation.
    546 
    547      release       Build a full release as per ``make release''.  This option
    548                    implies the distribution operation.
    549 
    550      makewrapper   Create the nbmake-MACHINE wrapper.  This operation is auto-
    551                    matically performed for any of the other operations.
    552 
    553      obj           Perform ``make obj''.
    554 
    555      tools         Build and install the host tools from src/tools.
    556 
    557      install=idir  Install the contents of DESTDIR to idir, using ``make
    558                    installworld''.
    559 
    560      kernel=kconf  Build a new kernel.  The kconf argument is the name of a
    561                    configuration file suitable for use by config(1).  If kconf
    562                    does not contain any `/' characters, the configuration file
    563                    is expected to be found in the KERNCONFDIR directory, which
    564                    is typically sys/arch/MACHINE/conf.  The new kernel will be
    565                    built in a subdirectory of KERNOBJDIR, which is typically
    566                    sys/arch/MACHINE/compile or an associated object directory.
    567                    In order to ensure that the kernel is built using up-to-
    568                    date tools, it is strongly recommended that the tools be
    569                    rebuilt (using the tools operation).
    570 
    571      releasekernel=kconf
    572                    Install a gzip(1)ed copy of the kernel built by
    573                    kernel=kconf into RELEASEDIR/MACHINE/binary/kernel, usually
    574                    as netbsd-kconf.gz, although the ``netbsd'' prefix is
    575                    determined from the ``config'' directives in kconf.
    576 
    577      sets          Perform ``make sets''.
    578 
    579      sourcesets    Perform ``make sourcesets''.
    580 
    581      syspkgs       Perform ``make syspkgs''.
    582 
    583      iso-image     Perform ``make iso-image''.
    584 
    585      The following command line options alter the behaviour of the build.sh
    586      operations described above:
    587 
    588      -a arch   Set the value of MACHINE_ARCH to arch.
    589 
    590      -B buildid
    591                Set the value of BUILDID to buildid.  This will also append the
    592                build idenfitier to the name of the ``make'' wrapper script so
    593                that the resulting name is of the form
    594                ``nbmake-MACHINE-BUILDID''.
    595 
    596      -D dest   Set the value of DESTDIR to dest.  If a relative path is speci-
    597                fied, it will be converted to an absolute path before being
    598                used.
    599 
    600      -E        Set `expert' mode.  This overrides various sanity checks, and
    601                allows: DESTDIR does not have to be set to a non-root path for
    602                builds, and MKUNPRIVED=yes does not have to be set when build-
    603                ing as a non-root user.
    604 
    605                Note: It is highly recommended that you know what you are doing
    606                when you use this option.
    607 
    608      -h        Print a help message.
    609 
    610      -j njob   Passed through to make(1).  Makefiles should use .WAIT or have
    611                explicit dependancies as necessary to enforce build ordering.
    612                If you see build failures with -j, please save complete build
    613                logs so the failures can be analyzed.
    614 
    615      -M obj    Set MAKEOBJDIRPREFIX to obj.  If a relative path is specified,
    616                it will be converted to an absolute path before being used.
    617                Unsets MAKEOBJDIR.
    618 
    619      -m mach   Set the value of MACHINE to mach.  This will also override any
    620                value of MACHINE_ARCH in the process environment with a value
    621                deduced from mach, unless -a is specified, or mach is a special
    622                case listed below.  All cross builds require -m, but if unset
    623                on a NetBSD host, the host's value of MACHINE will be detected
    624                and used automatically.
    625 
    626                Some machines support multiple values for MACHINE_ARCH.  For a
    627                given value of mach, the following MACHINE and MACHINE_ARCH
    628                values will result:
    629 
    630                      mach          MACHINE    MACHINE_ARCH
    631                      evbmips       evbmips    (not set)
    632                      evbmips-eb    evbmips    mipseb
    633                      evbmips-el    evbmips    mipsel
    634                      evbsh3        evbsh3     (not set)
    635                      evbsh3-eb     evbsh3     sh3eb
    636                      evbsh3-el     evbsh3     sh3el
    637                      sbmips        sbmips     (not set)
    638                      sbmips-eb     sbmips     mipseb
    639                      sbmips-el     sbmips     mipsel
    640 
    641      -N noiselevel
    642                Set the ``noisyness'' level of the build, by setting
    643                MAKEVERBOSE to noiselevel.
    644 
    645      -n        Show the commands that would be executed by build.sh, but do
    646                not make any changes.  This is similar in concept to ``make
    647                -n''.
    648 
    649      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
    650                place the built object files under obj.  If a relative path is
    651                specified, it will be converted to an absolute path before
    652                being used.  For instance, a setting of /usr/obj will place
    653                build-time files under /usr/obj/bin, /usr/obj/lib,
    654                /usr/obj/usr.bin, and so forth.  Unsets MAKEOBJDIRPREFIX.
    655 
    656      -o        Set the value of MKOBJDIRS to ``no''.  Otherwise, it will be
    657                automatically set to ``yes'' (which is opposite to the default
    658                behaviour).
    659 
    660      -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
    661                specified, it will be converted to an absolute path before
    662                being used.
    663 
    664      -r        Remove the contents of DESTDIR and TOOLDIR before building
    665                (provides a clean starting point).  This will skip deleting
    666                DESTDIR if building on a native system to the root directory.
    667 
    668      -T tools  Set the value of TOOLDIR to tools.  If a relative path is spec-
    669                ified, it will be converted to an absolute path before being
    670                used.  If set, the bootstrap ``make'' will only be rebuilt as
    671                needed (when the source files for make(1) change).
    672 
    673      -U        Set MKUNPRIVED=yes.
    674 
    675      -u        Set MKUPDATE=yes.
    676 
    677      -V var=[value]
    678                Set the environment variable var to an optional value.  This is
    679                propagated to the nbmake wrapper.
    680 
    681      -w wrapper
    682                Create the nbmake wrapper script (see below) in a custom loca-
    683                tion, specified by wrapper.  This allows, for instance, to
    684                place the wrapper in PATH automatically.  Note that wrapper is
    685                the full name of the file, not just a directory name.  If a
    686                relative path is specified, it will be converted to an absolute
    687                path before being used.
    688 
    689      -X x11src
    690                Set the value of X11SRCDIR to x11src.  If a relative path is
    691                specified, it will be converted to an absolute path before
    692                being used.
    693 
    694      -x        Set MKX11=yes.
    695 
    696      -Z var    Unset ("zap") the environment variable var.  This is propagated
    697                to the nbmake wrapper.
    698 
    699    The "nbmake-MACHINE" wrapper script
    700      If using the build.sh script to build NetBSD, a nbmake-MACHINE script
    701      will be created in TOOLDIR/bin upon the first build to assist in building
    702      subtrees on a cross-compile host.
    703 
    704      nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
    705      the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
    706      eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
    707      build.sh will also set variables specified with -V, and unset variables
    708      specified with -Z.
    709 
    710      This script can be symlinked into a directory listed in PATH, or called
    711      with an absolute path.
    712 
    713 EXAMPLES
    714      1.   % ./build.sh tools kernel=GENERIC
    715 
    716           Build a new toolchain, and use the new toolchain to configure and
    717           build a new GENERIC kernel.
    718 
    719      2.   % ./build.sh -U distribution
    720 
    721           Using unprivileged mode, build a complete distribution to a DESTDIR
    722           directory that build.sh selects (and will display).
    723 
    724      3.   # ./build.sh -U install=/
    725 
    726           As root, install to / the distribution that was built by example 2.
    727           Even though this is run as root, -U is required so that the permis-
    728           sions stored in DESTDIR/METALOG are correctly applied to the files
    729           as they're copied to /.
    730 
    731      4.   % ./build.sh -U -u release
    732 
    733           Using unprivileged mode, build a complete release to DESTDIR and
    734           RELEASEDIR directories that build.sh selects (and will display).
    735           MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that
    736           if this is run after example 2, it doesn't need to redo that portion
    737           of the release build.
    738 
    739 OBSOLETE VARIABLES
    740      NBUILDJOBS  Use the make(1) option -j, instead.
    741 
    742      USE_NEW_TOOLCHAIN
    743                  The new toolchain is now the default.  To disable, use
    744                  TOOLCHAIN_MISSING=yes.
    745 
    746 SEE ALSO
    747      make(1), hier(7), release(7), pkgsrc/sysutils/cdrtools
    748 
    749 HISTORY
    750      The build.sh based build scheme was introduced for NetBSD 1.6 as
    751      USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
    752 
    753 BUGS
    754      A few platforms are not yet using this build system.
    755 
    756 NetBSD                          January 4, 2006                         NetBSD
    757