Home | History | Annotate | Line # | Download | only in src
BUILDING revision 1.59.2.1
      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                    The INSTALLSETS environment variable may be set to a list
    489                    of distribution sets to be installed.  By default, all sets
    490                    except ``etc'' and ``xetc'' are installed (so most files in
    491                    INSTALLWORLDDIR/etc will not be installed or modified).
    492 
    493                    Note: Before performing this operation with
    494                    INSTALLWORLDDIR=/, it is highly recommended that you
    495                    upgrade your kernel and reboot.  After performing this
    496                    operation, it is recommended that you use etcupdate(8) to
    497                    update files in INSTALLWORLDDIR/etc and that you use
    498                    postinstall(8) to check for inconsistencies (and possibly
    499                    to fix them).
    500 
    501      sets          Create distribution sets from DESTDIR into
    502                    RELEASEDIR/MACHINE/binary/sets.  Should be run after ``make
    503                    distribution'' (as ``make build'' does not install all of
    504                    the required files).
    505 
    506      sourcesets    Create source sets of the source tree into
    507                    RELEASEDIR/source/sets.
    508 
    509      syspkgs       Create syspkgs from DESTDIR into
    510                    RELEASEDIR/MACHINE/binary/syspkgs.  Should be run after
    511                    ``make distribution'' (as ``make build'' does not install
    512                    all of the required files).
    513 
    514      release       Do a ``make distribution'', build kernels, distribution
    515                    media, and install sets (this as per ``make sets''), and
    516                    then package the system into a standard release layout as
    517                    described by release(7).  This requires that RELEASEDIR be
    518                    set (see above).
    519 
    520      iso-image     Create a CD-ROM image in
    521                    RELEASEDIR/MACHINE/installation/cdrom.  RELEASEDIR must
    522                    already have been populated by ``make release'' or equiva-
    523                    lent.  This requires the mkisofs(1) utility, which is not
    524                    part of NetBSD, but which can be installed from
    525                    pkgsrc/sysutils/cdrtools.
    526 
    527      regression-tests
    528                    Can only be run after building the regression tests in the
    529                    directory ``regress''.  Runs the compiled regression tests
    530                    on the local host.
    531 
    532    The "build.sh" script
    533      This script file is a Bourne shell script designed to build the entire
    534      NetBSD system on any host with a Bourne shell in /bin/sh, including many
    535      that are not POSIX compliant.  Note that if a host system's /bin/sh is
    536      unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
    537      a usable alternative.
    538 
    539      All cross-compile builds, and most native builds, of the entire system
    540      should make use of build.sh rather than just running ``make''.  This way,
    541      the make(1) program will be bootstrapped properly, in case the host sys-
    542      tem has an older or incompatible ``make'' program.
    543 
    544      When compiling the entire system via build.sh, many make(1) variables are
    545      set for you in order to help encapsulate the build process.  In the list
    546      of options below, variables that are automatically set by build.sh are
    547      noted where applicable.
    548 
    549      The following operations are supported by build.sh:
    550 
    551      build         Build the system as per ``make build''.  This option
    552                    implies the obj and tools operations.
    553 
    554      distribution  Build a full distribution as per ``make distribution''.
    555                    This option implies the build operation.
    556 
    557      release       Build a full release as per ``make release''.  This option
    558                    implies the distribution operation.
    559 
    560      makewrapper   Create the nbmake-MACHINE wrapper.  This operation is auto-
    561                    matically performed for any of the other operations.
    562 
    563      obj           Perform ``make obj''.
    564 
    565      tools         Build and install the host tools from src/tools.
    566 
    567      install=idir  Install the contents of DESTDIR to idir, using ``make
    568                    installworld''.  Note that files that are part of the
    569                    ``etc'' or ``xetc'' sets will not be installed.
    570 
    571      kernel=kconf  Build a new kernel.  The kconf argument is the name of a
    572                    configuration file suitable for use by config(1).  If kconf
    573                    does not contain any `/' characters, the configuration file
    574                    is expected to be found in the KERNCONFDIR directory, which
    575                    is typically sys/arch/MACHINE/conf.  The new kernel will be
    576                    built in a subdirectory of KERNOBJDIR, which is typically
    577                    sys/arch/MACHINE/compile or an associated object directory.
    578                    In order to ensure that the kernel is built using up-to-
    579                    date tools, it is strongly recommended that the tools be
    580                    rebuilt (using the tools operation).
    581 
    582      releasekernel=kconf
    583                    Install a gzip(1)ed copy of the kernel built by
    584                    kernel=kconf into RELEASEDIR/MACHINE/binary/kernel, usually
    585                    as netbsd-kconf.gz, although the ``netbsd'' prefix is
    586                    determined from the ``config'' directives in kconf.
    587 
    588      sets          Perform ``make sets''.
    589 
    590      sourcesets    Perform ``make sourcesets''.
    591 
    592      syspkgs       Perform ``make syspkgs''.
    593 
    594      iso-image     Perform ``make iso-image''.
    595 
    596      The following command line options alter the behaviour of the build.sh
    597      operations described above:
    598 
    599      -a arch   Set the value of MACHINE_ARCH to arch.
    600 
    601      -B buildid
    602                Set the value of BUILDID to buildid.  This will also append the
    603                build idenfitier to the name of the ``make'' wrapper script so
    604                that the resulting name is of the form
    605                ``nbmake-MACHINE-BUILDID''.
    606 
    607      -D dest   Set the value of DESTDIR to dest.  If a relative path is speci-
    608                fied, it will be converted to an absolute path before being
    609                used.
    610 
    611      -E        Set `expert' mode.  This overrides various sanity checks, and
    612                allows: DESTDIR does not have to be set to a non-root path for
    613                builds, and MKUNPRIVED=yes does not have to be set when build-
    614                ing as a non-root user.
    615 
    616                Note: It is highly recommended that you know what you are doing
    617                when you use this option.
    618 
    619      -h        Print a help message.
    620 
    621      -j njob   Passed through to make(1).  Makefiles should use .WAIT or have
    622                explicit dependancies as necessary to enforce build ordering.
    623                If you see build failures with -j, please save complete build
    624                logs so the failures can be analyzed.
    625 
    626      -M obj    Set MAKEOBJDIRPREFIX to obj.  If a relative path is specified,
    627                it will be converted to an absolute path before being used.
    628                Unsets MAKEOBJDIR.
    629 
    630      -m mach   Set the value of MACHINE to mach.  This will also override any
    631                value of MACHINE_ARCH in the process environment with a value
    632                deduced from mach, unless -a is specified, or mach is a special
    633                case listed below.  All cross builds require -m, but if unset
    634                on a NetBSD host, the host's value of MACHINE will be detected
    635                and used automatically.
    636 
    637                Some machines support multiple values for MACHINE_ARCH.  For a
    638                given value of mach, the following MACHINE and MACHINE_ARCH
    639                values will result:
    640 
    641                      mach          MACHINE    MACHINE_ARCH
    642                      evbmips       evbmips    (not set)
    643                      evbmips-eb    evbmips    mipseb
    644                      evbmips-el    evbmips    mipsel
    645                      evbsh3        evbsh3     (not set)
    646                      evbsh3-eb     evbsh3     sh3eb
    647                      evbsh3-el     evbsh3     sh3el
    648                      sbmips        sbmips     (not set)
    649                      sbmips-eb     sbmips     mipseb
    650                      sbmips-el     sbmips     mipsel
    651 
    652      -N noiselevel
    653                Set the ``noisyness'' level of the build, by setting
    654                MAKEVERBOSE to noiselevel.
    655 
    656      -n        Show the commands that would be executed by build.sh, but do
    657                not make any changes.  This is similar in concept to ``make
    658                -n''.
    659 
    660      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
    661                place the built object files under obj.  If a relative path is
    662                specified, it will be converted to an absolute path before
    663                being used.  For instance, a setting of /usr/obj will place
    664                build-time files under /usr/obj/bin, /usr/obj/lib,
    665                /usr/obj/usr.bin, and so forth.  Unsets MAKEOBJDIRPREFIX.
    666 
    667      -o        Set the value of MKOBJDIRS to ``no''.  Otherwise, it will be
    668                automatically set to ``yes'' (which is opposite to the default
    669                behaviour).
    670 
    671      -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
    672                specified, it will be converted to an absolute path before
    673                being used.
    674 
    675      -r        Remove the contents of DESTDIR and TOOLDIR before building
    676                (provides a clean starting point).  This will skip deleting
    677                DESTDIR if building on a native system to the root directory.
    678 
    679      -T tools  Set the value of TOOLDIR to tools.  If a relative path is spec-
    680                ified, it will be converted to an absolute path before being
    681                used.  If set, the bootstrap ``make'' will only be rebuilt as
    682                needed (when the source files for make(1) change).
    683 
    684      -U        Set MKUNPRIVED=yes.
    685 
    686      -u        Set MKUPDATE=yes.
    687 
    688      -V var=[value]
    689                Set the environment variable var to an optional value.  This is
    690                propagated to the nbmake wrapper.
    691 
    692      -w wrapper
    693                Create the nbmake wrapper script (see below) in a custom loca-
    694                tion, specified by wrapper.  This allows, for instance, to
    695                place the wrapper in PATH automatically.  Note that wrapper is
    696                the full name of the file, not just a directory name.  If a
    697                relative path is specified, it will be converted to an absolute
    698                path before being used.
    699 
    700      -X x11src
    701                Set the value of X11SRCDIR to x11src.  If a relative path is
    702                specified, it will be converted to an absolute path before
    703                being used.
    704 
    705      -x        Set MKX11=yes.
    706 
    707      -Z var    Unset ("zap") the environment variable var.  This is propagated
    708                to the nbmake wrapper.
    709 
    710    The "nbmake-MACHINE" wrapper script
    711      If using the build.sh script to build NetBSD, a nbmake-MACHINE script
    712      will be created in TOOLDIR/bin upon the first build to assist in building
    713      subtrees on a cross-compile host.
    714 
    715      nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
    716      the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
    717      eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
    718      build.sh will also set variables specified with -V, and unset variables
    719      specified with -Z.
    720 
    721      This script can be symlinked into a directory listed in PATH, or called
    722      with an absolute path.
    723 
    724 EXAMPLES
    725      1.   % ./build.sh tools kernel=GENERIC
    726 
    727           Build a new toolchain, and use the new toolchain to configure and
    728           build a new GENERIC kernel.
    729 
    730      2.   % ./build.sh -U distribution
    731 
    732           Using unprivileged mode, build a complete distribution to a DESTDIR
    733           directory that build.sh selects (and will display).
    734 
    735      3.   # ./build.sh -U install=/
    736 
    737           As root, install to / the distribution that was built by example 2.
    738           Even though this is run as root, -U is required so that the permis-
    739           sions stored in DESTDIR/METALOG are correctly applied to the files
    740           as they're copied to /.
    741 
    742      4.   % ./build.sh -U -u release
    743 
    744           Using unprivileged mode, build a complete release to DESTDIR and
    745           RELEASEDIR directories that build.sh selects (and will display).
    746           MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that
    747           if this is run after example 2, it doesn't need to redo that portion
    748           of the release build.
    749 
    750 OBSOLETE VARIABLES
    751      NBUILDJOBS  Use the make(1) option -j, instead.
    752 
    753      USE_NEW_TOOLCHAIN
    754                  The new toolchain is now the default.  To disable, use
    755                  TOOLCHAIN_MISSING=yes.
    756 
    757 SEE ALSO
    758      make(1), hier(7), release(7), etcupdate(8), postinstall(8),
    759      pkgsrc/sysutils/cdrtools
    760 
    761 HISTORY
    762      The build.sh based build scheme was introduced for NetBSD 1.6 as
    763      USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
    764 
    765 BUGS
    766      A few platforms are not yet using this build system.
    767 
    768 NetBSD                          March 27, 2007                          NetBSD
    769