[BACK]Return to BUILDING CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src

Annotation of src/BUILDING, Revision 1.59

1.1       tv          1: BUILDING(8)             NetBSD System Manager's Manual             BUILDING(8)
                      2:
                      3: NAME
1.52      jmc         4:      BUILDING -- Procedure for building NetBSD from source code.
1.1       tv          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:
1.44      lukem      12:      Discrepancies between this documentation and the current reality of
                     13:      implementation are noted specially, as with the note below:
1.1       tv         14:
                     15:      Note: This document applies only to platforms which use the new toolchain
1.15      lukem      16:      as indicated by the default setting of TOOLCHAIN_MISSING in <bsd.own.mk>.
1.5       tv         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.
1.1       tv         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
1.53      reed       31:      the NetBSD build process.  (See the environment variables section below
                     32:      if you need to override or manually select your compilers.)
1.1       tv         33:
                     34: FILES
                     35:    Source tree layout
1.17      wiz        36:      doc/BUILDING.mdoc
                     37:                     This document (in -mdoc troff format; the original copy).
1.1       tv         38:
1.2       wiz        39:      BUILDING       This document (in plaintext).
1.1       tv         40:
1.48      jmc        41:      tools/compat/README
                     42:                     Special notes for cross-hosting a NetBSD build on non-
                     43:                     NetBSD platforms.
                     44:
1.44      lukem      45:      Makefile       The main Makefile for NetBSD; should only be run for
                     46:                     native builds with an appropriately up-to-date version of
1.1       tv         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''
1.44      lukem      64:                     Makefile semantics when building these programs for a
                     65:                     native host.
1.1       tv         66:
                     67:      distrib/, etc/
                     68:                     Sources for items used when making a full release snap-
1.27      lukem      69:                     shot, such as files installed in DESTDIR/etc on the desti-
                     70:                     nation system, boot media, and release notes.
1.1       tv         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:
1.49      lukem      86:      x11/           ``Reachover'' build structure for X11R6; the source is in
                     87:                     X11SRCDIR.
                     88:
1.1       tv         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
1.8       lukem      94:    Environment variables
                     95:      Several environment variables control the behaviour of NetBSD builds.
                     96:
1.58      apb        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:
1.53      reed      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:
1.8       lukem     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-
1.59    ! apb       122:                        tory.  The value is subjected to variable expansion by
        !           123:                        make(1).  Used only if MAKEOBJDIRPREFIX is not defined.
1.36      lukem     124:                        MAKEOBJDIR can only be provided in the environment or
1.41      lukem     125:                        via the -O flag of build.sh.
1.8       lukem     126:
                    127:      MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  If
1.59    ! apb       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
1.36      lukem     133:                        build.sh.
1.8       lukem     134:
1.1       tv        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:
1.9       thorpej   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:
1.1       tv        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,
1.59    ! apb       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.
1.1       tv        153:
                    154:                  Default: Empty string if USETOOLS is ``yes''; unset other-
                    155:                  wise.
                    156:
