BUILDING revision 1.77
11.1StvBUILDING(8) NetBSD System Manager's Manual BUILDING(8) 21.1Stv 31.1StvNAME 41.52Sjmc BUILDING -- Procedure for building NetBSD from source code. 51.1Stv 61.1StvREQUIREMENTS 71.1Stv NetBSD is designed to be buildable on most POSIX-compliant host systems. 81.1Stv The basic build procedure is the same whether compiling natively (on the 91.1Stv same NetBSD architecture) or cross compiling (on another architecture or 101.1Stv OS). 111.1Stv 121.1Stv This source tree contains a special subtree, ``tools'', which uses the 131.1Stv host system to create a build toolchain for the target architecture. The 141.1Stv host system must have at least C and C++ compilers in order to create the 151.1Stv toolchain (make is not required); all other tools are created as part of 161.53Sreed the NetBSD build process. (See the environment variables section below 171.53Sreed if you need to override or manually select your compilers.) 181.1Stv 191.1StvFILES 201.1Stv Source tree layout 211.17Swiz doc/BUILDING.mdoc 221.17Swiz This document (in -mdoc troff format; the original copy). 231.1Stv 241.2Swiz BUILDING This document (in plaintext). 251.1Stv 261.48Sjmc tools/compat/README 271.48Sjmc Special notes for cross-hosting a NetBSD build on non- 281.48Sjmc NetBSD platforms. 291.48Sjmc 301.44Slukem Makefile The main Makefile for NetBSD; should only be run for 311.44Slukem native builds with an appropriately up-to-date version of 321.1Stv NetBSD make(1). (For building from out-of-date systems or 331.1Stv on a non-native host, see the build.sh shell script.) 341.1Stv 351.1Stv UPDATING Special notes for updating from an earlier revision of 361.1Stv NetBSD. It is important to read this file before every 371.1Stv build of an updated source tree. 381.1Stv 391.1Stv build.sh Bourne-compatible shell script used for building the host 401.1Stv build tools and the NetBSD system from scratch. Can be 411.1Stv used for both native and cross builds, and should be used 421.1Stv instead of make(1) for any source tree that is updated and 431.1Stv recompiled regularly. 441.1Stv 451.1Stv crypto/dist/, dist/, gnu/dist/ 461.1Stv Sources imported verbatim from third parties, without man- 471.1Stv gling the existing build structure. Other source trees in 481.1Stv bin through usr.sbin use the NetBSD make(1) ``reachover'' 491.44Slukem Makefile semantics when building these programs for a 501.44Slukem native host. 511.1Stv 521.1Stv distrib/, etc/ 531.1Stv Sources for items used when making a full release snap- 541.27Slukem shot, such as files installed in DESTDIR/etc on the desti- 551.27Slukem nation system, boot media, and release notes. 561.1Stv 571.70Sdholland tests/, regress/ 581.70Sdholland Regression test harness. Can be cross-compiled, but only 591.70Sdholland run natively. tests/ uses the atf(7) test framework; 601.70Sdholland regress/ contains older tests that have not yet been 611.70Sdholland migrated to atf(7). 621.1Stv 631.1Stv sys/ NetBSD kernel sources. 641.1Stv 651.1Stv tools/ ``Reachover'' build structure for the host build tools. 661.1Stv This has a special method of determining out-of-date sta- 671.1Stv tus. 681.1Stv 691.1Stv bin/ ... usr.sbin/ 701.1Stv Sources to the NetBSD userland (non-kernel) programs. If 711.1Stv any of these directories are missing, they will be skipped 721.1Stv during the build. 731.1Stv 741.49Slukem x11/ ``Reachover'' build structure for X11R6; the source is in 751.49Slukem X11SRCDIR. 761.49Slukem 771.1Stv Build tree layout 781.1Stv The NetBSD build tree is described in hier(7), and the release layout is 791.1Stv described in release(7). 801.1Stv 811.1StvCONFIGURATION 821.8Slukem Environment variables 831.8Slukem Several environment variables control the behaviour of NetBSD builds. 841.8Slukem 851.58Sapb HOST_SH Path name to a POSIX-compliant shell. If this is not 861.58Sapb set explicitly, then the default is set using heuris- 871.58Sapb tics dependent on the host platform, or from the shell 881.58Sapb under which build.sh is executed (if that can be deter- 891.58Sapb mined), or using the first copy of sh found in PATH. 901.58Sapb If the host system's /bin/sh is not POSIX-compliant, we 911.58Sapb suggest that you build using commands like 921.58Sapb 931.58Sapb HOST_SH=/path/to/working/shell 941.58Sapb export HOST_SH 951.58Sapb ${HOST_SH} build.sh [options] 961.58Sapb 971.53Sreed HOST_CC Path name to C compiler used to create the toolchain. 981.53Sreed 991.53Sreed HOST_CXX Path name to C++ compiler used to create the toolchain. 1001.53Sreed 1011.70Sdholland MACHINE Machine type, e.g., ``macppc''. 1021.8Slukem 1031.70Sdholland MACHINE_ARCH Machine architecture, e.g., ``powerpc''. 1041.8Slukem 1051.8Slukem MAKE Path name to invoke make(1) as. 1061.8Slukem 1071.8Slukem MAKEFLAGS Flags to invoke make(1) with. 1081.8Slukem 1091.8Slukem MAKEOBJDIR Directory to use as the .OBJDIR for the current direc- 1101.59Sapb tory. The value is subjected to variable expansion by 1111.73Sapb make(1). Typical usage is to set this variable to a 1121.73Sapb value involving the use of `${.CURDIR:S...}' or 1131.73Sapb `${.CURDIR:C...}', to derive the value of .OBJDIR from 1141.73Sapb the value of .CURDIR. Used only if MAKEOBJDIRPREFIX is 1151.73Sapb not defined. MAKEOBJDIR can be provided only in the 1161.73Sapb environment or via the -O flag of build.sh; it cannot 1171.73Sapb usefully be set inside a Makefile. 1181.8Slukem 1191.8Slukem MAKEOBJDIRPREFIX Top level directory of the object directory tree. If 1201.59Sapb specified, must be an absolute path. If this is 1211.59Sapb defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the 1221.59Sapb .OBJDIR for the current directory. The current direc- 1231.73Sapb tory may be read only. MAKEOBJDIRPREFIX can be pro- 1241.73Sapb vided only in the environment or via the -M flag of 1251.73Sapb build.sh; it cannot usefully be set inside a Makefile. 1261.8Slukem 1271.1Stv "make" variables 1281.1Stv Several variables control the behavior of NetBSD builds. Unless other- 1291.1Stv wise specified, these variables may be set in either the process environ- 1301.1Stv ment or the make(1) configuration file specified by MAKECONF. 1311.1Stv 1321.9Sthorpej BUILDID Identifier for the build. The identifier will be appended to 1331.9Sthorpej object directory names, and can be consulted in the make(1) 1341.9Sthorpej configuration file in order to set additional build parame- 1351.9Sthorpej ters, such as compiler flags. 1361.9Sthorpej 1371.72Sperry BUILDSEED GCC uses random numbers when compiling C++ code. This vari- 1381.72Sperry able seeds the gcc random number generator using the -fran- 1391.72Sperry dom-seed flag with this value. By default, it is set to 1401.72Sperry NetBSD-(majorversion). Using a fixed value causes C++ bina- 1411.72Sperry ries to be the same when built from the same sources. Addi- 1421.72Sperry tional information is available in the GCC documentation of 1431.72Sperry -frandom-seed. 1441.72Sperry 1451.1Stv DESTDIR Directory to contain the built NetBSD system. If set, spe- 1461.1Stv cial options are passed to the compilation tools to prevent 1471.1Stv their default use of the host system's /usr/include, 1481.59Sapb /usr/lib, and so forth. This pathname must be an absolute 1491.59Sapb path, and should not end with a slash (/) character. (For 1501.59Sapb installation into the system's root directory, set DESTDIR to 1511.59Sapb an empty string, not to ``/''). The directory must reside on 1521.59Sapb a file system which supports long file names and hard links. 1531.1Stv 1541.1Stv Default: Empty string if USETOOLS is ``yes''; unset other- 1551.1Stv wise. 1561.1Stv 1571.30Slukem Note: build.sh will provide a default of destdir.MACHINE (in 1581.70Sdholland the top-level .OBJDIR) unless run in `expert' mode. 1591.30Slukem 1601.1Stv MAKECONF The name of the make(1) configuration file. Only settable in 1611.1Stv the process environment. 1621.1Stv 1631.1Stv Default: ``/etc/mk.conf'' 1641.1Stv 1651.45Slukem MAKEVERBOSE 1661.45Slukem Level of verbosity of status messages. Supported values: 1671.45Slukem 1681.45Slukem 0 No descriptive messages are shown. 1691.45Slukem 1701.45Slukem 1 Descriptive messages are shown. 1711.45Slukem 1721.45Slukem 2 Descriptive messages (prefixed with a `#') and command 1731.45Slukem output is not suppressed. 1741.45Slukem 1751.45Slukem Default: 2 1761.45Slukem 1771.1Stv MKCATPAGES Can be set to ``yes'' or ``no''. Indicates whether prefor- 1781.1Stv matted plaintext manual pages will be created during a build. 1791.1Stv 1801.1Stv Default: ``yes'' 1811.1Stv 1821.1Stv MKCRYPTO Can be set to ``yes'' or ``no''. Indicates whether crypto- 1831.1Stv graphic code will be included in a build; provided for the 1841.1Stv benefit of countries that do not allow strong cryptography. 1851.44Slukem Will not affect use of the standard low-security password 1861.44Slukem encryption system, crypt(3). 1871.1Stv 1881.1Stv Default: ``yes'' 1891.1Stv 1901.1Stv MKDOC Can be set to ``yes'' or ``no''. Indicates whether system 1911.44Slukem documentation destined for DESTDIR/usr/share/doc will be 1921.44Slukem installed during a build. 1931.1Stv 1941.1Stv Default: ``yes'' 1951.1Stv 1961.77Slukem MKHTML Can be set to ``yes'' or ``no''. Indicates whether prefor- 1971.77Slukem matted HTML manual pages will be built and installed 1981.77Slukem 1991.77Slukem Default: ``yes'' 2001.77Slukem 2011.4Stv MKHOSTOBJ Can be set to ``yes'' or ``no''. If set to ``yes'', then for 2021.4Stv programs intended to be run on the compile host, the name, 2031.4Stv release, and architecture of the host operating system will 2041.4Stv be suffixed to the name of the object directory created by 2051.4Stv ``make obj''. (This allows multiple host systems to compile 2061.4Stv NetBSD for a single target.) If set to ``no'', then programs 2071.4Stv built to be run on the compile host will use the same object 2081.4Stv directory names as programs built to be run on the target. 2091.4Stv 2101.4Stv Default: ``no'' 2111.4Stv 2121.1Stv MKINFO Can be set to ``yes'' or ``no''. Indicates whether GNU Info 2131.1Stv files, used for the documentation for most of the compilation 2141.1Stv tools, will be created and installed during a build. 2151.1Stv 2161.1Stv Default: ``yes'' 2171.1Stv 2181.1Stv MKLINT Can be set to ``yes'' or ``no''. Indicates whether lint(1) 2191.1Stv will be run against portions of the NetBSD source code during 2201.1Stv the build, and whether lint libraries will be installed into 2211.27Slukem DESTDIR/usr/libdata/lint. 2221.1Stv 2231.1Stv Default: ``yes'' 2241.1Stv 2251.1Stv MKMAN Can be set to ``yes'' or ``no''. Indicates whether manual 2261.1Stv pages will be installed during a build. 2271.1Stv 2281.1Stv Default: ``yes'' 2291.1Stv 2301.1Stv MKNLS Can be set to ``yes'' or ``no''. Indicates whether Native 2311.44Slukem Language System locale zone files will be compiled and 2321.44Slukem installed during a build. 2331.1Stv 2341.1Stv Default: ``yes'' 2351.1Stv 2361.1Stv MKOBJ Can be set to ``yes'' or ``no''. Indicates whether object 2371.1Stv directories will be created when running ``make obj''. If 2381.1Stv set to ``no'', then all built files will be located inside 2391.1Stv the regular source tree. 2401.1Stv 2411.1Stv Default: ``yes'' 2421.1Stv 2431.70Sdholland Note that setting MKOBJ to ``no'' is not recommended and may 2441.70Sdholland cause problems when updating the tree with cvs(1). 2451.70Sdholland 2461.1Stv MKPIC Can be set to ``yes'' or ``no''. Indicates whether shared 2471.1Stv objects and libraries will be created and installed during a 2481.1Stv build. If set to ``no'', the entire built system will be 2491.1Stv statically linked. 2501.1Stv 2511.1Stv Default: Platform dependent. As of this writing, all plat- 2521.1Stv forms except sh3 default to ``yes''. 2531.1Stv 2541.1Stv MKPICINSTALL 2551.1Stv Can be set to ``yes'' or ``no''. Indicates whether the ar(1) 2561.44Slukem format libraries (lib*_pic.a), used to generate shared 2571.44Slukem libraries, are installed during a build. 2581.1Stv 2591.1Stv Default: ``yes'' 2601.1Stv 2611.1Stv MKPROFILE Can be set to ``yes'' or ``no''. Indicates whether profiled 2621.1Stv libraries (lib*_p.a) will be built and installed during a 2631.1Stv build. 2641.1Stv 2651.1Stv Default: ``yes''; however, some platforms turn off MKPROFILE 2661.1Stv by default at times due to toolchain problems with profiled 2671.1Stv code. 2681.1Stv 2691.1Stv MKSHARE Can be set to ``yes'' or ``no''. Indicates whether files 2701.44Slukem destined to reside in DESTDIR/usr/share will be built and 2711.44Slukem installed during a build. If set to ``no'', then all of 2721.27Slukem MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to 2731.27Slukem ``no'' unconditionally. 2741.1Stv 2751.1Stv Default: ``yes'' 2761.1Stv 2771.50Swiz MKTTINTERP Can be set to ``yes'' or ``no''. For X builds, decides if 2781.50Swiz the TrueType bytecode interpreter is turned on. See 2791.50Swiz http://www.freetype.org/patents.html for details. 2801.50Swiz 2811.50Swiz Default: ``no'' 2821.50Swiz 2831.44Slukem MKUNPRIVED Can be set to ``yes'' or ``no''. Indicates whether an 2841.44Slukem unprivileged install will occur. The user, group, permis- 2851.52Sjmc sions, and file flags, will not be set on the installed 2861.52Sjmc items; instead the information will be appended to a file 2871.52Sjmc called METALOG in DESTDIR. The contents of METALOG are used 2881.52Sjmc during the generation of the distribution tar files to ensure 2891.52Sjmc that the appropriate file ownership is stored. 2901.38Slukem 2911.38Slukem Default: ``no'' 2921.38Slukem 2931.44Slukem MKUPDATE Can be set to ``yes'' or ``no''. Indicates whether all 2941.44Slukem install operations intended to write to DESTDIR will compare 2951.38Slukem file timestamps before installing, and skip the install phase 2961.44Slukem if the destination files are up-to-date. This also has 2971.44Slukem implications on full builds (see next subsection). 2981.38Slukem 2991.38Slukem Default: ``no'' 3001.38Slukem 3011.49Slukem MKX11 Can be set to ``yes'' or ``no''. Indicates whether X11R6 is 3021.49Slukem built from X11SRCDIR. 3031.49Slukem 3041.76Slukem Mutually exclusive to MKXORG != no. 3051.76Slukem 3061.76Slukem Default: ``no'' 3071.76Slukem 3081.76Slukem MKXORG Can be set to ``yes'' or ``no''. Indicates whether X11R7 3091.76Slukem (modular Xorg) is built from X11SRCDIR. 3101.76Slukem 3111.76Slukem Mutually exclusive to MKX11 != no. 3121.76Slukem 3131.49Slukem Default: ``no'' 3141.49Slukem 3151.59Sapb TOOLDIR Directory to hold the host tools, once built. If specified, 3161.59Sapb must be an absolute path. This directory should be unique to 3171.59Sapb a given host system and NetBSD source tree. (However, multi- 3181.59Sapb ple targets may share the same TOOLDIR; the target-dependent 3191.59Sapb files have unique names.) If unset, a default based on the 3201.59Sapb uname(1) information of the host platform will be created in 3211.59Sapb the .OBJDIR of src. 3221.1Stv 3231.1Stv Default: Unset. 3241.1Stv 3251.1Stv USETOOLS Indicates whether the tools specified by TOOLDIR should be 3261.1Stv used as part of a build in progress. Must be set to ``yes'' 3271.1Stv if cross-compiling. 3281.1Stv 3291.1Stv yes Use the tools from TOOLDIR. 3301.1Stv 3311.1Stv no Do not use the tools from TOOLDIR, but refuse to build 3321.1Stv native compilation tool components that are version- 3331.1Stv specific for that tool. 3341.1Stv 3351.1Stv never Do not use the tools from TOOLDIR, even when building 3361.1Stv native tool components. This is similar to the tradi- 3371.1Stv tional NetBSD build method, but does not verify that 3381.1Stv the compilation tools in use are up-to-date enough in 3391.1Stv order to build the tree successfully. This may cause 3401.1Stv build or runtime problems when building the whole 3411.1Stv NetBSD source tree. 3421.1Stv 3431.71Sdholland Default: ``yes'', unless TOOLCHAIN_MISSING is set to ``yes''. 3441.71Sdholland 3451.71Sdholland USETOOLS is also set to ``no'' when using <bsd.*.mk> outside 3461.71Sdholland the NetBSD source tree. 3471.1Stv 3481.59Sapb X11SRCDIR Directory containing the X11R6 source. If specified, must be 3491.59Sapb an absolute path. The main X11R6 source is found in 3501.59Sapb X11SRCDIR/xfree/xc. 3511.49Slukem 3521.49Slukem Default: ``/usr/xsrc'' 3531.49Slukem 3541.1Stv "make" variables for full builds 3551.7Slukem These variables only affect the top level ``Makefile'' and do not affect 3561.7Slukem manually building subtrees of the NetBSD source code. 3571.1Stv 3581.20Slukem INSTALLWORLDDIR Location for the ``make installworld'' target to install 3591.59Sapb to. If specified, must be an absolute path. 3601.1Stv 3611.20Slukem Default: ``/'' 3621.1Stv 3631.44Slukem MKOBJDIRS Can be set to ``yes'' or ``no''. Indicates whether 3641.44Slukem object directories will be created automatically (via a 3651.20Slukem ``make obj'' pass) at the start of a build. 3661.1Stv 3671.34Slukem Default: ``no'' 3681.1Stv 3691.70Sdholland If using build.sh, the default is ``yes''. This may be 3701.70Sdholland set back to ``no'' by giving build.sh the -o option. 3711.70Sdholland 3721.38Slukem MKUPDATE Can be set to ``yes'' or ``no''. If set, then in addi- 3731.38Slukem tion to the effects described for MKUPDATE=yes above, 3741.38Slukem this implies the effects of NOCLEANDIR (i.e., ``make 3751.38Slukem cleandir'' is avoided). 3761.38Slukem 3771.38Slukem Default: ``no'' 3781.38Slukem 3791.70Sdholland If using build.sh, this may be set by giving the -u 3801.70Sdholland option. 3811.70Sdholland 3821.70Sdholland NBUILDJOBS Now obsolete. Use the make(1) option -j, instead. See 3831.70Sdholland below. 3841.1Stv 3851.20Slukem Default: Unset. 3861.1Stv 3871.20Slukem NOCLEANDIR If set, avoids the ``make cleandir'' phase of a full 3881.20Slukem build. This has the effect of allowing only changed 3891.20Slukem files in a source tree to be recompiled. This can speed 3901.20Slukem up builds when updating only a few files in the tree. 3911.1Stv 3921.20Slukem Default: Unset. 3931.1Stv 3941.70Sdholland See also MKUPDATE. 3951.70Sdholland 3961.20Slukem NODISTRIBDIRS If set, avoids the ``make distrib-dirs'' phase of a full 3971.20Slukem build. This skips running mtree(8) on DESTDIR, useful 3981.20Slukem on systems where building as an unprivileged user, or 3991.20Slukem where it is known that the system-wide mtree files have 4001.20Slukem not changed. 4011.1Stv 4021.20Slukem Default: Unset. 4031.1Stv 4041.20Slukem NOINCLUDES If set, avoids the ``make includes'' phase of a full 4051.20Slukem build. This has the effect of preventing make(1) from 4061.44Slukem thinking that some programs are out-of-date simply 4071.44Slukem because the system include files have changed. However, 4081.20Slukem this option should not be used when updating the entire 4091.20Slukem NetBSD source tree arbitrarily; it is suggested to use 4101.70Sdholland MKUPDATE=yes instead in that case. 4111.1Stv 4121.20Slukem Default: Unset. 4131.1Stv 4141.20Slukem RELEASEDIR If set, specifies the directory to which a release(7) 4151.20Slukem layout will be written at the end of a ``make release''. 4161.59Sapb If specified, must be an absolute path. 4171.20Slukem 4181.20Slukem Default: Unset. 4191.20Slukem 4201.30Slukem Note: build.sh will provide a default of releasedir (in 4211.70Sdholland the top-level .OBJDIR) unless run in `expert' mode. 4221.30Slukem 4231.1StvBUILDING 4241.1Stv "make" command line options 4251.52Sjmc This is not a summary of all the options available to make(1); only the 4261.52Sjmc options used most frequently with NetBSD builds are listed here. 4271.1Stv 4281.10Ssommerfe -j njob Run up to njob make(1) subjobs in parallel. Makefiles should 4291.52Sjmc use .WAIT or have explicit dependencies as necessary to 4301.74Sapb enforce build ordering. 4311.10Ssommerfe 4321.1Stv -m dir Specify the default directory for searching for system Make- 4331.1Stv file segments, mainly the <bsd.*.mk> files. When building any 4341.1Stv full NetBSD source tree, this should be set to the 4351.70Sdholland ``share/mk'' directory in the source tree. This is set auto- 4361.70Sdholland matically when building from the top level, or when using 4371.70Sdholland build.sh. 4381.1Stv 4391.1Stv -n Display the commands that would have been executed, but do not 4401.1Stv actually execute them. This will still cause recursion to 4411.1Stv take place. 4421.1Stv 4431.47Szuntum -V var Print make(1)'s idea of the value of var. Does not build any 4441.1Stv targets. 4451.1Stv 4461.1Stv var=value Set the variable var to value, overriding any setting speci- 4471.1Stv fied by the process environment, the MAKECONF configuration 4481.1Stv file, or the system Makefile segments. 4491.1Stv 4501.1Stv "make" targets 4511.1Stv These default targets may be built by running make(1) in any subtree of 4521.1Stv the NetBSD source code. It is recommended that none of these be used 4531.1Stv from the top level Makefile; as a specific exception, ``make obj'' and 4541.1Stv ``make cleandir'' are useful in that context. 4551.1Stv 4561.1Stv all Build programs, libraries, and preformatted documentation. 4571.1Stv 4581.1Stv clean Remove program and library object code files. 4591.1Stv 4601.44Slukem cleandir Same as clean, but also remove preformatted documentation, 4611.44Slukem dependency files generated by ``make depend'', and any other 4621.49Slukem files known to be created at build time. 4631.1Stv 4641.44Slukem depend Create dependency files (.depend) containing more detailed 4651.44Slukem information about the dependencies of source code on header 4661.1Stv files. Allows programs to be recompiled automatically when a 4671.1Stv dependency changes. 4681.1Stv 4691.1Stv dependall Does a ``make depend'' immediately followed by a ``make all''. 4701.10Ssommerfe This improves cache locality of the build since both passes 4711.10Ssommerfe read the source files in their entirety. 4721.1Stv 4731.49Slukem distclean Synonym for cleandir. 4741.49Slukem 4751.44Slukem includes Build and install system header files. Typically needed 4761.44Slukem before any system libraries or programs can be built. 4771.1Stv 4781.1Stv install Install programs, libraries, and documentation into DESTDIR. 4791.27Slukem Few files will be installed to DESTDIR/dev, DESTDIR/etc, 4801.27Slukem DESTDIR/root or DESTDIR/var in order to prevent user supplied 4811.27Slukem configuration data from being overwritten. 4821.1Stv 4831.1Stv lint Run lint(1) against the C source code, where appropriate, and 4841.1Stv generate system-installed lint libraries. 4851.1Stv 4861.1Stv obj Create object directories to be used for built files, instead 4871.1Stv of building directly in the source tree. 4881.1Stv 4891.1Stv tags Create ctags(1) searchable function lists usable by the ex(1) 4901.1Stv and vi(1) text editors. 4911.1Stv 4921.1Stv "make" targets for the top level 4931.1Stv Additional make(1) targets are usable specifically from the top source 4941.1Stv level to facilitate building the entire NetBSD source tree. 4951.1Stv 4961.68Sreed build Build the entire NetBSD system (except the kernel). This 4971.68Sreed orders portions of the source tree such that prerequisites 4981.68Sreed will be built in the proper order. 4991.20Slukem 5001.20Slukem distribution Do a ``make build'', and then install a full distribution 5011.68Sreed (which does not include a kernel) into DESTDIR, including 5021.68Sreed files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and 5031.68Sreed DESTDIR/var. 5041.20Slukem 5051.20Slukem buildworld As per ``make distribution'', except that it ensures that 5061.20Slukem DESTDIR is not the root directory. 5071.20Slukem 5081.70Sdholland installworld Install the distribution from DESTDIR to INSTALLWORLDDIR, 5091.70Sdholland which defaults to the root directory. Ensures that 5101.52Sjmc INSTALLWORLDDIR is not the root directory if cross compil- 5111.20Slukem ing. 5121.20Slukem 5131.61Sapb The INSTALLSETS environment variable may be set to a list 5141.61Sapb of distribution sets to be installed. By default, all sets 5151.70Sdholland except ``etc'' and ``xetc'' are installed, so most files in 5161.70Sdholland INSTALLWORLDDIR/etc will not be installed or modified. 5171.61Sapb 5181.61Sapb Note: Before performing this operation with 5191.61Sapb INSTALLWORLDDIR=/, it is highly recommended that you 5201.61Sapb upgrade your kernel and reboot. After performing this 5211.61Sapb operation, it is recommended that you use etcupdate(8) to 5221.61Sapb update files in INSTALLWORLDDIR/etc and that you use 5231.61Sapb postinstall(8) to check for inconsistencies (and possibly 5241.61Sapb to fix them). 5251.20Slukem 5261.25Slukem sets Create distribution sets from DESTDIR into 5271.69Slukem RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run 5281.70Sdholland after ``make distribution'', as ``make build'' alone does 5291.70Sdholland not install all of the required files. 5301.25Slukem 5311.31Slukem sourcesets Create source sets of the source tree into 5321.31Slukem RELEASEDIR/source/sets. 5331.31Slukem 5341.54Sapb syspkgs Create syspkgs from DESTDIR into 5351.69Slukem RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run 5361.70Sdholland after ``make distribution'', as ``make build'' alone does 5371.70Sdholland not install all of the required files. 5381.54Sapb 5391.44Slukem release Do a ``make distribution'', build kernels, distribution 5401.44Slukem media, and install sets (this as per ``make sets''), and 5411.44Slukem then package the system into a standard release layout as 5421.44Slukem described by release(7). This requires that RELEASEDIR be 5431.25Slukem set (see above). 5441.1Stv 5451.62Sapb iso-image Create a NetBSD installation CD-ROM image in the 5461.62Sapb RELEASEDIR/iso directory. The CD-ROM file system will have 5471.62Sapb a layout as described in release(7). 5481.62Sapb 5491.62Sapb For most machine types, the CD-ROM will be bootable, and 5501.62Sapb will automatically run the sysinst(8) menu-based installa- 5511.62Sapb tion program, which can be used to install or upgrade a 5521.62Sapb NetBSD system. Bootable CD-ROMs also contain tools that 5531.62Sapb may be useful in repairing a damaged NetBSD installation. 5541.62Sapb 5551.62Sapb Before ``make iso-image'' is attempted, RELEASEDIR must be 5561.62Sapb populated by ``make release'' or equivalent. 5571.62Sapb 5581.62Sapb Note that other, smaller, CD-ROM images may be created in 5591.69Slukem the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc- 5601.69Slukem tory by ``make release''. These smaller images usually 5611.69Slukem contain the same tools as the larger images in 5621.69Slukem RELEASEDIR/iso, but do not contain additional content such 5631.69Slukem as the distribution sets. 5641.62Sapb 5651.62Sapb Note that the mac68k port still uses an older method of 5661.62Sapb creating CD-ROM images. This requires the mkisofs(1) util- 5671.62Sapb ity, which is not part of NetBSD, but which can be 5681.62Sapb installed from pkgsrc/sysutils/cdrtools. 5691.56Sapb 5701.64Sjnemeth iso-image-source 5711.64Sjnemeth Create a NetBSD installation CD-ROM image in the 5721.64Sjnemeth RELEASEDIR/iso directory. The CD-ROM file system will have 5731.64Sjnemeth a layout as described in release(7). It will have top 5741.64Sjnemeth level directories for the machine type and source. 5751.64Sjnemeth 5761.64Sjnemeth For most machine types, the CD-ROM will be bootable, and 5771.64Sjnemeth will automatically run the sysinst(8) menu-based installa- 5781.64Sjnemeth tion program, which can be used to install or upgrade a 5791.64Sjnemeth NetBSD system. Bootable CD-ROMs also contain tools that 5801.64Sjnemeth may be useful in repairing a damaged NetBSD installation. 5811.64Sjnemeth 5821.64Sjnemeth Before ``make iso-image-source'' is attempted, RELEASEDIR 5831.64Sjnemeth must be populated by ``make sourcesets release'' or equiva- 5841.64Sjnemeth lent. 5851.64Sjnemeth 5861.64Sjnemeth Note that other, smaller, CD-ROM images may be created in 5871.69Slukem the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc- 5881.69Slukem tory by ``make release''. These smaller images usually 5891.69Slukem contain the same tools as the larger images in 5901.69Slukem RELEASEDIR/iso, but do not contain additional content such 5911.69Slukem as the distribution sets. 5921.64Sjnemeth 5931.64Sjnemeth Note that the mac68k port still uses an older method of 5941.64Sjnemeth creating CD-ROM images. This requires the mkisofs(1) util- 5951.64Sjnemeth ity, which is not part of NetBSD, but which can be 5961.64Sjnemeth installed from pkgsrc/sysutils/cdrtools. 5971.64Sjnemeth 5981.1Stv regression-tests 5991.20Slukem Can only be run after building the regression tests in the 6001.70Sdholland directory ``regress''. Runs those compiled regression 6011.70Sdholland tests on the local host. Note that most tests are now man- 6021.70Sdholland aged instead using atf(7); this target should probably run 6031.70Sdholland those as well but currently does not. 6041.1Stv 6051.1Stv The "build.sh" script 6061.1Stv This script file is a Bourne shell script designed to build the entire 6071.1Stv NetBSD system on any host with a Bourne shell in /bin/sh, including many 6081.1Stv that are not POSIX compliant. Note that if a host system's /bin/sh is 6091.1Stv unusually old and broken, the Korn Shell (/bin/ksh), if available, may be 6101.1Stv a usable alternative. 6111.1Stv 6121.1Stv All cross-compile builds, and most native builds, of the entire system 6131.1Stv should make use of build.sh rather than just running ``make''. This way, 6141.1Stv the make(1) program will be bootstrapped properly, in case the host sys- 6151.1Stv tem has an older or incompatible ``make'' program. 6161.1Stv 6171.1Stv When compiling the entire system via build.sh, many make(1) variables are 6181.1Stv set for you in order to help encapsulate the build process. In the list 6191.1Stv of options below, variables that are automatically set by build.sh are 6201.1Stv noted where applicable. 6211.1Stv 6221.22Slukem The following operations are supported by build.sh: 6231.22Slukem 6241.70Sdholland build Build the system as per ``make build''. Before the main 6251.70Sdholland part of the build commences, this command runs the obj 6261.70Sdholland operation (unless the -o option is given), ``make 6271.70Sdholland cleandir'' (unless the -u option is given), and the tools 6281.70Sdholland operation. 6291.22Slukem 6301.22Slukem distribution Build a full distribution as per ``make distribution''. 6311.70Sdholland This command first runs the build operation. 6321.22Slukem 6331.70Sdholland release Build a full release as per ``make release''. This command 6341.70Sdholland first runs the distribution operation. 6351.22Slukem 6361.23Slukem makewrapper Create the nbmake-MACHINE wrapper. This operation is auto- 6371.23Slukem matically performed for any of the other operations. 6381.23Slukem 6391.75Slukem cleandir Perform ``make cleandir''. 6401.75Slukem 6411.22Slukem obj Perform ``make obj''. 6421.22Slukem 6431.70Sdholland tools Build and install the host tools from src/tools. This com- 6441.70Sdholland mand will first run ``make obj'' and ``make cleandir'' in 6451.70Sdholland the tools subdirectory unless the -o or -u options (respec- 6461.70Sdholland tively) are given. 6471.22Slukem 6481.35Slukem install=idir Install the contents of DESTDIR to idir, using ``make 6491.61Sapb installworld''. Note that files that are part of the 6501.61Sapb ``etc'' or ``xetc'' sets will not be installed. 6511.35Slukem 6521.22Slukem kernel=kconf Build a new kernel. The kconf argument is the name of a 6531.54Sapb configuration file suitable for use by config(1). If kconf 6541.22Slukem does not contain any `/' characters, the configuration file 6551.22Slukem is expected to be found in the KERNCONFDIR directory, which 6561.22Slukem is typically sys/arch/MACHINE/conf. The new kernel will be 6571.22Slukem built in a subdirectory of KERNOBJDIR, which is typically 6581.22Slukem sys/arch/MACHINE/compile or an associated object directory. 6591.70Sdholland 6601.70Sdholland This command does not imply the tools command; run the 6611.70Sdholland tools command first unless it is certain that the tools 6621.70Sdholland already exist and are up to date. 6631.70Sdholland 6641.70Sdholland This command will run ``make cleandir'' on the kernel in 6651.70Sdholland question first unless the -u option is given. 6661.22Slukem 6671.35Slukem releasekernel=kconf 6681.70Sdholland Install a gzip(1)ed copy of the kernel previously built by 6691.69Slukem kernel=kconf into 6701.69Slukem RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as 6711.69Slukem netbsd-kconf.gz, although the ``netbsd'' prefix is deter- 6721.69Slukem mined from the ``config'' directives in kconf. 6731.24Slukem 6741.24Slukem sets Perform ``make sets''. 6751.31Slukem 6761.31Slukem sourcesets Perform ``make sourcesets''. 6771.22Slukem 6781.54Sapb syspkgs Perform ``make syspkgs''. 6791.54Sapb 6801.56Sapb iso-image Perform ``make iso-image''. 6811.56Sapb 6821.65Sjnemeth iso-image-source 6831.65Sjnemeth Perform ``make iso-image-source''. 6841.65Sjnemeth 6851.51Swiz The following command line options alter the behaviour of the build.sh 6861.51Swiz operations described above: 6871.1Stv 6881.1Stv -a arch Set the value of MACHINE_ARCH to arch. 6891.9Sthorpej 6901.9Sthorpej -B buildid 6911.9Sthorpej Set the value of BUILDID to buildid. This will also append the 6921.67Ssborrill build identifier to the name of the ``make'' wrapper script so 6931.37Slukem that the resulting name is of the form 6941.37Slukem ``nbmake-MACHINE-BUILDID''. 6951.1Stv 6961.67Ssborrill -C cdextras 6971.67Ssborrill Set the value of CDEXTRA to cdextras which is a space-separated 6981.67Ssborrill list of files or directories which will be added in order to 6991.67Ssborrill the CD-ROM image when used in conjunction with ``iso-image'' or 7001.67Ssborrill ``iso-image-source''. Files will be added to the root of the 7011.67Ssborrill CD-ROM image, whereas directories will be copied recursively. 7021.67Ssborrill If relative paths are specified, they will be converted to 7031.67Ssborrill absolute paths before being used. 7041.66Sjnemeth 7051.59Sapb -D dest Set the value of DESTDIR to dest. If a relative path is speci- 7061.59Sapb fied, it will be converted to an absolute path before being 7071.59Sapb used. 7081.18Slukem 7091.23Slukem -E Set `expert' mode. This overrides various sanity checks, and 7101.23Slukem allows: DESTDIR does not have to be set to a non-root path for 7111.38Slukem builds, and MKUNPRIVED=yes does not have to be set when build- 7121.38Slukem ing as a non-root user. 7131.23Slukem 7141.23Slukem Note: It is highly recommended that you know what you are doing 7151.23Slukem when you use this option. 7161.19Slukem 7171.51Swiz -h Print a help message. 7181.51Swiz 7191.70Sdholland -j njob Run up to njob make(1) subjobs in parallel; passed through to 7201.74Sapb make(1). If you see failures for reasons other than running 7211.74Sapb out of memory while using build.sh with -j, please save com- 7221.74Sapb plete build logs so the failures can be analyzed. 7231.74Sapb 7241.74Sapb To achieve the fastest builds, -j values between (1 + the num- 7251.74Sapb ber of CPUs) and (2 * the number of CPUs) are recommended. Use 7261.74Sapb lower values on machines with limited memory or I/O bandwidth. 7271.1Stv 7281.73Sapb -M obj Set MAKEOBJDIRPREFIX to obj. For instance, if the source 7291.73Sapb directory is /usr/src, a setting of ``-M /usr/obj'' will place 7301.73Sapb build-time files under /usr/obj/usr/src/bin, 7311.73Sapb /usr/obj/usr/src/lib, /usr/obj/usr/src/usr.bin, and so forth. 7321.73Sapb If a relative path is specified, it will be converted to an 7331.73Sapb absolute path before being used. Unsets MAKEOBJDIR. See ``-O 7341.73Sapb -obj'' for more information. 7351.18Slukem 7361.60Sapb -m mach Set the value of MACHINE to mach, except in some special cases 7371.60Sapb listed below. This will also override any value of 7381.60Sapb MACHINE_ARCH in the process environment with a value deduced 7391.60Sapb from mach, unless -a is specified. All cross builds require 7401.60Sapb -m, but if unset on a NetBSD host, the host's value of MACHINE 7411.60Sapb will be detected and used automatically. 7421.60Sapb 7431.60Sapb Some machines support multiple values for MACHINE_ARCH. The 7441.60Sapb following special cases for the mach argument are defined to 7451.60Sapb set the listed values of MACHINE and MACHINE_ARCH: 7461.33Slukem 7471.33Slukem mach MACHINE MACHINE_ARCH 7481.60Sapb evbarm evbarm (not set) 7491.60Sapb evbarm-eb evbarm armeb 7501.60Sapb evbarm-el evbarm arm 7511.33Slukem evbmips evbmips (not set) 7521.33Slukem evbmips-eb evbmips mipseb 7531.33Slukem evbmips-el evbmips mipsel 7541.33Slukem evbsh3 evbsh3 (not set) 7551.33Slukem evbsh3-eb evbsh3 sh3eb 7561.33Slukem evbsh3-el evbsh3 sh3el 7571.33Slukem sbmips sbmips (not set) 7581.33Slukem sbmips-eb sbmips mipseb 7591.33Slukem sbmips-el sbmips mipsel 7601.1Stv 7611.45Slukem -N noiselevel 7621.46Slukem Set the ``noisyness'' level of the build, by setting 7631.46Slukem MAKEVERBOSE to noiselevel. 7641.45Slukem 7651.1Stv -n Show the commands that would be executed by build.sh, but do 7661.1Stv not make any changes. This is similar in concept to ``make 7671.1Stv -n''. 7681.1Stv 7691.18Slukem -O obj Create an appropriate transform macro for MAKEOBJDIR that will 7701.73Sapb place the built object files under obj. For instance, a set- 7711.73Sapb ting of ``-O /usr/obj'' will place build-time files under 7721.73Sapb /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and so forth. If 7731.73Sapb a relative path is specified, it will be converted to an abso- 7741.73Sapb lute path before being used. Unsets MAKEOBJDIRPREFIX. 7751.73Sapb 7761.73Sapb In normal use, exactly one of the -M or -O options should be 7771.73Sapb specified. If the source directory is /usr/src and neither -M 7781.73Sapb nor -O is specified, then a default object directory will be 7791.73Sapb chosen according to rules in <bsd.obj.mk>; this default is usu- 7801.73Sapb ally either /usr/obj or /usr/obj.MACHINE. 7811.18Slukem 7821.34Slukem -o Set the value of MKOBJDIRS to ``no''. Otherwise, it will be 7831.70Sdholland automatically set to ``yes''. This default is opposite to the 7841.70Sdholland behaviour when not using build.sh. 7851.1Stv 7861.59Sapb -R rel Set the value of RELEASEDIR to rel. If a relative path is 7871.59Sapb specified, it will be converted to an absolute path before 7881.59Sapb being used. 7891.18Slukem 7901.1Stv -r Remove the contents of DESTDIR and TOOLDIR before building 7911.1Stv (provides a clean starting point). This will skip deleting 7921.1Stv DESTDIR if building on a native system to the root directory. 7931.1Stv 7941.72Sperry -S seed Change the value of BUILDSEED to seed. This should rarely be 7951.72Sperry necessary. 7961.72Sperry 7971.59Sapb -T tools Set the value of TOOLDIR to tools. If a relative path is spec- 7981.59Sapb ified, it will be converted to an absolute path before being 7991.70Sdholland used. If set, the bootstrap ``make'' will only be rebuilt if 8001.70Sdholland the source files for make(1) have changed. 8011.18Slukem 8021.38Slukem -U Set MKUNPRIVED=yes. 8031.18Slukem 8041.38Slukem -u Set MKUPDATE=yes. 8051.1Stv 8061.21Slukem -V var=[value] 8071.40Slukem Set the environment variable var to an optional value. This is 8081.40Slukem propagated to the nbmake wrapper. 8091.21Slukem 8101.1Stv -w wrapper 8111.1Stv Create the nbmake wrapper script (see below) in a custom loca- 8121.1Stv tion, specified by wrapper. This allows, for instance, to 8131.1Stv place the wrapper in PATH automatically. Note that wrapper is 8141.59Sapb the full name of the file, not just a directory name. If a 8151.59Sapb relative path is specified, it will be converted to an absolute 8161.59Sapb path before being used. 8171.1Stv 8181.49Slukem -X x11src 8191.59Sapb Set the value of X11SRCDIR to x11src. If a relative path is 8201.59Sapb specified, it will be converted to an absolute path before 8211.59Sapb being used. 8221.49Slukem 8231.49Slukem -x Set MKX11=yes. 8241.49Slukem 8251.40Slukem -Z var Unset ("zap") the environment variable var. This is propagated 8261.40Slukem to the nbmake wrapper. 8271.40Slukem 8281.1Stv The "nbmake-MACHINE" wrapper script 8291.1Stv If using the build.sh script to build NetBSD, a nbmake-MACHINE script 8301.1Stv will be created in TOOLDIR/bin upon the first build to assist in building 8311.1Stv subtrees on a cross-compile host. 8321.1Stv 8331.1Stv nbmake-MACHINE can be invoked in lieu of make(1), and will instead call 8341.1Stv the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev- 8351.1Stv eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR. 8361.70Sdholland nbmake-MACHINE will also set variables specified with -V, and unset vari- 8371.70Sdholland ables specified with -Z. 8381.40Slukem 8391.1Stv This script can be symlinked into a directory listed in PATH, or called 8401.1Stv with an absolute path. 8411.1Stv 8421.16SlukemEXAMPLES 8431.44Slukem 1. % ./build.sh tools kernel=GENERIC 8441.28Slukem 8451.28Slukem Build a new toolchain, and use the new toolchain to configure and 8461.28Slukem build a new GENERIC kernel. 8471.28Slukem 8481.44Slukem 2. % ./build.sh -U distribution 8491.28Slukem 8501.30Slukem Using unprivileged mode, build a complete distribution to a DESTDIR 8511.30Slukem directory that build.sh selects (and will display). 8521.28Slukem 8531.43Smartti 3. # ./build.sh -U install=/ 8541.28Slukem 8551.29Slukem As root, install to / the distribution that was built by example 2. 8561.29Slukem Even though this is run as root, -U is required so that the permis- 8571.30Slukem sions stored in DESTDIR/METALOG are correctly applied to the files 8581.30Slukem as they're copied to /. 8591.28Slukem 8601.44Slukem 4. % ./build.sh -U -u release 8611.28Slukem 8621.30Slukem Using unprivileged mode, build a complete release to DESTDIR and 8631.30Slukem RELEASEDIR directories that build.sh selects (and will display). 8641.38Slukem MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that 8651.38Slukem if this is run after example 2, it doesn't need to redo that portion 8661.38Slukem of the release build. 8671.16Slukem 8681.10SsommerfeOBSOLETE VARIABLES 8691.70Sdholland NBUILDJOBS Use the make(1) option -j instead. 8701.15Slukem 8711.15Slukem USE_NEW_TOOLCHAIN 8721.15Slukem The new toolchain is now the default. To disable, use 8731.15Slukem TOOLCHAIN_MISSING=yes. 8741.10Ssommerfe 8751.1StvSEE ALSO 8761.62Sapb make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8), 8771.61Sapb pkgsrc/sysutils/cdrtools 8781.1Stv 8791.1StvHISTORY 8801.15Slukem The build.sh based build scheme was introduced for NetBSD 1.6 as 8811.15Slukem USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that. 8821.1Stv 8831.75SlukemNetBSD August 18, 2008 NetBSD 884