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

Annotation of src/BUILDING, Revision 1.73

1.1       tv          1: BUILDING(8)             NetBSD System Manager's Manual             BUILDING(8)
                      3: NAME
1.52      jmc         4:      BUILDING -- Procedure for building NetBSD from source code.
1.1       tv          5:
                      6: REQUIREMENTS
                      7:      NetBSD is designed to be buildable on most POSIX-compliant host systems.
                      8:      The basic build procedure is the same whether compiling natively (on the
                      9:      same NetBSD architecture) or cross compiling (on another architecture or
                     10:      OS).
                     12:      This source tree contains a special subtree, ``tools'', which uses the
                     13:      host system to create a build toolchain for the target architecture.  The
                     14:      host system must have at least C and C++ compilers in order to create the
                     15:      toolchain (make is not required); all other tools are created as part of
1.53      reed       16:      the NetBSD build process.  (See the environment variables section below
                     17:      if you need to override or manually select your compilers.)
1.1       tv         18:
                     19: FILES
                     20:    Source tree layout
1.17      wiz        21:      doc/BUILDING.mdoc
                     22:                     This document (in -mdoc troff format; the original copy).
1.1       tv         23:
1.2       wiz        24:      BUILDING       This document (in plaintext).
1.1       tv         25:
1.48      jmc        26:      tools/compat/README
                     27:                     Special notes for cross-hosting a NetBSD build on non-
                     28:                     NetBSD platforms.
1.44      lukem      30:      Makefile       The main Makefile for NetBSD; should only be run for
                     31:                     native builds with an appropriately up-to-date version of
1.1       tv         32:                     NetBSD make(1).  (For building from out-of-date systems or
                     33:                     on a non-native host, see the build.sh shell script.)
                     35:      UPDATING       Special notes for updating from an earlier revision of
                     36:                     NetBSD.  It is important to read this file before every
                     37:                     build of an updated source tree.
                     39:      build.sh       Bourne-compatible shell script used for building the host
                     40:                     build tools and the NetBSD system from scratch.  Can be
                     41:                     used for both native and cross builds, and should be used
                     42:                     instead of make(1) for any source tree that is updated and
                     43:                     recompiled regularly.
                     45:      crypto/dist/, dist/, gnu/dist/
                     46:                     Sources imported verbatim from third parties, without man-
                     47:                     gling the existing build structure.  Other source trees in
                     48:                     bin through usr.sbin use the NetBSD make(1) ``reachover''
1.44      lukem      49:                     Makefile semantics when building these programs for a
                     50:                     native host.
1.1       tv         51:
                     52:      distrib/, etc/
                     53:                     Sources for items used when making a full release snap-
1.27      lukem      54:                     shot, such as files installed in DESTDIR/etc on the desti-
                     55:                     nation system, boot media, and release notes.
1.1       tv         56:
1.70      dholland   57:      tests/, regress/
                     58:                     Regression test harness.  Can be cross-compiled, but only
                     59:                     run natively.  tests/ uses the atf(7) test framework;
                     60:                     regress/ contains older tests that have not yet been
                     61:                     migrated to atf(7).
1.1       tv         62:
                     63:      sys/           NetBSD kernel sources.
                     65:      tools/         ``Reachover'' build structure for the host build tools.
                     66:                     This has a special method of determining out-of-date sta-
                     67:                     tus.
                     69:      bin/ ... usr.sbin/
                     70:                     Sources to the NetBSD userland (non-kernel) programs.  If
                     71:                     any of these directories are missing, they will be skipped
                     72:                     during the build.
1.49      lukem      74:      x11/           ``Reachover'' build structure for X11R6; the source is in
                     75:                     X11SRCDIR.
1.1       tv         77:    Build tree layout
                     78:      The NetBSD build tree is described in hier(7), and the release layout is
                     79:      described in release(7).
                     81: CONFIGURATION
1.8       lukem      82:    Environment variables
                     83:      Several environment variables control the behaviour of NetBSD builds.
1.58      apb        85:      HOST_SH           Path name to a POSIX-compliant shell.  If this is not
                     86:                        set explicitly, then the default is set using heuris-
                     87:                        tics dependent on the host platform, or from the shell
                     88:                        under which build.sh is executed (if that can be deter-
                     89:                        mined), or using the first copy of sh found in PATH.
                     90:                        If the host system's /bin/sh is not POSIX-compliant, we
                     91:                        suggest that you build using commands like
                     93:                              HOST_SH=/path/to/working/shell
                     94:                              export HOST_SH
                     95:                              ${HOST_SH} build.sh [options]
1.53      reed       97:      HOST_CC           Path name to C compiler used to create the toolchain.
                     99:      HOST_CXX          Path name to C++ compiler used to create the toolchain.
1.70      dholland  101:      MACHINE           Machine type, e.g., ``macppc''.
1.8       lukem     102:
1.70      dholland  103:      MACHINE_ARCH      Machine architecture, e.g., ``powerpc''.
1.8       lukem     104:
                    105:      MAKE              Path name to invoke make(1) as.
                    107:      MAKEFLAGS         Flags to invoke make(1) with.
                    109:      MAKEOBJDIR        Directory to use as the .OBJDIR for the current direc-
