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

Annotation of src/BUILDING, Revision 1.67

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

CVSweb <webmaster@jp.NetBSD.org>