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

Annotation of src/BUILDING, Revision 1.6

1.1       tv          1: BUILDING(8)             NetBSD System Manager's Manual             BUILDING(8)
                      3: NAME
                      4:      BUILDING - Procedure for building NetBSD from source code.
                      6: STATUS
                      7:      This document is a work-in-progress.  As such, the information described
                      8:      here may not match the reality of the build system as of this writing.
                      9:      Once this document is completely in sync with reality, this paragraph
                     10:      will be removed.
                     12:      Discrepancies between this documentation and the current reality of im-
                     13:      plementation are noted specially, as with the note below:
                     15:      Note: This document applies only to platforms which use the new toolchain
1.5       tv         16:      as indicated by the default setting of USE_NEW_TOOLCHAIN in <bsd.own.mk>.
                     17:      Platforms which have not yet been switched to the new toolchain should
                     18:      continue building traditionally, using the notes specified in the file
                     19:      UPDATING.
1.1       tv         20:
                     21: REQUIREMENTS
                     22:      NetBSD is designed to be buildable on most POSIX-compliant host systems.
                     23:      The basic build procedure is the same whether compiling natively (on the
                     24:      same NetBSD architecture) or cross compiling (on another architecture or
                     25:      OS).
                     27:      This source tree contains a special subtree, ``tools'', which uses the
                     28:      host system to create a build toolchain for the target architecture.  The
                     29:      host system must have at least C and C++ compilers in order to create the
                     30:      toolchain (make is not required); all other tools are created as part of
                     31:      the NetBSD build process.
                     33:            Note: A couple host toolchain components are not yet available in
                     34:            the tools directory.  Also, some tools use non-POSIX, non-ANSI C
                     35:            extensions and need to be standardized.  As a result, cross-compil-
                     36:            ing from systems other than NetBSD is not currently supported.
                     38: FILES
                     39:    Source tree layout
                     41:      BUILDING.mdoc  This document (in -mdoc troff format; the original copy).
1.2       wiz        43:      BUILDING       This document (in plaintext).
1.1       tv         44:
                     45:      Makefile       The main Makefile for NetBSD; should only be run for na-
                     46:                     tive builds with an appropriately up-to-date version of
                     47:                     NetBSD make(1).  (For building from out-of-date systems or
                     48:                     on a non-native host, see the build.sh shell script.)
                     50:      UPDATING       Special notes for updating from an earlier revision of
                     51:                     NetBSD.  It is important to read this file before every
                     52:                     build of an updated source tree.
                     54:      build.sh       Bourne-compatible shell script used for building the host
                     55:                     build tools and the NetBSD system from scratch.  Can be
                     56:                     used for both native and cross builds, and should be used
                     57:                     instead of make(1) for any source tree that is updated and
                     58:                     recompiled regularly.
                     60:      crypto/dist/, dist/, gnu/dist/
                     61:                     Sources imported verbatim from third parties, without man-
                     62:                     gling the existing build structure.  Other source trees in
                     63:                     bin through usr.sbin use the NetBSD make(1) ``reachover''
                     64:                     Makefile semantics when building these programs for a na-
                     65:                     tive host.
                     67:      distrib/, etc/
                     68:                     Sources for items used when making a full release snap-
                     69:                     shot, such as files installed in /etc on the destination
                     70:                     system, boot media, and release notes.
                     72:      regress/       Regression test harness.  Can be cross-compiled, but only
                     73:                     run natively.
                     75:      sys/           NetBSD kernel sources.
                     77:      tools/         ``Reachover'' build structure for the host build tools.
                     78:                     This has a special method of determining out-of-date sta-
                     79:                     tus.
                     81:      bin/ ... usr.sbin/
                     82:                     Sources to the NetBSD userland (non-kernel) programs.  If
                     83:                     any of these directories are missing, they will be skipped
                     84:                     during the build.
                     86:    Build tree layout
                     87:      The NetBSD build tree is described in hier(7), and the release layout is
                     88:      described in release(7).
                     90: CONFIGURATION
                     91:    "make" variables
                     92:      Several variables control the behavior of NetBSD builds.  Unless other-
                     93:      wise specified, these variables may be set in either the process environ-
                     94:      ment or the make(1) configuration file specified by MAKECONF.
                     96:      DESTDIR     Directory to contain the built NetBSD system.  If set, spe-
                     97:                  cial options are passed to the compilation tools to prevent
                     98:                  their default use of the host system's /usr/include,
                     99:                  /usr/lib, and so forth.  This pathname should not end with a
                    100:                  slash (/) character (for installation into the system's root
                    101:                  directory, set DESTDIR to an empty string).
                    103:                  Default: Empty string if USETOOLS is ``yes''; unset other-
                    104:                  wise.
                    106:      MAKECONF    The name of the make(1) configuration file.  Only settable in
                    107:                  the process environment.
                    109:                  Default: ``/etc/mk.conf''
                    111:      MKCATPAGES  Can be set to ``yes'' or ``no''.  Indicates whether prefor-
                    112:                  matted plaintext manual pages will be created during a build.
                    114:                  Default: ``yes''
                    116:      MKCRYPTO    Can be set to ``yes'' or ``no''.  Indicates whether crypto-
                    117:                  graphic code will be included in a build; provided for the
                    118:                  benefit of countries that do not allow strong cryptography.
                    119:                  Will not affect use of the standard low-security password en-
                    120:                  cryption system, crypt(3).
                    122:                  Default: ``yes''
                    124:      MKDOC       Can be set to ``yes'' or ``no''.  Indicates whether system
                    125:                  documentation destined for /usr/share/doc will be installed
                    126:                  during a build.
                    128:                  Default: ``yes''