1.59      apb       110:                        tory.  The value is subjected to variable expansion by
1.73    ! apb       111:                        make(1).  Typical usage is to set this variable to a
        !           112:                        value involving the use of `${.CURDIR:S...}' or
        !           113:                        `${.CURDIR:C...}', to derive the value of .OBJDIR from
        !           114:                        the value of .CURDIR.  Used only if MAKEOBJDIRPREFIX is
        !           115:                        not defined.  MAKEOBJDIR can be provided only in the
        !           116:                        environment or via the -O flag of build.sh; it cannot
        !           117:                        usefully be set inside a Makefile.
1.8       lukem     118:
                    119:      MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  If
1.59      apb       120:                        specified, must be an absolute path.  If this is
                    121:                        defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the
                    122:                        .OBJDIR for the current directory.  The current direc-
1.73    ! apb       123:                        tory may be read only.  MAKEOBJDIRPREFIX can be pro-
        !           124:                        vided only in the environment or via the -M flag of
        !           125:                        build.sh; it cannot usefully be set inside a Makefile.
1.8       lukem     126:
1.1       tv        127:    "make" variables
                    128:      Several variables control the behavior of NetBSD builds.  Unless other-
                    129:      wise specified, these variables may be set in either the process environ-
                    130:      ment or the make(1) configuration file specified by MAKECONF.
1.9       thorpej   132:      BUILDID     Identifier for the build.  The identifier will be appended to
                    133:                  object directory names, and can be consulted in the make(1)
                    134:                  configuration file in order to set additional build parame-
                    135:                  ters, such as compiler flags.
1.72      perry     137:      BUILDSEED   GCC uses random numbers when compiling C++ code.  This vari-
                    138:                  able seeds the gcc random number generator using the -fran-
                    139:                  dom-seed flag with this value.  By default, it is set to
                    140:                  NetBSD-(majorversion).  Using a fixed value causes C++ bina-
                    141:                  ries to be the same when built from the same sources.  Addi-
                    142:                  tional information is available in the GCC documentation of
                    143:                  -frandom-seed.
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.
1.30      lukem     157:                  Note: build.sh will provide a default of destdir.MACHINE (in
1.70      dholland  158:                  the top-level .OBJDIR) unless run in `expert' mode.
1.30      lukem     159:
1.1       tv        160:      MAKECONF    The name of the make(1) configuration file.  Only settable in
                    161:                  the process environment.
                    163:                  Default: ``/etc/mk.conf''
1.45      lukem     165:      MAKEVERBOSE
                    166:                  Level of verbosity of status messages.  Supported values:
                    168:                  0    No descriptive messages are shown.
                    170:                  1    Descriptive messages are shown.
                    172:                  2    Descriptive messages (prefixed with a `#') and command
                    173:                       output is not suppressed.
                    175:                  Default: 2
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.
                    180:                  Default: ``yes''
                    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''
                    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''
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.
                    205:                  Default: ``no''
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.
                    211:                  Default: ``yes''
                    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''
                    220:      MKMAN       Can be set to ``yes'' or ``no''.  Indicates whether manual
                    221:                  pages will be installed during a build.
                    223:                  Default: ``yes''
                    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''
                    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.
                    236:                  Default: ``yes''
1.70      dholland  238:                  Note that setting MKOBJ to ``no'' is not recommended and may
                    239:                  cause problems when updating the tree with cvs(1).
1.1       tv        241:      MKPIC       Can be set to ``yes'' or ``no''.  Indicates whether shared
                    242:                  objects and libraries will be created and installed during a
                    243:                  build.  If set to ``no'', the entire built system will be
                    244:                  statically linked.
                    246:                  Default: Platform dependent.  As of this writing, all plat-
                    247:                  forms except sh3 default to ``yes''.
                    249:      MKPICINSTALL
                    250:                  Can be set to ``yes'' or ``no''.  Indicates whether the ar(1)
1.44      lukem     251:                  format libraries (lib*_pic.a), used to generate shared
                    252:                  libraries, are installed during a build.
1.1       tv        253:
                    254:                  Default: ``yes''
                    256:      MKPROFILE   Can be set to ``yes'' or ``no''.  Indicates whether profiled
                    257:                  libraries (lib*_p.a) will be built and installed during a
                    258:                  build.
                    260:                  Default: ``yes''; however, some platforms turn off MKPROFILE
                    261:                  by default at times due to toolchain problems with profiled
                    262:                  code.
                    264:      MKSHARE     Can be set to ``yes'' or ``no''.  Indicates whether files
1.44      lukem     265:                  destined to reside in DESTDIR/usr/share will be built and
                    266:                  installed during a build.  If set to ``no'', then all of
1.27      lukem     267:                  MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
                    268:                  ``no'' unconditionally.
1.1       tv        269:
                    270:                  Default: ``yes''
1.50      wiz       272:      MKTTINTERP  Can be set to ``yes'' or ``no''.  For X builds, decides if
                    273:                  the TrueType bytecode interpreter is turned on.  See
                    274:                  http://www.freetype.org/patents.html for details.
                    276:                  Default: ``no''