1.30      lukem     157:                  Note: build.sh will provide a default of destdir.MACHINE (in
                    158:                  the top-level .OBJDIR) unless run in `expert' mode
                    159:
1.1       tv        160:      MAKECONF    The name of the make(1) configuration file.  Only settable in
                    161:                  the process environment.
                    162:
                    163:                  Default: ``/etc/mk.conf''
                    164:
1.45      lukem     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:
1.1       tv        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.
1.44      lukem     185:                  Will not affect use of the standard low-security password
                    186:                  encryption system, crypt(3).
1.1       tv        187:
                    188:                  Default: ``yes''
                    189:
                    190:      MKDOC       Can be set to ``yes'' or ``no''.  Indicates whether system
1.44      lukem     191:                  documentation destined for DESTDIR/usr/share/doc will be
                    192:                  installed during a build.
1.1       tv        193:
                    194:                  Default: ``yes''
                    195:
1.4       tv        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:
1.1       tv        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
1.27      lukem     216:                  DESTDIR/usr/libdata/lint.
1.1       tv        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
1.44      lukem     226:                  Language System locale zone files will be compiled and
                    227:                  installed during a build.
1.1       tv        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)
1.44      lukem     248:                  format libraries (lib*_pic.a), used to generate shared
                    249:                  libraries, are installed during a build.
1.1       tv        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
1.44      lukem     262:                  destined to reside in DESTDIR/usr/share will be built and
                    263:                  installed during a build.  If set to ``no'', then all of
1.27      lukem     264:                  MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
                    265:                  ``no'' unconditionally.
1.1       tv        266:
                    267:                  Default: ``yes''
                    268:
1.50      wiz       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:
1.44      lukem     275:      MKUNPRIVED  Can be set to ``yes'' or ``no''.  Indicates whether an
                    276:                  unprivileged install will occur.  The user, group, permis-
1.52      jmc       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.
1.38      lukem     282:
                    283:                  Default: ``no''
                    284:
1.44      lukem     285:      MKUPDATE    Can be set to ``yes'' or ``no''.  Indicates whether all
                    286:                  install operations intended to write to DESTDIR will compare
1.38      lukem     287:                  file timestamps before installing, and skip the install phase
1.44      lukem     288:                  if the destination files are up-to-date.  This also has
                    289:                  implications on full builds (see next subsection).
1.38      lukem     290:
                    291:                  Default: ``no''
                    292:
1.49      lukem     293:      MKX11       Can be set to ``yes'' or ``no''.  Indicates whether X11R6 is
                    294:                  built from X11SRCDIR.
                    295:
                    296:                  Default: ``no''
                    297:
1.59    ! apb       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.
1.1       tv        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
1.44      lukem     328:                  preserve traditional semantics of the <bsd.*.mk> make(1)
                    329:                  include files).
1.1       tv        330:
1.59    ! apb       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.
1.49      lukem     334:
                    335:                  Default: ``/usr/xsrc''
                    336:
1.1       tv        337:    "make" variables for full builds
1.7       lukem     338:      These variables only affect the top level ``Makefile'' and do not affect
                    339:      manually building subtrees of the NetBSD source code.
1.1       tv        340:
1.20      lukem     341:      INSTALLWORLDDIR  Location for the ``make installworld'' target to install
1.59    ! apb       342:                       to.  If specified, must be an absolute path.
1.1       tv        343:
1.20      lukem     344:                       Default: ``/''
1.1       tv        345:
1.44      lukem     346:      MKOBJDIRS        Can be set to ``yes'' or ``no''.  Indicates whether
                    347:                       object directories will be created automatically (via a
1.20      lukem     348:                       ``make obj'' pass) at the start of a build.
1.1       tv        349:
1.34      lukem     350:                       Default: ``no''
1.1       tv        351:
1.38      lukem     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:
1.20      lukem     359:      NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead (see
                    360:                       below)
1.1       tv        361:
1.20      lukem     362:                       Default: Unset.
1.1       tv        363:
1.20      lukem     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.
1.1       tv        368:
1.20      lukem     369:                       Default: Unset.
1.1       tv        370:
1.20      lukem     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.
1.1       tv        376:
1.20      lukem     377:                       Default: Unset.
1.1       tv        378:
1.20      lukem     379:      NOINCLUDES       If set, avoids the ``make includes'' phase of a full
                    380:                       build.  This has the effect of preventing make(1) from
1.44      lukem     381:                       thinking that some programs are out-of-date simply
                    382:                       because the system include files have changed.  However,
1.20      lukem     383:                       this option should not be used when updating the entire
                    384:                       NetBSD source tree arbitrarily; it is suggested to use
1.38      lukem     385:                       MKUPDATE=yes in that case.
1.1       tv        386:
1.20      lukem     387:                       Default: Unset.
1.1       tv        388:
1.20      lukem     389:      RELEASEDIR       If set, specifies the directory to which a release(7)
                    390:                       layout will be written at the end of a ``make release''.
1.59    ! apb       391:                       If specified, must be an absolute path.
1.20      lukem     392:
                    393:                       Default: Unset.
                    394:
1.30      lukem     395:                       Note: build.sh will provide a default of releasedir (in
                    396:                       the top-level .OBJDIR) unless run in `expert' mode
                    397:
1.1       tv        398: BUILDING
                    399:    "make" command line options
