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

Annotation of src/BUILDING, Revision 1.58

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

CVSweb <webmaster@jp.NetBSD.org>