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

Annotation of src/BUILDING, Revision 1.95

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.
1.94      apb       107:      MAKEFLAGS         Flags to invoke make(1) with.  Note that build.sh
                    108:                        ignores the value of MAKEFLAGS passed in the environ-
                    109:                        ment, but allows MAKEFLAGS to be set via the -V option.
1.8       lukem     110:
                    111:      MAKEOBJDIR        Directory to use as the .OBJDIR for the current direc-
1.59      apb       112:                        tory.  The value is subjected to variable expansion by
1.73      apb       113:                        make(1).  Typical usage is to set this variable to a
                    114:                        value involving the use of `${.CURDIR:S...}' or
                    115:                        `${.CURDIR:C...}', to derive the value of .OBJDIR from
                    116:                        the value of .CURDIR.  Used only if MAKEOBJDIRPREFIX is
                    117:                        not defined.  MAKEOBJDIR can be provided only in the
                    118:                        environment or via the -O flag of build.sh; it cannot
1.82      mrg       119:                        usefully be set inside a Makefile, including mk.conf or
                    120:                        ${MAKECONF}.
1.8       lukem     121:
1.88      apb       122:      MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  The
                    123:                        value is subjected to variable expansion by make(1).
                    124:                        build.sh will create the ${MAKEOBJDIRPREFIX} directory
                    125:                        if necessary, but if make(1) is used without build.sh,
                    126:                        then rules in <bsd.obj.mk> will abort the build if the
                    127:                        ${MAKEOBJDIRPREFIX} directory does not exist.  If the
                    128:                        value is defined and valid, then ${MAKEOBJDIRPRE-
                    129:                        FIX}/${.CURDIR} is used as the .OBJDIR for the current
                    130:                        directory.  The current directory may be read only.
                    131:                        MAKEOBJDIRPREFIX can be provided only in the environ-
                    132:                        ment or via the -M flag of build.sh; it cannot usefully
                    133:                        be set inside a Makefile, including mk.conf or
                    134:                        ${MAKECONF}.
1.8       lukem     135:
1.1       tv        136:    "make" variables
                    137:      Several variables control the behavior of NetBSD builds.  Unless other-
                    138:      wise specified, these variables may be set in either the process environ-
                    139:      ment or the make(1) configuration file specified by MAKECONF.
1.9       thorpej   141:      BUILDID     Identifier for the build.  The identifier will be appended to
                    142:                  object directory names, and can be consulted in the make(1)
                    143:                  configuration file in order to set additional build parame-
                    144:                  ters, such as compiler flags.
1.72      perry     146:      BUILDSEED   GCC uses random numbers when compiling C++ code.  This vari-
                    147:                  able seeds the gcc random number generator using the -fran-
                    148:                  dom-seed flag with this value.  By default, it is set to
                    149:                  NetBSD-(majorversion).  Using a fixed value causes C++ bina-
1.84      hubertf   150:                  ries to be the same when built from the same sources, result-
1.85      hubertf   151:                  ing in identical (reproducible) builds.  Additional informa-
1.84      hubertf   152:                  tion is available in the GCC documentation of -frandom-seed.
1.72      perry     153:
1.1       tv        154:      DESTDIR     Directory to contain the built NetBSD system.  If set, spe-
                    155:                  cial options are passed to the compilation tools to prevent
                    156:                  their default use of the host system's /usr/include,
1.59      apb       157:                  /usr/lib, and so forth.  This pathname must be an absolute
                    158:                  path, and should not end with a slash (/) character.  (For
                    159:                  installation into the system's root directory, set DESTDIR to
                    160:                  an empty string, not to ``/'').  The directory must reside on
                    161:                  a file system which supports long file names and hard links.
1.1       tv        162:
                    163:                  Default: Empty string if USETOOLS is ``yes''; unset other-
                    164:                  wise.
1.30      lukem     166:                  Note: build.sh will provide a default of destdir.MACHINE (in
1.70      dholland  167:                  the top-level .OBJDIR) unless run in `expert' mode.
1.30      lukem     168:
1.1       tv        169:      MAKECONF    The name of the make(1) configuration file.  Only settable in
                    170:                  the process environment.
                    172:                  Default: ``/etc/mk.conf''
1.45      lukem     174:      MAKEVERBOSE
                    175:                  Level of verbosity of status messages.  Supported values:
1.80      apb       177:                  0    No descriptive messages or commands executed by make(1)
                    178:                       are shown.
1.45      lukem     179:
1.80      apb       180:                  1    Brief messages are shown describing what is being done,
                    181:                       but the actual commands executed by make(1) are not dis-
                    182:                       played.
                    184:                  2    Descriptive messages are shown as above (prefixed with a
                    185:                       `#'), and ordinary commands performed by make(1) are
                    186:                       displayed.
                    188:                  3    In addition to the above, all commands performed by
                    189:                       make(1) are displayed, even if they would ordinarily
                    190:                       have been hidden through use of the ``@'' prefix in the
                    191:                       relevant makefile.
1.45      lukem     192:
1.80      apb       193:                  4    In addition to the above, commands executed by make(1)
                    194:                       are traced through use of the sh(1) ``-x'' flag.
1.45      lukem     195:
                    196:                  Default: 2