1.44      lukem     278:      MKUNPRIVED  Can be set to ``yes'' or ``no''.  Indicates whether an
                    279:                  unprivileged install will occur.  The user, group, permis-
1.52      jmc       280:                  sions, and file flags, will not be set on the installed
                    281:                  items; instead the information will be appended to a file
                    282:                  called METALOG in DESTDIR.  The contents of METALOG are used
                    283:                  during the generation of the distribution tar files to ensure
                    284:                  that the appropriate file ownership is stored.
1.38      lukem     285:
                    286:                  Default: ``no''
1.44      lukem     288:      MKUPDATE    Can be set to ``yes'' or ``no''.  Indicates whether all
                    289:                  install operations intended to write to DESTDIR will compare
1.38      lukem     290:                  file timestamps before installing, and skip the install phase
1.44      lukem     291:                  if the destination files are up-to-date.  This also has
                    292:                  implications on full builds (see next subsection).
1.38      lukem     293:
                    294:                  Default: ``no''
1.49      lukem     296:      MKX11       Can be set to ``yes'' or ``no''.  Indicates whether X11R6 is
                    297:                  built from X11SRCDIR.
                    299:                  Default: ``no''
1.59      apb       301:      TOOLDIR     Directory to hold the host tools, once built.  If specified,
                    302:                  must be an absolute path.  This directory should be unique to
                    303:                  a given host system and NetBSD source tree.  (However, multi-
                    304:                  ple targets may share the same TOOLDIR; the target-dependent
                    305:                  files have unique names.)  If unset, a default based on the
                    306:                  uname(1) information of the host platform will be created in
                    307:                  the .OBJDIR of src.
1.1       tv        308:
                    309:                  Default: Unset.
                    311:      USETOOLS    Indicates whether the tools specified by TOOLDIR should be
                    312:                  used as part of a build in progress.  Must be set to ``yes''
                    313:                  if cross-compiling.
                    315:                  yes    Use the tools from TOOLDIR.
                    317:                  no     Do not use the tools from TOOLDIR, but refuse to build
                    318:                         native compilation tool components that are version-
                    319:                         specific for that tool.
                    321:                  never  Do not use the tools from TOOLDIR, even when building
                    322:                         native tool components.  This is similar to the tradi-
                    323:                         tional NetBSD build method, but does not verify that
                    324:                         the compilation tools in use are up-to-date enough in
                    325:                         order to build the tree successfully.  This may cause
                    326:                         build or runtime problems when building the whole
                    327:                         NetBSD source tree.
1.71      dholland  329:                  Default: ``yes'', unless TOOLCHAIN_MISSING is set to ``yes''.
                    331:                  USETOOLS is also set to ``no'' when using <bsd.*.mk> outside
                    332:                  the NetBSD source tree.
1.1       tv        333:
1.59      apb       334:      X11SRCDIR   Directory containing the X11R6 source.  If specified, must be
                    335:                  an absolute path.  The main X11R6 source is found in
                    336:                  X11SRCDIR/xfree/xc.
1.49      lukem     337:
                    338:                  Default: ``/usr/xsrc''
1.1       tv        340:    "make" variables for full builds
1.7       lukem     341:      These variables only affect the top level ``Makefile'' and do not affect
                    342:      manually building subtrees of the NetBSD source code.
1.1       tv        343:
1.20      lukem     344:      INSTALLWORLDDIR  Location for the ``make installworld'' target to install
1.59      apb       345:                       to.  If specified, must be an absolute path.
1.1       tv        346:
1.20      lukem     347:                       Default: ``/''
1.1       tv        348:
1.44      lukem     349:      MKOBJDIRS        Can be set to ``yes'' or ``no''.  Indicates whether
                    350:                       object directories will be created automatically (via a
1.20      lukem     351:                       ``make obj'' pass) at the start of a build.
1.1       tv        352:
1.34      lukem     353:                       Default: ``no''
1.1       tv        354:
1.70      dholland  355:                       If using build.sh, the default is ``yes''.  This may be
                    356:                       set back to ``no'' by giving build.sh the -o option.
1.38      lukem     358:      MKUPDATE         Can be set to ``yes'' or ``no''.  If set, then in addi-
                    359:                       tion to the effects described for MKUPDATE=yes above,
                    360:                       this implies the effects of NOCLEANDIR (i.e., ``make
                    361:                       cleandir'' is avoided).
                    363:                       Default: ``no''
1.70      dholland  365:                       If using build.sh, this may be set by giving the -u
                    366:                       option.
                    368:      NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead.  See
                    369:                       below.
1.1       tv        370:
1.20      lukem     371:                       Default: Unset.
1.1       tv        372:
1.20      lukem     373:      NOCLEANDIR       If set, avoids the ``make cleandir'' phase of a full
                    374:                       build.  This has the effect of allowing only changed
                    375:                       files in a source tree to be recompiled.  This can speed
                    376:                       up builds when updating only a few files in the tree.