1.4       tv        130:      MKHOSTOBJ   Can be set to ``yes'' or ``no''.  If set to ``yes'', then for
                    131:                  programs intended to be run on the compile host, the name,
                    132:                  release, and architecture of the host operating system will
                    133:                  be suffixed to the name of the object directory created by
                    134:                  ``make obj''.  (This allows multiple host systems to compile
                    135:                  NetBSD for a single target.)  If set to ``no'', then programs
                    136:                  built to be run on the compile host will use the same object
                    137:                  directory names as programs built to be run on the target.
                    139:                  Default: ``no''
1.1       tv        141:      MKINFO      Can be set to ``yes'' or ``no''.  Indicates whether GNU Info
                    142:                  files, used for the documentation for most of the compilation
                    143:                  tools, will be created and installed during a build.
                    145:                  Default: ``yes''
                    147:      MKLINT      Can be set to ``yes'' or ``no''.  Indicates whether lint(1)
                    148:                  will be run against portions of the NetBSD source code during
                    149:                  the build, and whether lint libraries will be installed into
                    150:                  /usr/libdata/lint.
                    152:                  Default: ``yes''
                    154:      MKMAN       Can be set to ``yes'' or ``no''.  Indicates whether manual
                    155:                  pages will be installed during a build.
                    157:                  Default: ``yes''
                    159:      MKNLS       Can be set to ``yes'' or ``no''.  Indicates whether Native
                    160:                  Language System locale zone files will be compiled and in-
                    161:                  stalled during a build.
                    163:                  Default: ``yes''
                    165:      MKOBJ       Can be set to ``yes'' or ``no''.  Indicates whether object
                    166:                  directories will be created when running ``make obj''.  If
                    167:                  set to ``no'', then all built files will be located inside
                    168:                  the regular source tree.
                    170:                  Default: ``yes''
                    172:      MKPIC       Can be set to ``yes'' or ``no''.  Indicates whether shared
                    173:                  objects and libraries will be created and installed during a
                    174:                  build.  If set to ``no'', the entire built system will be
                    175:                  statically linked.
                    177:                  Default: Platform dependent.  As of this writing, all plat-
                    178:                  forms except sh3 default to ``yes''.
                    180:      MKPICINSTALL
                    181:                  Can be set to ``yes'' or ``no''.  Indicates whether the ar(1)
                    182:                  format libraries (lib*_pic.a), used to generate shared li-
                    183:                  braries, are installed during a build.
                    185:                  Default: ``yes''
                    187:      MKPROFILE   Can be set to ``yes'' or ``no''.  Indicates whether profiled
                    188:                  libraries (lib*_p.a) will be built and installed during a
                    189:                  build.
                    191:                  Default: ``yes''; however, some platforms turn off MKPROFILE
                    192:                  by default at times due to toolchain problems with profiled
                    193:                  code.
                    195:      MKSHARE     Can be set to ``yes'' or ``no''.  Indicates whether files
                    196:                  destined to reside in /usr/share will be built and installed
                    197:                  during a build.  If set to ``no'', then all of MKCATPAGES,
                    198:                  MKDOC, MKINFO, MKMAN, and MKNLS will be set to ``no'' uncon-
                    199:                  ditionally.
                    201:                  Default: ``yes''
                    203:      TOOLDIR     Directory to hold the host tools, once built.  This directory
                    204:                  should be unique to a given host system and NetBSD source
                    205:                  tree.  (However, multiple targets may share the same TOOLDIR;
                    206:                  the target-dependent files have unique names.)  If unset, a
                    207:                  default based on the uname(1) information of the host plat-
                    208:                  form will be created in the .OBJDIR of src/tools.
                    210:                  Default: Unset.
                    212:      UPDATE      If set, then all install operations intended to write to
                    213:                  DESTDIR will compare file timestamps before installing, and
                    214:                  skip the install phase if the destination files are up-to-
                    215:                  date.  This also has implications on full builds (see next
                    216:                  subsection).
                    218:                  Default: Unset.
                    220:      USETOOLS    Indicates whether the tools specified by TOOLDIR should be
                    221:                  used as part of a build in progress.  Must be set to ``yes''
                    222:                  if cross-compiling.
                    224:                  yes    Use the tools from TOOLDIR.
                    226:                  no     Do not use the tools from TOOLDIR, but refuse to build
                    227:                         native compilation tool components that are version-
                    228:                         specific for that tool.
                    230:                  never  Do not use the tools from TOOLDIR, even when building
                    231:                         native tool components.  This is similar to the tradi-
                    232:                         tional NetBSD build method, but does not verify that
                    233:                         the compilation tools in use are up-to-date enough in
                    234:                         order to build the tree successfully.  This may cause
                    235:                         build or runtime problems when building the whole
                    236:                         NetBSD source tree.
                    238:                  Default: ``yes'' if building all or part of a whole NetBSD
                    239:                  source tree (detected automatically); ``no'' otherwise (to
                    240:                  preserve traditional semantics of the <bsd.*.mk> make(1) in-
                    241:                  clude files).
                    243:    "make" variables for full builds
                    244:      These variables only affect the top level ``Makefile'' and do not manual-
                    245:      ly building subtrees of the NetBSD source code.
                    247:      MKOBJDIRS      Can be set to ``yes'' or ``no''.  Indicates whether object
                    248:                     directories will be created automatically (via a ``make
                    249:                     obj'' pass) at the start of a build.
                    251:                     Default: ``yes''
                    253:      NBUILDJOBS     If set, specifies the number of parallel make(1) processes
                    254:                     that should be run simultaneously.  This can speed up
                    255:                     builds on SMP machines, or machines with much more CPU
                    256:                     power than I/O availability.  This should be used instead
                    257:                     of the make(1) option -j, in order to ensure proper order-
                    258:                     ing of build components.
                    260:                     Default: Unset.
                    262:      NOCLEANDIR     If set, avoids the ``make cleandir'' phase of a full
                    263:                     build.  This has the effect of allowing only changed files
                    264:                     in a source tree to be recompiled.  This can speed up
                    265:                     builds when updating only a few files in the tree.
                    267:                     Default: Unset.
                    269:      NODISTRIBDIRS  If set, avoids the ``make distrib-dirs'' phase of a full
                    270:                     build.  This skips running mtree(8) on DESTDIR, useful on
                    271:                     systems where building as an unprivileged user, or where
                    272:                     it is known that the system-wide mtree files have not
                    273:                     changed.
                    275:                     Default: Unset.
                    277:      NOINCLUDES     If set, avoids the ``make includes'' phase of a full
                    278:                     build.  This has the effect of preventing make(1) from
                    279:                     thinking that some programs are out-of-date simply because
                    280:                     the system include files have changed.  However, this op-
                    281:                     tion should not be used when updating the entire NetBSD
                    282:                     source tree arbitrarily; it is suggested to use UPDATE in
                    283:                     that case.
                    285:                     Default: Unset.
                    287:      RELEASEDIR     If set, specifies the directory to which a release(7) lay-
                    288:                     out will be written at the end of a ``make release''.
                    290:                     Default: Unset.
                    292:      UPDATE         If set, then in addition to the effects described for UP-
                    293:                     DATE above, this implies the effects of NOCLEANDIR.
                    295: BUILDING
                    296:    "make" command line options
                    297:      This is only a summary of options available to make(1); only the options
                    298:      used most frequently with NetBSD builds are listed here.
                    300:      -m dir     Specify the default directory for searching for system Make-
                    301:                 file segments, mainly the <bsd.*.mk> files.  When building any
                    302:                 full NetBSD source tree, this should be set to the
                    303:                 ``share/mk'' directory in the source tree.  (This is set auto-
                    304:                 matically when building from the top level.)
                    306:      -n         Display the commands that would have been executed, but do not
                    307:                 actually execute them.  This will still cause recursion to
                    308:                 take place.
                    310:      -v var     Print make(1)'s idea of the value of var.  Does not build any
                    311:                 targets.
                    313:      var=value  Set the variable var to value, overriding any setting speci-
                    314:                 fied by the process environment, the MAKECONF configuration
                    315:                 file, or the system Makefile segments.
                    317:    "make" targets
                    318:      These default targets may be built by running make(1) in any subtree of
                    319:      the NetBSD source code.  It is recommended that none of these be used
                    320:      from the top level Makefile; as a specific exception, ``make obj'' and
                    321:      ``make cleandir'' are useful in that context.
                    323:      all        Build programs, libraries, and preformatted documentation.
                    325:      clean      Remove program and library object code files.
                    327:      cleandir   Same as clean, but also remove preformatted documentation, de-
                    328:                 pendency files generated by ``make depend'', and any other
                    329:                 files known to be created at build time.  ``make distclean''
                    330:                 may be used as a synonym, for familiarity with a similar well-
                    331:                 known convention.
                    333:      depend     Create dependency files (.depend) containing more detailed in-
                    334:                 formation about the dependencies of source code on header
                    335:                 files.  Allows programs to be recompiled automatically when a
                    336:                 dependency changes.
                    338:      dependall  Does a ``make depend'' immediately followed by a ``make all''.
                    339:                 This combined target recurses as an atomic unit, so that the
                    340:                 ``make depend'' phase can participate in make -j parallelism.
                    342:      includes   Build and install system header files.  Typically needed be-
                    343:                 fore any system libraries or programs can be built.
                    345:      install    Install programs, libraries, and documentation into DESTDIR.
                    347:      lint       Run lint(1) against the C source code, where appropriate, and
                    348:                 generate system-installed lint libraries.
                    350:      obj        Create object directories to be used for built files, instead
                    351:                 of building directly in the source tree.
                    353:      tags       Create ctags(1) searchable function lists usable by the ex(1)
                    354:                 and vi(1) text editors.
                    356:    "make" targets for the top level
                    357:      Additional make(1) targets are usable specifically from the top source
                    358:      level to facilitate building the entire NetBSD source tree.
                    360:      build      Build the entire NetBSD system.  This orders portions of the
                    361:                 source tree such that prerequisites will be built in the prop-
                    362:                 er order.
                    364:      release    Do a ``make build'', then package the system into a standard
                    365:                 release layout as described by release(7).  This requires that
                    366:                 RELEASEDIR be set (see above).
                    368:      regression-tests
                    369:                 Can only be run after building the regression tests in the di-
                    370:                 rectory ``regress''.  Runs the compiled regression tests on
                    371:                 the local host.
                    373:    The "build.sh" script
                    374:      This script file is a Bourne shell script designed to build the entire
                    375:      NetBSD system on any host with a Bourne shell in /bin/sh, including many
                    376:      that are not POSIX compliant.  Note that if a host system's /bin/sh is
                    377:      unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
                    378:      a usable alternative.
                    380:      All cross-compile builds, and most native builds, of the entire system
                    381:      should make use of build.sh rather than just running ``make''.  This way,
                    382:      the make(1) program will be bootstrapped properly, in case the host sys-
                    383:      tem has an older or incompatible ``make'' program.
                    385:      When compiling the entire system via build.sh, many make(1) variables are
                    386:      set for you in order to help encapsulate the build process.  In the list
                    387:      of options below, variables that are automatically set by build.sh are
                    388:      noted where applicable.
                    390:      The following are available command line options that may be supplied to
                    391:      build.sh:
                    393:      -a arch   Set the value of MACHINE_ARCH to arch.
                    395:      -b        Bootstrap ``make'' and create a nbmake-MACHINE script (see be-
                    396:                low).