1.52      jmc       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.
1.1       tv        402:
1.10      sommerfe  403:      -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
1.52      jmc       404:                 use .WAIT or have explicit dependencies as necessary to
1.44      lukem     405:                 enforce build ordering.  If you see build failures with -j,
1.10      sommerfe  406:                 please save complete build logs so the failures can be ana-
                    407:                 lyzed.
                    408:
1.1       tv        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:
1.47      zuntum    419:      -V var     Print make(1)'s idea of the value of var.  Does not build any
1.1       tv        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:
1.44      lukem     436:      cleandir   Same as clean, but also remove preformatted documentation,
                    437:                 dependency files generated by ``make depend'', and any other
1.49      lukem     438:                 files known to be created at build time.
1.1       tv        439:
1.44      lukem     440:      depend     Create dependency files (.depend) containing more detailed
                    441:                 information about the dependencies of source code on header
1.1       tv        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''.
1.10      sommerfe  446:                 This improves cache locality of the build since both passes
                    447:                 read the source files in their entirety.
1.1       tv        448:
1.49      lukem     449:      distclean  Synonym for cleandir.
                    450:
1.44      lukem     451:      includes   Build and install system header files.  Typically needed
                    452:                 before any system libraries or programs can be built.
1.1       tv        453:
                    454:      install    Install programs, libraries, and documentation into DESTDIR.
1.27      lukem     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.
1.1       tv        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:
1.20      lukem     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
1.27      lukem     477:                    into DESTDIR, including files in DESTDIR/dev, DESTDIR/etc,
                    478:                    DESTDIR/root and DESTDIR/var.
1.20      lukem     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
1.52      jmc       485:                    INSTALLWORLDDIR is not the root directory if cross compil-
1.20      lukem     486:                    ing.
                    487:
                    488:                    Note: It is highly recommended that you upgrade your kernel
                    489:                    and reboot before performing this operation.
                    490:
1.25      lukem     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:
1.31      lukem     496:      sourcesets    Create source sets of the source tree into
                    497:                    RELEASEDIR/source/sets.
                    498:
1.54      apb       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:
1.44      lukem     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
1.25      lukem     508:                    set (see above).
1.1       tv        509:
1.56      apb       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
1.57      apb       515:                    pkgsrc/sysutils/cdrtools.
1.56      apb       516:
1.1       tv        517:      regression-tests
1.20      lukem     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.
1.1       tv        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:
1.22      lukem     539:      The following operations are supported by build.sh:
                    540:
1.44      lukem     541:      build         Build the system as per ``make build''.  This option
                    542:                    implies the obj and tools operations.
1.22      lukem     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:
1.23      lukem     550:      makewrapper   Create the nbmake-MACHINE wrapper.  This operation is auto-
                    551:                    matically performed for any of the other operations.
                    552:
1.22      lukem     553:      obj           Perform ``make obj''.
                    554:
                    555:      tools         Build and install the host tools from src/tools.
                    556:
1.35      lukem     557:      install=idir  Install the contents of DESTDIR to idir, using ``make
                    558:                    installworld''.
                    559:
1.22      lukem     560:      kernel=kconf  Build a new kernel.  The kconf argument is the name of a
1.54      apb       561:                    configuration file suitable for use by config(1).  If kconf
1.22      lukem     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:
1.35      lukem     571:      releasekernel=kconf
                    572:                    Install a gzip(1)ed copy of the kernel built by
                    573:                    kernel=kconf into RELEASEDIR/MACHINE/binary/kernel, usually
1.44      lukem     574:                    as netbsd-kconf.gz, although the ``netbsd'' prefix is
                    575:                    determined from the ``config'' directives in kconf.
1.24      lukem     576:
                    577:      sets          Perform ``make sets''.
1.31      lukem     578:
                    579:      sourcesets    Perform ``make sourcesets''.
1.22      lukem     580:
1.54      apb       581:      syspkgs       Perform ``make syspkgs''.
                    582:
1.56      apb       583:      iso-image     Perform ``make iso-image''.
                    584:
1.51      wiz       585:      The following command line options alter the behaviour of the build.sh
                    586:      operations described above:
1.1       tv        587:
                    588:      -a arch   Set the value of MACHINE_ARCH to arch.
