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

Annotation of src/doc/BUILDING.mdoc, Revision 1.85

1.85    ! apb         1: .\"    $NetBSD: BUILDING.mdoc,v 1.84 2011/09/09 14:23:38 apb Exp $
1.1       lukem       2: .\"
1.82      apb         3: .\" Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
1.1       lukem       4: .\" All rights reserved.
                      5: .\"
                      6: .\" This code is derived from software contributed to The NetBSD Foundation
1.9       lukem       7: .\" by Todd Vierling and Luke Mewburn.
1.1       lukem       8: .\"
                      9: .\" Redistribution and use in source and binary forms, with or without
                     10: .\" modification, are permitted provided that the following conditions
                     11: .\" are met:
                     12: .\" 1. Redistributions of source code must retain the above copyright
                     13: .\"    notice, this list of conditions and the following disclaimer.
                     14: .\" 2. Redistributions in binary form must reproduce the above copyright
                     15: .\"    notice, this list of conditions and the following disclaimer in the
                     16: .\"    documentation and/or other materials provided with the distribution.
                     17: .\"
                     18: .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     19: .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     20: .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     21: .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     22: .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     23: .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     24: .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     25: .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     26: .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     27: .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     28: .\" POSSIBILITY OF SUCH DAMAGE.
                     29: .\"
1.84      apb        30: .\" NOTE: After changing this file, run "make regen" in the src/doc
                     31: .\" directory, and check in both src/BUILDING and src/doc/BUILDING.mdoc.
1.1       lukem      32: .\"
1.13      lukem      33: .\" Toolchain prefix for commands
                     34: .ds toolprefix nb
                     35: .
1.82      apb        36: .Dd September 9, 2011
1.1       lukem      37: .Dt BUILDING 8
                     38: .Os NetBSD
                     39: .
                     40: .Sh NAME
                     41: .
                     42: .Nm BUILDING
                     43: .Nd Procedure for building
                     44: .Nx
                     45: from source code.
                     46: .
                     47: .Sh REQUIREMENTS
                     48: .
                     49: .Nx
                     50: is designed to be buildable on most POSIX-compliant host systems.
                     51: The basic build procedure is the same whether compiling
                     52: .Em natively
                     53: (on the same
                     54: .Nx
                     55: architecture) or
                     56: .Em cross compiling
                     57: (on another architecture or OS).
                     58: .Pp
                     59: This source tree contains a special subtree,
                     60: .Dq tools ,
                     61: which uses the host system to create a build toolchain for the target
1.6       wiz        62: architecture.
                     63: The host system must have at least C and C++
1.1       lukem      64: compilers in order to create the toolchain
                     65: .Nm ( make
                     66: is not required); all other tools are created as part of the
                     67: .Nx
                     68: build process.
1.38      reed       69: (See the environment variables section below if you need
                     70: to override or manually select your compilers.)
1.1       lukem      71: .
                     72: .Sh FILES
                     73: .
                     74: .Ss Source tree layout
                     75: .
                     76: .Bl -tag -width "BUILDING.mdoc"
1.3       wiz        77: .It Sy doc/BUILDING.mdoc
1.1       lukem      78: This document (in -mdoc troff format; the original copy).
                     79: .It Sy BUILDING
                     80: This document (in plaintext).
1.33      jmc        81: .It Sy tools/compat/README
                     82: Special notes for cross-hosting a NetBSD build on non-NetBSD platforms.
1.1       lukem      83: .It Sy Makefile
                     84: The main Makefile for
                     85: .Nx ;
                     86: should only be run for native builds with an appropriately up-to-date
                     87: version of
                     88: .Nx
                     89: .Xr make 1 .
                     90: (For building from out-of-date systems or on a non-native host, see the
                     91: .Nm build.sh
                     92: shell script.)
                     93: .It Sy UPDATING
                     94: Special notes for updating from an earlier revision of
                     95: .Nx .
                     96: It is important to read this file before every build of an updated
                     97: source tree.
                     98: .It Sy build.sh
                     99: Bourne-compatible shell script used for building the host build tools
                    100: and the
                    101: .Nx
1.6       wiz       102: system from scratch.
                    103: Can be used for both native and cross builds, and should be used instead of
1.1       lukem     104: .Xr make 1
                    105: for any source tree that is updated and recompiled regularly.
                    106: .It Sy crypto/dist/ , dist/ , gnu/dist/
                    107: Sources imported verbatim from third parties, without mangling the
1.6       wiz       108: existing build structure.
                    109: Other source trees in
1.1       lukem     110: .Sy bin
                    111: through
                    112: .Sy usr.sbin
                    113: use the
                    114: .Nx
                    115: .Xr make 1
                    116: .Dq reachover
                    117: Makefile semantics when building these programs for a native host.
                    118: .It Sy distrib/ , etc/
                    119: Sources for items used when making a full release snapshot, such as
                    120: files installed in
1.14      lukem     121: .Sy DESTDIR Ns Pa /etc
1.1       lukem     122: on the destination system, boot media, and release notes.
1.57      dholland  123: .It Sy tests/ , regress/
1.6       wiz       124: Regression test harness.
                    125: Can be cross-compiled, but only run natively.
1.57      dholland  126: .Pa tests/
                    127: uses the
                    128: .Xr atf 7
                    129: test framework;
                    130: .Pa regress/
                    131: contains older tests that have not yet been migrated to
                    132: .Xr atf 7 .
1.1       lukem     133: .It Sy sys/
                    134: .Nx
                    135: kernel sources.
                    136: .It Sy tools/
                    137: .Dq Reachover
1.6       wiz       138: build structure for the host build tools.
                    139: This has a special method of determining out-of-date status.
1.1       lukem     140: .It Sy bin/ ... usr.sbin/
                    141: Sources to the
                    142: .Nx
1.6       wiz       143: userland (non-kernel) programs.
                    144: If any of these directories are missing, they will be skipped during the build.
1.34      lukem     145: .It Sy x11/
                    146: .Dq Reachover
                    147: build structure for X11R6; the source is in
                    148: .Sy X11SRCDIR .
1.1       lukem     149: .El
                    150: .
                    151: .Ss Build tree layout
                    152: .
                    153: The
                    154: .Nx
                    155: build tree is described in
                    156: .Xr hier 7 ,
                    157: and the release layout is described in
                    158: .Xr release 7 .
                    159: .Pp
                    160: .
                    161: .Sh CONFIGURATION
                    162: .
                    163: .Ss Environment variables
                    164: ..
                    165: Several environment variables control the behaviour of
                    166: .Nx
                    167: builds.
                    168: .
                    169: .Bl -tag -width "MAKEOBJDIRPREFIX"
                    170: .
1.38      reed      171: .
1.44      apb       172: .It Sy HOST_SH
1.85    ! apb       173: Path name to a shell available on the host system
        !           174: and suitable for use during the build.
        !           175: The
        !           176: .Nx
        !           177: build system requires a modern Bourne-like shell
        !           178: with POSIX-compliant features,
        !           179: and also requires support for the
        !           180: .Dq local
        !           181: keyword to declare local variables in shell functions
        !           182: (which is a widely-implemented but non-standardised feature).
        !           183: .Pp
        !           184: Depending on the host system, a suitable shell may be
        !           185: .Pa /bin/sh ,
        !           186: .Pa /usr/xpg4/bin/sh ,
        !           187: .Pa /bin/ksh
        !           188: (provided it is a variant of ksh that supports the
        !           189: .Dq local
        !           190: keyword,
        !           191: such as ksh88, but not ksh93),
        !           192: or
        !           193: .Pa /usr/local/bin/bash .
        !           194: .Pp
        !           195: Most parts of the build require
        !           196: .Sy HOST_SH
        !           197: to be an absolute path; however,
1.44      apb       198: .Nm build.sh
1.85    ! apb       199: allows it to be a simple command name, which will be converted
        !           200: to an absolute path by searching the
1.44      apb       201: .Sy PATH .
                    202: .
1.38      reed      203: .It Sy HOST_CC
                    204: Path name to C compiler used to create the toolchain.
                    205: .
                    206: .It Sy HOST_CXX
                    207: Path name to C++ compiler used to create the toolchain.
                    208: .
1.1       lukem     209: .It Sy MACHINE
1.57      dholland  210: Machine type, e.g.,
                    211: .Dq macppc .
1.1       lukem     212: .
                    213: .It Sy MACHINE_ARCH
1.57      dholland  214: Machine architecture, e.g.,
                    215: .Dq powerpc .
1.1       lukem     216: .
                    217: .It Sy MAKE
                    218: Path name to invoke
                    219: .Xr make 1
                    220: as.
                    221: .
                    222: .It Sy MAKEFLAGS
                    223: Flags to invoke
                    224: .Xr make 1
                    225: with.
1.82      apb       226: Note that
                    227: .Sy build.sh
                    228: ignores the value of
                    229: .Sy MAKEFLAGS
                    230: passed in the environment, but allows
                    231: .Sy MAKEFLAGS
                    232: to be set via the
                    233: .Fl V
                    234: option.
