BUILDING revision 1.69
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.1Stv regress/ Regression test harness. Can be cross-compiled, but only 581.1Stv run natively. 591.1Stv 601.1Stv sys/ NetBSD kernel sources. 611.1Stv 621.1Stv tools/ ``Reachover'' build structure for the host build tools. 631.1Stv This has a special method of determining out-of-date sta- 641.1Stv tus. 651.1Stv 661.1Stv bin/ ... usr.sbin/ 671.1Stv Sources to the NetBSD userland (non-kernel) programs. If 681.1Stv any of these directories are missing, they will be skipped 691.1Stv during the build. 701.1Stv 711.49Slukem x11/ ``Reachover'' build structure for X11R6; the source is in 721.49Slukem X11SRCDIR. 731.49Slukem 741.1Stv Build tree layout 751.1Stv The NetBSD build tree is described in hier(7), and the release layout is 761.1Stv described in release(7). 771.1Stv 781.1StvCONFIGURATION 791.8Slukem Environment variables 801.8Slukem Several environment variables control the behaviour of NetBSD builds. 811.8Slukem 821.58Sapb HOST_SH Path name to a POSIX-compliant shell. If this is not 831.58Sapb set explicitly, then the default is set using heuris- 841.58Sapb tics dependent on the host platform, or from the shell 851.58Sapb under which build.sh is executed (if that can be deter- 861.58Sapb mined), or using the first copy of sh found in PATH. 871.58Sapb If the host system's /bin/sh is not POSIX-compliant, we 881.58Sapb suggest that you build using commands like 891.58Sapb 901.58Sapb HOST_SH=/path/to/working/shell 911.58Sapb export HOST_SH 921.58Sapb ${HOST_SH} build.sh [options] 931.58Sapb 941.53Sreed HOST_CC Path name to C compiler used to create the toolchain. 951.53Sreed 961.53Sreed HOST_CXX Path name to C++ compiler used to create the toolchain. 971.53Sreed 981.8Slukem MACHINE Machine type. 991.8Slukem 1001.8Slukem MACHINE_ARCH Machine architecture. 1011.8Slukem 1021.8Slukem MAKE Path name to invoke make(1) as. 1031.8Slukem 1041.8Slukem MAKEFLAGS Flags to invoke make(1) with. 1051.8Slukem 1061.8Slukem MAKEOBJDIR Directory to use as the .OBJDIR for the current direc- 1071.59Sapb tory. The value is subjected to variable expansion by 1081.59Sapb make(1). Used only if MAKEOBJDIRPREFIX is not defined. 1091.36Slukem MAKEOBJDIR can only be provided in the environment or 1101.41Slukem via the -O flag of build.sh. 1111.8Slukem 1121.8Slukem MAKEOBJDIRPREFIX Top level directory of the object directory tree. If 1131.59Sapb specified, must be an absolute path. If this is 1141.59Sapb defined, ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the 1151.59Sapb .OBJDIR for the current directory. The current direc- 1161.59Sapb tory may be read only. MAKEOBJDIRPREFIX can only be 1171.59Sapb provided in the environment or via the -M flag of 1181.36Slukem build.sh. 1191.8Slukem 1201.1Stv "make" variables 1211.1Stv Several variables control the behavior of NetBSD builds. Unless other- 1221.1Stv wise specified, these variables may be set in either the process environ- 1231.1Stv ment or the make(1) configuration file specified by MAKECONF. 1241.1Stv 1251.9Sthorpej BUILDID Identifier for the build. The identifier will be appended to 1261.9Sthorpej object directory names, and can be consulted in the make(1) 1271.9Sthorpej configuration file in order to set additional build parame- 1281.9Sthorpej ters, such as compiler flags. 1291.9Sthorpej 1301.1Stv DESTDIR Directory to contain the built NetBSD system. If set, spe- 1311.1Stv cial options are passed to the compilation tools to prevent 1321.1Stv their default use of the host system's /usr/include, 1331.59Sapb /usr/lib, and so forth. This pathname must be an absolute 1341.59Sapb path, and should not end with a slash (/) character. (For 1351.59Sapb installation into the system's root directory, set DESTDIR to 1361.59Sapb an empty string, not to ``/''). The directory must reside on 1371.59Sapb a file system which supports long file names and hard links. 1381.1Stv 1391.1Stv Default: Empty string if USETOOLS is ``yes''; unset other- 1401.1Stv wise. 1411.1Stv 1421.30Slukem Note: build.sh will provide a default of destdir.MACHINE (in 1431.30Slukem the top-level .OBJDIR) unless run in `expert' mode 1441.30Slukem 1451.1Stv MAKECONF The name of the make(1) configuration file. Only settable in 1461.1Stv the process environment. 1471.1Stv 1481.1Stv Default: ``/etc/mk.conf'' 1491.1Stv 1501.45Slukem MAKEVERBOSE 1511.45Slukem Level of verbosity of status messages. Supported values: 1521.45Slukem 1531.45Slukem 0 No descriptive messages are shown. 1541.45Slukem 1551.45Slukem 1 Descriptive messages are shown. 1561.45Slukem 1571.45Slukem 2 Descriptive messages (prefixed with a `#') and command 1581.45Slukem output is not suppressed. 1591.45Slukem 1601.45Slukem Default: 2 1611.45Slukem 1621.1Stv MKCATPAGES Can be set to ``yes'' or ``no''. Indicates whether prefor- 1631.1Stv matted plaintext manual pages will be created during a build. 1641.1Stv 1651.1Stv Default: ``yes'' 1661.1Stv 1671.1Stv MKCRYPTO Can be set to ``yes'' or ``no''. Indicates whether crypto- 1681.1Stv graphic code will be included in a build; provided for the 1691.1Stv benefit of countries that do not allow strong cryptography. 1701.44Slukem Will not affect use of the standard low-security password 1711.44Slukem encryption system, crypt(3). 1721.1Stv 1731.1Stv Default: ``yes'' 1741.1Stv 1751.1Stv MKDOC Can be set to ``yes'' or ``no''. Indicates whether system 1761.44Slukem documentation destined for DESTDIR/usr/share/doc will be 1771.44Slukem installed during a build. 1781.1Stv 1791.1Stv Default: ``yes'' 1801.1Stv 1811.4Stv MKHOSTOBJ Can be set to ``yes'' or ``no''. If set to ``yes'', then for 1821.4Stv programs intended to be run on the compile host, the name, 1831.4Stv release, and architecture of the host operating system will 1841.4Stv be suffixed to the name of the object directory created by 1851.4Stv ``make obj''. (This allows multiple host systems to compile 1861.4Stv NetBSD for a single target.) If set to ``no'', then programs 1871.4Stv built to be run on the compile host will use the same object 1881.4Stv directory names as programs built to be run on the target. 1891.4Stv 1901.4Stv Default: ``no'' 1911.4Stv 1921.1Stv MKINFO Can be set to ``yes'' or ``no''. Indicates whether GNU Info 1931.1Stv files, used for the documentation for most of the compilation 1941.1Stv tools, will be created and installed during a build. 1951.1Stv 1961.1Stv Default: ``yes'' 1971.1Stv 1981.1Stv MKLINT Can be set to ``yes'' or ``no''. Indicates whether lint(1) 1991.1Stv will be run against portions of the NetBSD source code during 2001.1Stv the build, and whether lint libraries will be installed into 2011.27Slukem DESTDIR/usr/libdata/lint. 2021.1Stv 2031.1Stv Default: ``yes'' 2041.1Stv 2051.1Stv MKMAN Can be set to ``yes'' or ``no''. Indicates whether manual 2061.1Stv pages will be installed during a build. 2071.1Stv 2081.1Stv Default: ``yes'' 2091.1Stv 2101.1Stv MKNLS Can be set to ``yes'' or ``no''. Indicates whether Native 2111.44Slukem Language System locale zone files will be compiled and 2121.44Slukem installed during a build. 2131.1Stv 2141.1Stv Default: ``yes'' 2151.1Stv 2161.1Stv MKOBJ Can be set to ``yes'' or ``no''. Indicates whether object 2171.1Stv directories will be created when running ``make obj''. If 2181.1Stv set to ``no'', then all built files will be located inside 2191.1Stv the regular source tree. 2201.1Stv 2211.1Stv Default: ``yes'' 2221.1Stv 2231.1Stv MKPIC Can be set to ``yes'' or ``no''. Indicates whether shared 2241.1Stv objects and libraries will be created and installed during a 2251.1Stv build. If set to ``no'', the entire built system will be 2261.1Stv statically linked. 2271.1Stv 2281.1Stv Default: Platform dependent. As of this writing, all plat- 2291.1Stv forms except sh3 default to ``yes''. 2301.1Stv 2311.1Stv MKPICINSTALL 2321.1Stv Can be set to ``yes'' or ``no''. Indicates whether the ar(1) 2331.44Slukem format libraries (lib*_pic.a), used to generate shared 2341.44Slukem libraries, are installed during a build. 2351.1Stv 2361.1Stv Default: ``yes'' 2371.1Stv 2381.1Stv MKPROFILE Can be set to ``yes'' or ``no''. Indicates whether profiled 2391.1Stv libraries (lib*_p.a) will be built and installed during a 2401.1Stv build. 2411.1Stv 2421.1Stv Default: ``yes''; however, some platforms turn off MKPROFILE 2431.1Stv by default at times due to toolchain problems with profiled 2441.1Stv code. 2451.1Stv 2461.1Stv MKSHARE Can be set to ``yes'' or ``no''. Indicates whether files 2471.44Slukem destined to reside in DESTDIR/usr/share will be built and 2481.44Slukem installed during a build. If set to ``no'', then all of 2491.27Slukem MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to 2501.27Slukem ``no'' unconditionally. 2511.1Stv 2521.1Stv Default: ``yes'' 2531.1Stv 2541.50Swiz MKTTINTERP Can be set to ``yes'' or ``no''. For X builds, decides if 2551.50Swiz the TrueType bytecode interpreter is turned on. See 2561.50Swiz http://www.freetype.org/patents.html for details. 2571.50Swiz 2581.50Swiz Default: ``no'' 2591.50Swiz 2601.44Slukem MKUNPRIVED Can be set to ``yes'' or ``no''. Indicates whether an 2611.44Slukem unprivileged install will occur. The user, group, permis- 2621.52Sjmc sions, and file flags, will not be set on the installed 2631.52Sjmc items; instead the information will be appended to a file 2641.52Sjmc called METALOG in DESTDIR. The contents of METALOG are used 2651.52Sjmc during the generation of the distribution tar files to ensure 2661.52Sjmc that the appropriate file ownership is stored. 2671.38Slukem 2681.38Slukem Default: ``no'' 2691.38Slukem 2701.44Slukem MKUPDATE Can be set to ``yes'' or ``no''. Indicates whether all 2711.44Slukem install operations intended to write to DESTDIR will compare 2721.38Slukem file timestamps before installing, and skip the install phase 2731.44Slukem if the destination files are up-to-date. This also has 2741.44Slukem implications on full builds (see next subsection). 2751.38Slukem 2761.38Slukem Default: ``no'' 2771.38Slukem 2781.49Slukem MKX11 Can be set to ``yes'' or ``no''. Indicates whether X11R6 is 2791.49Slukem built from X11SRCDIR. 2801.49Slukem 2811.49Slukem Default: ``no'' 2821.49Slukem 2831.59Sapb TOOLDIR Directory to hold the host tools, once built. If specified, 2841.59Sapb must be an absolute path. This directory should be unique to 2851.59Sapb a given host system and NetBSD source tree. (However, multi- 2861.59Sapb ple targets may share the same TOOLDIR; the target-dependent 2871.59Sapb files have unique names.) If unset, a default based on the 2881.59Sapb uname(1) information of the host platform will be created in 2891.59Sapb the .OBJDIR of src. 2901.1Stv 2911.1Stv Default: Unset. 2921.1Stv 2931.1Stv USETOOLS Indicates whether the tools specified by TOOLDIR should be 2941.1Stv used as part of a build in progress. Must be set to ``yes'' 2951.1Stv if cross-compiling. 2961.1Stv 2971.1Stv yes Use the tools from TOOLDIR. 2981.1Stv 2991.1Stv no Do not use the tools from TOOLDIR, but refuse to build 3001.1Stv native compilation tool components that are version- 3011.1Stv specific for that tool. 3021.1Stv 3031.1Stv never Do not use the tools from TOOLDIR, even when building 3041.1Stv native tool components. This is similar to the tradi- 3051.1Stv tional NetBSD build method, but does not verify that 3061.1Stv the compilation tools in use are up-to-date enough in 3071.1Stv order to build the tree successfully. This may cause 3081.1Stv build or runtime problems when building the whole 3091.1Stv NetBSD source tree. 3101.1Stv 3111.1Stv Default: ``yes'' if building all or part of a whole NetBSD 3121.1Stv source tree (detected automatically); ``no'' otherwise (to 3131.44Slukem preserve traditional semantics of the <bsd.*.mk> make(1) 3141.44Slukem include files). 3151.1Stv 3161.59Sapb X11SRCDIR Directory containing the X11R6 source. If specified, must be 3171.59Sapb an absolute path. The main X11R6 source is found in 3181.59Sapb X11SRCDIR/xfree/xc. 3191.49Slukem 3201.49Slukem Default: ``/usr/xsrc'' 3211.49Slukem 3221.1Stv "make" variables for full builds 3231.7Slukem These variables only affect the top level ``Makefile'' and do not affect 3241.7Slukem manually building subtrees of the NetBSD source code. 3251.1Stv 3261.20Slukem INSTALLWORLDDIR Location for the ``make installworld'' target to install 3271.59Sapb to. If specified, must be an absolute path. 3281.1Stv 3291.20Slukem Default: ``/'' 3301.1Stv 3311.44Slukem MKOBJDIRS Can be set to ``yes'' or ``no''. Indicates whether 3321.44Slukem object directories will be created automatically (via a 3331.20Slukem ``make obj'' pass) at the start of a build. 3341.1Stv 3351.34Slukem Default: ``no'' 3361.1Stv 3371.38Slukem MKUPDATE Can be set to ``yes'' or ``no''. If set, then in addi- 3381.38Slukem tion to the effects described for MKUPDATE=yes above, 3391.38Slukem this implies the effects of NOCLEANDIR (i.e., ``make 3401.38Slukem cleandir'' is avoided). 3411.38Slukem 3421.38Slukem Default: ``no'' 3431.38Slukem 3441.20Slukem NBUILDJOBS Now obsolete. Use the make(1) option -j, instead (see 3451.20Slukem below) 3461.1Stv 3471.20Slukem Default: Unset. 3481.1Stv 3491.20Slukem NOCLEANDIR If set, avoids the ``make cleandir'' phase of a full 3501.20Slukem build. This has the effect of allowing only changed 3511.20Slukem files in a source tree to be recompiled. This can speed 3521.20Slukem up builds when updating only a few files in the tree. 3531.1Stv 3541.20Slukem Default: Unset. 3551.1Stv 3561.20Slukem NODISTRIBDIRS If set, avoids the ``make distrib-dirs'' phase of a full 3571.20Slukem build. This skips running mtree(8) on DESTDIR, useful 3581.20Slukem on systems where building as an unprivileged user, or 3591.20Slukem where it is known that the system-wide mtree files have 3601.20Slukem not changed. 3611.1Stv 3621.20Slukem Default: Unset. 3631.1Stv 3641.20Slukem NOINCLUDES If set, avoids the ``make includes'' phase of a full 3651.20Slukem build. This has the effect of preventing make(1) from 3661.44Slukem thinking that some programs are out-of-date simply 3671.44Slukem because the system include files have changed. However, 3681.20Slukem this option should not be used when updating the entire 3691.20Slukem NetBSD source tree arbitrarily; it is suggested to use 3701.38Slukem MKUPDATE=yes in that case. 3711.1Stv 3721.20Slukem Default: Unset. 3731.1Stv 3741.20Slukem RELEASEDIR If set, specifies the directory to which a release(7) 3751.20Slukem layout will be written at the end of a ``make release''. 3761.59Sapb If specified, must be an absolute path. 3771.20Slukem 3781.20Slukem Default: Unset. 3791.20Slukem 3801.30Slukem Note: build.sh will provide a default of releasedir (in 3811.30Slukem the top-level .OBJDIR) unless run in `expert' mode 3821.30Slukem 3831.1StvBUILDING 3841.1Stv "make" command line options 3851.52Sjmc This is not a summary of all the options available to make(1); only the 3861.52Sjmc options used most frequently with NetBSD builds are listed here. 3871.1Stv 3881.10Ssommerfe -j njob Run up to njob make(1) subjobs in parallel. Makefiles should 3891.52Sjmc use .WAIT or have explicit dependencies as necessary to 3901.44Slukem enforce build ordering. If you see build failures with -j, 3911.10Ssommerfe please save complete build logs so the failures can be ana- 3921.10Ssommerfe lyzed. 3931.10Ssommerfe 3941.1Stv -m dir Specify the default directory for searching for system Make- 3951.1Stv file segments, mainly the <bsd.*.mk> files. When building any 3961.1Stv full NetBSD source tree, this should be set to the 3971.1Stv ``share/mk'' directory in the source tree. (This is set auto- 3981.1Stv matically when building from the top level.) 3991.1Stv 4001.1Stv -n Display the commands that would have been executed, but do not 4011.1Stv actually execute them. This will still cause recursion to 4021.1Stv take place. 4031.1Stv 4041.47Szuntum -V var Print make(1)'s idea of the value of var. Does not build any 4051.1Stv targets. 4061.1Stv 4071.1Stv var=value Set the variable var to value, overriding any setting speci- 4081.1Stv fied by the process environment, the MAKECONF configuration 4091.1Stv file, or the system Makefile segments. 4101.1Stv 4111.1Stv "make" targets 4121.1Stv These default targets may be built by running make(1) in any subtree of 4131.1Stv the NetBSD source code. It is recommended that none of these be used 4141.1Stv from the top level Makefile; as a specific exception, ``make obj'' and 4151.1Stv ``make cleandir'' are useful in that context. 4161.1Stv 4171.1Stv all Build programs, libraries, and preformatted documentation. 4181.1Stv 4191.1Stv clean Remove program and library object code files. 4201.1Stv 4211.44Slukem cleandir Same as clean, but also remove preformatted documentation, 4221.44Slukem dependency files generated by ``make depend'', and any other 4231.49Slukem files known to be created at build time. 4241.1Stv 4251.44Slukem depend Create dependency files (.depend) containing more detailed 4261.44Slukem information about the dependencies of source code on header 4271.1Stv files. Allows programs to be recompiled automatically when a 4281.1Stv dependency changes. 4291.1Stv 4301.1Stv dependall Does a ``make depend'' immediately followed by a ``make all''. 4311.10Ssommerfe This improves cache locality of the build since both passes 4321.10Ssommerfe read the source files in their entirety. 4331.1Stv 4341.49Slukem distclean Synonym for cleandir. 4351.49Slukem 4361.44Slukem includes Build and install system header files. Typically needed 4371.44Slukem before any system libraries or programs can be built. 4381.1Stv 4391.1Stv install Install programs, libraries, and documentation into DESTDIR. 4401.27Slukem Few files will be installed to DESTDIR/dev, DESTDIR/etc, 4411.27Slukem DESTDIR/root or DESTDIR/var in order to prevent user supplied 4421.27Slukem configuration data from being overwritten. 4431.1Stv 4441.1Stv lint Run lint(1) against the C source code, where appropriate, and 4451.1Stv generate system-installed lint libraries. 4461.1Stv 4471.1Stv obj Create object directories to be used for built files, instead 4481.1Stv of building directly in the source tree. 4491.1Stv 4501.1Stv tags Create ctags(1) searchable function lists usable by the ex(1) 4511.1Stv and vi(1) text editors. 4521.1Stv 4531.1Stv "make" targets for the top level 4541.1Stv Additional make(1) targets are usable specifically from the top source 4551.1Stv level to facilitate building the entire NetBSD source tree. 4561.1Stv 4571.68Sreed build Build the entire NetBSD system (except the kernel). This 4581.68Sreed orders portions of the source tree such that prerequisites 4591.68Sreed will be built in the proper order. 4601.20Slukem 4611.20Slukem distribution Do a ``make build'', and then install a full distribution 4621.68Sreed (which does not include a kernel) into DESTDIR, including 4631.68Sreed files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and 4641.68Sreed DESTDIR/var. 4651.20Slukem 4661.20Slukem buildworld As per ``make distribution'', except that it ensures that 4671.20Slukem DESTDIR is not the root directory. 4681.20Slukem 4691.20Slukem installworld Install the distribution from DESTDIR to INSTALLWORLDDIR 4701.20Slukem (which defaults to the root directory). Ensures that 4711.52Sjmc INSTALLWORLDDIR is not the root directory if cross compil- 4721.20Slukem ing. 4731.20Slukem 4741.61Sapb The INSTALLSETS environment variable may be set to a list 4751.61Sapb of distribution sets to be installed. By default, all sets 4761.61Sapb except ``etc'' and ``xetc'' are installed (so most files in 4771.61Sapb INSTALLWORLDDIR/etc will not be installed or modified). 4781.61Sapb 4791.61Sapb Note: Before performing this operation with 4801.61Sapb INSTALLWORLDDIR=/, it is highly recommended that you 4811.61Sapb upgrade your kernel and reboot. After performing this 4821.61Sapb operation, it is recommended that you use etcupdate(8) to 4831.61Sapb update files in INSTALLWORLDDIR/etc and that you use 4841.61Sapb postinstall(8) to check for inconsistencies (and possibly 4851.61Sapb to fix them). 4861.20Slukem 4871.25Slukem sets Create distribution sets from DESTDIR into 4881.69Slukem RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run 4891.69Slukem after ``make distribution'' (as ``make build'' does not 4901.69Slukem install all of the required files). 4911.25Slukem 4921.31Slukem sourcesets Create source sets of the source tree into 4931.31Slukem RELEASEDIR/source/sets. 4941.31Slukem 4951.54Sapb syspkgs Create syspkgs from DESTDIR into 4961.69Slukem RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run 4971.69Slukem after ``make distribution'' (as ``make build'' does not 4981.69Slukem install all of the required files). 4991.54Sapb 5001.44Slukem release Do a ``make distribution'', build kernels, distribution 5011.44Slukem media, and install sets (this as per ``make sets''), and 5021.44Slukem then package the system into a standard release layout as 5031.44Slukem described by release(7). This requires that RELEASEDIR be 5041.25Slukem set (see above). 5051.1Stv 5061.62Sapb iso-image Create a NetBSD installation CD-ROM image in the 5071.62Sapb RELEASEDIR/iso directory. The CD-ROM file system will have 5081.62Sapb a layout as described in release(7). 5091.62Sapb 5101.62Sapb For most machine types, the CD-ROM will be bootable, and 5111.62Sapb will automatically run the sysinst(8) menu-based installa- 5121.62Sapb tion program, which can be used to install or upgrade a 5131.62Sapb NetBSD system. Bootable CD-ROMs also contain tools that 5141.62Sapb may be useful in repairing a damaged NetBSD installation. 5151.62Sapb 5161.62Sapb Before ``make iso-image'' is attempted, RELEASEDIR must be 5171.62Sapb populated by ``make release'' or equivalent. 5181.62Sapb 5191.62Sapb Note that other, smaller, CD-ROM images may be created in 5201.69Slukem the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc- 5211.69Slukem tory by ``make release''. These smaller images usually 5221.69Slukem contain the same tools as the larger images in 5231.69Slukem RELEASEDIR/iso, but do not contain additional content such 5241.69Slukem as the distribution sets. 5251.62Sapb 5261.62Sapb Note that the mac68k port still uses an older method of 5271.62Sapb creating CD-ROM images. This requires the mkisofs(1) util- 5281.62Sapb ity, which is not part of NetBSD, but which can be 5291.62Sapb installed from pkgsrc/sysutils/cdrtools. 5301.56Sapb 5311.64Sjnemeth iso-image-source 5321.64Sjnemeth Create a NetBSD installation CD-ROM image in the 5331.64Sjnemeth RELEASEDIR/iso directory. The CD-ROM file system will have 5341.64Sjnemeth a layout as described in release(7). It will have top 5351.64Sjnemeth level directories for the machine type and source. 5361.64Sjnemeth 5371.64Sjnemeth For most machine types, the CD-ROM will be bootable, and 5381.64Sjnemeth will automatically run the sysinst(8) menu-based installa- 5391.64Sjnemeth tion program, which can be used to install or upgrade a 5401.64Sjnemeth NetBSD system. Bootable CD-ROMs also contain tools that 5411.64Sjnemeth may be useful in repairing a damaged NetBSD installation. 5421.64Sjnemeth 5431.64Sjnemeth Before ``make iso-image-source'' is attempted, RELEASEDIR 5441.64Sjnemeth must be populated by ``make sourcesets release'' or equiva- 5451.64Sjnemeth lent. 5461.64Sjnemeth 5471.64Sjnemeth Note that other, smaller, CD-ROM images may be created in 5481.69Slukem the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc- 5491.69Slukem tory by ``make release''. These smaller images usually 5501.69Slukem contain the same tools as the larger images in 5511.69Slukem RELEASEDIR/iso, but do not contain additional content such 5521.69Slukem as the distribution sets. 5531.64Sjnemeth 5541.64Sjnemeth Note that the mac68k port still uses an older method of 5551.64Sjnemeth creating CD-ROM images. This requires the mkisofs(1) util- 5561.64Sjnemeth ity, which is not part of NetBSD, but which can be 5571.64Sjnemeth installed from pkgsrc/sysutils/cdrtools. 5581.64Sjnemeth 5591.1Stv regression-tests 5601.20Slukem Can only be run after building the regression tests in the 5611.20Slukem directory ``regress''. Runs the compiled regression tests 5621.20Slukem on the local host. 5631.1Stv 5641.1Stv The "build.sh" script 5651.1Stv This script file is a Bourne shell script designed to build the entire 5661.1Stv NetBSD system on any host with a Bourne shell in /bin/sh, including many 5671.1Stv that are not POSIX compliant. Note that if a host system's /bin/sh is 5681.1Stv unusually old and broken, the Korn Shell (/bin/ksh), if available, may be 5691.1Stv a usable alternative. 5701.1Stv 5711.1Stv All cross-compile builds, and most native builds, of the entire system 5721.1Stv should make use of build.sh rather than just running ``make''. This way, 5731.1Stv the make(1) program will be bootstrapped properly, in case the host sys- 5741.1Stv tem has an older or incompatible ``make'' program. 5751.1Stv 5761.1Stv When compiling the entire system via build.sh, many make(1) variables are 5771.1Stv set for you in order to help encapsulate the build process. In the list 5781.1Stv of options below, variables that are automatically set by build.sh are 5791.1Stv noted where applicable. 5801.1Stv 5811.22Slukem The following operations are supported by build.sh: 5821.22Slukem 5831.44Slukem build Build the system as per ``make build''. This option 5841.44Slukem implies the obj and tools operations. 5851.22Slukem 5861.22Slukem distribution Build a full distribution as per ``make distribution''. 5871.22Slukem This option implies the build operation. 5881.22Slukem 5891.22Slukem release Build a full release as per ``make release''. This option 5901.22Slukem implies the distribution operation. 5911.22Slukem 5921.23Slukem makewrapper Create the nbmake-MACHINE wrapper. This operation is auto- 5931.23Slukem matically performed for any of the other operations. 5941.23Slukem 5951.22Slukem obj Perform ``make obj''. 5961.22Slukem 5971.22Slukem tools Build and install the host tools from src/tools. 5981.22Slukem 5991.35Slukem install=idir Install the contents of DESTDIR to idir, using ``make 6001.61Sapb installworld''. Note that files that are part of the 6011.61Sapb ``etc'' or ``xetc'' sets will not be installed. 6021.35Slukem 6031.22Slukem kernel=kconf Build a new kernel. The kconf argument is the name of a 6041.54Sapb configuration file suitable for use by config(1). If kconf 6051.22Slukem does not contain any `/' characters, the configuration file 6061.22Slukem is expected to be found in the KERNCONFDIR directory, which 6071.22Slukem is typically sys/arch/MACHINE/conf. The new kernel will be 6081.22Slukem built in a subdirectory of KERNOBJDIR, which is typically 6091.22Slukem sys/arch/MACHINE/compile or an associated object directory. 6101.22Slukem In order to ensure that the kernel is built using up-to- 6111.22Slukem date tools, it is strongly recommended that the tools be 6121.22Slukem rebuilt (using the tools operation). 6131.22Slukem 6141.35Slukem releasekernel=kconf 6151.35Slukem Install a gzip(1)ed copy of the kernel built by 6161.69Slukem kernel=kconf into 6171.69Slukem RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as 6181.69Slukem netbsd-kconf.gz, although the ``netbsd'' prefix is deter- 6191.69Slukem mined from the ``config'' directives in kconf. 6201.24Slukem 6211.24Slukem sets Perform ``make sets''. 6221.31Slukem 6231.31Slukem sourcesets Perform ``make sourcesets''. 6241.22Slukem 6251.54Sapb syspkgs Perform ``make syspkgs''. 6261.54Sapb 6271.56Sapb iso-image Perform ``make iso-image''. 6281.56Sapb 6291.65Sjnemeth iso-image-source 6301.65Sjnemeth Perform ``make iso-image-source''. 6311.65Sjnemeth 6321.51Swiz The following command line options alter the behaviour of the build.sh 6331.51Swiz operations described above: 6341.1Stv 6351.1Stv -a arch Set the value of MACHINE_ARCH to arch. 6361.9Sthorpej 6371.9Sthorpej -B buildid 6381.9Sthorpej Set the value of BUILDID to buildid. This will also append the 6391.67Ssborrill build identifier to the name of the ``make'' wrapper script so 6401.37Slukem that the resulting name is of the form 6411.37Slukem ``nbmake-MACHINE-BUILDID''. 6421.1Stv 6431.67Ssborrill -C cdextras 6441.67Ssborrill Set the value of CDEXTRA to cdextras which is a space-separated 6451.67Ssborrill list of files or directories which will be added in order to 6461.67Ssborrill the CD-ROM image when used in conjunction with ``iso-image'' or 6471.67Ssborrill ``iso-image-source''. Files will be added to the root of the 6481.67Ssborrill CD-ROM image, whereas directories will be copied recursively. 6491.67Ssborrill If relative paths are specified, they will be converted to 6501.67Ssborrill absolute paths before being used. 6511.66Sjnemeth 6521.59Sapb -D dest Set the value of DESTDIR to dest. If a relative path is speci- 6531.59Sapb fied, it will be converted to an absolute path before being 6541.59Sapb used. 6551.18Slukem 6561.23Slukem -E Set `expert' mode. This overrides various sanity checks, and 6571.23Slukem allows: DESTDIR does not have to be set to a non-root path for 6581.38Slukem builds, and MKUNPRIVED=yes does not have to be set when build- 6591.38Slukem ing as a non-root user. 6601.23Slukem 6611.23Slukem Note: It is highly recommended that you know what you are doing 6621.23Slukem when you use this option. 6631.19Slukem 6641.51Swiz -h Print a help message. 6651.51Swiz 6661.10Ssommerfe -j njob Passed through to make(1). Makefiles should use .WAIT or have 6671.10Ssommerfe explicit dependancies as necessary to enforce build ordering. 6681.10Ssommerfe If you see build failures with -j, please save complete build 6691.10Ssommerfe logs so the failures can be analyzed. 6701.1Stv 6711.59Sapb -M obj Set MAKEOBJDIRPREFIX to obj. If a relative path is specified, 6721.59Sapb it will be converted to an absolute path before being used. 6731.59Sapb Unsets MAKEOBJDIR. 6741.18Slukem 6751.60Sapb -m mach Set the value of MACHINE to mach, except in some special cases 6761.60Sapb listed below. This will also override any value of 6771.60Sapb MACHINE_ARCH in the process environment with a value deduced 6781.60Sapb from mach, unless -a is specified. All cross builds require 6791.60Sapb -m, but if unset on a NetBSD host, the host's value of MACHINE 6801.60Sapb will be detected and used automatically. 6811.60Sapb 6821.60Sapb Some machines support multiple values for MACHINE_ARCH. The 6831.60Sapb following special cases for the mach argument are defined to 6841.60Sapb set the listed values of MACHINE and MACHINE_ARCH: 6851.33Slukem 6861.33Slukem mach MACHINE MACHINE_ARCH 6871.60Sapb evbarm evbarm (not set) 6881.60Sapb evbarm-eb evbarm armeb 6891.60Sapb evbarm-el evbarm arm 6901.33Slukem evbmips evbmips (not set) 6911.33Slukem evbmips-eb evbmips mipseb 6921.33Slukem evbmips-el evbmips mipsel 6931.33Slukem evbsh3 evbsh3 (not set) 6941.33Slukem evbsh3-eb evbsh3 sh3eb 6951.33Slukem evbsh3-el evbsh3 sh3el 6961.33Slukem sbmips sbmips (not set) 6971.33Slukem sbmips-eb sbmips mipseb 6981.33Slukem sbmips-el sbmips mipsel 6991.1Stv 7001.45Slukem -N noiselevel 7011.46Slukem Set the ``noisyness'' level of the build, by setting 7021.46Slukem MAKEVERBOSE to noiselevel. 7031.45Slukem 7041.1Stv -n Show the commands that would be executed by build.sh, but do 7051.1Stv not make any changes. This is similar in concept to ``make 7061.1Stv -n''. 7071.1Stv 7081.18Slukem -O obj Create an appropriate transform macro for MAKEOBJDIR that will 7091.59Sapb place the built object files under obj. If a relative path is 7101.59Sapb specified, it will be converted to an absolute path before 7111.59Sapb being used. For instance, a setting of /usr/obj will place 7121.59Sapb build-time files under /usr/obj/bin, /usr/obj/lib, 7131.59Sapb /usr/obj/usr.bin, and so forth. Unsets MAKEOBJDIRPREFIX. 7141.18Slukem 7151.34Slukem -o Set the value of MKOBJDIRS to ``no''. Otherwise, it will be 7161.34Slukem automatically set to ``yes'' (which is opposite to the default 7171.34Slukem behaviour). 7181.1Stv 7191.59Sapb -R rel Set the value of RELEASEDIR to rel. If a relative path is 7201.59Sapb specified, it will be converted to an absolute path before 7211.59Sapb being used. 7221.18Slukem 7231.1Stv -r Remove the contents of DESTDIR and TOOLDIR before building 7241.1Stv (provides a clean starting point). This will skip deleting 7251.1Stv DESTDIR if building on a native system to the root directory. 7261.1Stv 7271.59Sapb -T tools Set the value of TOOLDIR to tools. If a relative path is spec- 7281.59Sapb ified, it will be converted to an absolute path before being 7291.59Sapb used. If set, the bootstrap ``make'' will only be rebuilt as 7301.59Sapb needed (when the source files for make(1) change). 7311.18Slukem 7321.38Slukem -U Set MKUNPRIVED=yes. 7331.18Slukem 7341.38Slukem -u Set MKUPDATE=yes. 7351.1Stv 7361.21Slukem -V var=[value] 7371.40Slukem Set the environment variable var to an optional value. This is 7381.40Slukem propagated to the nbmake wrapper. 7391.21Slukem 7401.1Stv -w wrapper 7411.1Stv Create the nbmake wrapper script (see below) in a custom loca- 7421.1Stv tion, specified by wrapper. This allows, for instance, to 7431.1Stv place the wrapper in PATH automatically. Note that wrapper is 7441.59Sapb the full name of the file, not just a directory name. If a 7451.59Sapb relative path is specified, it will be converted to an absolute 7461.59Sapb path before being used. 7471.1Stv 7481.49Slukem -X x11src 7491.59Sapb Set the value of X11SRCDIR to x11src. If a relative path is 7501.59Sapb specified, it will be converted to an absolute path before 7511.59Sapb being used. 7521.49Slukem 7531.49Slukem -x Set MKX11=yes. 7541.49Slukem 7551.40Slukem -Z var Unset ("zap") the environment variable var. This is propagated 7561.40Slukem to the nbmake wrapper. 7571.40Slukem 7581.1Stv The "nbmake-MACHINE" wrapper script 7591.1Stv If using the build.sh script to build NetBSD, a nbmake-MACHINE script 7601.1Stv will be created in TOOLDIR/bin upon the first build to assist in building 7611.1Stv subtrees on a cross-compile host. 7621.1Stv 7631.1Stv nbmake-MACHINE can be invoked in lieu of make(1), and will instead call 7641.1Stv the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev- 7651.1Stv eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR. 7661.40Slukem build.sh will also set variables specified with -V, and unset variables 7671.40Slukem specified with -Z. 7681.40Slukem 7691.1Stv This script can be symlinked into a directory listed in PATH, or called 7701.1Stv with an absolute path. 7711.1Stv 7721.16SlukemEXAMPLES 7731.44Slukem 1. % ./build.sh tools kernel=GENERIC 7741.28Slukem 7751.28Slukem Build a new toolchain, and use the new toolchain to configure and 7761.28Slukem build a new GENERIC kernel. 7771.28Slukem 7781.44Slukem 2. % ./build.sh -U distribution 7791.28Slukem 7801.30Slukem Using unprivileged mode, build a complete distribution to a DESTDIR 7811.30Slukem directory that build.sh selects (and will display). 7821.28Slukem 7831.43Smartti 3. # ./build.sh -U install=/ 7841.28Slukem 7851.29Slukem As root, install to / the distribution that was built by example 2. 7861.29Slukem Even though this is run as root, -U is required so that the permis- 7871.30Slukem sions stored in DESTDIR/METALOG are correctly applied to the files 7881.30Slukem as they're copied to /. 7891.28Slukem 7901.44Slukem 4. % ./build.sh -U -u release 7911.28Slukem 7921.30Slukem Using unprivileged mode, build a complete release to DESTDIR and 7931.30Slukem RELEASEDIR directories that build.sh selects (and will display). 7941.38Slukem MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that 7951.38Slukem if this is run after example 2, it doesn't need to redo that portion 7961.38Slukem of the release build. 7971.16Slukem 7981.10SsommerfeOBSOLETE VARIABLES 7991.15Slukem NBUILDJOBS Use the make(1) option -j, instead. 8001.15Slukem 8011.15Slukem USE_NEW_TOOLCHAIN 8021.15Slukem The new toolchain is now the default. To disable, use 8031.15Slukem TOOLCHAIN_MISSING=yes. 8041.10Ssommerfe 8051.1StvSEE ALSO 8061.62Sapb make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8), 8071.61Sapb pkgsrc/sysutils/cdrtools 8081.1Stv 8091.1StvHISTORY 8101.15Slukem The build.sh based build scheme was introduced for NetBSD 1.6 as 8111.15Slukem USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that. 8121.1Stv 8131.1StvBUGS 8141.15Slukem A few platforms are not yet using this build system. 8151.1Stv 8161.69SlukemNetBSD March 18, 2008 NetBSD 817