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

Annotation of src/BUILDING, Revision 1.9

1.1       tv          1: BUILDING(8)             NetBSD System Manager's Manual             BUILDING(8)
                      2:
                      3: NAME
                      4:      BUILDING - Procedure for building NetBSD from source code.
                      5:
                      6: STATUS
                      7:      This document is a work-in-progress.  As such, the information described
                      8:      here may not match the reality of the build system as of this writing.
                      9:      Once this document is completely in sync with reality, this paragraph
                     10:      will be removed.
                     11:
                     12:      Discrepancies between this documentation and the current reality of im-
                     13:      plementation are noted specially, as with the note below:
                     14:
                     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).
                     26:
                     27:      This source tree contains a special subtree, ``tools'', which uses the
                     28:      host system to create a build toolchain for the target architecture.  The
                     29:      host system must have at least C and C++ compilers in order to create the
                     30:      toolchain (make is not required); all other tools are created as part of
                     31:      the NetBSD build process.
                     32:
                     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.
                     37:
                     38: FILES
                     39:    Source tree layout
                     40:
                     41:      BUILDING.mdoc  This document (in -mdoc troff format; the original copy).
                     42:
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.)
                     49:
                     50:      UPDATING       Special notes for updating from an earlier revision of
                     51:                     NetBSD.  It is important to read this file before every
                     52:                     build of an updated source tree.
                     53:
                     54:      build.sh       Bourne-compatible shell script used for building the host
                     55:                     build tools and the NetBSD system from scratch.  Can be
                     56:                     used for both native and cross builds, and should be used
                     57:                     instead of make(1) for any source tree that is updated and
                     58:                     recompiled regularly.
                     59:
                     60:      crypto/dist/, dist/, gnu/dist/
                     61:                     Sources imported verbatim from third parties, without man-
                     62:                     gling the existing build structure.  Other source trees in
                     63:                     bin through usr.sbin use the NetBSD make(1) ``reachover''
                     64:                     Makefile semantics when building these programs for a na-
                     65:                     tive host.
                     66:
                     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.
                     71:
                     72:      regress/       Regression test harness.  Can be cross-compiled, but only
                     73:                     run natively.
                     74:
                     75:      sys/           NetBSD kernel sources.
                     76:
                     77:      tools/         ``Reachover'' build structure for the host build tools.
                     78:                     This has a special method of determining out-of-date sta-
                     79:                     tus.
                     80:
                     81:      bin/ ... usr.sbin/
                     82:                     Sources to the NetBSD userland (non-kernel) programs.  If
                     83:                     any of these directories are missing, they will be skipped
                     84:                     during the build.
                     85:
                     86:    Build tree layout
                     87:      The NetBSD build tree is described in hier(7), and the release layout is
                     88:      described in release(7).
                     89:
                     90: CONFIGURATION
1.8       lukem      91:    Environment variables
                     92:      Several environment variables control the behaviour of NetBSD builds.
                     93:
                     94:      MACHINE           Machine type.
                     95:
                     96:      MACHINE_ARCH      Machine architecture.
                     97:
                     98:      MAKE              Path name to invoke make(1) as.
                     99:
                    100:      MAKEFLAGS         Flags to invoke make(1) with.
                    101:
                    102:      MAKEOBJDIR        Directory to use as the .OBJDIR for the current direc-
                    103:                        tory.  Used only if MAKEOBJDIRPREFIX is not defined.
                    104:                        MAKEOBJDIR can only be provided in the environment.
                    105:
                    106:      MAKEOBJDIRPREFIX  Top level directory of the object directory tree.  If
                    107:                        this is defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used
                    108:                        as the .OBJDIR for the current directory.  The current
                    109:                        directory may be read only.  MAKEOBJDIRPREFIX can only
                    110:                        be provided in the environment.
                    111:
1.1       tv        112:    "make" variables
                    113:      Several variables control the behavior of NetBSD builds.  Unless other-
                    114:      wise specified, these variables may be set in either the process environ-
                    115:      ment or the make(1) configuration file specified by MAKECONF.
                    116:
1.9     ! thorpej   117:      BUILDID     Identifier for the build.  The identifier will be appended to
        !           118:                  object directory names, and can be consulted in the make(1)
        !           119:                  configuration file in order to set additional build parame-
        !           120:                  ters, such as compiler flags.
        !           121:
1.1       tv        122:      DESTDIR     Directory to contain the built NetBSD system.  If set, spe-
                    123:                  cial options are passed to the compilation tools to prevent
                    124:                  their default use of the host system's /usr/include,
                    125:                  /usr/lib, and so forth.  This pathname should not end with a
                    126:                  slash (/) character (for installation into the system's root
1.7       lukem     127:                  directory, set DESTDIR to an empty string).  The directory
                    128:                  must reside on a file system which supports long file names
                    129:                  and hard links.