1.1       lukem     235: .
                    236: .It Sy MAKEOBJDIR
                    237: Directory to use as the
                    238: .Sy .OBJDIR
                    239: for the current directory.
1.46      apb       240: The value is subjected to variable expansion by
                    241: .Xr make 1 .
1.61      apb       242: Typical usage is to set this variable to a value involving the use of
                    243: .Sq ${.CURDIR:S...}
                    244: or
                    245: .Sq ${.CURDIR:C...} ,
                    246: to derive the value of
                    247: .Sy .OBJDIR
                    248: from the value of
                    249: .Sy .CURDIR .
1.1       lukem     250: Used only if
                    251: .Sy MAKEOBJDIRPREFIX
                    252: is not defined.
                    253: .Sy MAKEOBJDIR
1.61      apb       254: can be provided only in the environment or via the
1.28      lukem     255: .Fl O
1.23      lukem     256: flag of
1.61      apb       257: .Nm build.sh ;
1.71      mrg       258: it cannot usefully be set inside a Makefile, including
                    259: .Pa mk.conf
                    260: or
                    261: .Sy ${MAKECONF} .
1.1       lukem     262: .
                    263: .It Sy MAKEOBJDIRPREFIX
                    264: Top level directory of the object directory tree.
1.77      apb       265: The value is subjected to variable expansion by
                    266: .Xr make 1 .
                    267: .Sy build.sh
                    268: will create the
                    269: ${MAKEOBJDIRPREFIX}
                    270: directory if necessary, but if
                    271: .Xr make 1
                    272: is used without
                    273: .Sy build.sh ,
                    274: then rules in
                    275: .Aq bsd.obj.mk
                    276: will abort the build if the
                    277: ${MAKEOBJDIRPREFIX}
                    278: directory does not exist.
                    279: If the value is defined and valid, then
1.1       lukem     280: ${MAKEOBJDIRPREFIX}/${.CURDIR}
                    281: is used as the
                    282: .Sy .OBJDIR
                    283: for the current directory.
                    284: The current directory may be read only.
                    285: .Sy MAKEOBJDIRPREFIX
1.61      apb       286: can be provided only in the environment or via the
1.23      lukem     287: .Fl M
                    288: flag of
1.61      apb       289: .Nm build.sh ;
1.71      mrg       290: it cannot usefully be set inside a Makefile, including
                    291: .Pa mk.conf
                    292: or
                    293: .Sy ${MAKECONF} .
1.1       lukem     294: .
                    295: .El
                    296: .
                    297: .Ss \*qmake\*q variables
                    298: .
                    299: .de YorN
                    300: Can be set to
                    301: .Dq yes
                    302: or
                    303: .Dq no .
                    304: ..
                    305: .de DFLT
                    306: .Pp
                    307: .Em Default :
                    308: ..
                    309: .de DFLTu
                    310: .DFLT
                    311: Unset.
                    312: ..
                    313: .de DFLTy
                    314: .DFLT
                    315: .Dq yes
                    316: ..
                    317: .de DFLTn
                    318: .DFLT
                    319: .Dq no
                    320: ..
                    321: Several variables control the behavior of
                    322: .Nx
1.6       wiz       323: builds.
                    324: Unless otherwise specified, these variables may be set in
1.1       lukem     325: either the process environment or the
                    326: .Xr make 1
                    327: configuration file specified by
                    328: .Sy MAKECONF .
                    329: .
                    330: .Bl -tag -width "MKCATPAGES"
                    331: .
                    332: .It Sy BUILDID
1.6       wiz       333: Identifier for the build.
                    334: The identifier will be appended to
1.1       lukem     335: object directory names, and can be consulted in the
                    336: .Xr make 1
                    337: configuration file in order to set additional build parameters,
                    338: such as compiler flags.
                    339: .
1.60      perry     340: .It Sy BUILDSEED
                    341: GCC uses random numbers when compiling C++ code.
                    342: This variable seeds the gcc random number generator using
                    343: the -frandom-seed flag with this value.
                    344: By default, it is set to NetBSD-(majorversion).
                    345: Using a fixed value causes C++ binaries to be the same when
1.74      hubertf   346: built from the same sources, resulting in identical (reproducible) builds.
1.60      perry     347: Additional information is available in the GCC
                    348: documentation of -frandom-seed.
                    349: .
1.1       lukem     350: .It Sy DESTDIR
                    351: Directory to contain the built
                    352: .Nx
1.6       wiz       353: system.
                    354: If set, special options are passed to the compilation tools to
1.1       lukem     355: prevent their default use of the host system's
                    356: .Sy /usr/include , /usr/lib ,
1.6       wiz       357: and so forth.
1.46      apb       358: This pathname must be an absolute path, and should
1.1       lukem     359: .Em not
                    360: end with a slash
                    361: .Pq /
1.46      apb       362: character.
                    363: (For installation into the system's root directory, set
1.1       lukem     364: .Sy DESTDIR
1.46      apb       365: to an empty string, not to
                    366: .Dq / ) .
1.1       lukem     367: The directory must reside on a file system which supports long file
                    368: names and hard links.
                    369: .DFLT
                    370: Empty string if
                    371: .Sy USETOOLS
                    372: is
                    373: .Dq yes ;
                    374: unset otherwise.
1.17      lukem     375: .Pp
                    376: .Em Note :
                    377: .Sy build.sh
                    378: will provide a default of
                    379: .Pa destdir. Ns Sy MACHINE
                    380: (in the top-level
                    381: .Sy .OBJDIR )
                    382: unless run in
                    383: .Sq expert
1.57      dholland  384: mode.
1.1       lukem     385: .
                    386: .It Sy MAKECONF
                    387: The name of the
                    388: .Xr make 1
                    389: configuration file.
                    390: .Em Only settable in the process environment.
                    391: .DFLT
                    392: .Dq /etc/mk.conf
                    393: .
1.30      lukem     394: .It Sy MAKEVERBOSE
                    395: Level of verbosity of status messages.
                    396: Supported values:
                    397: .Bl -tag -width xxx
                    398: .It 0
1.69      apb       399: No descriptive messages or commands executed by
                    400: .Xr make 1
                    401: are shown.
1.30      lukem     402: .It 1
1.69      apb       403: Brief messages are shown describing what is being done,
                    404: but the actual commands executed by
                    405: .Xr make 1
                    406: are not displayed.