1.1       tv        377:
1.20      lukem     378:                       Default: Unset.
1.1       tv        379:
1.70      dholland  380:                       See also MKUPDATE.
1.20      lukem     382:      NODISTRIBDIRS    If set, avoids the ``make distrib-dirs'' phase of a full
                    383:                       build.  This skips running mtree(8) on DESTDIR, useful
                    384:                       on systems where building as an unprivileged user, or
                    385:                       where it is known that the system-wide mtree files have
                    386:                       not changed.
1.1       tv        387:
1.20      lukem     388:                       Default: Unset.
1.1       tv        389:
1.20      lukem     390:      NOINCLUDES       If set, avoids the ``make includes'' phase of a full
                    391:                       build.  This has the effect of preventing make(1) from
1.44      lukem     392:                       thinking that some programs are out-of-date simply
                    393:                       because the system include files have changed.  However,
1.20      lukem     394:                       this option should not be used when updating the entire
                    395:                       NetBSD source tree arbitrarily; it is suggested to use
1.70      dholland  396:                       MKUPDATE=yes instead in that case.
1.1       tv        397:
1.20      lukem     398:                       Default: Unset.
1.1       tv        399:
1.20      lukem     400:      RELEASEDIR       If set, specifies the directory to which a release(7)
                    401:                       layout will be written at the end of a ``make release''.
1.59      apb       402:                       If specified, must be an absolute path.
1.20      lukem     403:
                    404:                       Default: Unset.