1.1       tv        130:
                    131:                  Default: Empty string if USETOOLS is ``yes''; unset other-
                    132:                  wise.
                    133:
                    134:      MAKECONF    The name of the make(1) configuration file.  Only settable in
                    135:                  the process environment.
                    136:
                    137:                  Default: ``/etc/mk.conf''
                    138:
                    139:      MKCATPAGES  Can be set to ``yes'' or ``no''.  Indicates whether prefor-
                    140:                  matted plaintext manual pages will be created during a build.
                    141:
                    142:                  Default: ``yes''
                    143:
                    144:      MKCRYPTO    Can be set to ``yes'' or ``no''.  Indicates whether crypto-
                    145:                  graphic code will be included in a build; provided for the
                    146:                  benefit of countries that do not allow strong cryptography.
                    147:                  Will not affect use of the standard low-security password en-
                    148:                  cryption system, crypt(3).
                    149:
                    150:                  Default: ``yes''
                    151:
                    152:      MKDOC       Can be set to ``yes'' or ``no''.  Indicates whether system
                    153:                  documentation destined for /usr/share/doc will be installed
                    154:                  during a build.
                    155:
                    156:                  Default: ``yes''
                    157:
1.4       tv        158:      MKHOSTOBJ   Can be set to ``yes'' or ``no''.  If set to ``yes'', then for
                    159:                  programs intended to be run on the compile host, the name,
                    160:                  release, and architecture of the host operating system will
                    161:                  be suffixed to the name of the object directory created by
                    162:                  ``make obj''.  (This allows multiple host systems to compile
                    163:                  NetBSD for a single target.)  If set to ``no'', then programs
                    164:                  built to be run on the compile host will use the same object
                    165:                  directory names as programs built to be run on the target.
                    166:
                    167:                  Default: ``no''
                    168:
1.1       tv        169:      MKINFO      Can be set to ``yes'' or ``no''.  Indicates whether GNU Info
                    170:                  files, used for the documentation for most of the compilation
                    171:                  tools, will be created and installed during a build.
                    172:
                    173:                  Default: ``yes''
                    174:
                    175:      MKLINT      Can be set to ``yes'' or ``no''.  Indicates whether lint(1)
                    176:                  will be run against portions of the NetBSD source code during
                    177:                  the build, and whether lint libraries will be installed into
                    178:                  /usr/libdata/lint.
                    179:
                    180:                  Default: ``yes''
                    181:
                    182:      MKMAN       Can be set to ``yes'' or ``no''.  Indicates whether manual
                    183:                  pages will be installed during a build.
                    184:
                    185:                  Default: ``yes''
                    186:
                    187:      MKNLS       Can be set to ``yes'' or ``no''.  Indicates whether Native
                    188:                  Language System locale zone files will be compiled and in-
                    189:                  stalled during a build.
                    190:
                    191:                  Default: ``yes''
                    192:
                    193:      MKOBJ       Can be set to ``yes'' or ``no''.  Indicates whether object
                    194:                  directories will be created when running ``make obj''.  If
                    195:                  set to ``no'', then all built files will be located inside
                    196:                  the regular source tree.
                    197:
                    198:                  Default: ``yes''
                    199:
                    200:      MKPIC       Can be set to ``yes'' or ``no''.  Indicates whether shared
                    201:                  objects and libraries will be created and installed during a
                    202:                  build.  If set to ``no'', the entire built system will be
                    203:                  statically linked.
                    204:
                    205:                  Default: Platform dependent.  As of this writing, all plat-
                    206:                  forms except sh3 default to ``yes''.
                    207:
                    208:      MKPICINSTALL
                    209:                  Can be set to ``yes'' or ``no''.  Indicates whether the ar(1)
                    210:                  format libraries (lib*_pic.a), used to generate shared li-
                    211:                  braries, are installed during a build.
                    212:
                    213:                  Default: ``yes''
                    214:
                    215:      MKPROFILE   Can be set to ``yes'' or ``no''.  Indicates whether profiled
                    216:                  libraries (lib*_p.a) will be built and installed during a
                    217:                  build.
                    218:
                    219:                  Default: ``yes''; however, some platforms turn off MKPROFILE
                    220:                  by default at times due to toolchain problems with profiled
                    221:                  code.
                    222:
                    223:      MKSHARE     Can be set to ``yes'' or ``no''.  Indicates whether files
                    224:                  destined to reside in /usr/share will be built and installed
                    225:                  during a build.  If set to ``no'', then all of MKCATPAGES,
                    226:                  MKDOC, MKINFO, MKMAN, and MKNLS will be set to ``no'' uncon-
                    227:                  ditionally.
                    228:
                    229:                  Default: ``yes''
                    230:
                    231:      TOOLDIR     Directory to hold the host tools, once built.  This directory
                    232:                  should be unique to a given host system and NetBSD source
                    233:                  tree.  (However, multiple targets may share the same TOOLDIR;
                    234:                  the target-dependent files have unique names.)  If unset, a
                    235:                  default based on the uname(1) information of the host plat-
                    236:                  form will be created in the .OBJDIR of src/tools.
                    237:
                    238:                  Default: Unset.
                    239:
1.7       lukem     240:      UNPRIVED    If set, then an unprivileged install will occur.  The user,
                    241:                  group, permissions, and file flags, will not be set on the
                    242:                  installed item; instead the information will be appended to a
                    243:                  file called METALOG in the .OBJDIR of src.  The contents of
                    244:                  METALOG is used during the generation of the distribution tar
                    245:                  files to ensure that the appropriate file ownership is
                    246:                  stored.
                    247:
                    248:                  Default: Unset.
                    249:
1.1       tv        250:      UPDATE      If set, then all install operations intended to write to
                    251:                  DESTDIR will compare file timestamps before installing, and
                    252:                  skip the install phase if the destination files are up-to-
                    253:                  date.  This also has implications on full builds (see next
                    254:                  subsection).
                    255:
                    256:                  Default: Unset.
                    257:
                    258:      USETOOLS    Indicates whether the tools specified by TOOLDIR should be
                    259:                  used as part of a build in progress.  Must be set to ``yes''
                    260:                  if cross-compiling.
                    261:
                    262:                  yes    Use the tools from TOOLDIR.
                    263:
                    264:                  no     Do not use the tools from TOOLDIR, but refuse to build
                    265:                         native compilation tool components that are version-
                    266:                         specific for that tool.
                    267:
                    268:                  never  Do not use the tools from TOOLDIR, even when building
                    269:                         native tool components.  This is similar to the tradi-
                    270:                         tional NetBSD build method, but does not verify that
                    271:                         the compilation tools in use are up-to-date enough in
                    272:                         order to build the tree successfully.  This may cause
                    273:                         build or runtime problems when building the whole
                    274:                         NetBSD source tree.
                    275:
                    276:                  Default: ``yes'' if building all or part of a whole NetBSD
                    277:                  source tree (detected automatically); ``no'' otherwise (to
                    278:                  preserve traditional semantics of the <bsd.*.mk> make(1) in-
                    279:                  clude files).
                    280:
                    281:    "make" variables for full builds
1.7       lukem     282:      These variables only affect the top level ``Makefile'' and do not affect
                    283:      manually building subtrees of the NetBSD source code.