1.6     ! thorpej   398:      -d        Build a full distribution.  This differs from a normal build in
        !           399:                that etc files will also be installed.  Note this does not
        !           400:                build a ``release''; no release sets are placed in ${RE-
        !           401:                LEASEDIR}.
        !           402:
1.1       tv        403:      -j njob   Set the value of NBUILDJOBS to njob.  This provides similar
                    404:                functionality to the familiar ``make -j'', but preserves the
                    405:                ordering of the top level ``make build''.
                    407:      -m mach   Set the value of MACHINE to mach.  This will also override any
                    408:                value of MACHINE_ARCH in the process environment with a value
                    409:                deduced from mach, unless -a is specified.  All cross builds
                    410:                require -m, but if unset on a NetBSD host, the host's value of
                    411:                MACHINE will be detected and used automatically.
                    413:      -n        Show the commands that would be executed by build.sh, but do
                    414:                not make any changes.  This is similar in concept to ``make
                    415:                -n''.
                    417:      -o        Set the value of MKOBJDIRS to ``no''.
                    419:      -r        Remove the contents of DESTDIR and TOOLDIR before building
                    420:                (provides a clean starting point).  This will skip deleting
                    421:                DESTDIR if building on a native system to the root directory.
                    423:      -t        Build and install the host tools from src/tools only.  This op-
                    424:                tion implies -b.
                    426:      -u        Set the UPDATE variable.
                    428:      -w wrapper
                    429:                Create the nbmake wrapper script (see below) in a custom loca-
                    430:                tion, specified by wrapper.  This allows, for instance, to
                    431:                place the wrapper in PATH automatically.  Note that wrapper is
                    432:                the full name of the file, not just a directory name.
                    434:      -D dest   Set the value of DESTDIR to dest.
                    436:      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
                    437:                place the built object files under obj.  For instance, a set-
                    438:                ting of /usr/obj will place build-time files files under
                    439:                /usr/obj/bin, /usr/obj/lib, and so forth.
                    441:      -R rel    Set the value of RELEASEDIR to rel.  Setting this option will
                    442:                cause build.sh to run ``make release'' instead of ``make
                    443:                build''.
                    445:      -T tools  Set the value of TOOLDIR to tools.  If set, the bootstrap
                    446:                ``make'' will only be rebuilt as needed (when the source files
                    447:                for make(1) change).
                    449:    The "nbmake-MACHINE" wrapper script
                    450:      If using the build.sh script to build NetBSD, a nbmake-MACHINE script
                    451:      will be created in TOOLDIR/bin upon the first build to assist in building
                    452:      subtrees on a cross-compile host.
                    454:      nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
                    455:      the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
                    456:      eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
                    457:      This script can be symlinked into a directory listed in PATH, or called
                    458:      with an absolute path.
                    460: SEE ALSO
                    461:      make(1), hier(7), release(7)
                    463: HISTORY
                    464:      The USE_NEW_TOOLCHAIN based build scheme was introduced in the ``NetBSD-
                    465:      current'' development sources between NetBSD 1.5 and NetBSD 1.6.
                    467: BUGS
                    468:      Many platforms are not yet using the USE_NEW_TOOLCHAIN system.
1.4       tv        470: NetBSD                         November 12, 2001                             8

CVSweb <webmaster@jp.NetBSD.org>