BUILDING revision 1.107
11.104SwizBUILDING(8) System Manager's Manual BUILDING(8) 21.1Stv 31.105SwizNAME 41.105Swiz BUILDING -- Procedure for building NetBSD from source code. 51.1Stv 61.105SwizREQUIREMENTS 71.1Stv NetBSD is designed to be buildable on most POSIX-compliant host systems. 81.105Swiz The basic build procedure is the same whether compiling natively (on the 91.105Swiz 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.105Swiz 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.105SwizFILES 201.105Swiz Source tree layout 211.105Swiz doc/BUILDING.mdoc 221.17Swiz This document (in -mdoc troff format; the original copy). 231.1Stv 241.105Swiz BUILDING This document (in plaintext). 251.1Stv 261.105Swiz tools/compat/README 271.48Sjmc Special notes for cross-hosting a NetBSD build on non- 281.48Sjmc NetBSD platforms. 291.48Sjmc 301.105Swiz 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.105Swiz on a non-native host, see the build.sh shell script.) 341.1Stv 351.105Swiz 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.105Swiz 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.105Swiz crypto/dist/, dist/, gnu/dist/ 461.104Swiz Sources imported verbatim from third parties, without 471.104Swiz mangling the existing build structure. Other source trees 481.105Swiz in bin through usr.sbin use the NetBSD make(1) 491.104Swiz ``reachover'' Makefile semantics when building these 501.104Swiz programs for a native host. 511.104Swiz 521.106Swiz external, sys/external 531.106Swiz Sources and build infrastructure for components imported 541.106Swiz (mostly) unchanged from upstream maintainers, sorted by 551.106Swiz applicable license. This is (slowly) replacing the 561.106Swiz crypto/dist, dist, and gnu/dist directories. 571.106Swiz 581.105Swiz distrib/, etc/ 591.104Swiz Sources for items used when making a full release 601.105Swiz snapshot, such as files installed in DESTDIR/etc on the 611.104Swiz destination system, boot media, and release notes. 621.1Stv 631.105Swiz tests/, regress/ 641.70Sdholland Regression test harness. Can be cross-compiled, but only 651.105Swiz run natively. tests/ uses the atf(7) test framework; 661.105Swiz regress/ contains older tests that have not yet been 671.70Sdholland migrated to atf(7). 681.1Stv 691.105Swiz sys/ NetBSD kernel sources. 701.1Stv 711.105Swiz tools/ ``Reachover'' build structure for the host build tools. 721.104Swiz This has a special method of determining out-of-date 731.104Swiz status. 741.1Stv 751.105Swiz bin/ ... usr.sbin/ 761.1Stv Sources to the NetBSD userland (non-kernel) programs. If 771.1Stv any of these directories are missing, they will be skipped 781.1Stv during the build. 791.1Stv 801.105Swiz x11/ ``Reachover'' build structure for X11R6; the source is in 811.105Swiz X11SRCDIR. 821.49Slukem 831.105Swiz Build tree layout 841.1Stv The NetBSD build tree is described in hier(7), and the release layout is 851.1Stv described in release(7). 861.1Stv 871.105SwizCONFIGURATION 881.105Swiz Environment variables 891.8Slukem Several environment variables control the behaviour of NetBSD builds. 901.8Slukem 911.105Swiz HOST_SH Path name to a shell available on the host system and 921.96Sapb suitable for use during the build. The NetBSD build 931.96Sapb system requires a modern Bourne-like shell with POSIX- 941.96Sapb compliant features, and also requires support for the 951.96Sapb ``local'' keyword to declare local variables in shell 961.104Swiz functions (which is a widely-implemented but non- 971.104Swiz standardised feature). 981.96Sapb 991.96Sapb Depending on the host system, a suitable shell may be 1001.105Swiz /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a 1011.96Sapb variant of ksh that supports the ``local'' keyword, 1021.105Swiz such as ksh88, but not ksh93), or /usr/local/bin/bash. 1031.96Sapb 1041.105Swiz Most parts of the build require HOST_SH to be an 1051.105Swiz absolute path; however, build.sh allows it to be a 1061.104Swiz simple command name, which will be converted to an 1071.105Swiz absolute path by searching the PATH. 1081.58Sapb 1091.105Swiz HOST_CC Path name to C compiler used to create the toolchain. 1101.53Sreed 1111.105Swiz HOST_CXX Path name to C++ compiler used to create the toolchain. 1121.53Sreed 1131.105Swiz MACHINE Machine type, e.g., ``macppc''. 1141.8Slukem 1151.105Swiz MACHINE_ARCH Machine architecture, e.g., ``powerpc''. 1161.8Slukem 1171.105Swiz MAKE Path name to invoke make(1) as. 1181.8Slukem 1191.105Swiz MAKEFLAGS Flags to invoke make(1) with. Note that build.sh 1201.105Swiz ignores the value of MAKEFLAGS passed in the 1211.105Swiz environment, but allows MAKEFLAGS to be set via the -V 1221.104Swiz option. 1231.8Slukem 1241.105Swiz MAKEOBJDIR Directory to use as the .OBJDIR for the current 1251.104Swiz directory. The value is subjected to variable 1261.104Swiz expansion by make(1). Typical usage is to set this 1271.104Swiz variable to a value involving the use of 1281.104Swiz `${.CURDIR:S...}' or `${.CURDIR:C...}', to derive the 1291.105Swiz value of .OBJDIR from the value of .CURDIR. Used only 1301.105Swiz if MAKEOBJDIRPREFIX is not defined. MAKEOBJDIR can be 1311.105Swiz provided only in the environment or via the -O flag of 1321.105Swiz build.sh; it cannot usefully be set inside a Makefile, 1331.105Swiz including mk.conf or ${MAKECONF}. 1341.8Slukem 1351.105Swiz MAKEOBJDIRPREFIX Top level directory of the object directory tree. The 1361.88Sapb value is subjected to variable expansion by make(1). 1371.105Swiz build.sh will create the ${MAKEOBJDIRPREFIX} directory 1381.105Swiz if necessary, but if make(1) is used without build.sh, 1391.88Sapb then rules in <bsd.obj.mk> will abort the build if the 1401.88Sapb ${MAKEOBJDIRPREFIX} directory does not exist. If the 1411.104Swiz value is defined and valid, then 1421.105Swiz ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR 1431.104Swiz for the current directory. The current directory may 1441.105Swiz be read only. MAKEOBJDIRPREFIX can be provided only in 1451.105Swiz the environment or via the -M flag of build.sh; it 1461.104Swiz cannot usefully be set inside a Makefile, including 1471.105Swiz mk.conf or ${MAKECONF}. 1481.104Swiz 1491.105Swiz "make" variables 1501.104Swiz Several variables control the behavior of NetBSD builds. Unless 1511.104Swiz otherwise specified, these variables may be set in either the process 1521.105Swiz environment or the make(1) configuration file specified by MAKECONF. 1531.1Stv 1541.107Sapb BUILDID Identifier for the build. If set, this should be a short 1551.107Sapb string that is suitable for use as part of a file or 1561.107Sapb directory name. The identifier will be appended to object 1571.107Sapb directory names, and can be consulted in the make(1) 1581.104Swiz configuration file in order to set additional build 1591.107Sapb parameters, such as compiler flags. It will also be used as 1601.107Sapb part of the kernel version string, which can be printed by 1611.107Sapb ``uname -v''. 1621.107Sapb 1631.107Sapb Default: Unset. 1641.9Sthorpej 1651.105Swiz BUILDSEED GCC uses random numbers when compiling C++ code. This 1661.104Swiz variable seeds the gcc random number generator using the 1671.104Swiz -frandom-seed flag with this value. By default, it is set to 1681.104Swiz NetBSD-(majorversion). Using a fixed value causes C++ 1691.104Swiz binaries to be the same when built from the same sources, 1701.104Swiz resulting in identical (reproducible) builds. Additional 1711.104Swiz information is available in the GCC documentation of 1721.104Swiz -frandom-seed. 1731.104Swiz 1741.105Swiz DESTDIR Directory to contain the built NetBSD system. If set, 1751.104Swiz special options are passed to the compilation tools to 1761.105Swiz prevent their default use of the host system's /usr/include, 1771.105Swiz /usr/lib, and so forth. This pathname must be an absolute 1781.105Swiz path, and should not end with a slash (/) character. (For 1791.105Swiz installation into the system's root directory, set DESTDIR to 1801.59Sapb an empty string, not to ``/''). The directory must reside on 1811.59Sapb a file system which supports long file names and hard links. 1821.1Stv 1831.105Swiz Default: Empty string if USETOOLS is ``yes''; unset 1841.104Swiz otherwise. 1851.1Stv 1861.105Swiz Note: build.sh will provide a default of destdir.MACHINE (in 1871.105Swiz the top-level .OBJDIR) unless run in `expert' mode. 1881.30Slukem 1891.105Swiz MAKECONF The name of the make(1) configuration file. Only settable in 1901.105Swiz the process environment. 1911.1Stv 1921.105Swiz Default: ``/etc/mk.conf'' 1931.1Stv 1941.105Swiz MAKEVERBOSE 1951.45Slukem Level of verbosity of status messages. Supported values: 1961.45Slukem 1971.80Sapb 0 No descriptive messages or commands executed by make(1) 1981.80Sapb are shown. 1991.45Slukem 2001.80Sapb 1 Brief messages are shown describing what is being done, 2011.104Swiz but the actual commands executed by make(1) are not 2021.104Swiz displayed. 2031.80Sapb 2041.80Sapb 2 Descriptive messages are shown as above (prefixed with a 2051.80Sapb `#'), and ordinary commands performed by make(1) are 2061.80Sapb displayed. 2071.80Sapb 2081.80Sapb 3 In addition to the above, all commands performed by 2091.80Sapb make(1) are displayed, even if they would ordinarily 2101.80Sapb have been hidden through use of the ``@'' prefix in the 2111.80Sapb relevant makefile. 2121.45Slukem 2131.80Sapb 4 In addition to the above, commands executed by make(1) 2141.105Swiz are traced through use of the sh(1) ``-x'' flag. 2151.45Slukem 2161.105Swiz Default: 2 2171.45Slukem 2181.105Swiz MKCATPAGES Can be set to ``yes'' or ``no''. Indicates whether 2191.104Swiz preformatted plaintext manual pages will be created during a 2201.104Swiz build. 2211.1Stv 2221.105Swiz Default: ``no'' 2231.1Stv 2241.106Swiz MKCROSSGDB Can be set to ``yes'' or ``no''. Create a cross-gdb as a 2251.106Swiz host tool. 2261.106Swiz 2271.106Swiz Default: ``no'' 2281.106Swiz 2291.105Swiz MKCRYPTO Can be set to ``yes'' or ``no''. Indicates whether 2301.104Swiz cryptographic code will be included in a build; provided for 2311.104Swiz the benefit of countries that do not allow strong 2321.104Swiz cryptography. Will not affect use of the standard low- 2331.104Swiz security password encryption system, crypt(3). 2341.1Stv 2351.105Swiz Default: ``yes'' 2361.1Stv 2371.106Swiz MKDEBUG Can be set to ``yes'' or ``no''. Indicates whether debug 2381.106Swiz information should be generated for all userland binaries 2391.106Swiz compiled. The result is collected as an additional debug.tgz 2401.106Swiz and xdebug.tgz set and installed in /usr/libdata/debug. 2411.106Swiz 2421.106Swiz Default: ``no'' 2431.106Swiz 2441.106Swiz MKDEBUGLIB Can be set to ``yes'' or ``no''. Indicates whether debug 2451.106Swiz information (see MKDEBUG) should also be generated for all 2461.106Swiz libraries build. 2471.106Swiz 2481.106Swiz Default: ``no'' 2491.106Swiz 2501.105Swiz MKDOC Can be set to ``yes'' or ``no''. Indicates whether system 2511.105Swiz documentation destined for DESTDIR/usr/share/doc will be 2521.44Slukem installed during a build. 2531.1Stv 2541.105Swiz Default: ``yes'' 2551.1Stv 2561.105Swiz MKHTML Can be set to ``yes'' or ``no''. Indicates whether 2571.104Swiz preformatted HTML manual pages will be built and installed 2581.77Slukem 2591.105Swiz Default: ``yes'' 2601.77Slukem 2611.105Swiz MKHOSTOBJ Can be set to ``yes'' or ``no''. If set to ``yes'', then for 2621.4Stv programs intended to be run on the compile host, the name, 2631.4Stv release, and architecture of the host operating system will 2641.4Stv be suffixed to the name of the object directory created by 2651.4Stv ``make obj''. (This allows multiple host systems to compile 2661.4Stv NetBSD for a single target.) If set to ``no'', then programs 2671.4Stv built to be run on the compile host will use the same object 2681.4Stv directory names as programs built to be run on the target. 2691.4Stv 2701.105Swiz Default: ``no'' 2711.4Stv 2721.105Swiz MKINFO Can be set to ``yes'' or ``no''. Indicates whether GNU Info 2731.1Stv files, used for the documentation for most of the compilation 2741.1Stv tools, will be created and installed during a build. 2751.1Stv 2761.105Swiz Default: ``yes'' 2771.1Stv 2781.106Swiz MKKDEBUG Can be set to ``yes'' or ``no''. Force generation of full- 2791.106Swiz debug symbol versions of all kernels compiled. Alongside of 2801.106Swiz the netbsd kernel file, an unstripped version netbsd.gdb is 2811.106Swiz created. This is useful if a cross-gdb is built as well (see 2821.106Swiz MKCROSSGDB). 2831.106Swiz 2841.106Swiz Default: ``no'' 2851.106Swiz 2861.105Swiz MKKMOD Can be set to ``yes'' or ``no''. Indicates whether kernel 2871.95Sapb modules are built and installed. 2881.95Sapb 2891.105Swiz Default: ``yes'' 2901.95Sapb 2911.105Swiz MKLINT Can be set to ``yes'' or ``no''. Indicates whether lint(1) 2921.1Stv will be run against portions of the NetBSD source code during 2931.1Stv the build, and whether lint libraries will be installed into 2941.105Swiz DESTDIR/usr/libdata/lint. 2951.1Stv 2961.105Swiz Default: ``yes'' 2971.1Stv 2981.105Swiz MKMAN Can be set to ``yes'' or ``no''. Indicates whether manual 2991.1Stv pages will be installed during a build. 3001.1Stv 3011.105Swiz Default: ``yes'' 3021.1Stv 3031.105Swiz MKNLS Can be set to ``yes'' or ``no''. Indicates whether Native 3041.44Slukem Language System locale zone files will be compiled and 3051.44Slukem installed during a build. 3061.1Stv 3071.105Swiz Default: ``yes'' 3081.1Stv 3091.105Swiz MKOBJ Can be set to ``yes'' or ``no''. Indicates whether object 3101.1Stv directories will be created when running ``make obj''. If 3111.1Stv set to ``no'', then all built files will be located inside 3121.1Stv the regular source tree. 3131.1Stv 3141.105Swiz Default: ``yes'' 3151.1Stv 3161.105Swiz Note that setting MKOBJ to ``no'' is not recommended and may 3171.70Sdholland cause problems when updating the tree with cvs(1). 3181.70Sdholland 3191.105Swiz MKPIC Can be set to ``yes'' or ``no''. Indicates whether shared 3201.1Stv objects and libraries will be created and installed during a 3211.1Stv build. If set to ``no'', the entire built system will be 3221.1Stv statically linked. 3231.1Stv 3241.105Swiz Default: Platform dependent. As of this writing, all 3251.105Swiz platforms except sh3 default to ``yes''. 3261.1Stv 3271.105Swiz MKPICINSTALL 3281.1Stv Can be set to ``yes'' or ``no''. Indicates whether the ar(1) 3291.105Swiz format libraries (lib*_pic.a), used to generate shared 3301.44Slukem libraries, are installed during a build. 3311.1Stv 3321.105Swiz Default: ``yes'' 3331.1Stv 3341.105Swiz MKPROFILE Can be set to ``yes'' or ``no''. Indicates whether profiled 3351.105Swiz libraries (lib*_p.a) will be built and installed during a 3361.1Stv build. 3371.1Stv 3381.105Swiz Default: ``yes''; however, some platforms turn off MKPROFILE 3391.1Stv by default at times due to toolchain problems with profiled 3401.1Stv code. 3411.1Stv 3421.105Swiz MKREPRO Can be set to ``yes'' or ``no''. Create reproducable builds. 3431.100Swiz This enables different switches to make two builds from the 3441.100Swiz same source tree result in the same build results. 3451.100Swiz 3461.105Swiz Default: ``no'' 3471.100Swiz 3481.105Swiz MKSHARE Can be set to ``yes'' or ``no''. Indicates whether files 3491.105Swiz destined to reside in DESTDIR/usr/share will be built and 3501.44Slukem installed during a build. If set to ``no'', then all of 3511.105Swiz MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to 3521.27Slukem ``no'' unconditionally. 3531.1Stv 3541.105Swiz Default: ``yes'' 3551.1Stv 3561.105Swiz MKSTRIPIDENT 3571.102Sabs Can be set to ``yes'' or ``no''. Indicates whether RCS IDs, 3581.104Swiz for use with ident(1), should be stripped from program 3591.104Swiz binaries and shared libraries. 3601.78Sapb 3611.105Swiz Default: ``no'' 3621.78Sapb 3631.105Swiz MKUNPRIVED Can be set to ``yes'' or ``no''. Indicates whether an 3641.104Swiz unprivileged install will occur. The user, group, 3651.104Swiz permissions, and file flags, will not be set on the installed 3661.52Sjmc items; instead the information will be appended to a file 3671.105Swiz called METALOG in DESTDIR. The contents of METALOG are used 3681.52Sjmc during the generation of the distribution tar files to ensure 3691.52Sjmc that the appropriate file ownership is stored. 3701.38Slukem 3711.105Swiz Default: ``no'' 3721.38Slukem 3731.105Swiz MKUPDATE Can be set to ``yes'' or ``no''. Indicates whether all 3741.105Swiz install operations intended to write to DESTDIR will compare 3751.38Slukem file timestamps before installing, and skip the install phase 3761.44Slukem if the destination files are up-to-date. This also has 3771.44Slukem implications on full builds (see next subsection). 3781.38Slukem 3791.105Swiz Default: ``no'' 3801.38Slukem 3811.105Swiz MKX11 Can be set to ``yes'' or ``no''. Indicates whether X11 is 3821.105Swiz built from X11SRCDIR. 3831.49Slukem 3841.105Swiz Default: ``no'' 3851.49Slukem 3861.105Swiz TOOLDIR Directory to hold the host tools, once built. If specified, 3871.59Sapb must be an absolute path. This directory should be unique to 3881.104Swiz a given host system and NetBSD source tree. (However, 3891.105Swiz multiple targets may share the same TOOLDIR; the target- 3901.104Swiz dependent files have unique names.) If unset, a default 3911.104Swiz based on the uname(1) information of the host platform will 3921.105Swiz be created in the .OBJDIR of src. 3931.1Stv 3941.105Swiz Default: Unset. 3951.1Stv 3961.105Swiz USETOOLS Indicates whether the tools specified by TOOLDIR should be 3971.1Stv used as part of a build in progress. Must be set to ``yes'' 3981.1Stv if cross-compiling. 3991.1Stv 4001.105Swiz yes Use the tools from TOOLDIR. 4011.1Stv 4021.105Swiz no Do not use the tools from TOOLDIR, but refuse to build 4031.1Stv native compilation tool components that are version- 4041.1Stv specific for that tool. 4051.1Stv 4061.105Swiz never Do not use the tools from TOOLDIR, even when building 4071.104Swiz native tool components. This is similar to the 4081.105Swiz traditional NetBSD build method, but does not verify 4091.104Swiz that the compilation tools in use are up-to-date 4101.104Swiz enough in order to build the tree successfully. This 4111.104Swiz may cause build or runtime problems when building the 4121.104Swiz whole NetBSD source tree. 4131.1Stv 4141.105Swiz Default: ``yes'', unless TOOLCHAIN_MISSING is set to ``yes''. 4151.71Sdholland 4161.105Swiz USETOOLS is also set to ``no'' when using <bsd.*.mk> outside 4171.71Sdholland the NetBSD source tree. 4181.1Stv 4191.105Swiz X11SRCDIR Directory containing the X11R6 source. If specified, must be 4201.59Sapb an absolute path. The main X11R6 source is found in 4211.105Swiz X11SRCDIR/xfree/xc. 4221.49Slukem 4231.105Swiz Default: NETBSDRCDIR/../xsrc, if that exists; otherwise 4241.105Swiz /usr/xsrc. 4251.49Slukem 4261.105Swiz X11FLAVOUR The style of X11 cross-built, set to either ``Xorg'' or 4271.79Smrg ``XFree86''. 4281.79Smrg 4291.105Swiz Default: ``Xorg'' on amd64, i386, macppc, shark and sparc64 4301.81Smrg platforms, ``XFree86'' on everything else. 4311.79Smrg 4321.105Swiz "make" variables for full builds 4331.7Slukem These variables only affect the top level ``Makefile'' and do not affect 4341.7Slukem manually building subtrees of the NetBSD source code. 4351.1Stv 4361.105Swiz INSTALLWORLDDIR Location for the ``make installworld'' target to install 4371.59Sapb to. If specified, must be an absolute path. 4381.1Stv 4391.105Swiz Default: ``/'' 4401.1Stv 4411.105Swiz MKOBJDIRS Can be set to ``yes'' or ``no''. Indicates whether 4421.44Slukem object directories will be created automatically (via a 4431.20Slukem ``make obj'' pass) at the start of a build. 4441.1Stv 4451.105Swiz Default: ``no'' 4461.1Stv 4471.105Swiz If using build.sh, the default is ``yes''. This may be 4481.105Swiz set back to ``no'' by giving build.sh the -o option. 4491.70Sdholland 4501.105Swiz MKUPDATE Can be set to ``yes'' or ``no''. If set, then in 4511.105Swiz addition to the effects described for MKUPDATE=yes 4521.105Swiz above, this implies the effects of NOCLEANDIR (i.e., 4531.104Swiz ``make cleandir'' is avoided). 4541.38Slukem 4551.105Swiz Default: ``no'' 4561.38Slukem 4571.105Swiz If using build.sh, this may be set by giving the -u 4581.70Sdholland option. 4591.70Sdholland 4601.105Swiz NBUILDJOBS Now obsolete. Use the make(1) option -j, instead. See 4611.70Sdholland below. 4621.1Stv 4631.105Swiz Default: Unset. 4641.1Stv 4651.105Swiz NOCLEANDIR If set, avoids the ``make cleandir'' phase of a full 4661.20Slukem build. This has the effect of allowing only changed 4671.20Slukem files in a source tree to be recompiled. This can speed 4681.20Slukem up builds when updating only a few files in the tree. 4691.1Stv 4701.105Swiz Default: Unset. 4711.1Stv 4721.105Swiz See also MKUPDATE. 4731.70Sdholland 4741.105Swiz NODISTRIBDIRS If set, avoids the ``make distrib-dirs'' phase of a full 4751.105Swiz build. This skips running mtree(8) on DESTDIR, useful 4761.20Slukem on systems where building as an unprivileged user, or 4771.20Slukem where it is known that the system-wide mtree files have 4781.20Slukem not changed. 4791.1Stv 4801.105Swiz Default: Unset. 4811.1Stv 4821.105Swiz NOINCLUDES If set, avoids the ``make includes'' phase of a full 4831.20Slukem build. This has the effect of preventing make(1) from 4841.44Slukem thinking that some programs are out-of-date simply 4851.44Slukem because the system include files have changed. However, 4861.20Slukem this option should not be used when updating the entire 4871.20Slukem NetBSD source tree arbitrarily; it is suggested to use 4881.105Swiz MKUPDATE=yes instead in that case. 4891.1Stv 4901.105Swiz Default: Unset. 4911.1Stv 4921.105Swiz RELEASEDIR If set, specifies the directory to which a release(7) 4931.20Slukem layout will be written at the end of a ``make release''. 4941.59Sapb If specified, must be an absolute path. 4951.20Slukem 4961.105Swiz Default: Unset. 4971.20Slukem 4981.105Swiz Note: build.sh will provide a default of releasedir (in 4991.105Swiz the top-level .OBJDIR) unless run in `expert' mode. 5001.30Slukem 5011.105SwizBUILDING 5021.105Swiz "make" command line options 5031.52Sjmc This is not a summary of all the options available to make(1); only the 5041.52Sjmc options used most frequently with NetBSD builds are listed here. 5051.1Stv 5061.105Swiz -j njob Run up to njob make(1) subjobs in parallel. Makefiles should 5071.52Sjmc use .WAIT or have explicit dependencies as necessary to 5081.74Sapb enforce build ordering. 5091.10Ssommerfe 5101.105Swiz -m dir Specify the default directory for searching for system 5111.104Swiz Makefile segments, mainly the <bsd.*.mk> files. When building 5121.104Swiz any full NetBSD source tree, this should be set to the 5131.104Swiz ``share/mk'' directory in the source tree. This is set 5141.104Swiz automatically when building from the top level, or when using 5151.105Swiz build.sh. 5161.1Stv 5171.105Swiz -n Display the commands that would have been executed, but do not 5181.1Stv actually execute them. This will still cause recursion to 5191.1Stv take place. 5201.1Stv 5211.105Swiz -V var Print make(1)'s idea of the value of var. Does not build any 5221.1Stv targets. 5231.1Stv 5241.105Swiz var=value Set the variable var to value, overriding any setting 5251.105Swiz specified by the process environment, the MAKECONF 5261.104Swiz configuration file, or the system Makefile segments. 5271.1Stv 5281.105Swiz "make" targets 5291.1Stv These default targets may be built by running make(1) in any subtree of 5301.1Stv the NetBSD source code. It is recommended that none of these be used 5311.1Stv from the top level Makefile; as a specific exception, ``make obj'' and 5321.1Stv ``make cleandir'' are useful in that context. 5331.1Stv 5341.105Swiz all Build programs, libraries, and preformatted documentation. 5351.1Stv 5361.105Swiz clean Remove program and library object code files. 5371.1Stv 5381.105Swiz cleandir Same as clean, but also remove preformatted documentation, 5391.44Slukem dependency files generated by ``make depend'', and any other 5401.49Slukem files known to be created at build time. 5411.1Stv 5421.105Swiz depend Create dependency files (.depend) containing more detailed 5431.44Slukem information about the dependencies of source code on header 5441.1Stv files. Allows programs to be recompiled automatically when a 5451.1Stv dependency changes. 5461.1Stv 5471.105Swiz dependall Does a ``make depend'' immediately followed by a ``make all''. 5481.10Ssommerfe This improves cache locality of the build since both passes 5491.10Ssommerfe read the source files in their entirety. 5501.1Stv 5511.105Swiz distclean Synonym for cleandir. 5521.49Slukem 5531.105Swiz includes Build and install system header files. Typically needed 5541.44Slukem before any system libraries or programs can be built. 5551.1Stv 5561.105Swiz install Install programs, libraries, and documentation into DESTDIR. 5571.105Swiz Few files will be installed to DESTDIR/dev, DESTDIR/etc, 5581.105Swiz DESTDIR/root or DESTDIR/var in order to prevent user supplied 5591.27Slukem configuration data from being overwritten. 5601.1Stv 5611.105Swiz lint Run lint(1) against the C source code, where appropriate, and 5621.1Stv generate system-installed lint libraries. 5631.1Stv 5641.105Swiz obj Create object directories to be used for built files, instead 5651.1Stv of building directly in the source tree. 5661.1Stv 5671.105Swiz tags Create ctags(1) searchable function lists usable by the ex(1) 5681.1Stv and vi(1) text editors. 5691.1Stv 5701.105Swiz "make" targets for the top level 5711.1Stv Additional make(1) targets are usable specifically from the top source 5721.1Stv level to facilitate building the entire NetBSD source tree. 5731.1Stv 5741.105Swiz build Build the entire NetBSD system (except the kernel). This 5751.68Sreed orders portions of the source tree such that prerequisites 5761.68Sreed will be built in the proper order. 5771.20Slukem 5781.105Swiz distribution Do a ``make build'', and then install a full distribution 5791.105Swiz (which does not include a kernel) into DESTDIR, including 5801.105Swiz files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and 5811.105Swiz DESTDIR/var. 5821.20Slukem 5831.105Swiz buildworld As per ``make distribution'', except that it ensures that 5841.105Swiz DESTDIR is not the root directory. 5851.20Slukem 5861.105Swiz installworld Install the distribution from DESTDIR to INSTALLWORLDDIR, 5871.70Sdholland which defaults to the root directory. Ensures that 5881.105Swiz INSTALLWORLDDIR is not the root directory if cross 5891.104Swiz compiling. 5901.20Slukem 5911.105Swiz The INSTALLSETS environment variable may be set to a space- 5921.95Sapb separated list of distribution sets to be installed. By 5931.95Sapb default, all sets except ``etc'' and ``xetc'' are 5941.105Swiz installed, so most files in INSTALLWORLDDIR/etc will not be 5951.95Sapb installed or modified. 5961.61Sapb 5971.105Swiz Note: Before performing this operation with 5981.105Swiz INSTALLWORLDDIR=/, it is highly recommended that you 5991.61Sapb upgrade your kernel and reboot. After performing this 6001.61Sapb operation, it is recommended that you use etcupdate(8) to 6011.105Swiz update files in INSTALLWORLDDIR/etc, and postinstall(8) to 6021.102Sabs check for or fix inconsistencies. 6031.20Slukem 6041.105Swiz sets Create distribution sets from DESTDIR into 6051.105Swiz RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run 6061.70Sdholland after ``make distribution'', as ``make build'' alone does 6071.70Sdholland not install all of the required files. 6081.25Slukem 6091.105Swiz sourcesets Create source sets of the source tree into 6101.105Swiz RELEASEDIR/source/sets. 6111.31Slukem 6121.105Swiz syspkgs Create syspkgs from DESTDIR into 6131.105Swiz RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run 6141.70Sdholland after ``make distribution'', as ``make build'' alone does 6151.70Sdholland not install all of the required files. 6161.54Sapb 6171.105Swiz release Do a ``make distribution'', build kernels, distribution 6181.44Slukem media, and install sets (this as per ``make sets''), and 6191.44Slukem then package the system into a standard release layout as 6201.105Swiz described by release(7). This requires that RELEASEDIR be 6211.25Slukem set (see above). 6221.1Stv 6231.105Swiz iso-image Create a NetBSD installation CD-ROM image in the 6241.105Swiz RELEASEDIR/iso directory. The CD-ROM file system will have 6251.62Sapb a layout as described in release(7). 6261.62Sapb 6271.62Sapb For most machine types, the CD-ROM will be bootable, and 6281.104Swiz will automatically run the sysinst(8) menu-based 6291.104Swiz installation program, which can be used to install or 6301.104Swiz upgrade a NetBSD system. Bootable CD-ROMs also contain 6311.104Swiz tools that may be useful in repairing a damaged NetBSD 6321.104Swiz installation. 6331.62Sapb 6341.62Sapb Before ``make iso-image'' is attempted, RELEASEDIR must be 6351.62Sapb populated by ``make release'' or equivalent. 6361.62Sapb 6371.62Sapb Note that other, smaller, CD-ROM images may be created in 6381.105Swiz the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom 6391.104Swiz directory by ``make release''. These smaller images 6401.104Swiz usually contain the same tools as the larger images in 6411.105Swiz RELEASEDIR/iso, but do not contain additional content such 6421.69Slukem as the distribution sets. 6431.62Sapb 6441.62Sapb Note that the mac68k port still uses an older method of 6451.104Swiz creating CD-ROM images. This requires the mkisofs(1) 6461.104Swiz utility, which is not part of NetBSD, but which can be 6471.105Swiz installed from pkgsrc/sysutils/cdrtools. 6481.56Sapb 6491.105Swiz iso-image-source 6501.64Sjnemeth Create a NetBSD installation CD-ROM image in the 6511.105Swiz RELEASEDIR/iso directory. The CD-ROM file system will have 6521.64Sjnemeth a layout as described in release(7). It will have top 6531.64Sjnemeth level directories for the machine type and source. 6541.64Sjnemeth 6551.64Sjnemeth For most machine types, the CD-ROM will be bootable, and 6561.104Swiz will automatically run the sysinst(8) menu-based 6571.104Swiz installation program, which can be used to install or 6581.104Swiz upgrade a NetBSD system. Bootable CD-ROMs also contain 6591.104Swiz tools that may be useful in repairing a damaged NetBSD 6601.104Swiz installation. 6611.64Sjnemeth 6621.64Sjnemeth Before ``make iso-image-source'' is attempted, RELEASEDIR 6631.104Swiz must be populated by ``make sourcesets release'' or 6641.104Swiz equivalent. 6651.64Sjnemeth 6661.64Sjnemeth Note that other, smaller, CD-ROM images may be created in 6671.105Swiz the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom 6681.104Swiz directory by ``make release''. These smaller images 6691.104Swiz usually contain the same tools as the larger images in 6701.105Swiz RELEASEDIR/iso, but do not contain additional content such 6711.69Slukem as the distribution sets. 6721.64Sjnemeth 6731.64Sjnemeth Note that the mac68k port still uses an older method of 6741.104Swiz creating CD-ROM images. This requires the mkisofs(1) 6751.104Swiz utility, which is not part of NetBSD, but which can be 6761.105Swiz installed from pkgsrc/sysutils/cdrtools. 6771.64Sjnemeth 6781.105Swiz install-image 6791.98Sapb Create a bootable NetBSD installation disk image in the 6801.105Swiz RELEASEDIR/RELEASEMACHINEDIR/installation/installimage 6811.98Sapb directory. The installation disk image is suitable for 6821.98Sapb copying to bootable USB flash memory sticks, etc., for 6831.98Sapb machines which are able to boot from such devices. The 6841.98Sapb file system in the bootable disk image will have a layout 6851.98Sapb as described in release(7). 6861.97Stsutsui 6871.97Stsutsui The installation image is bootable, and will automatically 6881.97Stsutsui run the sysinst(8) menu-based installation program, which 6891.98Sapb can be used to install or upgrade a NetBSD system. The 6901.98Sapb image also contains tools that may be useful in repairing a 6911.98Sapb damaged NetBSD installation. 6921.97Stsutsui 6931.105Swiz Before ``make install-image'' is attempted, RELEASEDIR must 6941.98Sapb be populated by ``make release'' or equivalent. The build 6951.105Swiz must have been performed with MKUNPRIVED=yes because ``make 6961.105Swiz install-image'' relies on information in DESTDIR/METALOG. 6971.97Stsutsui 6981.97Stsutsui live-image Create NetBSD live images in the 6991.105Swiz RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage 7001.104Swiz directory. The live image contains all necessary files to 7011.104Swiz boot NetBSD up to multi-user mode, including all files 7021.104Swiz which should be extracted during installation, NetBSD 7031.104Swiz disklabel, bootloaders, etc. 7041.104Swiz 7051.104Swiz The live image is suitable for use as a disk image in 7061.104Swiz virtual machine environments such as QEMU, and also useful 7071.104Swiz to boot NetBSD from a USB flash memory stick on a real 7081.98Sapb machine, without the need for installation. 7091.97Stsutsui 7101.97Stsutsui Before ``make live-image'' is attempted, RELEASEDIR must be 7111.99Stsutsui populated by ``make release'' or equivalent. The build 7121.105Swiz must have been performed with MKUNPRIVED=yes because ``make 7131.105Swiz install-image'' relies on information in DESTDIR/METALOG. 7141.97Stsutsui 7151.105Swiz regression-tests 7161.20Slukem Can only be run after building the regression tests in the 7171.70Sdholland directory ``regress''. Runs those compiled regression 7181.104Swiz tests on the local host. Note that most tests are now 7191.104Swiz managed instead using atf(7); this target should probably 7201.104Swiz run those as well but currently does not. 7211.1Stv 7221.105Swiz The "build.sh" script 7231.96Sapb This script file is a shell script designed to build the entire NetBSD 7241.104Swiz system on any host with a suitable modern shell and some common 7251.105Swiz utilities. The required shell features are described under the HOST_SH 7261.104Swiz variable. 7271.96Sapb 7281.96Sapb If a host system's default shell does support the required features, then 7291.96Sapb we suggest that you explicitly specify a suitable shell using a command 7301.96Sapb like 7311.96Sapb 7321.105Swiz /path/to/suitable/shell build.sh [options] 7331.96Sapb 7341.105Swiz The above command will usually enable build.sh to automatically set 7351.105Swiz HOST_SH=/path/to/suitable/shell, but if that fails, then the following 7361.96Sapb set of commands may be used instead: 7371.96Sapb 7381.105Swiz HOST_SH=/path/to/suitable/shell 7391.96Sapb export HOST_SH 7401.105Swiz ${HOST_SH} build.sh [options] 7411.96Sapb 7421.105Swiz If build.sh detects that it is being executed under an unsuitable shell, 7431.96Sapb it attempts to exec a suitable shell instead, or prints an error message. 7441.105Swiz If HOST_SH is not set explicitly, then build.sh sets a default using 7451.96Sapb heuristics dependent on the host platform, or from the shell under which 7461.105Swiz build.sh is executed (if that can be determined), or using the first copy 7471.105Swiz of sh found in PATH. 7481.1Stv 7491.1Stv All cross-compile builds, and most native builds, of the entire system 7501.105Swiz should make use of build.sh rather than just running ``make''. This way, 7511.104Swiz the make(1) program will be bootstrapped properly, in case the host 7521.104Swiz system has an older or incompatible ``make'' program. 7531.1Stv 7541.105Swiz When compiling the entire system via build.sh, many make(1) variables are 7551.1Stv set for you in order to help encapsulate the build process. In the list 7561.105Swiz of options below, variables that are automatically set by build.sh are 7571.1Stv noted where applicable. 7581.1Stv 7591.105Swiz The following operations are supported by build.sh: 7601.22Slukem 7611.105Swiz build Build the system as per ``make build''. Before the main 7621.105Swiz part of the build commences, this command runs the obj 7631.105Swiz operation (unless the -o option is given), ``make 7641.105Swiz cleandir'' (unless the -u option is given), and the tools 7651.70Sdholland operation. 7661.22Slukem 7671.105Swiz distribution Build a full distribution as per ``make distribution''. 7681.105Swiz This command first runs the build operation. 7691.22Slukem 7701.105Swiz release Build a full release as per ``make release''. This command 7711.105Swiz first runs the distribution operation. 7721.22Slukem 7731.105Swiz makewrapper Create the nbmake-MACHINE wrapper. This operation is 7741.104Swiz automatically performed for any of the other operations. 7751.23Slukem 7761.105Swiz cleandir Perform ``make cleandir''. 7771.75Slukem 7781.105Swiz obj Perform ``make obj''. 7791.22Slukem 7801.105Swiz tools Build and install the host tools from src/tools. This 7811.104Swiz command will first run ``make obj'' and ``make cleandir'' 7821.105Swiz in the tools subdirectory unless the -o or -u options 7831.104Swiz (respectively) are given. 7841.22Slukem 7851.105Swiz install=idir Install the contents of DESTDIR to idir, using ``make 7861.61Sapb installworld''. Note that files that are part of the 7871.95Sapb ``etc'' or ``xetc'' sets will not be installed, unless 7881.95Sapb overridden by the INSTALLSETS environment variable. 7891.35Slukem 7901.105Swiz kernel=kconf Build a new kernel. The kconf argument is the name of a 7911.105Swiz configuration file suitable for use by config(1). If kconf 7921.22Slukem does not contain any `/' characters, the configuration file 7931.105Swiz is expected to be found in the KERNCONFDIR directory, which 7941.105Swiz is typically sys/arch/MACHINE/conf. The new kernel will be 7951.105Swiz built in a subdirectory of KERNOBJDIR, which is typically 7961.105Swiz sys/arch/MACHINE/compile or an associated object directory. 7971.70Sdholland 7981.105Swiz This command does not imply the tools command; run the 7991.105Swiz tools command first unless it is certain that the tools 8001.70Sdholland already exist and are up to date. 8011.70Sdholland 8021.70Sdholland This command will run ``make cleandir'' on the kernel in 8031.105Swiz question first unless the -u option is given. 8041.22Slukem 8051.106Swiz kernel.gdb=kconf 8061.106Swiz Build a new kernel with debug information. Similar to the 8071.106Swiz above kernel=kconf operation, but creates a netbsd.gdb file 8081.106Swiz alongside of the kernel netbsd, which contains a full 8091.106Swiz symbol table and can be used for debugging (for example 8101.106Swiz with a cross-gdb built by MKCROSSGDB). 8111.106Swiz 8121.105Swiz modules This command will build kernel modules and install them 8131.105Swiz into DESTDIR. 8141.86Sjnemeth 8151.105Swiz releasekernel=kconf 8161.70Sdholland Install a gzip(1)ed copy of the kernel previously built by 8171.105Swiz kernel=kconf into 8181.105Swiz RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as 8191.105Swiz netbsd-kconf.gz, although the ``netbsd'' prefix is 8201.105Swiz determined from the ``config'' directives in kconf. 8211.24Slukem 8221.105Swiz sets Perform ``make sets''. 8231.31Slukem 8241.105Swiz sourcesets Perform ``make sourcesets''. 8251.22Slukem 8261.105Swiz syspkgs Perform ``make syspkgs''. 8271.54Sapb 8281.105Swiz iso-image Perform ``make iso-image''. 8291.56Sapb 8301.105Swiz iso-image-source 8311.65Sjnemeth Perform ``make iso-image-source''. 8321.65Sjnemeth 8331.105Swiz install-image 8341.98Sapb Perform ``make install-image''. 8351.97Stsutsui 8361.105Swiz live-image Perform ``make live-image''. 8371.97Stsutsui 8381.105Swiz The following command line options alter the behaviour of the build.sh 8391.51Swiz operations described above: 8401.1Stv 8411.105Swiz -a arch Set the value of MACHINE_ARCH to arch. 8421.9Sthorpej 8431.105Swiz -B buildid 8441.105Swiz Set the value of BUILDID to buildid. This will also append the 8451.67Ssborrill build identifier to the name of the ``make'' wrapper script so 8461.37Slukem that the resulting name is of the form 8471.105Swiz ``nbmake-MACHINE-BUILDID''. 8481.1Stv 8491.105Swiz -C cdextras 8501.105Swiz Append cdextras to the CDEXTRA variable, which is a space- 8511.104Swiz separated list of files or directories that will be added to 8521.104Swiz the CD-ROM image that may be create by the ``iso-image'' or 8531.87Sapb ``iso-image-source'' operations. Files will be added to the 8541.87Sapb root of the CD-ROM image, whereas directories will be copied 8551.87Sapb recursively. If relative paths are specified, they will be 8561.87Sapb converted to absolute paths before being used. Multiple paths 8571.105Swiz may be specified via multiple -C options, or via a single 8581.87Sapb option whose argument contains multiple space-separated paths. 8591.66Sjnemeth 8601.105Swiz -D dest Set the value of DESTDIR to dest. If a relative path is 8611.104Swiz specified, it will be converted to an absolute path before 8621.104Swiz being used. 8631.104Swiz 8641.105Swiz -E Set `expert' mode. This overrides various sanity checks, and 8651.105Swiz allows: DESTDIR does not have to be set to a non-root path for 8661.105Swiz builds, and MKUNPRIVED=yes does not have to be set when 8671.104Swiz building as a non-root user. 8681.23Slukem 8691.105Swiz Note: It is highly recommended that you know what you are doing 8701.23Slukem when you use this option. 8711.19Slukem 8721.105Swiz -h Print a help message. 8731.51Swiz 8741.105Swiz -j njob Run up to njob make(1) subjobs in parallel; passed through to 8751.74Sapb make(1). If you see failures for reasons other than running 8761.105Swiz out of memory while using build.sh with -j, please save 8771.104Swiz complete build logs so the failures can be analyzed. 8781.74Sapb 8791.105Swiz To achieve the fastest builds, -j values between (1 + the 8801.104Swiz number of CPUs) and (2 * the number of CPUs) are recommended. 8811.104Swiz Use lower values on machines with limited memory or I/O 8821.104Swiz bandwidth. 8831.104Swiz 8841.105Swiz -M obj Set MAKEOBJDIRPREFIX to obj. Unsets MAKEOBJDIR. See ``-O 8851.106Swiz obj'' for more information. 8861.104Swiz 8871.105Swiz For instance, if the source directory is /usr/src, a setting of 8881.105Swiz ``-M /usr/obj'' will place build-time files under 8891.105Swiz /usr/obj/usr/src/bin, /usr/obj/usr/src/lib, 8901.105Swiz /usr/obj/usr/src/usr.bin, and so forth. 8911.88Sapb 8921.73Sapb If a relative path is specified, it will be converted to an 8931.105Swiz absolute path before being used. build.sh imposes the 8941.105Swiz restriction that the argument to the -M option must not begin 8951.104Swiz with a ``$'' (dollar sign) character; otherwise it would be too 8961.104Swiz difficult to determine whether the value is an absolute or a 8971.104Swiz relative path. If the directory does not already exist, 8981.105Swiz build.sh will create it. 8991.18Slukem 9001.105Swiz -m mach Set the value of MACHINE to mach, except in some special cases 9011.60Sapb listed below. This will also override any value of 9021.105Swiz MACHINE_ARCH in the process environment with a value deduced 9031.105Swiz from mach, unless -a is specified. All cross builds require 9041.105Swiz -m, but if unset on a NetBSD host, the host's value of MACHINE 9051.60Sapb will be detected and used automatically. 9061.60Sapb 9071.105Swiz Some machines support multiple values for MACHINE_ARCH. The 9081.105Swiz following special cases for the mach argument are defined to 9091.105Swiz set the listed values of MACHINE and MACHINE_ARCH: 9101.33Slukem 9111.105Swiz mach MACHINE MACHINE_ARCH 9121.60Sapb evbarm evbarm (not set) 9131.60Sapb evbarm-eb evbarm armeb 9141.60Sapb evbarm-el evbarm arm 9151.33Slukem evbmips evbmips (not set) 9161.33Slukem evbmips-eb evbmips mipseb 9171.33Slukem evbmips-el evbmips mipsel 9181.33Slukem evbsh3 evbsh3 (not set) 9191.33Slukem evbsh3-eb evbsh3 sh3eb 9201.33Slukem evbsh3-el evbsh3 sh3el 9211.33Slukem sbmips sbmips (not set) 9221.33Slukem sbmips-eb sbmips mipseb 9231.33Slukem sbmips-el sbmips mipsel 9241.1Stv 9251.105Swiz -N noiselevel 9261.46Slukem Set the ``noisyness'' level of the build, by setting 9271.105Swiz MAKEVERBOSE to noiselevel. 9281.45Slukem 9291.105Swiz -n Show the commands that would be executed by build.sh, but do 9301.1Stv not make any changes. This is similar in concept to ``make 9311.1Stv -n''. 9321.1Stv 9331.105Swiz -O obj Create an appropriate transform macro for MAKEOBJDIR that will 9341.105Swiz place the built object files under obj. Unsets 9351.105Swiz MAKEOBJDIRPREFIX. 9361.88Sapb 9371.105Swiz For instance, a setting of ``-O /usr/obj'' will place build- 9381.105Swiz time files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, 9391.88Sapb and so forth. 9401.88Sapb 9411.88Sapb If a relative path is specified, it will be converted to an 9421.105Swiz absolute path before being used. build.sh imposes the 9431.105Swiz restriction that the argument to the -O option must not contain 9441.104Swiz a ``$'' (dollar sign) character. If the directory does not 9451.105Swiz already exist, build.sh will create it. 9461.73Sapb 9471.105Swiz In normal use, exactly one of the -M or -O options should be 9481.105Swiz specified. If neither -M nor -O is specified, then a default 9491.78Sapb object directory will be chosen according to rules in 9501.78Sapb <bsd.obj.mk>. Relying on this default is not recommended 9511.78Sapb because it is determined by complex rules that are influenced 9521.78Sapb by the values of several variables and by the location of the 9531.78Sapb source directory. 9541.18Slukem 9551.105Swiz -o Set the value of MKOBJDIRS to ``no''. Otherwise, it will be 9561.70Sdholland automatically set to ``yes''. This default is opposite to the 9571.105Swiz behaviour when not using build.sh. 9581.1Stv 9591.105Swiz -R rel Set the value of RELEASEDIR to rel. If a relative path is 9601.59Sapb specified, it will be converted to an absolute path before 9611.59Sapb being used. 9621.18Slukem 9631.105Swiz -r Remove the contents of DESTDIR and TOOLDIR before building 9641.1Stv (provides a clean starting point). This will skip deleting 9651.105Swiz DESTDIR if building on a native system to the root directory. 9661.1Stv 9671.105Swiz -S seed Change the value of BUILDSEED to seed. This should rarely be 9681.72Sperry necessary. 9691.72Sperry 9701.105Swiz -T tools Set the value of TOOLDIR to tools. If a relative path is 9711.104Swiz specified, it will be converted to an absolute path before 9721.104Swiz being used. If set, the bootstrap ``make'' will only be 9731.104Swiz rebuilt if the source files for make(1) have changed. 9741.104Swiz 9751.105Swiz -U Set MKUNPRIVED=yes. 9761.104Swiz 9771.105Swiz -u Set MKUPDATE=yes. 9781.104Swiz 9791.105Swiz -V var=[value] 9801.105Swiz Set the environment variable var to an optional value. This is 9811.105Swiz propagated to the nbmake wrapper. 9821.105Swiz 9831.105Swiz -w wrapper 9841.105Swiz Create the nbmake wrapper script (see below) in a custom 9851.105Swiz location, specified by wrapper. This allows, for instance, to 9861.105Swiz place the wrapper in PATH automatically. Note that wrapper is 9871.59Sapb the full name of the file, not just a directory name. If a 9881.59Sapb relative path is specified, it will be converted to an absolute 9891.59Sapb path before being used. 9901.1Stv 9911.105Swiz -X x11src 9921.105Swiz Set the value of X11SRCDIR to x11src. If a relative path is 9931.59Sapb specified, it will be converted to an absolute path before 9941.59Sapb being used. 9951.49Slukem 9961.105Swiz -x Set MKX11=yes. 9971.49Slukem 9981.105Swiz -Z var Unset ("zap") the environment variable var. This is propagated 9991.105Swiz to the nbmake wrapper. 10001.40Slukem 10011.105Swiz The "nbmake-MACHINE" wrapper script 10021.105Swiz If using the build.sh script to build NetBSD, a nbmake-MACHINE script 10031.105Swiz will be created in TOOLDIR/bin upon the first build to assist in building 10041.1Stv subtrees on a cross-compile host. 10051.1Stv 10061.105Swiz nbmake-MACHINE can be invoked in lieu of make(1), and will instead call 10071.105Swiz the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with 10081.105Swiz several key variables pre-set, including MACHINE, MACHINE_ARCH, and 10091.105Swiz TOOLDIR. nbmake-MACHINE will also set variables specified with -V, and 10101.105Swiz unset variables specified with -Z. 10111.40Slukem 10121.105Swiz This script can be symlinked into a directory listed in PATH, or called 10131.1Stv with an absolute path. 10141.1Stv 10151.105SwizEXAMPLES 10161.78Sapb 1. % ./build.sh [options] tools kernel=GENERIC 10171.28Slukem 10181.28Slukem Build a new toolchain, and use the new toolchain to configure and 10191.28Slukem build a new GENERIC kernel. 10201.28Slukem 10211.78Sapb 2. % ./build.sh [options] -U distribution 10221.28Slukem 10231.105Swiz Using unprivileged mode, build a complete distribution to a DESTDIR 10241.105Swiz directory that build.sh selects (and will display). 10251.28Slukem 10261.78Sapb 3. # ./build.sh [options] -U install=/ 10271.28Slukem 10281.105Swiz As root, install to / the distribution that was built by example 2. 10291.105Swiz Even though this is run as root, -U is required so that the 10301.105Swiz permissions stored in DESTDIR/METALOG are correctly applied to the 10311.105Swiz files as they're copied to /. 10321.28Slukem 10331.78Sapb 4. % ./build.sh [options] -U -u release 10341.28Slukem 10351.105Swiz Using unprivileged mode, build a complete release to DESTDIR and 10361.105Swiz RELEASEDIR directories that build.sh selects (and will display). 10371.105Swiz MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that 10381.38Slukem if this is run after example 2, it doesn't need to redo that portion 10391.38Slukem of the release build. 10401.16Slukem 10411.105SwizOBSOLETE VARIABLES 10421.105Swiz NBUILDJOBS Use the make(1) option -j instead. 10431.15Slukem 10441.105Swiz USE_NEW_TOOLCHAIN 10451.15Slukem The new toolchain is now the default. To disable, use 10461.105Swiz TOOLCHAIN_MISSING=yes. 10471.10Ssommerfe 10481.105SwizSEE ALSO 10491.62Sapb make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8), 10501.105Swiz pkgsrc/sysutils/cdrtools 10511.1Stv 10521.105SwizHISTORY 10531.105Swiz The build.sh based build scheme was introduced for NetBSD 1.6 as 10541.105Swiz USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that. 10551.1Stv 10561.107SapbNetBSD June 14, 2014 NetBSD 1057