1.1       tv        284:
                    285:      MKOBJDIRS      Can be set to ``yes'' or ``no''.  Indicates whether object
                    286:                     directories will be created automatically (via a ``make
                    287:                     obj'' pass) at the start of a build.
                    288:
                    289:                     Default: ``yes''
                    290:
                    291:      NBUILDJOBS     If set, specifies the number of parallel make(1) processes
                    292:                     that should be run simultaneously.  This can speed up
                    293:                     builds on SMP machines, or machines with much more CPU
                    294:                     power than I/O availability.  This should be used instead
                    295:                     of the make(1) option -j, in order to ensure proper order-
                    296:                     ing of build components.
                    297:
                    298:                     Default: Unset.
                    299:
                    300:      NOCLEANDIR     If set, avoids the ``make cleandir'' phase of a full
                    301:                     build.  This has the effect of allowing only changed files
                    302:                     in a source tree to be recompiled.  This can speed up
                    303:                     builds when updating only a few files in the tree.
                    304:
                    305:                     Default: Unset.
                    306:
                    307:      NODISTRIBDIRS  If set, avoids the ``make distrib-dirs'' phase of a full
                    308:                     build.  This skips running mtree(8) on DESTDIR, useful on
                    309:                     systems where building as an unprivileged user, or where
                    310:                     it is known that the system-wide mtree files have not
                    311:                     changed.
                    312:
                    313:                     Default: Unset.
                    314:
                    315:      NOINCLUDES     If set, avoids the ``make includes'' phase of a full
                    316:                     build.  This has the effect of preventing make(1) from
                    317:                     thinking that some programs are out-of-date simply because
                    318:                     the system include files have changed.  However, this op-
                    319:                     tion should not be used when updating the entire NetBSD
                    320:                     source tree arbitrarily; it is suggested to use UPDATE in
                    321:                     that case.
                    322:
                    323:                     Default: Unset.
                    324:
                    325:      RELEASEDIR     If set, specifies the directory to which a release(7) lay-
                    326:                     out will be written at the end of a ``make release''.
                    327:
                    328:                     Default: Unset.
                    329:
                    330:      UPDATE         If set, then in addition to the effects described for UP-
                    331:                     DATE above, this implies the effects of NOCLEANDIR.
                    332:
                    333: BUILDING
                    334:    "make" command line options
                    335:      This is only a summary of options available to make(1); only the options
                    336:      used most frequently with NetBSD builds are listed here.
                    337:
                    338:      -m dir     Specify the default directory for searching for system Make-
                    339:                 file segments, mainly the <bsd.*.mk> files.  When building any
                    340:                 full NetBSD source tree, this should be set to the
                    341:                 ``share/mk'' directory in the source tree.  (This is set auto-
                    342:                 matically when building from the top level.)
                    343:
                    344:      -n         Display the commands that would have been executed, but do not
                    345:                 actually execute them.  This will still cause recursion to
                    346:                 take place.
                    347:
                    348:      -v var     Print make(1)'s idea of the value of var.  Does not build any
                    349:                 targets.
                    350:
                    351:      var=value  Set the variable var to value, overriding any setting speci-
                    352:                 fied by the process environment, the MAKECONF configuration
                    353:                 file, or the system Makefile segments.
                    354:
                    355:    "make" targets
                    356:      These default targets may be built by running make(1) in any subtree of
                    357:      the NetBSD source code.  It is recommended that none of these be used
                    358:      from the top level Makefile; as a specific exception, ``make obj'' and
                    359:      ``make cleandir'' are useful in that context.
                    360:
                    361:      all        Build programs, libraries, and preformatted documentation.
                    362:
                    363:      clean      Remove program and library object code files.
                    364:
                    365:      cleandir   Same as clean, but also remove preformatted documentation, de-
                    366:                 pendency files generated by ``make depend'', and any other
                    367:                 files known to be created at build time.  ``make distclean''
                    368:                 may be used as a synonym, for familiarity with a similar well-
                    369:                 known convention.
                    370:
                    371:      depend     Create dependency files (.depend) containing more detailed in-
                    372:                 formation about the dependencies of source code on header
                    373:                 files.  Allows programs to be recompiled automatically when a
                    374:                 dependency changes.
                    375:
                    376:      dependall  Does a ``make depend'' immediately followed by a ``make all''.
                    377:                 This combined target recurses as an atomic unit, so that the
                    378:                 ``make depend'' phase can participate in make -j parallelism.
                    379:
                    380:      includes   Build and install system header files.  Typically needed be-
                    381:                 fore any system libraries or programs can be built.
                    382:
                    383:      install    Install programs, libraries, and documentation into DESTDIR.
                    384:
                    385:      lint       Run lint(1) against the C source code, where appropriate, and
                    386:                 generate system-installed lint libraries.
                    387:
                    388:      obj        Create object directories to be used for built files, instead
                    389:                 of building directly in the source tree.
                    390:
                    391:      tags       Create ctags(1) searchable function lists usable by the ex(1)
                    392:                 and vi(1) text editors.
                    393:
                    394:    "make" targets for the top level
                    395:      Additional make(1) targets are usable specifically from the top source
                    396:      level to facilitate building the entire NetBSD source tree.
                    397:
                    398:      build      Build the entire NetBSD system.  This orders portions of the
                    399:                 source tree such that prerequisites will be built in the prop-
                    400:                 er order.
                    401:
                    402:      release    Do a ``make build'', then package the system into a standard
                    403:                 release layout as described by release(7).  This requires that
                    404:                 RELEASEDIR be set (see above).
                    405:
                    406:      regression-tests
                    407:                 Can only be run after building the regression tests in the di-
                    408:                 rectory ``regress''.  Runs the compiled regression tests on
                    409:                 the local host.
                    410:
                    411:    The "build.sh" script
                    412:      This script file is a Bourne shell script designed to build the entire
                    413:      NetBSD system on any host with a Bourne shell in /bin/sh, including many
                    414:      that are not POSIX compliant.  Note that if a host system's /bin/sh is
                    415:      unusually old and broken, the Korn Shell (/bin/ksh), if available, may be
                    416:      a usable alternative.
                    417:
                    418:      All cross-compile builds, and most native builds, of the entire system
                    419:      should make use of build.sh rather than just running ``make''.  This way,
                    420:      the make(1) program will be bootstrapped properly, in case the host sys-
                    421:      tem has an older or incompatible ``make'' program.
                    422:
                    423:      When compiling the entire system via build.sh, many make(1) variables are
                    424:      set for you in order to help encapsulate the build process.  In the list
                    425:      of options below, variables that are automatically set by build.sh are
                    426:      noted where applicable.
                    427:
                    428:      The following are available command line options that may be supplied to
                    429:      build.sh:
                    430:
                    431:      -a arch   Set the value of MACHINE_ARCH to arch.