1.1       tv        198:      MKCATPAGES  Can be set to ``yes'' or ``no''.  Indicates whether prefor-
                    199:                  matted plaintext manual pages will be created during a build.
                    201:                  Default: ``yes''
                    203:      MKCRYPTO    Can be set to ``yes'' or ``no''.  Indicates whether crypto-
                    204:                  graphic code will be included in a build; provided for the
                    205:                  benefit of countries that do not allow strong cryptography.
1.44      lukem     206:                  Will not affect use of the standard low-security password
                    207:                  encryption system, crypt(3).
1.1       tv        208:
                    209:                  Default: ``yes''
                    211:      MKDOC       Can be set to ``yes'' or ``no''.  Indicates whether system
1.44      lukem     212:                  documentation destined for DESTDIR/usr/share/doc will be
                    213:                  installed during a build.
1.1       tv        214:
                    215:                  Default: ``yes''
1.77      lukem     217:      MKHTML      Can be set to ``yes'' or ``no''.  Indicates whether prefor-
                    218:                  matted HTML manual pages will be built and installed
                    220:                  Default: ``yes''
1.4       tv        222:      MKHOSTOBJ   Can be set to ``yes'' or ``no''.  If set to ``yes'', then for
                    223:                  programs intended to be run on the compile host, the name,
                    224:                  release, and architecture of the host operating system will
                    225:                  be suffixed to the name of the object directory created by
                    226:                  ``make obj''.  (This allows multiple host systems to compile
                    227:                  NetBSD for a single target.)  If set to ``no'', then programs
                    228:                  built to be run on the compile host will use the same object
                    229:                  directory names as programs built to be run on the target.
                    231:                  Default: ``no''
1.1       tv        233:      MKINFO      Can be set to ``yes'' or ``no''.  Indicates whether GNU Info
                    234:                  files, used for the documentation for most of the compilation
                    235:                  tools, will be created and installed during a build.
                    237:                  Default: ``yes''
1.95    ! apb       239:      MKKMOD      Can be set to ``yes'' or ``no''.  Indicates whether kernel
        !           240:                  modules are built and installed.
        !           241:
        !           242:                  Default: ``yes''
        !           243:
1.1       tv        244:      MKLINT      Can be set to ``yes'' or ``no''.  Indicates whether lint(1)
                    245:                  will be run against portions of the NetBSD source code during
                    246:                  the build, and whether lint libraries will be installed into
1.27      lukem     247:                  DESTDIR/usr/libdata/lint.
1.1       tv        248:
                    249:                  Default: ``yes''
                    251:      MKMAN       Can be set to ``yes'' or ``no''.  Indicates whether manual
                    252:                  pages will be installed during a build.
                    254:                  Default: ``yes''
                    256:      MKNLS       Can be set to ``yes'' or ``no''.  Indicates whether Native
1.44      lukem     257:                  Language System locale zone files will be compiled and
                    258:                  installed during a build.
1.1       tv        259:
                    260:                  Default: ``yes''
                    262:      MKOBJ       Can be set to ``yes'' or ``no''.  Indicates whether object
                    263:                  directories will be created when running ``make obj''.  If
                    264:                  set to ``no'', then all built files will be located inside
                    265:                  the regular source tree.
                    267:                  Default: ``yes''
1.70      dholland  269:                  Note that setting MKOBJ to ``no'' is not recommended and may
                    270:                  cause problems when updating the tree with cvs(1).
1.1       tv        272:      MKPIC       Can be set to ``yes'' or ``no''.  Indicates whether shared
                    273:                  objects and libraries will be created and installed during a
                    274:                  build.  If set to ``no'', the entire built system will be
                    275:                  statically linked.
                    277:                  Default: Platform dependent.  As of this writing, all plat-
                    278:                  forms except sh3 default to ``yes''.
                    280:      MKPICINSTALL
                    281:                  Can be set to ``yes'' or ``no''.  Indicates whether the ar(1)
1.44      lukem     282:                  format libraries (lib*_pic.a), used to generate shared
                    283:                  libraries, are installed during a build.
1.1       tv        284:
                    285:                  Default: ``yes''
                    287:      MKPROFILE   Can be set to ``yes'' or ``no''.  Indicates whether profiled
                    288:                  libraries (lib*_p.a) will be built and installed during a
                    289:                  build.
                    291:                  Default: ``yes''; however, some platforms turn off MKPROFILE
                    292:                  by default at times due to toolchain problems with profiled
                    293:                  code.
                    295:      MKSHARE     Can be set to ``yes'' or ``no''.  Indicates whether files
1.44      lukem     296:                  destined to reside in DESTDIR/usr/share will be built and
                    297:                  installed during a build.  If set to ``no'', then all of
1.27      lukem     298:                  MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to
                    299:                  ``no'' unconditionally.
1.1       tv        300:
                    301:                  Default: ``yes''
1.78      apb       303:      MKSTRIPIDENT
                    304:                  Can be set to ``yes'' or ``no''.  Indicates whether program
                    305:                  binaries and shared libraries should be built to include RCS
                    306:                  IDs for use with ident(1).
                    308:                  Default: ``no''
1.44      lukem     310:      MKUNPRIVED  Can be set to ``yes'' or ``no''.  Indicates whether an
                    311:                  unprivileged install will occur.  The user, group, permis-