1.30      lukem     406:                       Note: build.sh will provide a default of releasedir (in
1.70      dholland  407:                       the top-level .OBJDIR) unless run in `expert' mode.
1.30      lukem     408:
1.1       tv        409: BUILDING
                    410:    "make" command line options
1.52      jmc       411:      This is not a summary of all the options available to make(1); only the
                    412:      options used most frequently with NetBSD builds are listed here.
1.1       tv        413:
1.10      sommerfe  414:      -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
1.52      jmc       415:                 use .WAIT or have explicit dependencies as necessary to
1.44      lukem     416:                 enforce build ordering.  If you see build failures with -j,
1.10      sommerfe  417:                 please save complete build logs so the failures can be ana-
                    418:                 lyzed.
1.1       tv        420:      -m dir     Specify the default directory for searching for system Make-
                    421:                 file segments, mainly the <bsd.*.mk> files.  When building any
                    422:                 full NetBSD source tree, this should be set to the
1.70      dholland  423:                 ``share/mk'' directory in the source tree.  This is set auto-
                    424:                 matically when building from the top level, or when using
                    425:                 build.sh.
1.1       tv        426:
                    427:      -n         Display the commands that would have been executed, but do not
                    428:                 actually execute them.  This will still cause recursion to
                    429:                 take place.
1.47      zuntum    431:      -V var     Print make(1)'s idea of the value of var.  Does not build any
1.1       tv        432:                 targets.
                    434:      var=value  Set the variable var to value, overriding any setting speci-
                    435:                 fied by the process environment, the MAKECONF configuration
                    436:                 file, or the system Makefile segments.
                    438:    "make" targets
                    439:      These default targets may be built by running make(1) in any subtree of
                    440:      the NetBSD source code.  It is recommended that none of these be used
                    441:      from the top level Makefile; as a specific exception, ``make obj'' and
                    442:      ``make cleandir'' are useful in that context.
                    444:      all        Build programs, libraries, and preformatted documentation.
                    446:      clean      Remove program and library object code files.
1.44      lukem     448:      cleandir   Same as clean, but also remove preformatted documentation,
                    449:                 dependency files generated by ``make depend'', and any other
1.49      lukem     450:                 files known to be created at build time.
1.1       tv        451:
1.44      lukem     452:      depend     Create dependency files (.depend) containing more detailed
                    453:                 information about the dependencies of source code on header
1.1       tv        454:                 files.  Allows programs to be recompiled automatically when a
                    455:                 dependency changes.
                    457:      dependall  Does a ``make depend'' immediately followed by a ``make all''.
1.10      sommerfe  458:                 This improves cache locality of the build since both passes
                    459:                 read the source files in their entirety.
1.1       tv        460:
1.49      lukem     461:      distclean  Synonym for cleandir.
1.44      lukem     463:      includes   Build and install system header files.  Typically needed
                    464:                 before any system libraries or programs can be built.
1.1       tv        465:
                    466:      install    Install programs, libraries, and documentation into DESTDIR.
1.27      lukem     467:                 Few files will be installed to DESTDIR/dev, DESTDIR/etc,
                    468:                 DESTDIR/root or DESTDIR/var in order to prevent user supplied
                    469:                 configuration data from being overwritten.
1.1       tv        470:
                    471:      lint       Run lint(1) against the C source code, where appropriate, and
                    472:                 generate system-installed lint libraries.
                    474:      obj        Create object directories to be used for built files, instead
                    475:                 of building directly in the source tree.
                    477:      tags       Create ctags(1) searchable function lists usable by the ex(1)
                    478:                 and vi(1) text editors.
                    480:    "make" targets for the top level
                    481:      Additional make(1) targets are usable specifically from the top source
                    482:      level to facilitate building the entire NetBSD source tree.
1.68      reed      484:      build         Build the entire NetBSD system (except the kernel).  This
                    485:                    orders portions of the source tree such that prerequisites
                    486:                    will be built in the proper order.
1.20      lukem     487:
                    488:      distribution  Do a ``make build'', and then install a full distribution
1.68      reed      489:                    (which does not include a kernel) into DESTDIR, including
                    490:                    files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
                    491:                    DESTDIR/var.
1.20      lukem     492:
                    493:      buildworld    As per ``make distribution'', except that it ensures that
                    494:                    DESTDIR is not the root directory.
1.70      dholland  496:      installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR,
                    497:                    which defaults to the root directory.  Ensures that
1.52      jmc       498:                    INSTALLWORLDDIR is not the root directory if cross compil-
1.20      lukem     499:                    ing.
1.61      apb       501:                    The INSTALLSETS environment variable may be set to a list
                    502:                    of distribution sets to be installed.  By default, all sets
1.70      dholland  503:                    except ``etc'' and ``xetc'' are installed, so most files in
                    504:                    INSTALLWORLDDIR/etc will not be installed or modified.
1.61      apb       505:
                    506:                    Note: Before performing this operation with
                    507:                    INSTALLWORLDDIR=/, it is highly recommended that you
                    508:                    upgrade your kernel and reboot.  After performing this
                    509:                    operation, it is recommended that you use etcupdate(8) to
                    510:                    update files in INSTALLWORLDDIR/etc and that you use
                    511:                    postinstall(8) to check for inconsistencies (and possibly
                    512:                    to fix them).
1.20      lukem     513:
1.25      lukem     514:      sets          Create distribution sets from DESTDIR into
1.69      lukem     515:                    RELEASEDIR/RELEASEMACHINEDIR/binary/sets.  Should be run
1.70      dholland  516:                    after ``make distribution'', as ``make build'' alone does
                    517:                    not install all of the required files.
1.25      lukem     518:
1.31      lukem     519:      sourcesets    Create source sets of the source tree into
                    520:                    RELEASEDIR/source/sets.
1.54      apb       522:      syspkgs       Create syspkgs from DESTDIR into
1.69      lukem     523:                    RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.  Should be run
1.70      dholland  524:                    after ``make distribution'', as ``make build'' alone does
                    525:                    not install all of the required files.
1.54      apb       526:
1.44      lukem     527:      release       Do a ``make distribution'', build kernels, distribution
                    528:                    media, and install sets (this as per ``make sets''), and
                    529:                    then package the system into a standard release layout as
                    530:                    described by release(7).  This requires that RELEASEDIR be
1.25      lukem     531:                    set (see above).
1.1       tv        532:
1.62      apb       533:      iso-image     Create a NetBSD installation CD-ROM image in the
                    534:                    RELEASEDIR/iso directory.  The CD-ROM file system will have
                    535:                    a layout as described in release(7).
                    537:                    For most machine types, the CD-ROM will be bootable, and
                    538:                    will automatically run the sysinst(8) menu-based installa-
                    539:                    tion program, which can be used to install or upgrade a
                    540:                    NetBSD system.  Bootable CD-ROMs also contain tools that
                    541:                    may be useful in repairing a damaged NetBSD installation.
                    543:                    Before ``make iso-image'' is attempted, RELEASEDIR must be
                    544:                    populated by ``make release'' or equivalent.
                    546:                    Note that other, smaller, CD-ROM images may be created in
1.69      lukem     547:                    the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
                    548:                    tory by ``make release''.  These smaller images usually
                    549:                    contain the same tools as the larger images in
                    550:                    RELEASEDIR/iso, but do not contain additional content such
                    551:                    as the distribution sets.
1.62      apb       552:
                    553:                    Note that the mac68k port still uses an older method of
                    554:                    creating CD-ROM images.  This requires the mkisofs(1) util-
                    555:                    ity, which is not part of NetBSD, but which can be
                    556:                    installed from pkgsrc/sysutils/cdrtools.
1.56      apb       557:
1.64      jnemeth   558:      iso-image-source
                    559:                    Create a NetBSD installation CD-ROM image in the
                    560:                    RELEASEDIR/iso directory.  The CD-ROM file system will have
                    561:                    a layout as described in release(7).  It will have top
                    562:                    level directories for the machine type and source.
                    564:                    For most machine types, the CD-ROM will be bootable, and
                    565:                    will automatically run the sysinst(8) menu-based installa-
                    566:                    tion program, which can be used to install or upgrade a
                    567:                    NetBSD system.  Bootable CD-ROMs also contain tools that
                    568:                    may be useful in repairing a damaged NetBSD installation.
                    570:                    Before ``make iso-image-source'' is attempted, RELEASEDIR
                    571:                    must be populated by ``make sourcesets release'' or equiva-
                    572:                    lent.
                    574:                    Note that other, smaller, CD-ROM images may be created in
1.69      lukem     575:                    the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
                    576:                    tory by ``make release''.  These smaller images usually
                    577:                    contain the same tools as the larger images in
                    578:                    RELEASEDIR/iso, but do not contain additional content such
                    579:                    as the distribution sets.
1.64      jnemeth   580:
                    581:                    Note that the mac68k port still uses an older method of
                    582:                    creating CD-ROM images.  This requires the mkisofs(1) util-
                    583:                    ity, which is not part of NetBSD, but which can be
                    584:                    installed from pkgsrc/sysutils/cdrtools.
1.1       tv        586:      regression-tests
1.20      lukem     587:                    Can only be run after building the regression tests in the
1.70      dholland  588:                    directory ``regress''.  Runs those compiled regression
                    589:                    tests on the local host.  Note that most tests are now man-
                    590:                    aged instead using atf(7); this target should probably run
                    591:                    those as well but currently does not.
1.1       tv        592:
                    593:    The "build.sh" script
                    594:      This script file is a Bourne shell script designed to build the entire
                    595:      NetBSD system on any host with a Bourne shell in /bin/sh, including many
                    596:      that are not POSIX compliant.  Note that if a host system's /bin/sh is
                    597:      unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
                    598:      a usable alternative.
                    600:      All cross-compile builds, and most native builds, of the entire system
                    601:      should make use of build.sh rather than just running ``make''.  This way,
                    602:      the make(1) program will be bootstrapped properly, in case the host sys-
                    603:      tem has an older or incompatible ``make'' program.
                    605:      When compiling the entire system via build.sh, many make(1) variables are
                    606:      set for you in order to help encapsulate the build process.  In the list
                    607:      of options below, variables that are automatically set by build.sh are
                    608:      noted where applicable.
1.22      lukem     610:      The following operations are supported by build.sh:
1.70      dholland  612:      build         Build the system as per ``make build''.  Before the main
                    613:                    part of the build commences, this command runs the obj
                    614:                    operation (unless the -o option is given), ``make
                    615:                    cleandir'' (unless the -u option is given), and the tools
                    616:                    operation.
1.22      lukem     617:
                    618:      distribution  Build a full distribution as per ``make distribution''.
1.70      dholland  619:                    This command first runs the build operation.
1.22      lukem     620:
1.70      dholland  621:      release       Build a full release as per ``make release''.  This command
                    622:                    first runs the distribution operation.
1.22      lukem     623:
1.23      lukem     624:      makewrapper   Create the nbmake-MACHINE wrapper.  This operation is auto-
                    625:                    matically performed for any of the other operations.
1.22      lukem     627:      obj           Perform ``make obj''.
1.70      dholland  629:      tools         Build and install the host tools from src/tools.  This com-
                    630:                    mand will first run ``make obj'' and ``make cleandir'' in
                    631:                    the tools subdirectory unless the -o or -u options (respec-
                    632:                    tively) are given.
1.22      lukem     633:
1.35      lukem     634:      install=idir  Install the contents of DESTDIR to idir, using ``make
1.61      apb       635:                    installworld''.  Note that files that are part of the
                    636:                    ``etc'' or ``xetc'' sets will not be installed.
1.35      lukem     637:
1.22      lukem     638:      kernel=kconf  Build a new kernel.  The kconf argument is the name of a
1.54      apb       639:                    configuration file suitable for use by config(1).  If kconf
1.22      lukem     640:                    does not contain any `/' characters, the configuration file
                    641:                    is expected to be found in the KERNCONFDIR directory, which
                    642:                    is typically sys/arch/MACHINE/conf.  The new kernel will be
                    643:                    built in a subdirectory of KERNOBJDIR, which is typically
                    644:                    sys/arch/MACHINE/compile or an associated object directory.