1.9     ! thorpej   432:
        !           433:      -B buildid
        !           434:                Set the value of BUILDID to buildid.  This will also append the
        !           435:                build idenfitier to the name of the ``make'' wrapper script so
        !           436:                that the resulting name is of the form ``nbmake-MACHINE-
        !           437:                BUILDID''.
1.1       tv        438:
                    439:      -b        Bootstrap ``make'' and create a nbmake-MACHINE script (see be-
                    440:                low).
                    441:
1.6       thorpej   442:      -d        Build a full distribution.  This differs from a normal build in
                    443:                that etc files will also be installed.  Note this does not
                    444:                build a ``release''; no release sets are placed in ${RE-
                    445:                LEASEDIR}.
                    446:
1.1       tv        447:      -j njob   Set the value of NBUILDJOBS to njob.  This provides similar
                    448:                functionality to the familiar ``make -j'', but preserves the
                    449:                ordering of the top level ``make build''.
                    450:
                    451:      -m mach   Set the value of MACHINE to mach.  This will also override any
                    452:                value of MACHINE_ARCH in the process environment with a value
                    453:                deduced from mach, unless -a is specified.  All cross builds
                    454:                require -m, but if unset on a NetBSD host, the host's value of
                    455:                MACHINE will be detected and used automatically.
                    456:
                    457:      -n        Show the commands that would be executed by build.sh, but do
                    458:                not make any changes.  This is similar in concept to ``make
                    459:                -n''.
                    460:
                    461:      -o        Set the value of MKOBJDIRS to ``no''.
                    462:
                    463:      -r        Remove the contents of DESTDIR and TOOLDIR before building
                    464:                (provides a clean starting point).  This will skip deleting
                    465:                DESTDIR if building on a native system to the root directory.
                    466:
                    467:      -t        Build and install the host tools from src/tools only.  This op-
                    468:                tion implies -b.
                    469:
                    470:      -u        Set the UPDATE variable.
                    471:
                    472:      -w wrapper
                    473:                Create the nbmake wrapper script (see below) in a custom loca-
                    474:                tion, specified by wrapper.  This allows, for instance, to
                    475:                place the wrapper in PATH automatically.  Note that wrapper is
                    476:                the full name of the file, not just a directory name.
                    477:
                    478:      -D dest   Set the value of DESTDIR to dest.
                    479:
                    480:      -O obj    Create an appropriate transform macro for MAKEOBJDIR that will
                    481:                place the built object files under obj.  For instance, a set-
                    482:                ting of /usr/obj will place build-time files files under
                    483:                /usr/obj/bin, /usr/obj/lib, and so forth.
                    484:
                    485:      -R rel    Set the value of RELEASEDIR to rel.  Setting this option will
                    486:                cause build.sh to run ``make release'' instead of ``make
                    487:                build''.
                    488:
                    489:      -T tools  Set the value of TOOLDIR to tools.  If set, the bootstrap
                    490:                ``make'' will only be rebuilt as needed (when the source files
                    491:                for make(1) change).
                    492:
1.7       lukem     493:      -U        Set the UNPRIVED variable.
                    494:
1.1       tv        495:    The "nbmake-MACHINE" wrapper script
                    496:      If using the build.sh script to build NetBSD, a nbmake-MACHINE script
                    497:      will be created in TOOLDIR/bin upon the first build to assist in building
                    498:      subtrees on a cross-compile host.
                    499:
                    500:      nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
                    501:      the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev-
                    502:      eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR.
                    503:      This script can be symlinked into a directory listed in PATH, or called
                    504:      with an absolute path.
                    505:
                    506: SEE ALSO
                    507:      make(1), hier(7), release(7)
                    508:
                    509: HISTORY
                    510:      The USE_NEW_TOOLCHAIN based build scheme was introduced in the ``NetBSD-
                    511:      current'' development sources between NetBSD 1.5 and NetBSD 1.6.
                    512:
                    513: BUGS
                    514:      Many platforms are not yet using the USE_NEW_TOOLCHAIN system.
                    515:
1.8       lukem     516: NetBSD                           March 5, 2002                               8

CVSweb <webmaster@jp.NetBSD.org>