1.52      jmc       312:                  sions, and file flags, will not be set on the installed
                    313:                  items; instead the information will be appended to a file
                    314:                  called METALOG in DESTDIR.  The contents of METALOG are used
                    315:                  during the generation of the distribution tar files to ensure
                    316:                  that the appropriate file ownership is stored.
1.38      lukem     317:
                    318:                  Default: ``no''
1.44      lukem     320:      MKUPDATE    Can be set to ``yes'' or ``no''.  Indicates whether all
                    321:                  install operations intended to write to DESTDIR will compare
1.38      lukem     322:                  file timestamps before installing, and skip the install phase
1.44      lukem     323:                  if the destination files are up-to-date.  This also has
                    324:                  implications on full builds (see next subsection).
1.38      lukem     325:
                    326:                  Default: ``no''
1.79      mrg       328:      MKX11       Can be set to ``yes'' or ``no''.  Indicates whether X11 is
1.49      lukem     329:                  built from X11SRCDIR.
                    331:                  Default: ``no''
1.59      apb       333:      TOOLDIR     Directory to hold the host tools, once built.  If specified,
                    334:                  must be an absolute path.  This directory should be unique to
                    335:                  a given host system and NetBSD source tree.  (However, multi-
                    336:                  ple targets may share the same TOOLDIR; the target-dependent
                    337:                  files have unique names.)  If unset, a default based on the
                    338:                  uname(1) information of the host platform will be created in
                    339:                  the .OBJDIR of src.
1.1       tv        340:
                    341:                  Default: Unset.
                    343:      USETOOLS    Indicates whether the tools specified by TOOLDIR should be
                    344:                  used as part of a build in progress.  Must be set to ``yes''
                    345:                  if cross-compiling.
                    347:                  yes    Use the tools from TOOLDIR.
                    349:                  no     Do not use the tools from TOOLDIR, but refuse to build
                    350:                         native compilation tool components that are version-
                    351:                         specific for that tool.
                    353:                  never  Do not use the tools from TOOLDIR, even when building
                    354:                         native tool components.  This is similar to the tradi-
                    355:                         tional NetBSD build method, but does not verify that
                    356:                         the compilation tools in use are up-to-date enough in
                    357:                         order to build the tree successfully.  This may cause
                    358:                         build or runtime problems when building the whole
                    359:                         NetBSD source tree.
1.71      dholland  361:                  Default: ``yes'', unless TOOLCHAIN_MISSING is set to ``yes''.
                    363:                  USETOOLS is also set to ``no'' when using <bsd.*.mk> outside
                    364:                  the NetBSD source tree.
1.1       tv        365:
1.59      apb       366:      X11SRCDIR   Directory containing the X11R6 source.  If specified, must be
                    367:                  an absolute path.  The main X11R6 source is found in
                    368:                  X11SRCDIR/xfree/xc.
1.49      lukem     369:
1.89      apb       370:                  Default: NETBSDRCDIR/../xsrc, if that exists; otherwise
                    371:                  /usr/xsrc.
1.49      lukem     372:
1.79      mrg       373:      X11FLAVOUR  The style of X11 cross-built, set to either ``Xorg'' or
                    374:                  ``XFree86''.
1.81      mrg       376:                  Default: ``Xorg'' on amd64, i386, macppc, shark and sparc64
                    377:                  platforms, ``XFree86'' on everything else.
1.79      mrg       378:
1.1       tv        379:    "make" variables for full builds
1.7       lukem     380:      These variables only affect the top level ``Makefile'' and do not affect
                    381:      manually building subtrees of the NetBSD source code.
1.1       tv        382:
1.20      lukem     383:      INSTALLWORLDDIR  Location for the ``make installworld'' target to install
1.59      apb       384:                       to.  If specified, must be an absolute path.
1.1       tv        385:
1.20      lukem     386:                       Default: ``/''
1.1       tv        387:
1.44      lukem     388:      MKOBJDIRS        Can be set to ``yes'' or ``no''.  Indicates whether
                    389:                       object directories will be created automatically (via a
1.20      lukem     390:                       ``make obj'' pass) at the start of a build.
1.1       tv        391:
1.34      lukem     392:                       Default: ``no''
1.1       tv        393:
1.70      dholland  394:                       If using build.sh, the default is ``yes''.  This may be
                    395:                       set back to ``no'' by giving build.sh the -o option.
1.38      lukem     397:      MKUPDATE         Can be set to ``yes'' or ``no''.  If set, then in addi-
                    398:                       tion to the effects described for MKUPDATE=yes above,
                    399:                       this implies the effects of NOCLEANDIR (i.e., ``make
                    400:                       cleandir'' is avoided).
                    402:                       Default: ``no''
1.70      dholland  404:                       If using build.sh, this may be set by giving the -u
                    405:                       option.
                    407:      NBUILDJOBS       Now obsolete.  Use the make(1) option -j, instead.  See
                    408:                       below.
1.1       tv        409:
1.20      lukem     410:                       Default: Unset.
1.1       tv        411:
1.20      lukem     412:      NOCLEANDIR       If set, avoids the ``make cleandir'' phase of a full
                    413:                       build.  This has the effect of allowing only changed
                    414:                       files in a source tree to be recompiled.  This can speed
                    415:                       up builds when updating only a few files in the tree.