1.70      dholland  645:
                    646:                    This command does not imply the tools command; run the
                    647:                    tools command first unless it is certain that the tools
                    648:                    already exist and are up to date.
                    650:                    This command will run ``make cleandir'' on the kernel in
                    651:                    question first unless the -u option is given.
1.22      lukem     652:
1.35      lukem     653:      releasekernel=kconf
1.70      dholland  654:                    Install a gzip(1)ed copy of the kernel previously built by
1.69      lukem     655:                    kernel=kconf into
                    656:                    RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
                    657:                    netbsd-kconf.gz, although the ``netbsd'' prefix is deter-
                    658:                    mined from the ``config'' directives in kconf.
1.24      lukem     659:
                    660:      sets          Perform ``make sets''.
1.31      lukem     661:
                    662:      sourcesets    Perform ``make sourcesets''.
1.22      lukem     663:
1.54      apb       664:      syspkgs       Perform ``make syspkgs''.
1.56      apb       666:      iso-image     Perform ``make iso-image''.
1.65      jnemeth   668:      iso-image-source
                    669:                    Perform ``make iso-image-source''.
1.51      wiz       671:      The following command line options alter the behaviour of the build.sh
                    672:      operations described above:
1.1       tv        673:
                    674:      -a arch   Set the value of MACHINE_ARCH to arch.
1.9       thorpej   675:
                    676:      -B buildid
                    677:                Set the value of BUILDID to buildid.  This will also append the