1.30      lukem     407: .It 2
1.69      apb       408: Descriptive messages are shown as above (prefixed with a
                    409: .Sq # ) ,
                    410: and ordinary commands performed by
                    411: .Xr make 1
                    412: are displayed.
                    413: .It 3
                    414: In addition to the above, all commands performed by
                    415: .Xr make 1
                    416: are displayed, even if they would ordinarily have been hidden
                    417: through use of the
                    418: .Dq \&@
                    419: prefix in the relevant makefile.
                    420: .It 4
                    421: In addition to the above, commands executed by
                    422: .Xr make 1
                    423: are traced through use of the
                    424: .Xr sh 1
                    425: .Dq Fl x
                    426: flag.
1.30      lukem     427: .El
                    428: .DFLT
                    429: 2
                    430: .
1.1       lukem     431: .It Sy MKCATPAGES
                    432: .YorN
                    433: Indicates whether preformatted plaintext manual pages will be created
                    434: during a build.
                    435: .DFLTy
                    436: .
                    437: .It Sy MKCRYPTO
                    438: .YorN
                    439: Indicates whether cryptographic code will be included in a build;
                    440: provided for the benefit of countries that do not allow strong
1.6       wiz       441: cryptography.
                    442: Will not affect use of the standard low-security password encryption system,
1.1       lukem     443: .Xr crypt 3 .
                    444: .DFLTy
                    445: .
                    446: .It Sy MKDOC
                    447: .YorN
                    448: Indicates whether system documentation destined for
1.14      lukem     449: .Sy DESTDIR Ns Pa /usr/share/doc
1.1       lukem     450: will be installed during a build.
                    451: .DFLTy
                    452: .
1.65      lukem     453: .It Sy MKHTML
                    454: .YorN
                    455: Indicates whether preformatted HTML manual pages will be built
                    456: and installed
                    457: .DFLTy
                    458: .
1.1       lukem     459: .It Sy MKHOSTOBJ
                    460: .YorN
                    461: If set to
                    462: .Dq yes ,
                    463: then for programs intended to be run on the compile host,
                    464: the name, release, and architecture of the host operating system
                    465: will be suffixed to the name of the object directory created by
                    466: .Dq make obj .
                    467: (This allows multiple host systems to compile NetBSD for a single target.)
                    468: If set to
                    469: .Dq no ,
                    470: then programs built to be run on the compile host will use the same
                    471: object directory names as programs built to be run on the target.
                    472: .DFLTn
                    473: .
                    474: .It Sy MKINFO
                    475: .YorN
                    476: Indicates whether GNU Info files, used for the documentation for
                    477: most of the compilation tools, will be created and installed during a
                    478: build.
                    479: .DFLTy
                    480: .
1.83      apb       481: .It Sy MKKMOD
                    482: .YorN
                    483: Indicates whether kernel modules are built and installed.
                    484: .DFLTy
                    485: .
1.1       lukem     486: .It Sy MKLINT
                    487: .YorN
                    488: Indicates whether
                    489: .Xr lint 1
                    490: will be run against portions of the
                    491: .Nx
                    492: source code during the build, and whether lint libraries will be
                    493: installed into
1.14      lukem     494: .Sy DESTDIR Ns Pa /usr/libdata/lint .
1.1       lukem     495: .DFLTy
                    496: .
                    497: .It Sy MKMAN
                    498: .YorN
                    499: Indicates whether manual pages will be installed during a build.
                    500: .DFLTy
                    501: .
                    502: .It Sy MKNLS
                    503: .YorN
                    504: Indicates whether Native Language System locale zone files will be
                    505: compiled and installed during a build.
                    506: .DFLTy
                    507: .
                    508: .It Sy MKOBJ
                    509: .YorN
                    510: Indicates whether object directories will be created when running
                    511: .Dq make obj .
                    512: If set to
                    513: .Dq no ,
                    514: then all built files will be located inside the regular source tree.
                    515: .DFLTy
1.57      dholland  516: .Pp
                    517: Note that setting
                    518: .Sy MKOBJ
                    519: to
                    520: .Dq no
                    521: is not recommended and may cause problems when updating the tree with
                    522: .Xr cvs 1 .
1.1       lukem     523: .
                    524: .It Sy MKPIC
                    525: .YorN
                    526: Indicates whether shared objects and libraries will be created and
1.6       wiz       527: installed during a build.
                    528: If set to
1.1       lukem     529: .Dq no ,
                    530: the entire built system will be statically linked.
                    531: .DFLT
1.6       wiz       532: Platform dependent.
                    533: As of this writing, all platforms except
1.1       lukem     534: .Sy sh3
                    535: default to
                    536: .Dq yes .
                    537: .
                    538: .It Sy MKPICINSTALL
                    539: .YorN
                    540: Indicates whether the
                    541: .Xr ar 1
                    542: format libraries
                    543: .Sy ( lib*_pic.a ) ,
                    544: used to generate shared libraries, are installed during a build.
                    545: .DFLTy
                    546: .
                    547: .It Sy MKPROFILE
                    548: .YorN
                    549: Indicates whether profiled libraries
                    550: .Sy ( lib*_p.a )
                    551: will be built and installed during a build.
                    552: .DFLT
                    553: .Dq yes ;
                    554: however, some platforms turn off
                    555: .Sy MKPROFILE
                    556: by default at times due to toolchain problems with profiled code.
                    557: .
                    558: .It Sy MKSHARE
                    559: .YorN
                    560: Indicates whether files destined to reside in
1.14      lukem     561: .Sy DESTDIR Ns Pa /usr/share
1.6       wiz       562: will be built and installed during a build.
                    563: If set to
1.1       lukem     564: .Dq no ,
                    565: then all of
                    566: .Sy MKCATPAGES , MKDOC , MKINFO , MKMAN ,
                    567: and
                    568: .Sy MKNLS
                    569: will be set to
                    570: .Dq no
                    571: unconditionally.
                    572: .DFLTy
                    573: .
1.66      joerg     574: .It Sy MKSTRIPIDENT
                    575: .YorN
                    576: Indicates whether program binaries and shared libraries should be built
                    577: to include RCS IDs for use with
                    578: .Xr ident 1 .
                    579: .DFLTn
                    580: .
1.25      lukem     581: .It Sy MKUNPRIVED
                    582: .YorN
                    583: Indicates whether an unprivileged install will occur.
1.1       lukem     584: The user, group, permissions, and file flags, will not be set on
1.37      jmc       585: the installed items; instead the information will be appended to
1.1       lukem     586: a file called
                    587: .Pa METALOG
                    588: in
                    589: .Sy DESTDIR .
                    590: The contents of
                    591: .Pa METALOG
1.37      jmc       592: are used during the generation of the distribution tar files to ensure
1.1       lukem     593: that the appropriate file ownership is stored.
1.25      lukem     594: .DFLTn
1.1       lukem     595: .
1.25      lukem     596: .It Sy MKUPDATE
                    597: .YorN
                    598: Indicates whether all install operations intended to write to
1.1       lukem     599: .Sy DESTDIR
                    600: will compare file timestamps before installing, and skip the install
1.6       wiz       601: phase if the destination files are up-to-date.
                    602: This also has implications on full builds (see next subsection).
1.25      lukem     603: .DFLTn
                    604: .
1.34      lukem     605: .It Sy MKX11
                    606: .YorN
1.68      mrg       607: Indicates whether X11 is built from
1.34      lukem     608: .Sy X11SRCDIR .
                    609: .DFLTn
                    610: .
1.25      lukem     611: .It Sy TOOLDIR
                    612: Directory to hold the host tools, once built.
1.46      apb       613: If specified, must be an absolute path.
1.25      lukem     614: This directory should be unique to a given host system and
                    615: .Nx
                    616: source tree.
                    617: (However, multiple targets may share the same
                    618: .Sy TOOLDIR ;
                    619: the target-dependent files have unique names.)  If unset, a default based
                    620: on the
                    621: .Xr uname 1
                    622: information of the host platform will be created in the
                    623: .Sy .OBJDIR
                    624: of
1.26      lukem     625: .Pa src .
1.1       lukem     626: .DFLTu
                    627: .
                    628: .It Sy USETOOLS
                    629: Indicates whether the tools specified by
                    630: .Sy TOOLDIR
1.6       wiz       631: should be used as part of a build in progress.
                    632: Must be set to
1.1       lukem     633: .Dq yes
                    634: if cross-compiling.
                    635: .Bl -tag -width "never"
                    636: .It Sy yes
                    637: Use the tools from
                    638: .Sy TOOLDIR .
                    639: .It Sy no
                    640: Do not use the tools from
                    641: .Sy TOOLDIR ,
                    642: but refuse to build native compilation tool components that are
                    643: version-specific for that tool.
                    644: .It Sy never
                    645: Do not use the tools from
                    646: .Sy TOOLDIR ,
1.6       wiz       647: even when building native tool components.
                    648: This is similar to the traditional
1.1       lukem     649: .Nx
                    650: build method, but does
                    651: .Em not
                    652: verify that the compilation tools in use are up-to-date enough in order
1.6       wiz       653: to build the tree successfully.
                    654: This may cause build or runtime problems when building the whole
1.1       lukem     655: .Nx
                    656: source tree.
                    657: .El
1.58      dholland  658: .DFLT
                    659: .Dq yes ,
                    660: unless
                    661: .Sy TOOLCHAIN_MISSING
                    662: is set to
                    663: .Dq yes .
                    664: .Pp
                    665: .Sy USETOOLS
                    666: is also set to
                    667: .Dq no
                    668: when using
                    669: .Aq bsd.*.mk
                    670: outside the
                    671: .Nx
                    672: source tree.
1.1       lukem     673: .
1.34      lukem     674: .It Sy X11SRCDIR
                    675: Directory containing the X11R6 source.
1.46      apb       676: If specified, must be an absolute path.
1.34      lukem     677: The main X11R6 source is found in
                    678: .Sy X11SRCDIR Ns Pa /xfree/xc .
                    679: .DFLT
1.80      apb       680: .Sy NETBSDRCDIR Ns Pa /../xsrc ,
                    681: if that exists; otherwise
                    682: .Pa /usr/xsrc .
1.34      lukem     683: .
1.68      mrg       684: .It Sy X11FLAVOUR
                    685: The style of X11 cross-built, set to either
                    686: .Dq Xorg
                    687: or
                    688: .Dq XFree86 .
                    689: .DFLT
                    690: .Dq Xorg
1.70      mrg       691: on amd64, i386, macppc, shark and sparc64 platforms,
1.68      mrg       692: .Dq XFree86
                    693: on everything else.
                    694: .
1.1       lukem     695: .El
                    696: .
                    697: .Ss \*qmake\*q variables for full builds
                    698: These variables only affect the top level
                    699: .Dq Makefile
                    700: and do not affect manually building subtrees of the
                    701: .Nx
                    702: source code.
                    703: .
1.7       lukem     704: .Bl -tag -width "INSTALLWORLDDIR"
                    705: .
                    706: .It Sy INSTALLWORLDDIR
                    707: Location for the
                    708: .Dq make installworld
                    709: target to install to.
1.46      apb       710: If specified, must be an absolute path.
1.7       lukem     711: .DFLT
                    712: .Dq /
1.1       lukem     713: .
                    714: .It Sy MKOBJDIRS
                    715: .YorN
                    716: Indicates whether object directories will be created automatically
                    717: (via a
                    718: .Dq make obj
                    719: pass) at the start of a build.
1.21      lukem     720: .DFLTn
1.57      dholland  721: .Pp
                    722: If using
                    723: .Sy build.sh ,
                    724: the default is
                    725: .Dq yes .
                    726: This may be set back to
                    727: .Dq no
                    728: by giving
                    729: .Sy build.sh
                    730: the
                    731: .Fl o
                    732: option.
1.1       lukem     733: .
1.25      lukem     734: .It Sy MKUPDATE
                    735: .YorN
                    736: If set, then in addition to the effects described for
                    737: .Sy MKUPDATE=yes
                    738: above, this implies the effects of
                    739: .Sy NOCLEANDIR
                    740: (i.e.,
                    741: .Dq make cleandir
                    742: is avoided).
                    743: .DFLTn
1.57      dholland  744: .Pp
                    745: If using
                    746: .Sy build.sh ,
                    747: this may be set by giving the
                    748: .Fl u
                    749: option.
1.25      lukem     750: .
1.1       lukem     751: .It Sy NBUILDJOBS
1.6       wiz       752: Now obsolete.
                    753: Use the
1.1       lukem     754: .Xr make 1
                    755: option
1.4       lukem     756: .Fl j ,
1.57      dholland  757: instead.
                    758: See below.
1.1       lukem     759: .DFLTu
                    760: .
                    761: .It Sy NOCLEANDIR
                    762: If set, avoids the
                    763: .Dq make cleandir
1.6       wiz       764: phase of a full build.
                    765: This has the effect of allowing only changed
                    766: files in a source tree to be recompiled.
                    767: This can speed up builds when updating only a few files in the tree.
1.1       lukem     768: .DFLTu
1.57      dholland  769: .Pp
                    770: See also
                    771: .Sy MKUPDATE .
1.1       lukem     772: .
                    773: .It Sy NODISTRIBDIRS
                    774: If set, avoids the
                    775: .Dq make distrib-dirs
1.6       wiz       776: phase of a full build.
                    777: This skips running
1.1       lukem     778: .Xr mtree 8
                    779: on
                    780: .Sy DESTDIR ,
                    781: useful on systems where building as an unprivileged user, or where it is
                    782: known that the system-wide mtree files have not changed.
                    783: .DFLTu
                    784: .
                    785: .It Sy NOINCLUDES
                    786: If set, avoids the
                    787: .Dq make includes
1.6       wiz       788: phase of a full build.
                    789: This has the effect of preventing
1.1       lukem     790: .Xr make 1
                    791: from thinking that some programs are out-of-date simply because the
1.6       wiz       792: system include files have changed.
                    793: However, this option should not be used when updating the entire
1.1       lukem     794: .Nx
                    795: source tree arbitrarily; it is suggested to use
1.25      lukem     796: .Sy MKUPDATE=yes
1.57      dholland  797: instead in that case.
1.1       lukem     798: .DFLTu
                    799: .
                    800: .It Sy RELEASEDIR
                    801: If set, specifies the directory to which a
                    802: .Xr release 7
                    803: layout will be written at the end of a
                    804: .Dq make release .
1.46      apb       805: If specified, must be an absolute path.
1.1       lukem     806: .DFLTu
1.17      lukem     807: .Pp
                    808: .Em Note :
                    809: .Sy build.sh
                    810: will provide a default of
                    811: .Pa releasedir
                    812: (in the top-level
                    813: .Sy .OBJDIR )
                    814: unless run in
                    815: .Sq expert
1.57      dholland  816: mode.
1.1       lukem     817: .
                    818: .El
                    819: .
                    820: .Sh BUILDING
                    821: .
                    822: .Ss \*qmake\*q command line options
1.37      jmc       823: This is not a summary of all the options available to
1.1       lukem     824: .Xr make 1 ;
                    825: only the options used most frequently with
                    826: .Nx
                    827: builds are listed here.
                    828: .
                    829: .Bl -tag -width "var=value"
                    830: .
1.4       lukem     831: .It Fl j Ar njob
1.1       lukem     832: Run up to
1.4       lukem     833: .Ar njob
1.1       lukem     834: .Xr make 1
                    835: subjobs in parallel.
1.37      jmc       836: Makefiles should use .WAIT or have explicit dependencies
1.1       lukem     837: as necessary to enforce build ordering.
                    838: .
1.4       lukem     839: .It Fl m Ar dir
1.1       lukem     840: Specify the default directory for searching for system Makefile
                    841: segments, mainly the
                    842: .Aq bsd.*.mk
1.6       wiz       843: files.
                    844: When building any full
1.1       lukem     845: .Nx
                    846: source tree, this should be set to the
                    847: .Dq share/mk
1.6       wiz       848: directory in the source tree.
1.57      dholland  849: This is set automatically when building from the top level, or when using
                    850: .Sy build.sh .
1.1       lukem     851: .
1.4       lukem     852: .It Fl n
1.1       lukem     853: Display the commands that would have been executed, but do not
1.6       wiz       854: actually execute them.
                    855: This will still cause recursion to take place.
1.1       lukem     856: .
1.32      zuntum    857: .It Fl V Ar var
1.1       lukem     858: Print
                    859: .Xr make 1 Ns 's
                    860: idea of the value of
1.4       lukem     861: .Ar var .
1.1       lukem     862: Does not build any targets.
                    863: .
                    864: .It Em var=value
                    865: Set the variable
                    866: .Em var
                    867: to
                    868: .Em value ,
                    869: overriding any setting specified by the process environment, the
                    870: .Sy MAKECONF
                    871: configuration file, or the system Makefile segments.
                    872: .
                    873: .El
                    874: .
                    875: .Ss \*qmake\*q targets
                    876: .
                    877: These default targets may be built by running
                    878: .Xr make 1
                    879: in any subtree of the
                    880: .Nx
1.6       wiz       881: source code.
                    882: It is recommended that none of these be used from the top
1.1       lukem     883: level Makefile; as a specific exception,
                    884: .Dq make obj
                    885: and
                    886: .Dq make cleandir
                    887: are useful in that context.
                    888: .
                    889: .Bl -tag -width "dependall"
                    890: .
                    891: .It Sy all
                    892: Build programs, libraries, and preformatted documentation.
                    893: .
                    894: .It Sy clean
                    895: Remove program and library object code files.
                    896: .
                    897: .It Sy cleandir
                    898: Same as
                    899: .Sy clean ,
                    900: but also remove preformatted documentation, dependency files generated
                    901: by
                    902: .Dq make depend ,
                    903: and any other files known to be created at build time.
                    904: .
                    905: .It Sy depend
                    906: Create dependency files
                    907: .Sy ( .depend )
                    908: containing more detailed information about the dependencies of source
1.6       wiz       909: code on header files.
                    910: Allows programs to be recompiled automatically when a dependency changes.
1.1       lukem     911: .
                    912: .It Sy dependall
                    913: Does a
                    914: .Dq make depend
                    915: immediately followed by a
                    916: .Dq make all .
                    917: This improves cache locality of the build since both passes read the source
                    918: files in their entirety.
                    919: .
1.34      lukem     920: .It Sy distclean
                    921: Synonym for
                    922: .Sy cleandir .
                    923: .
1.1       lukem     924: .It Sy includes
1.6       wiz       925: Build and install system header files.
                    926: Typically needed before any system libraries or programs can be built.
1.1       lukem     927: .
                    928: .It Sy install
                    929: Install programs, libraries, and documentation into
                    930: .Sy DESTDIR .
                    931: Few files will be installed to
1.14      lukem     932: .Sy DESTDIR Ns Pa /dev ,
                    933: .Sy DESTDIR Ns Pa /etc ,
                    934: .Sy DESTDIR Ns Pa /root
1.1       lukem     935: or
1.14      lukem     936: .Sy DESTDIR Ns Pa /var
1.1       lukem     937: in order to prevent user supplied configuration data from being overwritten.
                    938: .It Sy lint
                    939: Run
                    940: .Xr lint 1
                    941: against the C source code, where appropriate, and generate
                    942: system-installed lint libraries.
                    943: .
                    944: .It Sy obj
                    945: Create object directories to be used for built files, instead of
                    946: building directly in the source tree.
                    947: .
                    948: .It Sy tags
                    949: Create
                    950: .Xr ctags 1
                    951: searchable function lists usable by the
                    952: .Xr ex 1
                    953: and
                    954: .Xr vi 1
                    955: text editors.
                    956: .
                    957: .El
                    958: .
                    959: .Ss \*qmake\*q targets for the top level
                    960: .
                    961: Additional
                    962: .Xr make 1
                    963: targets are usable specifically from the top source level to facilitate
                    964: building the entire
                    965: .Nx
                    966: source tree.
                    967: .
1.7       lukem     968: .Bl -tag -width "distribution"
1.1       lukem     969: .
                    970: .It Sy build
                    971: Build the entire
                    972: .Nx
1.55      reed      973: system (except the kernel).
1.6       wiz       974: This orders portions of the source tree such that prerequisites
1.1       lukem     975: will be built in the proper order.
                    976: .
1.7       lukem     977: .It Sy distribution
                    978: Do a
                    979: .Dq make build ,
1.55      reed      980: and then install a full distribution (which does not include a kernel) into
1.9       lukem     981: .Sy DESTDIR ,
                    982: including files in
1.14      lukem     983: .Sy DESTDIR Ns Pa /dev ,
                    984: .Sy DESTDIR Ns Pa /etc ,
                    985: .Sy DESTDIR Ns Pa /root
1.9       lukem     986: and
1.14      lukem     987: .Sy DESTDIR Ns Pa /var .
1.7       lukem     988: .
                    989: .It Sy buildworld
                    990: As per
                    991: .Dq make distribution ,
                    992: except that it ensures that
                    993: .Sy DESTDIR
                    994: is not the root directory.
                    995: .
                    996: .It Sy installworld
                    997: Install the distribution from
                    998: .Sy DESTDIR
                    999: to
1.57      dholland 1000: .Sy INSTALLWORLDDIR ,
                   1001: which defaults to the root directory.
1.7       lukem    1002: Ensures that
                   1003: .Sy INSTALLWORLDDIR
1.37      jmc      1004: is not the root directory if cross compiling.
1.7       lukem    1005: .Pp
1.48      apb      1006: The
                   1007: .Sy INSTALLSETS
1.83      apb      1008: environment variable may be set to a space-separated list of
1.48      apb      1009: distribution sets to be installed.
                   1010: By default, all sets except
                   1011: .Dq etc
                   1012: and
                   1013: .Dq xetc
1.57      dholland 1014: are installed, so most files in
1.48      apb      1015: .Sy INSTALLWORLDDIR Ns Pa /etc
1.57      dholland 1016: will not be installed or modified.
1.48      apb      1017: .Pp
1.7       lukem    1018: .Em Note :
1.48      apb      1019: Before performing this operation with
                   1020: .Sy INSTALLWORLDDIR Ns = Ns Pa / ,
                   1021: it is highly recommended that you upgrade your kernel and reboot.
                   1022: After performing this operation,
                   1023: it is recommended that you use
                   1024: .Xr etcupdate 8
                   1025: to update files in
                   1026: .Sy INSTALLWORLDDIR Ns Pa /etc
                   1027: and that you use
                   1028: .Xr postinstall 8
                   1029: to check for inconsistencies (and possibly to fix them).
1.12      lukem    1030: .It Sy sets
                   1031: Create distribution sets from
                   1032: .Sy DESTDIR
                   1033: into
1.56      lukem    1034: .Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/sets .
1.12      lukem    1035: Should be run after
1.57      dholland 1036: .Dq make distribution ,
                   1037: as
1.12      lukem    1038: .Dq make build
1.57      dholland 1039: alone does not install all of the required files.
1.12      lukem    1040: .
1.18      lukem    1041: .It Sy sourcesets
                   1042: Create source sets of the source tree into
                   1043: .Sy RELEASEDIR Ns Pa /source/sets .
                   1044: .
1.40      apb      1045: .It Sy syspkgs
                   1046: Create syspkgs from
                   1047: .Sy DESTDIR
                   1048: into
1.56      lukem    1049: .Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/syspkgs .
1.40      apb      1050: Should be run after
1.57      dholland 1051: .Dq make distribution ,
                   1052: as
1.40      apb      1053: .Dq make build
1.57      dholland 1054: alone does not install all of the required files.
1.40      apb      1055: .
1.1       lukem    1056: .It Sy release
                   1057: Do a
1.9       lukem    1058: .Dq make distribution ,
1.12      lukem    1059: build kernels, distribution media, and install sets
                   1060: (this as per
                   1061: .Dq make sets ) ,
                   1062: and
1.1       lukem    1063: then package the system into a standard release layout as described by
                   1064: .Xr release 7 .
                   1065: This requires that
                   1066: .Sy RELEASEDIR
                   1067: be set (see above).
                   1068: .
1.57      dholland 1069: .It Sy iso-image
1.49      apb      1070: Create a
                   1071: .Nx
                   1072: installation CD-ROM image in the
                   1073: .Sy RELEASEDIR Ns Pa /iso
                   1074: directory.
                   1075: The CD-ROM file system will have a layout as described in
                   1076: .Xr release 7 .
                   1077: .Pp
                   1078: For most machine types, the CD-ROM will be bootable, and will automatically
                   1079: run the
                   1080: .Xr sysinst 8
                   1081: menu-based installation program, which can be used to install or upgrade a
                   1082: .Nx
                   1083: system.
                   1084: Bootable CD-ROMs also contain tools that may be useful in
                   1085: repairing a damaged
                   1086: .Nx
                   1087: installation.
                   1088: .Pp
                   1089: Before
                   1090: .Dq make iso-image
                   1091: is attempted, RELEASEDIR must be populated by
1.42      apb      1092: .Dq make release
                   1093: or equivalent.
1.49      apb      1094: .Pp
                   1095: Note that other, smaller, CD-ROM images may be created in the
1.56      lukem    1096: .Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /installation/cdrom
1.49      apb      1097: directory by
                   1098: .Dq "make release" .
                   1099: These smaller images usually contain the same tools as the larger images in
                   1100: .Sy RELEASEDIR Ns Pa /iso ,
                   1101: but do not contain additional content such as the distribution sets.
                   1102: .Pp
                   1103: Note that the mac68k port still uses an older method of creating
                   1104: CD-ROM images.
1.42      apb      1105: This requires the
                   1106: .Xr mkisofs 1
                   1107: utility, which is not part of
                   1108: .Nx ,
                   1109: but which can be installed from
1.43      apb      1110: .Pa pkgsrc/sysutils/cdrtools .
1.42      apb      1111: .
1.63      lukem    1112: .It Sy iso-image-source
1.51      jnemeth  1113: Create a
                   1114: .Nx
                   1115: installation CD-ROM image in the
                   1116: .Sy RELEASEDIR Ns Pa /iso
                   1117: directory.
                   1118: The CD-ROM file system will have a layout as described in
                   1119: .Xr release 7 .
                   1120: It will have top level directories for the machine type and source.
                   1121: .Pp
                   1122: For most machine types, the CD-ROM will be bootable, and will automatically
                   1123: run the
                   1124: .Xr sysinst 8
                   1125: menu-based installation program, which can be used to install or upgrade a
                   1126: .Nx
                   1127: system.
                   1128: Bootable CD-ROMs also contain tools that may be useful in
                   1129: repairing a damaged
                   1130: .Nx
                   1131: installation.
                   1132: .Pp
                   1133: Before
                   1134: .Dq make iso-image-source
                   1135: is attempted, RELEASEDIR must be populated by
                   1136: .Dq make sourcesets release
                   1137: or equivalent.
                   1138: .Pp
                   1139: Note that other, smaller, CD-ROM images may be created in the
1.56      lukem    1140: .Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /installation/cdrom
1.51      jnemeth  1141: directory by
                   1142: .Dq make release .
                   1143: These smaller images usually contain the same tools as the larger images in
                   1144: .Sy RELEASEDIR Ns Pa /iso ,
                   1145: but do not contain additional content such as the distribution sets.
                   1146: .Pp
                   1147: Note that the mac68k port still uses an older method of creating
                   1148: CD-ROM images.
                   1149: This requires the
                   1150: .Xr mkisofs 1
                   1151: utility, which is not part of
                   1152: .Nx ,
                   1153: but which can be installed from
                   1154: .Pa pkgsrc/sysutils/cdrtools .
                   1155: .
1.1       lukem    1156: .It Sy regression-tests
                   1157: Can only be run after building the regression tests in the directory
                   1158: .Dq regress .
1.57      dholland 1159: Runs those compiled regression tests on the local host.
                   1160: Note that most tests are now managed instead using
                   1161: .Xr atf 7 ;
                   1162: this target should probably run those as well but currently does not.
1.1       lukem    1163: .
                   1164: .El
                   1165: .
                   1166: .Ss The \*qbuild.sh\*q script
                   1167: .
1.85    ! apb      1168: This script file is a shell script designed to build the
1.1       lukem    1169: entire
                   1170: .Nx
1.85    ! apb      1171: system on any host with a suitable modern shell and some common
        !          1172: utilities.
        !          1173: The required shell features are described under the
        !          1174: .Sy HOST_SH
        !          1175: variable.
        !          1176: .Pp
        !          1177: If a host system's default shell does support the required
        !          1178: features, then we suggest that you explicitly specify
        !          1179: a suitable shell using a command like
        !          1180: .Bd -unfilled -offset indent
        !          1181: .Li /path/to/suitable/shell build.sh Op Ar options
        !          1182: .Ed
        !          1183: .Pp
        !          1184: The above command will usually enable
        !          1185: .Nm build.sh
        !          1186: to automatically set
        !          1187: .Sy HOST_SH Ns Cm = Ns Pa /path/to/suitable/shell ,
        !          1188: but if that fails, then the following set of commands may be used instead:
        !          1189: .Bd -unfilled -offset indent
        !          1190: .Li HOST_SH= Ns Va /path/to/suitable/shell
        !          1191: .Li export HOST_SH
        !          1192: .Li ${HOST_SH} build.sh Op Ar options
        !          1193: .Ed
        !          1194: .Pp
        !          1195: If
        !          1196: .Sy build.sh
        !          1197: detects that it is being executed under an unsuitable shell, it attempts
        !          1198: to exec a suitable shell instead, or prints an error message.
        !          1199: If
        !          1200: .Sy HOST_SH
        !          1201: is not set explicitly, then
        !          1202: .Nm build.sh
        !          1203: sets a default using heuristics dependent on the host platform,
        !          1204: or from the shell under which
        !          1205: .Nm build.sh
        !          1206: is executed (if that can be determined),
        !          1207: or using the first copy of
        !          1208: .Pa sh
        !          1209: found in
        !          1210: .Sy PATH .
1.1       lukem    1211: .Pp
                   1212: All cross-compile builds, and most native builds, of the entire system
                   1213: should make use of
                   1214: .Sy build.sh
                   1215: rather than just running
                   1216: .Dq make .
                   1217: This way, the
                   1218: .Xr make 1
                   1219: program will be bootstrapped properly, in case the host system has an
                   1220: older or incompatible
                   1221: .Dq make
                   1222: program.
                   1223: .Pp
                   1224: When compiling the entire system via
                   1225: .Sy build.sh ,
                   1226: many
                   1227: .Xr make 1
                   1228: variables are set for you in order to help encapsulate the build
1.6       wiz      1229: process.
                   1230: In the list of options below, variables that are automatically set by
1.1       lukem    1231: .Sy build.sh
                   1232: are noted where applicable.
1.9       lukem    1233: .
1.1       lukem    1234: .Pp
1.9       lukem    1235: The following operations are supported by
1.1       lukem    1236: .Sy build.sh :
                   1237: .
1.9       lukem    1238: .Bl -tag -width "distribution"
                   1239: .
                   1240: .It Sy build
                   1241: Build the system as per
                   1242: .Dq make build .
1.57      dholland 1243: Before the main part of the build commences, this command runs the
1.9       lukem    1244: .Sy obj
1.57      dholland 1245: operation (unless the
                   1246: .Fl o
                   1247: option is given),
                   1248: .Dq make cleandir
                   1249: (unless the
                   1250: .Fl u
                   1251: option is given),
                   1252: and the
1.9       lukem    1253: .Sy tools
1.57      dholland 1254: operation.
1.9       lukem    1255: .
                   1256: .It Sy distribution
                   1257: Build a full distribution as per
                   1258: .Dq make distribution .
1.57      dholland 1259: This command first runs the
1.9       lukem    1260: .Sy build
                   1261: operation.
                   1262: .
                   1263: .It Sy release
                   1264: Build a full release as per
                   1265: .Dq make release .
1.57      dholland 1266: This command first runs the
1.9       lukem    1267: .Sy distribution
                   1268: operation.
                   1269: .
1.10      lukem    1270: .It Sy makewrapper
                   1271: Create the
1.13      lukem    1272: .Sy \*[toolprefix]make-MACHINE
1.10      lukem    1273: wrapper.
                   1274: This operation is automatically performed for any of the other
                   1275: operations.
                   1276: .
1.63      lukem    1277: .It Sy cleandir
                   1278: Perform
                   1279: .Dq make cleandir .
                   1280: .
1.9       lukem    1281: .It Sy obj
                   1282: Perform
                   1283: .Dq make obj .
1.11      lukem    1284: .
1.9       lukem    1285: .It Sy tools
                   1286: Build and install the host tools from
                   1287: .Pa src/tools .
1.57      dholland 1288: This command will first run
                   1289: .Dq make obj
                   1290: and
                   1291: .Dq make cleandir
                   1292: in the
                   1293: .Pa tools
                   1294: subdirectory unless the
                   1295: .Fl o
                   1296: or
                   1297: .Fl u
                   1298: options (respectively) are given.
1.22      lukem    1299: .
                   1300: .It Sy install Ns = Ns Ar idir
                   1301: Install the contents of
                   1302: .Sy DESTDIR
                   1303: to
                   1304: .Ar idir ,
                   1305: using
                   1306: .Dq make installworld .
1.48      apb      1307: Note that files that are part of the
                   1308: .Dq etc
                   1309: or
                   1310: .Dq xetc
1.83      apb      1311: sets will not be installed, unless overridden by
                   1312: the INSTALLSETS environment variable.
1.22      lukem    1313: .
1.9       lukem    1314: .It Sy kernel Ns = Ns Ar kconf
                   1315: Build a new kernel.
                   1316: The
                   1317: .Ar kconf
                   1318: argument is the name of a configuration file suitable
                   1319: for use by
1.39      peter    1320: .Xr config 1 .
1.9       lukem    1321: If
                   1322: .Ar kconf
                   1323: does not contain any
                   1324: .Sq /
                   1325: characters, the configuration file is expected to be found in the
                   1326: .Sy KERNCONFDIR
                   1327: directory, which is typically
                   1328: .Sy sys/arch/MACHINE/conf .
                   1329: The new kernel will be built in a subdirectory of
                   1330: .Sy KERNOBJDIR ,
                   1331: which is typically
                   1332: .Sy sys/arch/MACHINE/compile
                   1333: or an associated object directory.
1.57      dholland 1334: .Pp
                   1335: This command does
                   1336: .Em not
                   1337: imply the
                   1338: .Sy tools
                   1339: command; run the
1.9       lukem    1340: .Sy tools
1.57      dholland 1341: command first unless it is
                   1342: .Em certain
                   1343: that the tools already exist and are up to date.
                   1344: .Pp
                   1345: This command will run
                   1346: .Dq make cleandir
                   1347: on the kernel in question first unless the
                   1348: .Fl u
                   1349: option is given.
1.9       lukem    1350: .
1.75      apb      1351: .It Sy modules
                   1352: This command will build kernel modules and install them into
                   1353: .Sy DESTDIR .
                   1354: .
1.22      lukem    1355: .It Sy releasekernel Ns = Ns Ar kconf
                   1356: Install a
                   1357: .Xr gzip 1 Ns ed
1.57      dholland 1358: copy of the kernel previously built by
1.22      lukem    1359: .Sy kernel Ns = Ns Ar kconf
                   1360: into
1.56      lukem    1361: .Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/kernel ,
1.22      lukem    1362: usually as
                   1363: .Pa netbsd- Ns Ar kconf Ns Pa .gz ,
                   1364: although the
                   1365: .Dq Pa netbsd
                   1366: prefix is determined from the
                   1367: .Dq Sy config
                   1368: directives in
                   1369: .Ar kconf .
1.9       lukem    1370: .
1.11      lukem    1371: .It Sy sets
                   1372: Perform
                   1373: .Dq make sets .
1.18      lukem    1374: .
                   1375: .It Sy sourcesets
                   1376: Perform
                   1377: .Dq make sourcesets .
                   1378: .
1.40      apb      1379: .It Sy syspkgs
                   1380: Perform
                   1381: .Dq make syspkgs .
                   1382: .
1.42      apb      1383: .It Sy iso-image
                   1384: Perform
                   1385: .Dq make iso-image .
                   1386: .
1.52      jnemeth  1387: .It Sy iso-image-source
                   1388: Perform
                   1389: .Dq make iso-image-source .
                   1390: .
1.9       lukem    1391: .El
                   1392: .
                   1393: .Pp
                   1394: The following command line options alter the behaviour of the
                   1395: .Sy build.sh
                   1396: operations described above:
                   1397: .
1.1       lukem    1398: .Bl -tag -width "-T tools"
                   1399: .
1.4       lukem    1400: .It Fl a Ar arch
1.1       lukem    1401: Set the value of
                   1402: .Sy MACHINE_ARCH
                   1403: to
1.4       lukem    1404: .Ar arch .
1.1       lukem    1405: .
1.4       lukem    1406: .It Fl B Ar buildid
1.1       lukem    1407: Set the value of
                   1408: .Sy BUILDID
                   1409: to
1.4       lukem    1410: .Ar buildid .
1.54      sborrill 1411: This will also append the build identifier to the name of the
1.1       lukem    1412: .Dq make
                   1413: wrapper script so that the resulting name is of the form
1.13      lukem    1414: .Dq Sy \*[toolprefix]make-MACHINE-BUILDID .
1.1       lukem    1415: .
1.54      sborrill 1416: .It Fl C Ar cdextras
1.76      apb      1417: Append
                   1418: .Ar cdextras
                   1419: to the
1.53      jnemeth  1420: .Sy CDEXTRA
1.76      apb      1421: variable,
                   1422: which is a space-separated list of files or directories that will be
                   1423: added to the CD-ROM image that may be create by the
1.53      jnemeth  1424: .Dq iso-image
                   1425: or
1.76      apb      1426: .Dq iso-image-source
                   1427: operations.
1.54      sborrill 1428: Files will be added to the root of the CD-ROM image, whereas directories
                   1429: will be copied recursively.
                   1430: If relative paths are specified, they will be converted to
                   1431: absolute paths before being used.
1.76      apb      1432: Multiple paths may be specified via multiple
                   1433: .Fl C
                   1434: options, or via a single option whose argument contains multiple
                   1435: space-separated paths.
1.53      jnemeth  1436: .
1.4       lukem    1437: .It Fl D Ar dest
                   1438: Set the value of
                   1439: .Sy DESTDIR
                   1440: to
                   1441: .Ar dest .
1.46      apb      1442: If a relative path is specified, it will be converted to an
                   1443: absolute path before being used.
1.4       lukem    1444: .
1.5       lukem    1445: .It Fl E
                   1446: Set
                   1447: .Sq expert
1.10      lukem    1448: mode.
                   1449: This overrides various sanity checks, and allows:
1.5       lukem    1450: .Sy DESTDIR
1.10      lukem    1451: does not have to be set to a non-root path for builds,
                   1452: and
1.25      lukem    1453: .Sy MKUNPRIVED=yes
1.10      lukem    1454: does not have to be set when building as a non-root user.
                   1455: .Pp
                   1456: .Em Note :
                   1457: It is highly recommended that you know what you are doing when
                   1458: you use this option.
1.7       lukem    1459: .
1.36      wiz      1460: .It Fl h
                   1461: Print a help message.
                   1462: .
1.4       lukem    1463: .It Fl j Ar njob
1.57      dholland 1464: Run up to
                   1465: .Ar njob
                   1466: .Xr make 1
                   1467: subjobs in parallel;
                   1468: passed through to
1.1       lukem    1469: .Xr make 1 .
1.62      apb      1470: If you see failures for reasons other than running out of memory
                   1471: while using
                   1472: .Sy build.sh
                   1473: with
                   1474: .Fl j ,
                   1475: please save complete build logs
1.1       lukem    1476: so the failures can be analyzed.
1.62      apb      1477: .Pp
                   1478: To achieve the fastest builds,
                   1479: .Fl j
                   1480: values between (1 + the number of CPUs) and (2 * the number of CPUs)
                   1481: are recommended.
                   1482: Use lower values on machines with limited memory or I/O bandwidth.
1.1       lukem    1483: .
1.4       lukem    1484: .It Fl M Ar obj
                   1485: Set
                   1486: .Sy MAKEOBJDIRPREFIX
                   1487: to
                   1488: .Ar obj .
1.77      apb      1489: Unsets
                   1490: .Sy MAKEOBJDIR .
                   1491: See
                   1492: .Dq Fl O obj
                   1493: for more information.
                   1494: .Pp
1.61      apb      1495: For instance, if the source directory is
                   1496: .Pa /usr/src ,
                   1497: a setting of
                   1498: .Dq Fl M Pa /usr/obj
                   1499: will place build-time files under
                   1500: .Pa /usr/obj/usr/src/bin ,
                   1501: .Pa /usr/obj/usr/src/lib ,
                   1502: .Pa /usr/obj/usr/src/usr.bin ,
                   1503: and so forth.
1.77      apb      1504: .Pp
1.46      apb      1505: If a relative path is specified, it will be converted to an
                   1506: absolute path before being used.
1.77      apb      1507: .Sy build.sh
                   1508: imposes the restriction that the argument to the
                   1509: .Fl M
                   1510: option must not begin with a
                   1511: .Dq \&$
                   1512: (dollar sign)
                   1513: character; otherwise it would be too difficult
                   1514: to determine whether the value is an absolute or a relative path.
                   1515: If the directory does not already exist,
                   1516: .Sy build.sh
                   1517: will create it.
1.4       lukem    1518: .
                   1519: .It Fl m Ar mach
1.1       lukem    1520: Set the value of
                   1521: .Sy MACHINE
                   1522: to
1.47      apb      1523: .Ar mach ,
                   1524: except in some special cases listed below.
1.1       lukem    1525: This will also override any value of
                   1526: .Sy MACHINE_ARCH
                   1527: in the process environment with a value deduced from
1.4       lukem    1528: .Ar mach ,
1.1       lukem    1529: unless
1.4       lukem    1530: .Fl a
1.47      apb      1531: is specified.
1.6       wiz      1532: All cross builds require
1.4       lukem    1533: .Fl m ,
1.1       lukem    1534: but if unset on a NetBSD host, the host's value of MACHINE will be
                   1535: detected and used automatically.
1.20      lukem    1536: .Pp
                   1537: Some machines support multiple values for
                   1538: .Sy MACHINE_ARCH .
1.47      apb      1539: The following special cases for the
                   1540: .Ar mach
                   1541: argument are defined to set the listed values of
1.20      lukem    1542: .Sy MACHINE
                   1543: and
1.47      apb      1544: .Sy MACHINE_ARCH :
1.20      lukem    1545: .Bl -column "evbmips-el" "MACHINE" "MACHINE_ARCH" -offset indent
1.24      lukem    1546: .It Sy mach Ta Sy "MACHINE" Ta Sy "MACHINE_ARCH"
1.47      apb      1547: .It evbarm Ta evbarm Ta (not set)
                   1548: .It evbarm-eb Ta evbarm Ta armeb
                   1549: .It evbarm-el Ta evbarm Ta arm
1.20      lukem    1550: .It evbmips Ta evbmips Ta (not set)
                   1551: .It evbmips-eb Ta evbmips Ta mipseb
                   1552: .It evbmips-el Ta evbmips Ta mipsel
                   1553: .It evbsh3 Ta evbsh3 Ta (not set)
                   1554: .It evbsh3-eb Ta evbsh3 Ta sh3eb
                   1555: .It evbsh3-el Ta evbsh3 Ta sh3el
                   1556: .It sbmips Ta sbmips Ta (not set)
                   1557: .It sbmips-eb Ta sbmips Ta mipseb
                   1558: .It sbmips-el Ta sbmips Ta mipsel
1.30      lukem    1559: .El
                   1560: .
                   1561: .It Fl N Ar noiselevel
                   1562: Set the
                   1563: .Dq noisyness
1.31      lukem    1564: level of the build, by setting
                   1565: .Sy MAKEVERBOSE
                   1566: to
                   1567: .Ar noiselevel .
1.1       lukem    1568: .
1.4       lukem    1569: .It Fl n
1.1       lukem    1570: Show the commands that would be executed by
                   1571: .Sy build.sh ,
1.6       wiz      1572: but do not make any changes.
                   1573: This is similar in concept to
1.1       lukem    1574: .Dq make -n .
                   1575: .
1.4       lukem    1576: .It Fl O Ar obj
1.1       lukem    1577: Create an appropriate transform macro for
                   1578: .Sy MAKEOBJDIR
                   1579: that will place the built object files under
1.4       lukem    1580: .Ar obj .
1.77      apb      1581: Unsets
                   1582: .Sy MAKEOBJDIRPREFIX .
                   1583: .Pp
1.1       lukem    1584: For instance, a setting of
1.61      apb      1585: .Dq Fl O Pa /usr/obj
1.1       lukem    1586: will place build-time files under
1.61      apb      1587: .Pa /usr/obj/bin ,
                   1588: .Pa /usr/obj/lib ,
                   1589: .Pa /usr/obj/usr.bin ,
1.1       lukem    1590: and so forth.
1.77      apb      1591: .Pp
1.61      apb      1592: If a relative path is specified, it will be converted to an
                   1593: absolute path before being used.
1.77      apb      1594: .Sy build.sh
                   1595: imposes the restriction that the argument to the
                   1596: .Fl O
                   1597: option must not contain a
                   1598: .Dq \&$
                   1599: (dollar sign)
                   1600: character.
                   1601: If the directory does not already exist,
                   1602: .Sy build.sh
                   1603: will create it.
1.61      apb      1604: .Pp
                   1605: In normal use, exactly one of the
                   1606: .Fl M
                   1607: or
                   1608: .Fl O
                   1609: options should be specified.
1.67      apb      1610: If neither
1.61      apb      1611: .Fl M
                   1612: nor
                   1613: .Fl O
                   1614: is specified, then a default object directory will be chosen
                   1615: according to rules in
1.67      apb      1616: .Aq bsd.obj.mk .
                   1617: Relying on this default is not recommended because
                   1618: it is determined by complex rules that are influenced
                   1619: by the values of several variables and
                   1620: by the location of the source directory.
1.4       lukem    1621: .It Fl o
                   1622: Set the value of
                   1623: .Sy MKOBJDIRS
                   1624: to
                   1625: .Dq no .
1.21      lukem    1626: Otherwise, it will be automatically set to
1.57      dholland 1627: .Dq yes .
                   1628: This default is opposite to the behaviour when not using
                   1629: .Sy build.sh .
1.4       lukem    1630: .
                   1631: .It Fl R Ar rel
1.1       lukem    1632: Set the value of
                   1633: .Sy RELEASEDIR
                   1634: to
1.4       lukem    1635: .Ar rel .
1.46      apb      1636: If a relative path is specified, it will be converted to an
                   1637: absolute path before being used.
1.1       lukem    1638: .
1.4       lukem    1639: .It Fl r
                   1640: Remove the contents of
                   1641: .Sy DESTDIR
                   1642: and
                   1643: .Sy TOOLDIR
1.6       wiz      1644: before building (provides a clean starting point).
                   1645: This will skip deleting
1.4       lukem    1646: .Sy DESTDIR
                   1647: if building on a native system to the root directory.
                   1648: .
1.60      perry    1649: .It Fl S Ar seed
                   1650: Change the value of
                   1651: .Sy BUILDSEED
                   1652: to
                   1653: .Ar seed .
                   1654: This should rarely be necessary.
                   1655: .
1.4       lukem    1656: .It Fl T Ar tools
1.1       lukem    1657: Set the value of
                   1658: .Sy TOOLDIR
                   1659: to
1.4       lukem    1660: .Ar tools .
1.46      apb      1661: If a relative path is specified, it will be converted to an
                   1662: absolute path before being used.
1.1       lukem    1663: If set, the bootstrap
                   1664: .Dq make
1.57      dholland 1665: will only be rebuilt if the source files for
1.1       lukem    1666: .Xr make 1
1.57      dholland 1667: have changed.
1.1       lukem    1668: .
1.4       lukem    1669: .It Fl U
1.25      lukem    1670: Set
                   1671: .Sy MKUNPRIVED=yes .
1.1       lukem    1672: .
1.4       lukem    1673: .It Fl u
1.25      lukem    1674: Set
                   1675: .Sy MKUPDATE=yes .
1.8       lukem    1676: .
                   1677: .It Xo
                   1678: .Fl V
                   1679: .Sm off
                   1680: .Ar var
                   1681: .Li =
                   1682: .Op Ar value
                   1683: .Sm on
                   1684: .Xc
1.27      lukem    1685: Set the environment variable
1.8       lukem    1686: .Ar var
1.27      lukem    1687: to an optional
                   1688: .Ar value .
                   1689: This is propagated to the
                   1690: .Sy \*[toolprefix]make
                   1691: wrapper.
1.4       lukem    1692: .
                   1693: .It Fl w Ar wrapper
1.27      lukem    1694: Create the
                   1695: .Sy \*[toolprefix]make
                   1696: wrapper script (see below) in a custom location,
1.4       lukem    1697: specified by
                   1698: .Ar wrapper .
                   1699: This allows, for instance, to place the wrapper in
                   1700: .Sy PATH
1.6       wiz      1701: automatically.
                   1702: Note that
1.4       lukem    1703: .Ar wrapper
                   1704: is the full name of the file, not just a directory name.
1.46      apb      1705: If a relative path is specified, it will be converted to an
                   1706: absolute path before being used.
1.4       lukem    1707: .
1.34      lukem    1708: .It Fl X Ar x11src
                   1709: Set the value of
                   1710: .Sy X11SRCDIR
                   1711: to
                   1712: .Ar x11src .
1.46      apb      1713: If a relative path is specified, it will be converted to an
                   1714: absolute path before being used.
1.34      lukem    1715: .
                   1716: .It Fl x
                   1717: Set
                   1718: .Sy MKX11=yes .
                   1719: .
1.27      lukem    1720: .It Fl Z Ar var
                   1721: Unset ("zap") the environment variable
                   1722: .Ar var .
                   1723: This is propagated to the
                   1724: .Sy \*[toolprefix]make
                   1725: wrapper.
                   1726: .
1.1       lukem    1727: .El
                   1728: .
1.13      lukem    1729: .Ss The \*q\*[toolprefix]make-MACHINE\*q wrapper script
1.1       lukem    1730: .
                   1731: If using the
                   1732: .Sy build.sh
                   1733: script to build
                   1734: .Nx ,
                   1735: a
1.13      lukem    1736: .Sy \*[toolprefix]make-MACHINE
1.1       lukem    1737: script will be created in
                   1738: .Sy TOOLDIR/bin
                   1739: upon the first build to assist in building subtrees on a cross-compile
                   1740: host.
                   1741: .Pp
1.13      lukem    1742: .Sy \*[toolprefix]make-MACHINE
1.1       lukem    1743: can be invoked in lieu of
                   1744: .Xr make 1 ,
                   1745: and will instead call the up-to-date version of
1.13      lukem    1746: .Dq \*[toolprefix]make
1.1       lukem    1747: installed into
                   1748: .Sy TOOLDIR/bin
                   1749: with several key variables pre-set, including
                   1750: .Sy MACHINE , MACHINE_ARCH ,
                   1751: and
                   1752: .Sy TOOLDIR .
1.57      dholland 1753: .Sy \*[toolprefix]make-MACHINE
1.27      lukem    1754: will also set variables specified with
                   1755: .Fl V ,
                   1756: and unset variables specified with
                   1757: .Fl Z .
                   1758: .Pp
1.1       lukem    1759: This script can be symlinked into a directory listed in
                   1760: .Sy PATH ,
                   1761: or called with an absolute path.
1.2       lukem    1762: .
                   1763: .Sh EXAMPLES
1.10      lukem    1764: .
1.15      lukem    1765: .Bl -enum
1.9       lukem    1766: .
1.15      lukem    1767: .It
1.67      apb      1768: .Li "% ./build.sh [options] tools kernel=GENERIC"
1.15      lukem    1769: .Pp
1.2       lukem    1770: Build a new toolchain, and use the new toolchain to
                   1771: configure and build a new GENERIC kernel.
1.9       lukem    1772: .
1.15      lukem    1773: .It
1.67      apb      1774: .Li "% ./build.sh [options] -U distribution"
1.15      lukem    1775: .Pp
1.2       lukem    1776: Using unprivileged mode,
1.17      lukem    1777: build a complete distribution to a
                   1778: .Sy DESTDIR
                   1779: directory that
                   1780: .Sy build.sh
                   1781: selects (and will display).
1.9       lukem    1782: .
1.15      lukem    1783: .It
1.67      apb      1784: .Li "# ./build.sh [options] -U install=/"
1.15      lukem    1785: .Pp
1.16      lukem    1786: As root, install to
                   1787: .Pa /
                   1788: the distribution that was built
                   1789: by example 2.
1.15      lukem    1790: Even though this is run as root,
1.9       lukem    1791: .Fl U
                   1792: is required so that the permissions stored in
1.17      lukem    1793: .Sy DESTDIR Ns Pa /METALOG
1.9       lukem    1794: are correctly applied to the files as they're copied to
1.15      lukem    1795: .Pa / .
1.9       lukem    1796: .
1.15      lukem    1797: .It
1.67      apb      1798: .Li "% ./build.sh [options] -U -u release"
1.15      lukem    1799: .Pp
1.2       lukem    1800: Using unprivileged mode,
1.17      lukem    1801: build a complete release to
                   1802: .Sy DESTDIR
                   1803: and
                   1804: .Sy RELEASEDIR
                   1805: directories that
                   1806: .Sy build.sh
                   1807: selects (and will display).
1.25      lukem    1808: .Sy MKUPDATE=yes
1.15      lukem    1809: .Pq Fl u
                   1810: is set to prevent the
                   1811: .Dq make cleandir ,
                   1812: so that if this is run after example 2, it doesn't need to redo that
                   1813: portion of the release build.
1.2       lukem    1814: .El
1.1       lukem    1815: .
                   1816: .Sh OBSOLETE VARIABLES
                   1817: .
                   1818: .Bl -tag -width "NBUILDJOBS"
                   1819: .
                   1820: .It Sy NBUILDJOBS
                   1821: Use the
                   1822: .Xr make 1
                   1823: option
1.57      dholland 1824: .Fl j
1.1       lukem    1825: instead.
                   1826: .
                   1827: .It Sy USE_NEW_TOOLCHAIN
                   1828: The new toolchain is now the default.
                   1829: To disable, use
                   1830: .Sy TOOLCHAIN_MISSING=yes .
                   1831: .El
                   1832: .Sh SEE ALSO
                   1833: .Xr make 1 ,
                   1834: .Xr hier 7 ,
1.42      apb      1835: .Xr release 7 ,
1.48      apb      1836: .Xr etcupdate 8 ,
                   1837: .Xr postinstall 8 ,
1.49      apb      1838: .Xr sysinst 8 ,
1.43      apb      1839: .Pa pkgsrc/sysutils/cdrtools
1.1       lukem    1840: .
                   1841: .Sh HISTORY
                   1842: .
                   1843: The
                   1844: .Nm build.sh
                   1845: based build scheme was introduced for
                   1846: .Nx 1.6
                   1847: as
                   1848: .Sy USE_NEW_TOOLCHAIN ,
                   1849: and re-worked to
                   1850: .Sy TOOLCHAIN_MISSING
                   1851: after that.

CVSweb <webmaster@jp.NetBSD.org>