1.1       tv        416:
1.20      lukem     417:                       Default: Unset.
1.1       tv        418:
1.70      dholland  419:                       See also MKUPDATE.
1.20      lukem     421:      NODISTRIBDIRS    If set, avoids the ``make distrib-dirs'' phase of a full
                    422:                       build.  This skips running mtree(8) on DESTDIR, useful
                    423:                       on systems where building as an unprivileged user, or
                    424:                       where it is known that the system-wide mtree files have
                    425:                       not changed.
1.1       tv        426:
1.20      lukem     427:                       Default: Unset.
1.1       tv        428:
1.20      lukem     429:      NOINCLUDES       If set, avoids the ``make includes'' phase of a full
                    430:                       build.  This has the effect of preventing make(1) from
1.44      lukem     431:                       thinking that some programs are out-of-date simply
                    432:                       because the system include files have changed.  However,
1.20      lukem     433:                       this option should not be used when updating the entire
                    434:                       NetBSD source tree arbitrarily; it is suggested to use
1.70      dholland  435:                       MKUPDATE=yes instead in that case.
1.1       tv        436:
1.20      lukem     437:                       Default: Unset.
1.1       tv        438:
1.20      lukem     439:      RELEASEDIR       If set, specifies the directory to which a release(7)
                    440:                       layout will be written at the end of a ``make release''.
1.59      apb       441:                       If specified, must be an absolute path.
1.20      lukem     442:
                    443:                       Default: Unset.