1.9       thorpej   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
1.37      lukem     593:                that the resulting name is of the form
                    594:                ``nbmake-MACHINE-BUILDID''.
1.1       tv        595:
1.59    ! apb       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.
1.18      lukem     599:
1.23      lukem     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
1.38      lukem     602:                builds, and MKUNPRIVED=yes does not have to be set when build-
                    603:                ing as a non-root user.
1.23      lukem     604:
                    605:                Note: It is highly recommended that you know what you are doing
                    606:                when you use this option.
1.19      lukem     607:
1.51      wiz       608:      -h        Print a help message.
                    609:
1.10      sommerfe  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.
1.1       tv        614:
1.59    ! apb       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.
1.18      lukem     618:
1.1       tv        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
1.33      lukem     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
1.1       tv        640:
1.45      lukem     641:      -N noiselevel
1.46      lukem     642:                Set the ``noisyness'' level of the build, by setting
                    643:                MAKEVERBOSE to noiselevel.
1.45      lukem     644:
1.1       tv        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:
1.18      lukem     649:      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
1.59    ! apb       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.
1.18      lukem     655:
1.34      lukem     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).
1.1       tv        659:
1.59    ! apb       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.
1.18      lukem     663:
1.1       tv        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:
1.59    ! apb       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).
1.18      lukem     672:
1.38      lukem     673:      -U        Set MKUNPRIVED=yes.
1.18      lukem     674:
1.38      lukem     675:      -u        Set MKUPDATE=yes.
1.1       tv        676:
1.21      lukem     677:      -V var=[value]
1.40      lukem     678:                Set the environment variable var to an optional value.  This is
                    679:                propagated to the nbmake wrapper.
1.21      lukem     680:
1.1       tv        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
1.59    ! apb       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.
1.1       tv        688:
1.49      lukem     689:      -X x11src
1.59    ! apb       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.
1.49      lukem     693:
                    694:      -x        Set MKX11=yes.
                    695:
1.40      lukem     696:      -Z var    Unset ("zap") the environment variable var.  This is propagated
                    697:                to the nbmake wrapper.
                    698:
1.1       tv        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.
1.40      lukem     707:      build.sh will also set variables specified with -V, and unset variables
                    708:      specified with -Z.
                    709:
1.1       tv        710:      This script can be symlinked into a directory listed in PATH, or called
                    711:      with an absolute path.
                    712:
1.16      lukem     713: EXAMPLES
1.44      lukem     714:      1.   % ./build.sh tools kernel=GENERIC
1.28      lukem     715:
                    716:           Build a new toolchain, and use the new toolchain to configure and
                    717:           build a new GENERIC kernel.
                    718:
1.44      lukem     719:      2.   % ./build.sh -U distribution
1.28      lukem     720:
1.30      lukem     721:           Using unprivileged mode, build a complete distribution to a DESTDIR
                    722:           directory that build.sh selects (and will display).
1.28      lukem     723:
1.43      martti    724:      3.   # ./build.sh -U install=/
1.28      lukem     725:
1.29      lukem     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-
1.30      lukem     728:           sions stored in DESTDIR/METALOG are correctly applied to the files
                    729:           as they're copied to /.
1.28      lukem     730:
1.44      lukem     731:      4.   % ./build.sh -U -u release
1.28      lukem     732:
1.30      lukem     733:           Using unprivileged mode, build a complete release to DESTDIR and
                    734:           RELEASEDIR directories that build.sh selects (and will display).
1.38      lukem     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.
1.16      lukem     738:
1.10      sommerfe  739: OBSOLETE VARIABLES
1.15      lukem     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.
1.10      sommerfe  745:
1.1       tv        746: SEE ALSO
1.57      apb       747:      make(1), hier(7), release(7), pkgsrc/sysutils/cdrtools
1.1       tv        748:
                    749: HISTORY
1.15      lukem     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.
1.1       tv        752:
                    753: BUGS
1.15      lukem     754:      A few platforms are not yet using this build system.
1.1       tv        755:
1.55      wiz       756: NetBSD                          January 4, 2006                         NetBSD

CVSweb <webmaster@jp.NetBSD.org>