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