1.30      lukem     445:                       Note: build.sh will provide a default of releasedir (in
1.70      dholland  446:                       the top-level .OBJDIR) unless run in `expert' mode.
1.30      lukem     447:
1.1       tv        448: BUILDING
                    449:    "make" command line options
1.52      jmc       450:      This is not a summary of all the options available to make(1); only the
                    451:      options used most frequently with NetBSD builds are listed here.
1.1       tv        452:
1.10      sommerfe  453:      -j njob    Run up to njob make(1) subjobs in parallel.  Makefiles should
1.52      jmc       454:                 use .WAIT or have explicit dependencies as necessary to
1.74      apb       455:                 enforce build ordering.
1.10      sommerfe  456:
1.1       tv        457:      -m dir     Specify the default directory for searching for system Make-
                    458:                 file segments, mainly the <bsd.*.mk> files.  When building any
                    459:                 full NetBSD source tree, this should be set to the
1.70      dholland  460:                 ``share/mk'' directory in the source tree.  This is set auto-
                    461:                 matically when building from the top level, or when using
                    462:                 build.sh.
1.1       tv        463:
                    464:      -n         Display the commands that would have been executed, but do not
                    465:                 actually execute them.  This will still cause recursion to
                    466:                 take place.
1.47      zuntum    468:      -V var     Print make(1)'s idea of the value of var.  Does not build any
1.1       tv        469:                 targets.
                    471:      var=value  Set the variable var to value, overriding any setting speci-
                    472:                 fied by the process environment, the MAKECONF configuration
                    473:                 file, or the system Makefile segments.
                    475:    "make" targets
                    476:      These default targets may be built by running make(1) in any subtree of
                    477:      the NetBSD source code.  It is recommended that none of these be used
                    478:      from the top level Makefile; as a specific exception, ``make obj'' and
                    479:      ``make cleandir'' are useful in that context.
                    481:      all        Build programs, libraries, and preformatted documentation.
                    483:      clean      Remove program and library object code files.
1.44      lukem     485:      cleandir   Same as clean, but also remove preformatted documentation,
                    486:                 dependency files generated by ``make depend'', and any other
1.49      lukem     487:                 files known to be created at build time.
1.1       tv        488:
1.44      lukem     489:      depend     Create dependency files (.depend) containing more detailed
                    490:                 information about the dependencies of source code on header
1.1       tv        491:                 files.  Allows programs to be recompiled automatically when a
                    492:                 dependency changes.
                    494:      dependall  Does a ``make depend'' immediately followed by a ``make all''.
1.10      sommerfe  495:                 This improves cache locality of the build since both passes
                    496:                 read the source files in their entirety.
1.1       tv        497:
1.49      lukem     498:      distclean  Synonym for cleandir.
1.44      lukem     500:      includes   Build and install system header files.  Typically needed
                    501:                 before any system libraries or programs can be built.
1.1       tv        502:
                    503:      install    Install programs, libraries, and documentation into DESTDIR.
1.27      lukem     504:                 Few files will be installed to DESTDIR/dev, DESTDIR/etc,
                    505:                 DESTDIR/root or DESTDIR/var in order to prevent user supplied
                    506:                 configuration data from being overwritten.
1.1       tv        507:
                    508:      lint       Run lint(1) against the C source code, where appropriate, and
                    509:                 generate system-installed lint libraries.
                    511:      obj        Create object directories to be used for built files, instead
                    512:                 of building directly in the source tree.
                    514:      tags       Create ctags(1) searchable function lists usable by the ex(1)
                    515:                 and vi(1) text editors.
                    517:    "make" targets for the top level
                    518:      Additional make(1) targets are usable specifically from the top source
                    519:      level to facilitate building the entire NetBSD source tree.
1.68      reed      521:      build         Build the entire NetBSD system (except the kernel).  This
                    522:                    orders portions of the source tree such that prerequisites
                    523:                    will be built in the proper order.
1.20      lukem     524:
                    525:      distribution  Do a ``make build'', and then install a full distribution
1.68      reed      526:                    (which does not include a kernel) into DESTDIR, including
                    527:                    files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
                    528:                    DESTDIR/var.
1.20      lukem     529:
                    530:      buildworld    As per ``make distribution'', except that it ensures that
                    531:                    DESTDIR is not the root directory.
1.70      dholland  533:      installworld  Install the distribution from DESTDIR to INSTALLWORLDDIR,
                    534:                    which defaults to the root directory.  Ensures that
1.52      jmc       535:                    INSTALLWORLDDIR is not the root directory if cross compil-
1.20      lukem     536:                    ing.
1.95    ! apb       538:                    The INSTALLSETS environment variable may be set to a space-
        !           539:                    separated list of distribution sets to be installed.  By
        !           540:                    default, all sets except ``etc'' and ``xetc'' are
        !           541:                    installed, so most files in INSTALLWORLDDIR/etc will not be
        !           542:                    installed or modified.
1.61      apb       543:
                    544:                    Note: Before performing this operation with
                    545:                    INSTALLWORLDDIR=/, it is highly recommended that you
                    546:                    upgrade your kernel and reboot.  After performing this
                    547:                    operation, it is recommended that you use etcupdate(8) to
                    548:                    update files in INSTALLWORLDDIR/etc and that you use
                    549:                    postinstall(8) to check for inconsistencies (and possibly
                    550:                    to fix them).
1.20      lukem     551:
1.25      lukem     552:      sets          Create distribution sets from DESTDIR into
1.69      lukem     553:                    RELEASEDIR/RELEASEMACHINEDIR/binary/sets.  Should be run
1.70      dholland  554:                    after ``make distribution'', as ``make build'' alone does
                    555:                    not install all of the required files.
1.25      lukem     556:
1.31      lukem     557:      sourcesets    Create source sets of the source tree into
                    558:                    RELEASEDIR/source/sets.
1.54      apb       560:      syspkgs       Create syspkgs from DESTDIR into
1.69      lukem     561:                    RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.  Should be run
1.70      dholland  562:                    after ``make distribution'', as ``make build'' alone does
                    563:                    not install all of the required files.
1.54      apb       564:
1.44      lukem     565:      release       Do a ``make distribution'', build kernels, distribution
                    566:                    media, and install sets (this as per ``make sets''), and
                    567:                    then package the system into a standard release layout as
                    568:                    described by release(7).  This requires that RELEASEDIR be
1.25      lukem     569:                    set (see above).
1.1       tv        570:
1.62      apb       571:      iso-image     Create a NetBSD installation CD-ROM image in the
                    572:                    RELEASEDIR/iso directory.  The CD-ROM file system will have
                    573:                    a layout as described in release(7).
                    575:                    For most machine types, the CD-ROM will be bootable, and
                    576:                    will automatically run the sysinst(8) menu-based installa-
                    577:                    tion program, which can be used to install or upgrade a
                    578:                    NetBSD system.  Bootable CD-ROMs also contain tools that
                    579:                    may be useful in repairing a damaged NetBSD installation.
                    581:                    Before ``make iso-image'' is attempted, RELEASEDIR must be
                    582:                    populated by ``make release'' or equivalent.
                    584:                    Note that other, smaller, CD-ROM images may be created in
1.69      lukem     585:                    the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
                    586:                    tory by ``make release''.  These smaller images usually
                    587:                    contain the same tools as the larger images in
                    588:                    RELEASEDIR/iso, but do not contain additional content such
                    589:                    as the distribution sets.
1.62      apb       590:
                    591:                    Note that the mac68k port still uses an older method of
                    592:                    creating CD-ROM images.  This requires the mkisofs(1) util-
                    593:                    ity, which is not part of NetBSD, but which can be
                    594:                    installed from pkgsrc/sysutils/cdrtools.
1.56      apb       595:
1.64      jnemeth   596:      iso-image-source
                    597:                    Create a NetBSD installation CD-ROM image in the
                    598:                    RELEASEDIR/iso directory.  The CD-ROM file system will have
                    599:                    a layout as described in release(7).  It will have top
                    600:                    level directories for the machine type and source.
                    602:                    For most machine types, the CD-ROM will be bootable, and
                    603:                    will automatically run the sysinst(8) menu-based installa-
                    604:                    tion program, which can be used to install or upgrade a
                    605:                    NetBSD system.  Bootable CD-ROMs also contain tools that
                    606:                    may be useful in repairing a damaged NetBSD installation.
                    608:                    Before ``make iso-image-source'' is attempted, RELEASEDIR
                    609:                    must be populated by ``make sourcesets release'' or equiva-
                    610:                    lent.
                    612:                    Note that other, smaller, CD-ROM images may be created in
1.69      lukem     613:                    the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc-
                    614:                    tory by ``make release''.  These smaller images usually
                    615:                    contain the same tools as the larger images in
                    616:                    RELEASEDIR/iso, but do not contain additional content such
                    617:                    as the distribution sets.
1.64      jnemeth   618:
                    619:                    Note that the mac68k port still uses an older method of
                    620:                    creating CD-ROM images.  This requires the mkisofs(1) util-
                    621:                    ity, which is not part of NetBSD, but which can be
                    622:                    installed from pkgsrc/sysutils/cdrtools.
1.1       tv        624:      regression-tests
1.20      lukem     625:                    Can only be run after building the regression tests in the
1.70      dholland  626:                    directory ``regress''.  Runs those compiled regression
                    627:                    tests on the local host.  Note that most tests are now man-
                    628:                    aged instead using atf(7); this target should probably run
                    629:                    those as well but currently does not.
1.1       tv        630:
                    631:    The "build.sh" script
                    632:      This script file is a Bourne shell script designed to build the entire
                    633:      NetBSD system on any host with a Bourne shell in /bin/sh, including many
                    634:      that are not POSIX compliant.  Note that if a host system's /bin/sh is
                    635:      unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
                    636:      a usable alternative.
                    638:      All cross-compile builds, and most native builds, of the entire system
                    639:      should make use of build.sh rather than just running ``make''.  This way,
                    640:      the make(1) program will be bootstrapped properly, in case the host sys-
                    641:      tem has an older or incompatible ``make'' program.
                    643:      When compiling the entire system via build.sh, many make(1) variables are
                    644:      set for you in order to help encapsulate the build process.  In the list
                    645:      of options below, variables that are automatically set by build.sh are
                    646:      noted where applicable.
1.22      lukem     648:      The following operations are supported by build.sh:
1.70      dholland  650:      build         Build the system as per ``make build''.  Before the main
                    651:                    part of the build commences, this command runs the obj
                    652:                    operation (unless the -o option is given), ``make
                    653:                    cleandir'' (unless the -u option is given), and the tools
                    654:                    operation.
1.22      lukem     655:
                    656:      distribution  Build a full distribution as per ``make distribution''.
1.70      dholland  657:                    This command first runs the build operation.
1.22      lukem     658:
1.70      dholland  659:      release       Build a full release as per ``make release''.  This command
                    660:                    first runs the distribution operation.
1.22      lukem     661:
1.23      lukem     662:      makewrapper   Create the nbmake-MACHINE wrapper.  This operation is auto-
                    663:                    matically performed for any of the other operations.
1.75      lukem     665:      cleandir      Perform ``make cleandir''.
1.22      lukem     667:      obj           Perform ``make obj''.
1.70      dholland  669:      tools         Build and install the host tools from src/tools.  This com-
                    670:                    mand will first run ``make obj'' and ``make cleandir'' in
                    671:                    the tools subdirectory unless the -o or -u options (respec-
                    672:                    tively) are given.
1.22      lukem     673:
1.35      lukem     674:      install=idir  Install the contents of DESTDIR to idir, using ``make
1.61      apb       675:                    installworld''.  Note that files that are part of the
1.95    ! apb       676:                    ``etc'' or ``xetc'' sets will not be installed, unless
        !           677:                    overridden by the INSTALLSETS environment variable.
1.35      lukem     678:
1.22      lukem     679:      kernel=kconf  Build a new kernel.  The kconf argument is the name of a
1.54      apb       680:                    configuration file suitable for use by config(1).  If kconf
1.22      lukem     681:                    does not contain any `/' characters, the configuration file
                    682:                    is expected to be found in the KERNCONFDIR directory, which
                    683:                    is typically sys/arch/MACHINE/conf.  The new kernel will be
                    684:                    built in a subdirectory of KERNOBJDIR, which is typically
                    685:                    sys/arch/MACHINE/compile or an associated object directory.