1.67      sborrill  678:                build identifier to the name of the ``make'' wrapper script so
1.37      lukem     679:                that the resulting name is of the form
                    680:                ``nbmake-MACHINE-BUILDID''.
1.1       tv        681:
1.67      sborrill  682:      -C cdextras
                    683:                Set the value of CDEXTRA to cdextras which is a space-separated
                    684:                list of files or directories which will be added in order to
                    685:                the CD-ROM image when used in conjunction with ``iso-image'' or
                    686:                ``iso-image-source''.  Files will be added to the root of the
                    687:                CD-ROM image, whereas directories will be copied recursively.
                    688:                If relative paths are specified, they will be converted to
                    689:                absolute paths before being used.
1.66      jnemeth   690:
1.59      apb       691:      -D dest   Set the value of DESTDIR to dest.  If a relative path is speci-
                    692:                fied, it will be converted to an absolute path before being
                    693:                used.
1.18      lukem     694:
1.23      lukem     695:      -E        Set `expert' mode.  This overrides various sanity checks, and
                    696:                allows: DESTDIR does not have to be set to a non-root path for
1.38      lukem     697:                builds, and MKUNPRIVED=yes does not have to be set when build-
                    698:                ing as a non-root user.
1.23      lukem     699:
                    700:                Note: It is highly recommended that you know what you are doing
                    701:                when you use this option.
1.19      lukem     702:
1.51      wiz       703:      -h        Print a help message.
1.70      dholland  705:      -j njob   Run up to njob make(1) subjobs in parallel; passed through to
                    706:                make(1).  Makefiles should use .WAIT or have explicit dependan-
                    707:                cies as necessary to enforce build ordering.  If you see build
                    708:                failures with -j, please save complete build logs so the fail-
                    709:                ures can be analyzed.
1.1       tv        710:
1.73    ! apb       711:      -M obj    Set MAKEOBJDIRPREFIX to obj.  For instance, if the source
        !           712:                directory is /usr/src, a setting of ``-M /usr/obj'' will place
        !           713:                build-time files under /usr/obj/usr/src/bin,
        !           714:                /usr/obj/usr/src/lib, /usr/obj/usr/src/usr.bin, and so forth.
        !           715:                If a relative path is specified, it will be converted to an
        !           716:                absolute path before being used.  Unsets MAKEOBJDIR.  See ``-O
        !           717:                -obj'' for more information.
1.18      lukem     718:
1.60      apb       719:      -m mach   Set the value of MACHINE to mach, except in some special cases
                    720:                listed below.  This will also override any value of
                    721:                MACHINE_ARCH in the process environment with a value deduced
                    722:                from mach, unless -a is specified.  All cross builds require
                    723:                -m, but if unset on a NetBSD host, the host's value of MACHINE
                    724:                will be detected and used automatically.
                    726:                Some machines support multiple values for MACHINE_ARCH.  The
                    727:                following special cases for the mach argument are defined to
                    728:                set the listed values of MACHINE and MACHINE_ARCH:
1.33      lukem     729:
                    730:                      mach          MACHINE    MACHINE_ARCH
1.60      apb       731:                      evbarm        evbarm     (not set)
                    732:                      evbarm-eb     evbarm     armeb
                    733:                      evbarm-el     evbarm     arm
1.33      lukem     734:                      evbmips       evbmips    (not set)
                    735:                      evbmips-eb    evbmips    mipseb
                    736:                      evbmips-el    evbmips    mipsel
                    737:                      evbsh3        evbsh3     (not set)
                    738:                      evbsh3-eb     evbsh3     sh3eb
                    739:                      evbsh3-el     evbsh3     sh3el
                    740:                      sbmips        sbmips     (not set)
                    741:                      sbmips-eb     sbmips     mipseb
                    742:                      sbmips-el     sbmips     mipsel
1.1       tv        743:
1.45      lukem     744:      -N noiselevel
1.46      lukem     745:                Set the ``noisyness'' level of the build, by setting
                    746:                MAKEVERBOSE to noiselevel.
1.45      lukem     747:
1.1       tv        748:      -n        Show the commands that would be executed by build.sh, but do
                    749:                not make any changes.  This is similar in concept to ``make
                    750:                -n''.
1.18      lukem     752:      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
1.73    ! apb       753:                place the built object files under obj.  For instance, a set-
        !           754:                ting of ``-O /usr/obj'' will place build-time files under
        !           755:                /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and so forth.  If
        !           756:                a relative path is specified, it will be converted to an abso-
        !           757:                lute path before being used.  Unsets MAKEOBJDIRPREFIX.
        !           758:
        !           759:                In normal use, exactly one of the -M or -O options should be
        !           760:                specified.  If the source directory is /usr/src and neither -M
        !           761:                nor -O is specified, then a default object directory will be
        !           762:                chosen according to rules in <bsd.obj.mk>; this default is usu-
        !           763:                ally either /usr/obj or /usr/obj.MACHINE.
1.18      lukem     764:
1.34      lukem     765:      -o        Set the value of MKOBJDIRS to ``no''.  Otherwise, it will be
1.70      dholland  766:                automatically set to ``yes''.  This default is opposite to the
                    767:                behaviour when not using build.sh.
1.1       tv        768:
1.59      apb       769:      -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
                    770:                specified, it will be converted to an absolute path before
                    771:                being used.
1.18      lukem     772:
1.1       tv        773:      -r        Remove the contents of DESTDIR and TOOLDIR before building
                    774:                (provides a clean starting point).  This will skip deleting
                    775:                DESTDIR if building on a native system to the root directory.
1.72      perry     777:      -S seed   Change the value of BUILDSEED to seed.  This should rarely be
                    778:                necessary.
1.59      apb       780:      -T tools  Set the value of TOOLDIR to tools.  If a relative path is spec-
                    781:                ified, it will be converted to an absolute path before being
1.70      dholland  782:                used.  If set, the bootstrap ``make'' will only be rebuilt if
                    783:                the source files for make(1) have changed.
1.18      lukem     784:
1.38      lukem     785:      -U        Set MKUNPRIVED=yes.
1.18      lukem     786:
1.38      lukem     787:      -u        Set MKUPDATE=yes.
1.1       tv        788:
1.21      lukem     789:      -V var=[value]
1.40      lukem     790:                Set the environment variable var to an optional value.  This is
                    791:                propagated to the nbmake wrapper.
1.21      lukem     792:
1.1       tv        793:      -w wrapper
                    794:                Create the nbmake wrapper script (see below) in a custom loca-
                    795:                tion, specified by wrapper.  This allows, for instance, to
                    796:                place the wrapper in PATH automatically.  Note that wrapper is
1.59      apb       797:                the full name of the file, not just a directory name.  If a
                    798:                relative path is specified, it will be converted to an absolute
                    799:                path before being used.
1.1       tv        800:
1.49      lukem     801:      -X x11src
1.59      apb       802:                Set the value of X11SRCDIR to x11src.  If a relative path is
                    803:                specified, it will be converted to an absolute path before
                    804:                being used.
1.49      lukem     805:
                    806:      -x        Set MKX11=yes.
1.40      lukem     808:      -Z var    Unset ("zap") the environment variable var.  This is propagated
                    809:                to the nbmake wrapper.
1.1       tv        811:    The "nbmake-MACHINE" wrapper script
                    812:      If using the build.sh script to build NetBSD, a nbmake-MACHINE script
                    813:      will be created in TOOLDIR/bin upon the first build to assist in building
                    814:      subtrees on a cross-compile host.
                    816:      nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
                    817:      the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
                    818:      eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
1.70      dholland  819:      nbmake-MACHINE will also set variables specified with -V, and unset vari-
                    820:      ables specified with -Z.
1.40      lukem     821:
1.1       tv        822:      This script can be symlinked into a directory listed in PATH, or called
                    823:      with an absolute path.
1.16      lukem     825: EXAMPLES
1.44      lukem     826:      1.   % ./build.sh tools kernel=GENERIC
1.28      lukem     827:
                    828:           Build a new toolchain, and use the new toolchain to configure and
                    829:           build a new GENERIC kernel.
1.44      lukem     831:      2.   % ./build.sh -U distribution
1.28      lukem     832:
1.30      lukem     833:           Using unprivileged mode, build a complete distribution to a DESTDIR
                    834:           directory that build.sh selects (and will display).
1.28      lukem     835:
1.43      martti    836:      3.   # ./build.sh -U install=/
1.28      lukem     837:
1.29      lukem     838:           As root, install to / the distribution that was built by example 2.
                    839:           Even though this is run as root, -U is required so that the permis-
1.30      lukem     840:           sions stored in DESTDIR/METALOG are correctly applied to the files
                    841:           as they're copied to /.
1.28      lukem     842:
1.44      lukem     843:      4.   % ./build.sh -U -u release
1.28      lukem     844:
1.30      lukem     845:           Using unprivileged mode, build a complete release to DESTDIR and
                    846:           RELEASEDIR directories that build.sh selects (and will display).
1.38      lukem     847:           MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that
                    848:           if this is run after example 2, it doesn't need to redo that portion
                    849:           of the release build.
1.16      lukem     850:
1.10      sommerfe  851: OBSOLETE VARIABLES
1.70      dholland  852:      NBUILDJOBS  Use the make(1) option -j instead.
1.15      lukem     853:
                    854:      USE_NEW_TOOLCHAIN
                    855:                  The new toolchain is now the default.  To disable, use
                    856:                  TOOLCHAIN_MISSING=yes.
1.10      sommerfe  857:
1.1       tv        858: SEE ALSO
1.62      apb       859:      make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8),
1.61      apb       860:      pkgsrc/sysutils/cdrtools
1.1       tv        861:
                    862: HISTORY
1.15      lukem     863:      The build.sh based build scheme was introduced for NetBSD 1.6 as
                    864:      USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
1.1       tv        865:
                    866: BUGS
1.15      lukem     867:      A few platforms are not yet using this build system.
1.1       tv        868:
1.73    ! apb       869: NetBSD                          August 5, 2008                          NetBSD

CVSweb <webmaster@jp.NetBSD.org>