1.70      dholland  686:
                    687:                    This command does not imply the tools command; run the
                    688:                    tools command first unless it is certain that the tools
                    689:                    already exist and are up to date.
                    691:                    This command will run ``make cleandir'' on the kernel in
                    692:                    question first unless the -u option is given.
1.22      lukem     693:
1.86      jnemeth   694:      modules       This command will build kernel modules and install them
                    695:                    into DESTDIR.
1.35      lukem     697:      releasekernel=kconf
1.70      dholland  698:                    Install a gzip(1)ed copy of the kernel previously built by
1.69      lukem     699:                    kernel=kconf into
                    700:                    RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
                    701:                    netbsd-kconf.gz, although the ``netbsd'' prefix is deter-
                    702:                    mined from the ``config'' directives in kconf.
1.24      lukem     703:
                    704:      sets          Perform ``make sets''.
1.31      lukem     705:
                    706:      sourcesets    Perform ``make sourcesets''.
1.22      lukem     707:
1.54      apb       708:      syspkgs       Perform ``make syspkgs''.
1.56      apb       710:      iso-image     Perform ``make iso-image''.
1.65      jnemeth   712:      iso-image-source
                    713:                    Perform ``make iso-image-source''.
1.51      wiz       715:      The following command line options alter the behaviour of the build.sh
                    716:      operations described above:
1.1       tv        717:
                    718:      -a arch   Set the value of MACHINE_ARCH to arch.
1.9       thorpej   719:
                    720:      -B buildid
                    721:                Set the value of BUILDID to buildid.  This will also append the
1.67      sborrill  722:                build identifier to the name of the ``make'' wrapper script so
1.37      lukem     723:                that the resulting name is of the form
                    724:                ``nbmake-MACHINE-BUILDID''.
1.1       tv        725:
1.67      sborrill  726:      -C cdextras
1.87      apb       727:                Append cdextras to the CDEXTRA variable, which is a space-sepa-
                    728:                rated list of files or directories that will be added to the
                    729:                CD-ROM image that may be create by the ``iso-image'' or
                    730:                ``iso-image-source'' operations.  Files will be added to the
                    731:                root of the CD-ROM image, whereas directories will be copied
                    732:                recursively.  If relative paths are specified, they will be
                    733:                converted to absolute paths before being used.  Multiple paths
                    734:                may be specified via multiple -C options, or via a single
                    735:                option whose argument contains multiple space-separated paths.
1.66      jnemeth   736:
1.59      apb       737:      -D dest   Set the value of DESTDIR to dest.  If a relative path is speci-
                    738:                fied, it will be converted to an absolute path before being
                    739:                used.
1.18      lukem     740:
1.23      lukem     741:      -E        Set `expert' mode.  This overrides various sanity checks, and
                    742:                allows: DESTDIR does not have to be set to a non-root path for
1.38      lukem     743:                builds, and MKUNPRIVED=yes does not have to be set when build-
                    744:                ing as a non-root user.
1.23      lukem     745:
                    746:                Note: It is highly recommended that you know what you are doing
                    747:                when you use this option.
1.19      lukem     748:
1.51      wiz       749:      -h        Print a help message.
1.70      dholland  751:      -j njob   Run up to njob make(1) subjobs in parallel; passed through to
1.74      apb       752:                make(1).  If you see failures for reasons other than running
                    753:                out of memory while using build.sh with -j, please save com-
                    754:                plete build logs so the failures can be analyzed.
                    756:                To achieve the fastest builds, -j values between (1 + the num-
                    757:                ber of CPUs) and (2 * the number of CPUs) are recommended.  Use
                    758:                lower values on machines with limited memory or I/O bandwidth.
1.1       tv        759:
1.88      apb       760:      -M obj    Set MAKEOBJDIRPREFIX to obj.  Unsets MAKEOBJDIR.  See ``-O
                    761:                -obj'' for more information.
                    763:                For instance, if the source directory is /usr/src, a setting of
                    764:                ``-M /usr/obj'' will place build-time files under
                    765:                /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
                    766:                /usr/obj/usr/src/usr.bin, and so forth.
1.73      apb       768:                If a relative path is specified, it will be converted to an
1.88      apb       769:                absolute path before being used.  build.sh imposes the restric-
                    770:                tion that the argument to the -M option must not begin with a
                    771:                ``$'' (dollar sign) character; otherwise it would be too diffi-
                    772:                cult to determine whether the value is an absolute or a rela-
                    773:                tive path.  If the directory does not already exist, build.sh
                    774:                will create it.
1.18      lukem     775:
1.60      apb       776:      -m mach   Set the value of MACHINE to mach, except in some special cases
                    777:                listed below.  This will also override any value of
                    778:                MACHINE_ARCH in the process environment with a value deduced
                    779:                from mach, unless -a is specified.  All cross builds require
                    780:                -m, but if unset on a NetBSD host, the host's value of MACHINE
                    781:                will be detected and used automatically.
                    783:                Some machines support multiple values for MACHINE_ARCH.  The
                    784:                following special cases for the mach argument are defined to
                    785:                set the listed values of MACHINE and MACHINE_ARCH:
1.33      lukem     786:
                    787:                      mach          MACHINE    MACHINE_ARCH
1.60      apb       788:                      evbarm        evbarm     (not set)
                    789:                      evbarm-eb     evbarm     armeb
                    790:                      evbarm-el     evbarm     arm
1.33      lukem     791:                      evbmips       evbmips    (not set)
                    792:                      evbmips-eb    evbmips    mipseb
                    793:                      evbmips-el    evbmips    mipsel
                    794:                      evbsh3        evbsh3     (not set)
                    795:                      evbsh3-eb     evbsh3     sh3eb
                    796:                      evbsh3-el     evbsh3     sh3el
                    797:                      sbmips        sbmips     (not set)
                    798:                      sbmips-eb     sbmips     mipseb
                    799:                      sbmips-el     sbmips     mipsel
1.1       tv        800:
1.45      lukem     801:      -N noiselevel
1.46      lukem     802:                Set the ``noisyness'' level of the build, by setting
                    803:                MAKEVERBOSE to noiselevel.
1.45      lukem     804:
1.1       tv        805:      -n        Show the commands that would be executed by build.sh, but do
                    806:                not make any changes.  This is similar in concept to ``make
                    807:                -n''.
1.18      lukem     809:      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
1.88      apb       810:                place the built object files under obj.  Unsets
                    811:                MAKEOBJDIRPREFIX.
                    813:                For instance, a setting of ``-O /usr/obj'' will place build-
                    814:                time files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin,
                    815:                and so forth.
                    817:                If a relative path is specified, it will be converted to an
                    818:                absolute path before being used.  build.sh imposes the restric-
                    819:                tion that the argument to the -O option must not contain a
                    820:                ``$'' (dollar sign) character.  If the directory does not
                    821:                already exist, build.sh will create it.
1.73      apb       822:
                    823:                In normal use, exactly one of the -M or -O options should be
1.78      apb       824:                specified.  If neither -M nor -O is specified, then a default
                    825:                object directory will be chosen according to rules in
                    826:                <bsd.obj.mk>.  Relying on this default is not recommended
                    827:                because it is determined by complex rules that are influenced
                    828:                by the values of several variables and by the location of the
                    829:                source directory.
1.18      lukem     830:
1.34      lukem     831:      -o        Set the value of MKOBJDIRS to ``no''.  Otherwise, it will be
1.70      dholland  832:                automatically set to ``yes''.  This default is opposite to the
                    833:                behaviour when not using build.sh.
1.1       tv        834:
1.59      apb       835:      -R rel    Set the value of RELEASEDIR to rel.  If a relative path is
                    836:                specified, it will be converted to an absolute path before
                    837:                being used.
1.18      lukem     838:
1.1       tv        839:      -r        Remove the contents of DESTDIR and TOOLDIR before building
                    840:                (provides a clean starting point).  This will skip deleting
                    841:                DESTDIR if building on a native system to the root directory.
1.72      perry     843:      -S seed   Change the value of BUILDSEED to seed.  This should rarely be
                    844:                necessary.
1.59      apb       846:      -T tools  Set the value of TOOLDIR to tools.  If a relative path is spec-
                    847:                ified, it will be converted to an absolute path before being
1.70      dholland  848:                used.  If set, the bootstrap ``make'' will only be rebuilt if
                    849:                the source files for make(1) have changed.
1.18      lukem     850:
1.38      lukem     851:      -U        Set MKUNPRIVED=yes.
1.18      lukem     852:
1.38      lukem     853:      -u        Set MKUPDATE=yes.
1.1       tv        854:
1.21      lukem     855:      -V var=[value]
1.40      lukem     856:                Set the environment variable var to an optional value.  This is
                    857:                propagated to the nbmake wrapper.
1.21      lukem     858:
1.1       tv        859:      -w wrapper
                    860:                Create the nbmake wrapper script (see below) in a custom loca-
                    861:                tion, specified by wrapper.  This allows, for instance, to
                    862:                place the wrapper in PATH automatically.  Note that wrapper is
1.59      apb       863:                the full name of the file, not just a directory name.  If a
                    864:                relative path is specified, it will be converted to an absolute
                    865:                path before being used.
1.1       tv        866:
1.49      lukem     867:      -X x11src
1.59      apb       868:                Set the value of X11SRCDIR to x11src.  If a relative path is
                    869:                specified, it will be converted to an absolute path before
                    870:                being used.
1.49      lukem     871:
                    872:      -x        Set MKX11=yes.
1.40      lukem     874:      -Z var    Unset ("zap") the environment variable var.  This is propagated
                    875:                to the nbmake wrapper.
1.1       tv        877:    The "nbmake-MACHINE" wrapper script
                    878:      If using the build.sh script to build NetBSD, a nbmake-MACHINE script
                    879:      will be created in TOOLDIR/bin upon the first build to assist in building
                    880:      subtrees on a cross-compile host.
                    882:      nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
                    883:      the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
                    884:      eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
1.70      dholland  885:      nbmake-MACHINE will also set variables specified with -V, and unset vari-
                    886:      ables specified with -Z.
1.40      lukem     887:
1.1       tv        888:      This script can be symlinked into a directory listed in PATH, or called
                    889:      with an absolute path.
1.16      lukem     891: EXAMPLES
1.78      apb       892:      1.   % ./build.sh [options] tools kernel=GENERIC
1.28      lukem     893:
                    894:           Build a new toolchain, and use the new toolchain to configure and
                    895:           build a new GENERIC kernel.
1.78      apb       897:      2.   % ./build.sh [options] -U distribution
1.28      lukem     898:
1.30      lukem     899:           Using unprivileged mode, build a complete distribution to a DESTDIR
                    900:           directory that build.sh selects (and will display).
1.28      lukem     901:
1.78      apb       902:      3.   # ./build.sh [options] -U install=/
1.28      lukem     903:
1.29      lukem     904:           As root, install to / the distribution that was built by example 2.
                    905:           Even though this is run as root, -U is required so that the permis-
1.30      lukem     906:           sions stored in DESTDIR/METALOG are correctly applied to the files
                    907:           as they're copied to /.
1.28      lukem     908:
1.78      apb       909:      4.   % ./build.sh [options] -U -u release
1.28      lukem     910:
1.30      lukem     911:           Using unprivileged mode, build a complete release to DESTDIR and
                    912:           RELEASEDIR directories that build.sh selects (and will display).
1.38      lukem     913:           MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that
                    914:           if this is run after example 2, it doesn't need to redo that portion
                    915:           of the release build.
1.16      lukem     916:
1.10      sommerfe  917: OBSOLETE VARIABLES
1.70      dholland  918:      NBUILDJOBS  Use the make(1) option -j instead.
1.15      lukem     919:
                    920:      USE_NEW_TOOLCHAIN
                    921:                  The new toolchain is now the default.  To disable, use
                    922:                  TOOLCHAIN_MISSING=yes.
1.10      sommerfe  923:
1.1       tv        924: SEE ALSO
1.62      apb       925:      make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8),
1.61      apb       926:      pkgsrc/sysutils/cdrtools
1.1       tv        927:
                    928: HISTORY
1.15      lukem     929:      The build.sh based build scheme was introduced for NetBSD 1.6 as
                    930:      USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
1.1       tv        931:
1.94      apb       932: NetBSD                         September 9, 2011                        NetBSD

CVSweb <webmaster@jp.NetBSD.org>