BUILDING revision 1.154
11.104SwizBUILDING(8) System Manager's Manual BUILDING(8) 21.1Stv 31.105SwizNAME 41.150Slukem 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.126Swiz This source tree contains a special subtree, "tools", which uses the host 131.126Swiz system to create a build toolchain for the target architecture. The host 141.126Swiz 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.147Slukem 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.151Slukem BUILDING This document (in plaintext). Generated from 221.151Slukem doc/BUILDING.mdoc. 231.48Sjmc 241.105Swiz Makefile The main Makefile for NetBSD; should only be run for 251.44Slukem native builds with an appropriately up-to-date version of 261.142Sandvar NetBSD make(1). Intended for expert use with knowledge of 271.129Ssevan its shortcomings, it has been superseded by the build.sh 281.129Ssevan shell script as the recommended means for building NetBSD. 291.1Stv 301.105Swiz UPDATING Special notes for updating from an earlier revision of 311.1Stv NetBSD. It is important to read this file before every 321.1Stv build of an updated source tree. 331.1Stv 341.105Swiz build.sh Bourne-compatible shell script used for building the host 351.1Stv build tools and the NetBSD system from scratch. Can be 361.1Stv used for both native and cross builds, and should be used 371.129Ssevan instead of make(1) as it performs additional checks to 381.129Ssevan prevent common issues going undetected, such as building 391.129Ssevan with an outdated version of make(1). 401.1Stv 411.105Swiz crypto/dist/, dist/, gnu/dist/ 421.104Swiz Sources imported verbatim from third parties, without 431.104Swiz mangling the existing build structure. Other source trees 441.126Swiz in bin through usr.sbin use the NetBSD make(1) "reachover" 451.126Swiz Makefile semantics when building these programs for a 461.126Swiz native host. 471.104Swiz 481.151Slukem distrib/, etc/ 491.151Slukem Sources for items used when making a full release 501.151Slukem snapshot, such as files installed in DESTDIR/etc on the 511.151Slukem destination system, boot media, and release notes. 521.151Slukem 531.151Slukem doc/BUILDING.mdoc 541.151Slukem This document, in -mdoc troff format; the original copy. 551.151Slukem Used to generate BUILDING. 561.151Slukem 571.106Swiz external, sys/external 581.106Swiz Sources and build infrastructure for components imported 591.106Swiz (mostly) unchanged from upstream maintainers, sorted by 601.106Swiz applicable license. This is (slowly) replacing the 611.106Swiz crypto/dist, dist, and gnu/dist directories. 621.106Swiz 631.151Slukem external/mit/xorg/ 641.151Slukem "Reachover" build structure for modular Xorg; the source 651.151Slukem is in X11SRCDIR. 661.1Stv 671.151Slukem regress/, tests/ 681.70Sdholland Regression test harness. Can be cross-compiled, but only 691.105Swiz run natively. tests/ uses the atf(7) test framework; 701.105Swiz regress/ contains older tests that have not yet been 711.70Sdholland migrated to atf(7). 721.1Stv 731.105Swiz sys/ NetBSD kernel sources. 741.1Stv 751.126Swiz tools/ "Reachover" build structure for the host build tools. 761.104Swiz This has a special method of determining out-of-date 771.104Swiz status. 781.1Stv 791.151Slukem tools/compat/README 801.151Slukem Special notes for cross-hosting a NetBSD build on non- 811.151Slukem NetBSD platforms. 821.151Slukem 831.151Slukem Other directories including bin/ ... usr.sbin/ 841.1Stv Sources to the NetBSD userland (non-kernel) programs. If 851.1Stv any of these directories are missing, they will be skipped 861.1Stv during the build. 871.1Stv 881.105Swiz Build tree layout 891.1Stv The NetBSD build tree is described in hier(7), and the release layout is 901.1Stv described in release(7). 911.1Stv 921.105SwizCONFIGURATION 931.105Swiz Environment variables 941.8Slukem Several environment variables control the behaviour of NetBSD builds. 951.8Slukem 961.152Slukem HOST_CC Path name to C compiler used to create the toolchain. 971.58Sapb 981.152Slukem HOST_CFLAGS Flags passed to the host C compiler. 991.53Sreed 1001.152Slukem HOST_CXX Path name to C++ compiler used to create the toolchain. 1011.137Suwe 1021.152Slukem HOST_CXXFLAGS Flags passed to the host C++ compiler. 1031.53Sreed 1041.152Slukem HOST_SH Path name to a shell available on the host system and 1051.152Slukem suitable for use during the build. The NetBSD build 1061.152Slukem system requires a modern Bourne-like shell with POSIX- 1071.152Slukem compliant features, and also requires support for the 1081.152Slukem "local" keyword to declare local variables in shell 1091.152Slukem functions (which is a widely-implemented but non- 1101.152Slukem standardised feature). 1111.152Slukem 1121.152Slukem Depending on the host system, a suitable shell may be 1131.152Slukem /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a 1141.152Slukem variant of ksh that supports the "local" keyword, such as 1151.152Slukem ksh88, but not ksh93), or /usr/local/bin/bash. 1161.152Slukem 1171.152Slukem Most parts of the build require HOST_SH to be an absolute 1181.152Slukem path; however, build.sh allows it to be a simple command 1191.152Slukem name, which will be converted to an absolute path by 1201.152Slukem searching the PATH. 1211.137Suwe 1221.147Slukem INSTALLBOOT_UBOOT_PATHS 1231.152Slukem A colon-separated list of search paths used by 1241.152Slukem installboot(8) to find U-Boot packages. 1251.147Slukem 1261.152Slukem MACHINE Machine type, e.g., "macppc". 1271.8Slukem 1281.152Slukem MACHINE_ARCH Machine architecture, e.g., "powerpc". 1291.8Slukem 1301.152Slukem MAKE Path name to invoke make(1) as. 1311.8Slukem 1321.152Slukem MAKECONF The name of the make(1) configuration file. See "make" 1331.152Slukem variables and mk.conf(5). 1341.151Slukem 1351.152Slukem Note: Only settable in the process environment. 1361.151Slukem 1371.152Slukem Default: "/etc/mk.conf" 1381.151Slukem 1391.152Slukem MAKEFLAGS Flags to invoke make(1) with. 1401.151Slukem 1411.152Slukem Note: build.sh ignores the value of MAKEFLAGS passed in 1421.152Slukem the environment, but allows MAKEFLAGS to be set via the 1431.152Slukem -V option. 1441.151Slukem 1451.152Slukem MAKEOBJDIR Directory to use as the .OBJDIR for the current 1461.152Slukem directory. The value is subjected to variable expansion 1471.152Slukem by make(1). Typical usage is to set this variable to a 1481.152Slukem value involving the use of `${.CURDIR:S...}' or 1491.152Slukem `${.CURDIR:C...}', to derive the value of .OBJDIR from 1501.152Slukem the value of .CURDIR. Used only if MAKEOBJDIRPREFIX is 1511.152Slukem not defined. 1521.151Slukem 1531.152Slukem Note: MAKEOBJDIR can be provided only in the environment 1541.152Slukem or via the -O flag of build.sh; it cannot usefully be set 1551.152Slukem inside a Makefile, including in mk.conf(5) or MAKECONF. 1561.151Slukem 1571.151Slukem MAKEOBJDIRPREFIX 1581.152Slukem Top level directory of the object directory tree. The 1591.152Slukem value is subjected to variable expansion by make(1). 1601.152Slukem build.sh will create the ${MAKEOBJDIRPREFIX} directory if 1611.152Slukem necessary, but if make(1) is used without build.sh, then 1621.152Slukem rules in <bsd.obj.mk> will abort the build if the 1631.152Slukem ${MAKEOBJDIRPREFIX} directory does not exist. If the 1641.152Slukem value is defined and valid, then 1651.152Slukem ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR for 1661.152Slukem the current directory. The current directory may be read 1671.152Slukem only. 1681.152Slukem 1691.152Slukem Note: MAKEOBJDIRPREFIX can be provided only in the 1701.152Slukem environment or via the -M flag of build.sh; it cannot 1711.152Slukem usefully be set inside a Makefile, including in 1721.152Slukem mk.conf(5) or MAKECONF. 1731.152Slukem 1741.152Slukem TMPDIR Top-level directory to store temporary directories used 1751.152Slukem by build.sh before paths to other directories such as 1761.152Slukem .OBJDIR can be determined. 1771.149Slukem 1781.152Slukem Note: Must support execution of binaries. I.e., without 1791.152Slukem mount(8)'s -o noexec option. 1801.149Slukem 1811.152Slukem Default: "/tmp". 1821.149Slukem 1831.105Swiz "make" variables 1841.104Swiz Several variables control the behavior of NetBSD builds. Unless 1851.104Swiz otherwise specified, these variables may be set in either the process 1861.150Slukem environment or the make(1) configuration file mk.conf(5) specified by 1871.151Slukem MAKECONF. 1881.151Slukem 1891.151Slukem This list is not comprehensive; all supported variables and their 1901.151Slukem defaults are documented in mk.conf(5). 1911.151Slukem 1921.152Slukem BSDOBJDIR The real path to the object directory tree for the NetBSD 1931.152Slukem source tree. 1941.151Slukem 1951.152Slukem Default: "/usr/obj" 1961.151Slukem 1971.152Slukem BSDSRCDIR The real path to the NetBSD source tree, if NETBSDSRCDIR 1981.152Slukem isn't defined. 1991.151Slukem 2001.152Slukem Default: "/usr/src" 2011.152Slukem 2021.152Slukem BUILDID Identifier for the build. If set, this should be a short 2031.152Slukem string that is suitable for use as part of a file or 2041.152Slukem directory name. The identifier will be appended to 2051.152Slukem object directory names, and can be consulted in the 2061.152Slukem make(1) configuration file in order to set additional 2071.152Slukem build parameters, such as compiler flags. It will also 2081.152Slukem be used as part of the kernel version string, which can 2091.152Slukem be shown by "uname -v". 2101.152Slukem 2111.152Slukem Default: Unset. 2121.152Slukem 2131.152Slukem BUILDINFO Optional multi-line string containing information about 2141.152Slukem the build. This will appear in DESTDIR/etc/release, and 2151.152Slukem it will be stored in the buildinfo variable in any 2161.152Slukem kernels that are built. When such kernels are booted, 2171.152Slukem the sysctl(7) kern.buildinfo variable will report this 2181.152Slukem value. The string may contain backslash escape 2191.152Slukem sequences, such as "\\" (representing a backslash 2201.152Slukem character) and "\n" (representing a newline). 2211.152Slukem 2221.152Slukem Default: Unset. 2231.152Slukem 2241.152Slukem BUILDSEED g++(1) uses random numbers when compiling C++ code. This 2251.152Slukem variable seeds the g++(1) random number generator using 2261.152Slukem -frandom-seed with this value. By default, it is set to 2271.152Slukem "NetBSD-(majorversion)". Using a fixed value causes C++ 2281.152Slukem binaries to be the same when built from the same sources, 2291.152Slukem resulting in identical (reproducible) builds. Additional 2301.152Slukem information is available in the g++(1) documentation of 2311.152Slukem -frandom-seed. 2321.152Slukem 2331.152Slukem Default: Unset. 2341.152Slukem 2351.154Slukem COPTS Extra options for the C compiler. Should be appended to 2361.154Slukem (e.g., COPTS+=-g), rather than explicitly set. 2371.154Slukem 2381.154Slukem Note: CPUFLAGS, not COPTS, should be used for compiler 2391.154Slukem flags that select CPU-related options. 2401.154Slukem 2411.154Slukem Note: CFLAGS should never be set in mk.conf(5). 2421.154Slukem 2431.154Slukem CPUFLAGS Additional options passed to the compiler/assembler to 2441.154Slukem select CPU instruction set options, CPU tuning options, 2451.154Slukem etc. 2461.154Slukem 2471.154Slukem Note: Such options should not be specified in COPTS, 2481.154Slukem because some parts of the build process need to override 2491.154Slukem CPU-related compiler options. 2501.152Slukem 2511.152Slukem Default: Unset. 2521.152Slukem 2531.152Slukem DESTDIR Directory to contain the built NetBSD system. If set, 2541.152Slukem special options are passed to the compilation tools to 2551.152Slukem prevent their default use of the host system's 2561.152Slukem /usr/include, /usr/lib, and so forth. This pathname must 2571.152Slukem be an absolute path, and should not end with a slash (/) 2581.152Slukem character. (For installation into the system's root 2591.152Slukem directory, set DESTDIR to an empty string, not to "/"). 2601.152Slukem The directory must reside on a file system which supports 2611.152Slukem long file names and hard links. 2621.151Slukem 2631.154Slukem Note: build.sh will provide a default of 2641.154Slukem "destdir.MACHINE" (in the top-level .OBJDIR) unless run 2651.154Slukem in `expert' mode. 2661.151Slukem 2671.154Slukem Default: Empty string if USETOOLS=yes; unset otherwise. 2681.151Slukem 2691.151Slukem EXTERNAL_TOOLCHAIN 2701.152Slukem If defined, this variable indicates the root directory of 2711.152Slukem an external toolchain which will be used to build the 2721.152Slukem tree. For example, if a platform is a TOOLCHAIN_MISSING 2731.152Slukem platform, EXTERNAL_TOOLCHAIN can be used to re-enable the 2741.152Slukem cross-compile framework. 2751.151Slukem 2761.152Slukem If EXTERNAL_TOOLCHAIN is defined, act as MKGCC=no, since 2771.152Slukem the external version of the compiler may not be able to 2781.152Slukem build the library components of the in-tree compiler. 2791.151Slukem 2801.152Slukem This variable should be used in conjunction with an 2811.152Slukem appropriate HAVE_GCC or HAVE_LLVM setting to control the 2821.152Slukem compiler flags. 2831.151Slukem 2841.152Slukem Note: This variable is not yet used in as many places as 2851.152Slukem it should be. Expect the exact semantics of this 2861.152Slukem variable to change in the short term as parts of the 2871.152Slukem cross-compile framework continue to be cleaned up. 2881.151Slukem 2891.152Slukem Default: Unset. 2901.151Slukem 2911.154Slukem INSTALLBOOT_BOARDS 2921.154Slukem A list of evbarm boards to create bootable images for. 2931.154Slukem If corresponding U-Boot packages are installed, bootable 2941.154Slukem images are created as part of a release. See the 2951.154Slukem -o board=name option of installboot(8). 2961.154Slukem 2971.154Slukem INSTALLWORLDDIR 2981.154Slukem Location for the top-level "make installworld" target to 2991.154Slukem install to. If specified, must be an absolute path. 3001.154Slukem 3011.154Slukem Default: "/" 3021.154Slukem 3031.152Slukem MAKEVERBOSE Level of verbosity of status messages. Supported values: 3041.151Slukem 3051.152Slukem 0 No descriptive messages or commands executed by 3061.152Slukem make(1) are shown. 3071.151Slukem 3081.152Slukem 1 Brief messages are shown describing what is being 3091.152Slukem done, but the actual commands executed by make(1) are 3101.152Slukem not shown. 3111.151Slukem 3121.152Slukem 2 Descriptive messages are shown as above (prefixed 3131.152Slukem with a `#'), and ordinary commands performed by 3141.152Slukem make(1) are shown. 3151.151Slukem 3161.152Slukem 3 In addition to the above, all commands performed by 3171.152Slukem make(1) are shown, even if they would ordinarily have 3181.152Slukem been hidden through use of the "@" prefix in the 3191.152Slukem relevant makefile. 3201.151Slukem 3211.152Slukem 4 In addition to the above, commands executed by 3221.152Slukem make(1) are traced through use of the sh(1) "-x" 3231.152Slukem flag. 3241.151Slukem 3251.152Slukem Default: 2 3261.151Slukem 3271.152Slukem MKCATPAGES Can be set to "yes" or "no". Indicates whether 3281.152Slukem preformatted plaintext manual pages will be created and 3291.152Slukem installed. 3301.151Slukem 3311.152Slukem Forced to "no" if MKMAN=no or MKSHARE=no. 3321.151Slukem 3331.152Slukem Default: "no" 3341.151Slukem 3351.152Slukem MKCROSSGDB Can be set to "yes" or "no". Create a cross-gdb as a 3361.152Slukem host tool. 3371.1Stv 3381.152Slukem Default: "no" 3391.151Slukem 3401.152Slukem MKDEBUG Can be set to "yes" or "no". Indicates whether debug 3411.152Slukem information should be generated for all userland 3421.152Slukem binaries. The result is collected as an additional 3431.152Slukem debug.tgz and xdebug.tgz set and installed in 3441.152Slukem DESTDIR/usr/libdata/debug. 3451.151Slukem 3461.152Slukem Forced to "no" if NODEBUG is defined, usually in the 3471.152Slukem Makefile before any make(1) .include directives. 3481.151Slukem 3491.152Slukem Default: "no" 3501.151Slukem 3511.152Slukem MKDEBUGKERNEL Can be set to "yes" or "no". Indicates whether debugging 3521.152Slukem symbols will be built for kernels by default; pretend as 3531.152Slukem if makeoptions DEBUG="-g" is specified in kernel 3541.152Slukem configuration files. This will also put the debug kernel 3551.152Slukem netbsd.gdb in the kernel sets. See options(4) for 3561.152Slukem details. This is useful if a cross-gdb is built as well 3571.152Slukem (see MKCROSSGDB). 3581.151Slukem 3591.152Slukem Default: "no" 3601.151Slukem 3611.152Slukem MKDEBUGLIB Can be set to "yes" or "no". Indicates whether debug 3621.152Slukem libraries (lib*_g.a) will be built and installed. Debug 3631.152Slukem libraries are compiled with "-g -DDEBUG". 3641.151Slukem 3651.152Slukem Forced to "no" if NODEBUGLIB is defined, usually in the 3661.152Slukem Makefile before any make(1) .include directives. 3671.151Slukem 3681.152Slukem Default: "no" 3691.151Slukem 3701.152Slukem MKDEBUGTOOLS Can be set to "yes" or "no". Indicates whether debug 3711.152Slukem information (lib*_g.a) will be included in the build 3721.152Slukem toolchain. 3731.151Slukem 3741.152Slukem Default: "no" 3751.107Sapb 3761.152Slukem MKDOC Can be set to "yes" or "no". Indicates whether system 3771.152Slukem documentation destined for DESTDIR/usr/share/doc will be 3781.152Slukem installed. 3791.151Slukem 3801.152Slukem Forced to "no" if NODOC is defined, usually in the 3811.152Slukem Makefile before any make(1) .include directives. 3821.151Slukem 3831.152Slukem Forced to "no" if MKSHARE=no. 3841.151Slukem 3851.152Slukem Default: "yes" 3861.151Slukem 3871.154Slukem MKHOSTOBJ Can be set to "yes" or "no". If "yes", then for programs 3881.154Slukem intended to be run on the compile host, the name, 3891.154Slukem release, and architecture of the host operating system 3901.154Slukem will be suffixed to the name of the object directory 3911.154Slukem created by "make obj". (This allows multiple host 3921.154Slukem systems to compile NetBSD for a single target 3931.154Slukem architecture.) If "no", then programs built to be run on 3941.154Slukem the compile host will use the same object directory names 3951.154Slukem as programs built to be run on the target architecture. 3961.9Sthorpej 3971.152Slukem Default: "no" 3981.108Sapb 3991.152Slukem MKHTML Can be set to "yes" or "no". Indicates whether the HTML 4001.154Slukem manual pages are created and installed. 4011.108Sapb 4021.152Slukem Forced to "no" if NOHTML is defined, usually in the 4031.152Slukem Makefile before any make(1) .include directives. 4041.104Swiz 4051.152Slukem Forced to "no" if MKMAN=no or MKSHARE=no. 4061.138Sthorpej 4071.152Slukem Default: "yes" 4081.138Sthorpej 4091.152Slukem MKINFO Can be set to "yes" or "no". Indicates whether GNU Info 4101.152Slukem files, used for the documentation for most of the 4111.152Slukem compilation tools, will be built and installed. 4121.1Stv 4131.152Slukem Forced to "no" if NOINFO is defined, usually in the 4141.152Slukem Makefile before any make(1) .include directives. 4151.1Stv 4161.152Slukem Forced to "no" if MKSHARE=no. 4171.30Slukem 4181.152Slukem Default: "yes" 4191.45Slukem 4201.152Slukem MKKMOD Can be set to "yes" or "no". Indicates whether kernel 4211.154Slukem modules will be built and installed. 4221.80Sapb 4231.152Slukem Default: "no" on or1k; "yes" on other platforms. 4241.80Sapb 4251.152Slukem MKLINKLIB Can be set to "yes" or "no". Indicates whether all of 4261.152Slukem the shared library infrastructure will be built and 4271.154Slukem installed. 4281.154Slukem 4291.154Slukem If "no", prevents: 4301.154Slukem - installation of the *.a libraries 4311.154Slukem - installation of the *_pic.a libraries on PIC systems 4321.154Slukem - building of *.a libraries on PIC systems 4331.154Slukem - installation of .so symlinks on ELF systems 4341.154Slukem 4351.154Slukem I.e, only install the shared library (and the .so.major 4361.154Slukem symlink on ELF). 4371.45Slukem 4381.152Slukem Forced to "no" if NOLINKLIB is defined, usually in the 4391.152Slukem Makefile before any make(1) .include directives. 4401.45Slukem 4411.152Slukem If "no", acts as MKLINT=no MKPICINSTALL=no MKPROFILE=no. 4421.45Slukem 4431.152Slukem Default: "yes" 4441.140Skamil 4451.152Slukem MKLINT Can be set to "yes" or "no". Indicates whether lint(1) 4461.152Slukem will be run against portions of the NetBSD source code 4471.152Slukem during the build, and whether lint libraries will be 4481.152Slukem installed into DESTDIR/usr/libdata/lint. 4491.140Skamil 4501.152Slukem Forced to "no" if NOLINT is defined, usually in the 4511.152Slukem Makefile before any make(1) .include directives. 4521.106Swiz 4531.152Slukem Forced to "no" if MKLINKLIB=no. 4541.106Swiz 4551.152Slukem Default: "no" 4561.106Swiz 4571.152Slukem MKMAN Can be set to "yes" or "no". Indicates whether manual 4581.152Slukem pages will be installed. 4591.106Swiz 4601.152Slukem Forced to "no" if NOMAN is defined, usually in the 4611.152Slukem Makefile before any make(1) .include directives. 4621.106Swiz 4631.152Slukem Forced to "no" if MKSHARE=no. 4641.106Swiz 4651.152Slukem If "no", acts as MKCATPAGES=no MKHTML=no. 4661.1Stv 4671.152Slukem Default: "yes" 4681.1Stv 4691.152Slukem MKNLS Can be set to "yes" or "no". Indicates whether Native 4701.152Slukem Language System (NLS) locale zone files will be built and 4711.152Slukem installed. 4721.77Slukem 4731.152Slukem Forced to "no" if NONLS is defined, usually in the 4741.152Slukem Makefile before any make(1) .include directives. 4751.77Slukem 4761.152Slukem Forced to "no" if MKSHARE=no. 4771.4Stv 4781.152Slukem Default: "yes" 4791.4Stv 4801.152Slukem MKOBJ Can be set to "yes" or "no". Indicates whether object 4811.152Slukem directories will be created when running "make obj". If 4821.154Slukem "no", then all built files will be located inside the 4831.154Slukem regular source tree. 4841.1Stv 4851.152Slukem Forced to "no" if NOOBJ is defined, usually in the 4861.152Slukem Makefile before any make(1) .include directives. 4871.1Stv 4881.152Slukem If "no", acts as MKOBJDIRS=no. 4891.143Slukem 4901.152Slukem Note: Setting MKOBJ to "no" is not recommended and may 4911.152Slukem cause problems when updating the tree with cvs(1). 4921.143Slukem 4931.152Slukem Default: "yes" 4941.95Sapb 4951.152Slukem MKOBJDIRS Can be set to "yes" or "no". Indicates whether object 4961.152Slukem directories will be created automatically (via a "make 4971.152Slukem obj" pass) at the start of a build. 4981.95Sapb 4991.152Slukem Forced to "no" if MKOBJ=no. 5001.1Stv 5011.154Slukem Note: If using build.sh, the default is "yes". This may 5021.154Slukem be set back to "no" by giving build.sh the -o option. 5031.154Slukem 5041.152Slukem Default: "no" 5051.1Stv 5061.152Slukem MKPIC Can be set to "yes" or "no". Indicates whether shared 5071.152Slukem objects and libraries will be created and installed. If 5081.152Slukem "no", the entire built system will be statically linked. 5091.1Stv 5101.152Slukem Forced to "no" if NOPIC is defined, usually in the 5111.152Slukem Makefile before any make(1) .include directives. 5121.1Stv 5131.152Slukem If "no", acts as MKPICLIB=no. 5141.1Stv 5151.152Slukem Default: "no" on m68000; "yes" on other platforms. 5161.1Stv 5171.152Slukem MKPICINSTALL Can be set to "yes" or "no". Indicates whether the ar(1) 5181.152Slukem format libraries (lib*_pic.a), used to generate shared 5191.152Slukem libraries, are installed. 5201.1Stv 5211.152Slukem Forced to "no" if NOPICINSTALL is defined, usually in the 5221.152Slukem Makefile before any make(1) .include directives. 5231.1Stv 5241.152Slukem Forced to "no" if MKLINKLIB=no. 5251.70Sdholland 5261.152Slukem Default: "no" 5271.1Stv 5281.152Slukem MKPROFILE Can be set to "yes" or "no". Indicates whether profiled 5291.152Slukem libraries (lib*_p.a) will be built and installed. 5301.1Stv 5311.152Slukem Forced to "no" if NOPROFILE is defined, usually in the 5321.152Slukem Makefile before any make(1) .include directives. 5331.1Stv 5341.152Slukem Forced to "no" if MKLINKLIB=no. 5351.1Stv 5361.152Slukem Default: "no" on or1k, riscv32, and riscv64 (due to 5371.152Slukem toolchain problems with profiled code); "yes" on other 5381.152Slukem platforms. 5391.1Stv 5401.152Slukem MKREPRO Can be set to "yes" or "no". Indicates whether builds 5411.152Slukem are to be reproducible. If "yes", two builds from the 5421.152Slukem same source tree will produce the same build results. 5431.1Stv 5441.152Slukem Used as the default for MKARZERO. 5451.100Swiz 5461.154Slukem Note: This may be set to "yes" by giving build.sh the -P 5471.152Slukem option. 5481.151Slukem 5491.154Slukem Default: "no" 5501.100Swiz 5511.122Swiz MKREPRO_TIMESTAMP 5521.152Slukem Unix timestamp. When MKREPRO is set, the timestamp of 5531.152Slukem all files in the sets will be set to this value. 5541.151Slukem 5551.154Slukem Note: This may be set automatically to the latest source 5561.154Slukem tree timestamp using cvslatest(1) by giving build.sh the 5571.154Slukem -P option. 5581.151Slukem 5591.152Slukem Default: Unset. 5601.151Slukem 5611.152Slukem MKSHARE Can be set to "yes" or "no". Indicates whether files 5621.152Slukem destined to reside in DESTDIR/usr/share will be built and 5631.152Slukem installed. 5641.151Slukem 5651.152Slukem Forced to "no" if NOSHARE is defined, usually in the 5661.152Slukem Makefile before any make(1) .include directives. 5671.122Swiz 5681.152Slukem If "no", acts as MKCATPAGES=no MKDOC=no MKINFO=no 5691.152Slukem MKHTML=no MKMAN=no MKNLS=no. 5701.49Slukem 5711.152Slukem Default: "yes" 5721.151Slukem 5731.152Slukem MKSTRIPIDENT Can be set to "yes" or "no". Indicates whether RCS IDs, 5741.152Slukem for use with ident(1), should be stripped from program 5751.152Slukem binaries and shared libraries. 5761.151Slukem 5771.152Slukem Default: "no" 5781.151Slukem 5791.152Slukem MKSTRIPSYM Can be set to "yes" or "no". Indicates whether all local 5801.152Slukem symbols should be stripped from shared libraries. If 5811.152Slukem "yes", strip all local symbols from shared libraries; the 5821.154Slukem effect is equivalent to the -x option of ld(1). If "no", 5831.154Slukem strip only temporary local symbols; the effect is 5841.152Slukem equivalent to the -X option of ld(1). Keeping non- 5851.152Slukem temporary local symbols such as static function names is 5861.152Slukem useful on using DTrace for userland libraries and getting 5871.152Slukem a backtrace from a rump kernel loading shared libraries. 5881.151Slukem 5891.152Slukem Default: "yes" 5901.151Slukem 5911.152Slukem MKUNPRIVED Can be set to "yes" or "no". Indicates whether an 5921.152Slukem unprivileged install will occur. The user, group, 5931.152Slukem permissions, and file flags, will not be set on the 5941.152Slukem installed items; instead the information will be appended 5951.154Slukem to a file called METALOG in DESTDIR. The METALOG 5961.154Slukem contents are used during the generation of the 5971.152Slukem distribution tar files to ensure that the appropriate 5981.154Slukem file ownership is stored. This allows a non-root `make 5991.154Slukem install'. 6001.151Slukem 6011.152Slukem Default: "no" 6021.151Slukem 6031.152Slukem MKUPDATE Can be set to "yes" or "no". Indicates whether all 6041.152Slukem install operations intended to write to DESTDIR will 6051.152Slukem compare file timestamps before installing, and skip the 6061.152Slukem install phase if the destination files are up-to-date. 6071.151Slukem 6081.154Slukem For top-level builds this this implies the effects of 6091.154Slukem NOCLEANDIR (i.e., "make cleandir" is avoided). 6101.154Slukem 6111.154Slukem Note: If using build.sh, this may be set by giving the -u 6121.154Slukem option. 6131.151Slukem 6141.152Slukem Default: "no" 6151.151Slukem 6161.154Slukem MKX11 Can be set to "yes" or "no". Indicates whether X11 will 6171.154Slukem be built and installed from X11SRCDIR, and whether the X 6181.152Slukem sets will be created. 6191.151Slukem 6201.152Slukem Note: If "yes", requires MKINET6=yes. 6211.151Slukem 6221.152Slukem Default: "no" 6231.151Slukem 6241.152Slukem NETBSDSRCDIR The path to the top level of the NetBSD sources. 6251.152Slukem 6261.152Slukem Default: Top level of the NetBSD source tree (as 6271.152Slukem determined by the presence of build.sh and tools/) if 6281.152Slukem make(1) is run from within that tree; otherwise BSDSRCDIR 6291.152Slukem will be used. 6301.151Slukem 6311.154Slukem NOCLEANDIR If set, avoids the "make cleandir" phase of a full build. 6321.154Slukem This has the effect of allowing only changed files in a 6331.154Slukem source tree to be recompiled. This can speed up builds 6341.154Slukem when updating only a few files in the tree. 6351.154Slukem 6361.154Slukem See also MKUPDATE. 6371.154Slukem 6381.154Slukem Default: Unset. 6391.154Slukem 6401.154Slukem NODISTRIBDIRS If set, avoids the "make distrib-dirs" phase of a full 6411.154Slukem build. This skips running mtree(8) on DESTDIR, useful on 6421.154Slukem systems where building as an unprivileged user, or where 6431.154Slukem it is known that the system-wide mtree(8) files have not 6441.154Slukem changed. 6451.154Slukem 6461.154Slukem Default: Unset. 6471.154Slukem 6481.154Slukem NOINCLUDES If set, avoids the "make includes" phase of a full build. 6491.154Slukem This has the effect of preventing make(1) from thinking 6501.154Slukem that some programs are out-of-date simply because the 6511.154Slukem system include files have changed. However, this option 6521.154Slukem should not be used when updating the entire NetBSD source 6531.154Slukem tree arbitrarily; it is suggested to use MKUPDATE=yes 6541.154Slukem instead in that case. 6551.154Slukem 6561.154Slukem Default: Unset. 6571.154Slukem 6581.154Slukem RELEASEDIR If set, specifies the directory to which a release(7) 6591.154Slukem layout will be written at the end of a "make release". 6601.154Slukem If specified, must be an absolute path. 6611.154Slukem 6621.154Slukem Note: build.sh will provide a default of "releasedir" (in 6631.154Slukem the top-level .OBJDIR) unless run in `expert' mode. 6641.154Slukem 6651.154Slukem Default: Unset. 6661.154Slukem 6671.151Slukem TOOLCHAIN_MISSING 6681.152Slukem Can be set to "yes" or "no". If not "no", this indicates 6691.152Slukem that the platform "MACHINE_ARCH" being built does not 6701.152Slukem have a working in-tree toolchain. 6711.152Slukem 6721.152Slukem If not "no", acts as MKBINUTILS=no MKGCC=no MKGDB=no. 6731.152Slukem 6741.152Slukem Default: "no" 6751.152Slukem 6761.152Slukem TOOLDIR Directory to hold the host tools, once built. If 6771.152Slukem specified, must be an absolute path. This directory 6781.152Slukem should be unique to a given host system and NetBSD source 6791.154Slukem tree. (However, multiple target architectures may share 6801.154Slukem the same TOOLDIR; the target-architecture-dependent files 6811.154Slukem have unique names.) If unset, a default based on the 6821.154Slukem uname(1) information of the host platform will be created 6831.154Slukem in the .OBJDIR of src. 6841.152Slukem 6851.152Slukem Default: Unset. 6861.152Slukem 6871.152Slukem USETOOLS Can be set to "yes" or "no". Indicates whether the tools 6881.152Slukem specified by TOOLDIR should be used as part of a build in 6891.152Slukem progress. Must be set to "yes" if cross-compiling. 6901.154Slukem Supported values: 6911.152Slukem 6921.152Slukem yes Use the tools from TOOLDIR. 6931.152Slukem 6941.152Slukem no Do not use the tools from TOOLDIR, but refuse to 6951.152Slukem build native compilation tool components that are 6961.152Slukem version-specific for that tool. 6971.152Slukem 6981.152Slukem never Do not use the tools from TOOLDIR, even when 6991.152Slukem building native tool components. This is similar 7001.152Slukem to the traditional NetBSD build method, but does 7011.152Slukem not verify that the compilation tools in use are 7021.152Slukem up-to-date enough in order to build the tree 7031.152Slukem successfully. This may cause build or runtime 7041.152Slukem problems when building the whole NetBSD source 7051.152Slukem tree. 7061.152Slukem 7071.152Slukem Default: "no" when using <bsd.*.mk> outside the NetBSD 7081.152Slukem source tree (detected automatically) or if 7091.152Slukem TOOLCHAIN_MISSING=yes; "yes" otherwise. 7101.152Slukem 7111.152Slukem X11SRCDIR Directory containing the modular Xorg source. If 7121.152Slukem specified, must be an absolute path. The main modular 7131.152Slukem Xorg source is found in X11SRCDIR/external/mit. 7141.151Slukem 7151.152Slukem Default: NETBSDSRCDIR/../xsrc, if that exists; otherwise 7161.152Slukem /usr/xsrc. 7171.49Slukem 7181.105SwizBUILDING 7191.105Swiz "make" command line options 7201.52Sjmc This is not a summary of all the options available to make(1); only the 7211.52Sjmc options used most frequently with NetBSD builds are listed here. 7221.1Stv 7231.105Swiz -j njob Run up to njob make(1) subjobs in parallel. Makefiles should 7241.52Sjmc use .WAIT or have explicit dependencies as necessary to 7251.74Sapb enforce build ordering. 7261.10Ssommerfe 7271.105Swiz -m dir Specify the default directory for searching for system 7281.104Swiz Makefile segments, mainly the <bsd.*.mk> files. When building 7291.104Swiz any full NetBSD source tree, this should be set to the 7301.126Swiz "share/mk" directory in the source tree. This is set 7311.104Swiz automatically when building from the top level, or when using 7321.105Swiz build.sh. 7331.1Stv 7341.148Slukem -n Show the commands that would have been executed, but do not 7351.1Stv actually execute them. This will still cause recursion to 7361.1Stv take place. 7371.1Stv 7381.148Slukem -V var Show make(1)'s idea of the value of var. Does not build any 7391.1Stv targets. 7401.1Stv 7411.105Swiz var=value Set the variable var to value, overriding any setting 7421.105Swiz specified by the process environment, the MAKECONF 7431.104Swiz configuration file, or the system Makefile segments. 7441.1Stv 7451.105Swiz "make" targets 7461.1Stv These default targets may be built by running make(1) in any subtree of 7471.1Stv the NetBSD source code. It is recommended that none of these be used 7481.126Swiz from the top level Makefile; as a specific exception, "make obj" and 7491.126Swiz "make cleandir" are useful in that context. 7501.1Stv 7511.105Swiz all Build programs, libraries, and preformatted documentation. 7521.1Stv 7531.105Swiz clean Remove program and library object code files. 7541.1Stv 7551.105Swiz cleandir Same as clean, but also remove preformatted documentation, 7561.126Swiz dependency files generated by "make depend", and any other 7571.49Slukem files known to be created at build time. 7581.1Stv 7591.105Swiz depend Create dependency files (.depend) containing more detailed 7601.44Slukem information about the dependencies of source code on header 7611.1Stv files. Allows programs to be recompiled automatically when a 7621.1Stv dependency changes. 7631.1Stv 7641.126Swiz dependall Does a "make depend" immediately followed by a "make all". 7651.10Ssommerfe This improves cache locality of the build since both passes 7661.10Ssommerfe read the source files in their entirety. 7671.1Stv 7681.105Swiz distclean Synonym for cleandir. 7691.49Slukem 7701.105Swiz includes Build and install system header files. Typically needed 7711.44Slukem before any system libraries or programs can be built. 7721.1Stv 7731.105Swiz install Install programs, libraries, and documentation into DESTDIR. 7741.105Swiz Few files will be installed to DESTDIR/dev, DESTDIR/etc, 7751.105Swiz DESTDIR/root or DESTDIR/var in order to prevent user supplied 7761.27Slukem configuration data from being overwritten. 7771.1Stv 7781.105Swiz lint Run lint(1) against the C source code, where appropriate, and 7791.1Stv generate system-installed lint libraries. 7801.1Stv 7811.105Swiz obj Create object directories to be used for built files, instead 7821.1Stv of building directly in the source tree. 7831.1Stv 7841.105Swiz tags Create ctags(1) searchable function lists usable by the ex(1) 7851.1Stv and vi(1) text editors. 7861.1Stv 7871.105Swiz "make" targets for the top level 7881.1Stv Additional make(1) targets are usable specifically from the top source 7891.1Stv level to facilitate building the entire NetBSD source tree. 7901.1Stv 7911.105Swiz build Build the entire NetBSD system (except the kernel). This 7921.68Sreed orders portions of the source tree such that prerequisites 7931.68Sreed will be built in the proper order. 7941.20Slukem 7951.126Swiz distribution Do a "make build", and then install a full distribution 7961.105Swiz (which does not include a kernel) into DESTDIR, including 7971.105Swiz files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and 7981.105Swiz DESTDIR/var. 7991.20Slukem 8001.126Swiz buildworld As per "make distribution", except that it ensures that 8011.105Swiz DESTDIR is not the root directory. 8021.20Slukem 8031.105Swiz installworld Install the distribution from DESTDIR to INSTALLWORLDDIR, 8041.70Sdholland which defaults to the root directory. Ensures that 8051.105Swiz INSTALLWORLDDIR is not the root directory if cross 8061.104Swiz compiling. 8071.20Slukem 8081.105Swiz The INSTALLSETS environment variable may be set to a space- 8091.95Sapb separated list of distribution sets to be installed. By 8101.126Swiz default, all sets except "etc" and "xetc" are installed, so 8111.126Swiz most files in INSTALLWORLDDIR/etc will not be installed or 8121.126Swiz modified. 8131.61Sapb 8141.105Swiz Note: Before performing this operation with 8151.105Swiz INSTALLWORLDDIR=/, it is highly recommended that you 8161.61Sapb upgrade your kernel and reboot. After performing this 8171.61Sapb operation, it is recommended that you use etcupdate(8) to 8181.105Swiz update files in INSTALLWORLDDIR/etc, and postinstall(8) to 8191.102Sabs check for or fix inconsistencies. 8201.20Slukem 8211.105Swiz sets Create distribution sets from DESTDIR into 8221.105Swiz RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run 8231.126Swiz after "make distribution", as "make build" alone does not 8241.126Swiz install all of the required files. 8251.25Slukem 8261.105Swiz sourcesets Create source sets of the source tree into 8271.105Swiz RELEASEDIR/source/sets. 8281.31Slukem 8291.105Swiz syspkgs Create syspkgs from DESTDIR into 8301.105Swiz RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run 8311.126Swiz after "make distribution", as "make build" alone does not 8321.126Swiz install all of the required files. 8331.54Sapb 8341.126Swiz release Do a "make distribution", build kernels, distribution 8351.126Swiz media, and install sets (this as per "make sets"), and then 8361.126Swiz package the system into a standard release layout as 8371.105Swiz described by release(7). This requires that RELEASEDIR be 8381.25Slukem set (see above). 8391.1Stv 8401.105Swiz iso-image Create a NetBSD installation CD-ROM image in the 8411.114Ssnj RELEASEDIR/images directory. The CD-ROM file system will 8421.114Ssnj have a layout as described in release(7). 8431.62Sapb 8441.62Sapb For most machine types, the CD-ROM will be bootable, and 8451.104Swiz will automatically run the sysinst(8) menu-based 8461.104Swiz installation program, which can be used to install or 8471.104Swiz upgrade a NetBSD system. Bootable CD-ROMs also contain 8481.104Swiz tools that may be useful in repairing a damaged NetBSD 8491.104Swiz installation. 8501.62Sapb 8511.126Swiz Before "make iso-image" is attempted, RELEASEDIR must be 8521.126Swiz populated by "make release" or equivalent. 8531.62Sapb 8541.151Slukem Note: Other, smaller, CD-ROM images may be created in the 8551.151Slukem RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom directory 8561.151Slukem by "make release". These smaller images usually contain 8571.151Slukem the same tools as the larger images in RELEASEDIR/images, 8581.151Slukem but do not contain additional content such as the 8591.151Slukem distribution sets. 8601.62Sapb 8611.151Slukem Note: The mac68k port still uses an older method of 8621.104Swiz creating CD-ROM images. This requires the mkisofs(1) 8631.104Swiz utility, which is not part of NetBSD, but which can be 8641.105Swiz installed from pkgsrc/sysutils/cdrtools. 8651.56Sapb 8661.105Swiz iso-image-source 8671.64Sjnemeth Create a NetBSD installation CD-ROM image in the 8681.114Ssnj RELEASEDIR/images directory. The CD-ROM file system will 8691.114Ssnj have a layout as described in release(7). It will have top 8701.64Sjnemeth level directories for the machine type and source. 8711.64Sjnemeth 8721.64Sjnemeth For most machine types, the CD-ROM will be bootable, and 8731.104Swiz will automatically run the sysinst(8) menu-based 8741.104Swiz installation program, which can be used to install or 8751.104Swiz upgrade a NetBSD system. Bootable CD-ROMs also contain 8761.104Swiz tools that may be useful in repairing a damaged NetBSD 8771.104Swiz installation. 8781.64Sjnemeth 8791.126Swiz Before "make iso-image-source" is attempted, RELEASEDIR 8801.126Swiz must be populated by "make sourcesets release" or 8811.104Swiz equivalent. 8821.64Sjnemeth 8831.151Slukem Note: Other, smaller, CD-ROM images may be created in the 8841.151Slukem RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom directory 8851.151Slukem by "make release". These smaller images usually contain 8861.151Slukem the same tools as the larger images in RELEASEDIR/images, 8871.151Slukem but do not contain additional content such as the 8881.151Slukem distribution sets. 8891.64Sjnemeth 8901.151Slukem Note: The mac68k port still uses an older method of 8911.104Swiz creating CD-ROM images. This requires the mkisofs(1) 8921.104Swiz utility, which is not part of NetBSD, but which can be 8931.105Swiz installed from pkgsrc/sysutils/cdrtools. 8941.64Sjnemeth 8951.105Swiz install-image 8961.98Sapb Create a bootable NetBSD installation disk image in the 8971.127Splunky RELEASEDIR/images directory. The installation disk image 8981.127Splunky is suitable for copying to bootable USB flash memory 8991.127Splunky sticks, etc., for machines which are able to boot from such 9001.127Splunky devices. The file system in the bootable disk image will 9011.127Splunky have a layout as described in release(7). 9021.97Stsutsui 9031.97Stsutsui The installation image is bootable, and will automatically 9041.97Stsutsui run the sysinst(8) menu-based installation program, which 9051.98Sapb can be used to install or upgrade a NetBSD system. The 9061.98Sapb image also contains tools that may be useful in repairing a 9071.98Sapb damaged NetBSD installation. 9081.97Stsutsui 9091.126Swiz Before "make install-image" is attempted, RELEASEDIR must 9101.126Swiz be populated by "make release" or equivalent. The build 9111.126Swiz must have been performed with MKUNPRIVED=yes because "make 9121.126Swiz install-image" relies on information in DESTDIR/METALOG. 9131.97Stsutsui 9141.120Spgoyette live-image Create NetBSD live images in the RELEASEDIR/images 9151.104Swiz directory. The live image contains all necessary files to 9161.104Swiz boot NetBSD up to multi-user mode, including all files 9171.104Swiz which should be extracted during installation, NetBSD 9181.104Swiz disklabel, bootloaders, etc. 9191.104Swiz 9201.104Swiz The live image is suitable for use as a disk image in 9211.104Swiz virtual machine environments such as QEMU, and also useful 9221.104Swiz to boot NetBSD from a USB flash memory stick on a real 9231.98Sapb machine, without the need for installation. 9241.97Stsutsui 9251.126Swiz Before "make live-image" is attempted, RELEASEDIR must be 9261.126Swiz populated by "make release" or equivalent. The build must 9271.126Swiz have been performed with MKUNPRIVED=yes because "make 9281.126Swiz install-image" relies on information in DESTDIR/METALOG. 9291.97Stsutsui 9301.105Swiz regression-tests 9311.20Slukem Can only be run after building the regression tests in the 9321.126Swiz directory "regress". Runs those compiled regression tests 9331.151Slukem on the local host. 9341.151Slukem 9351.151Slukem Note: Most tests are now managed instead using atf(7); this 9361.151Slukem target should probably run those as well but currently does 9371.151Slukem not. 9381.1Stv 9391.105Swiz The "build.sh" script 9401.96Sapb This script file is a shell script designed to build the entire NetBSD 9411.104Swiz system on any host with a suitable modern shell and some common 9421.105Swiz utilities. The required shell features are described under the HOST_SH 9431.104Swiz variable. 9441.96Sapb 9451.96Sapb If a host system's default shell does support the required features, then 9461.96Sapb we suggest that you explicitly specify a suitable shell using a command 9471.96Sapb like 9481.96Sapb 9491.105Swiz /path/to/suitable/shell build.sh [options] 9501.96Sapb 9511.105Swiz The above command will usually enable build.sh to automatically set 9521.105Swiz HOST_SH=/path/to/suitable/shell, but if that fails, then the following 9531.96Sapb set of commands may be used instead: 9541.96Sapb 9551.105Swiz HOST_SH=/path/to/suitable/shell 9561.96Sapb export HOST_SH 9571.105Swiz ${HOST_SH} build.sh [options] 9581.96Sapb 9591.105Swiz If build.sh detects that it is being executed under an unsuitable shell, 9601.148Slukem it attempts to exec a suitable shell instead, or shows an error message. 9611.105Swiz If HOST_SH is not set explicitly, then build.sh sets a default using 9621.96Sapb heuristics dependent on the host platform, or from the shell under which 9631.105Swiz build.sh is executed (if that can be determined), or using the first copy 9641.105Swiz of sh found in PATH. 9651.1Stv 9661.1Stv All cross-compile builds, and most native builds, of the entire system 9671.126Swiz should make use of build.sh rather than just running "make". This way, 9681.104Swiz the make(1) program will be bootstrapped properly, in case the host 9691.126Swiz system has an older or incompatible "make" program. 9701.1Stv 9711.105Swiz When compiling the entire system via build.sh, many make(1) variables are 9721.1Stv set for you in order to help encapsulate the build process. In the list 9731.105Swiz of options below, variables that are automatically set by build.sh are 9741.1Stv noted where applicable. 9751.1Stv 9761.105Swiz The following operations are supported by build.sh: 9771.22Slukem 9781.126Swiz build Build the system as per "make build". Before the main part 9791.126Swiz of the build commences, this command runs the obj operation 9801.126Swiz (unless the -o option is given), "make cleandir" (unless 9811.126Swiz the -u option is given), and the tools operation. 9821.22Slukem 9831.126Swiz distribution Build a full distribution as per "make distribution". This 9841.126Swiz command first runs the build operation. 9851.22Slukem 9861.126Swiz release Build a full release as per "make release". This command 9871.105Swiz first runs the distribution operation. 9881.22Slukem 9891.148Slukem help Show a help message, and exit. 9901.148Slukem 9911.105Swiz makewrapper Create the nbmake-MACHINE wrapper. This operation is 9921.104Swiz automatically performed for any of the other operations. 9931.23Slukem 9941.126Swiz cleandir Perform "make cleandir". 9951.75Slukem 9961.126Swiz obj Perform "make obj". 9971.22Slukem 9981.105Swiz tools Build and install the host tools from src/tools. This 9991.126Swiz command will first run "make obj" and "make cleandir" in 10001.126Swiz the tools subdirectory unless the -o or -u options 10011.104Swiz (respectively) are given. 10021.22Slukem 10031.126Swiz install=idir Install the contents of DESTDIR to idir, using "make 10041.151Slukem installworld". 10051.151Slukem 10061.151Slukem Note: Files that are part of the "etc" or "xetc" sets will 10071.151Slukem not be installed, unless overridden by the INSTALLSETS 10081.151Slukem environment variable. 10091.35Slukem 10101.105Swiz kernel=kconf Build a new kernel. The kconf argument is the name of a 10111.105Swiz configuration file suitable for use by config(1). If kconf 10121.22Slukem does not contain any `/' characters, the configuration file 10131.105Swiz is expected to be found in the KERNCONFDIR directory, which 10141.105Swiz is typically sys/arch/MACHINE/conf. The new kernel will be 10151.105Swiz built in a subdirectory of KERNOBJDIR, which is typically 10161.105Swiz sys/arch/MACHINE/compile or an associated object directory. 10171.70Sdholland 10181.105Swiz This command does not imply the tools command; run the 10191.105Swiz tools command first unless it is certain that the tools 10201.70Sdholland already exist and are up to date. 10211.70Sdholland 10221.126Swiz This command will run "make cleandir" on the kernel in 10231.105Swiz question first unless the -u option is given. 10241.22Slukem 10251.106Swiz kernel.gdb=kconf 10261.106Swiz Build a new kernel with debug information. Similar to the 10271.106Swiz above kernel=kconf operation, but creates a netbsd.gdb file 10281.106Swiz alongside of the kernel netbsd, which contains a full 10291.106Swiz symbol table and can be used for debugging (for example 10301.106Swiz with a cross-gdb built by MKCROSSGDB). 10311.106Swiz 10321.113Suebayasi kernels This command will build all kernels defined in port 10331.113Suebayasi specific release build procedure. 10341.111Suebayasi 10351.112Suebayasi This command internally calls the kernel=kconf operation 10361.112Suebayasi for each found kernel configuration file. 10371.111Suebayasi 10381.105Swiz modules This command will build kernel modules and install them 10391.105Swiz into DESTDIR. 10401.86Sjnemeth 10411.105Swiz releasekernel=kconf 10421.70Sdholland Install a gzip(1)ed copy of the kernel previously built by 10431.105Swiz kernel=kconf into 10441.105Swiz RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as 10451.126Swiz netbsd-kconf.gz, although the "netbsd" prefix is determined 10461.126Swiz from the "config" directives in kconf. 10471.24Slukem 10481.126Swiz sets Perform "make sets". 10491.31Slukem 10501.126Swiz sourcesets Perform "make sourcesets". 10511.22Slukem 10521.126Swiz syspkgs Perform "make syspkgs". 10531.54Sapb 10541.126Swiz iso-image Perform "make iso-image". 10551.56Sapb 10561.105Swiz iso-image-source 10571.126Swiz Perform "make iso-image-source". 10581.65Sjnemeth 10591.105Swiz install-image 10601.126Swiz Perform "make install-image". 10611.97Stsutsui 10621.126Swiz live-image Perform "make live-image". 10631.97Stsutsui 10641.148Slukem list-arch Show a list of valid MACHINE and MACHINE_ARCH settings, the 10651.148Slukem default MACHINE_ARCH for each MACHINE, and aliases for 10661.109Sapb MACHINE/MACHINE_ARCH pairs, and then exits. The -m or -a 10671.109Sapb options (or both) may be used to specify glob patterns that 10681.109Sapb will be used to narrow the list of results; for example, 10691.131Sleot "build.sh -m 'evb*' -a '*arm*' list-arch" will list all 10701.109Sapb known MACHINE/MACHINE_ARCH values in which either MACHINE 10711.109Sapb or ALIAS matches the pattern `evb*', and MACHINE_ARCH 10721.109Sapb matches the pattern `*arm*'. 10731.109Sapb 10741.105Swiz The following command line options alter the behaviour of the build.sh 10751.51Swiz operations described above: 10761.1Stv 10771.109Sapb -a arch Set the value of MACHINE_ARCH to arch. See the -m option for 10781.109Sapb more information. 10791.9Sthorpej 10801.105Swiz -B buildid 10811.105Swiz Set the value of BUILDID to buildid. This will also append the 10821.126Swiz build identifier to the name of the "make" wrapper script so 10831.37Slukem that the resulting name is of the form 10841.126Swiz "nbmake-MACHINE-BUILDID". 10851.1Stv 10861.105Swiz -C cdextras 10871.105Swiz Append cdextras to the CDEXTRA variable, which is a space- 10881.104Swiz separated list of files or directories that will be added to 10891.126Swiz the CD-ROM image that may be create by the "iso-image" or 10901.126Swiz "iso-image-source" operations. Files will be added to the root 10911.126Swiz of the CD-ROM image, whereas directories will be copied 10921.87Sapb recursively. If relative paths are specified, they will be 10931.87Sapb converted to absolute paths before being used. Multiple paths 10941.105Swiz may be specified via multiple -C options, or via a single 10951.87Sapb option whose argument contains multiple space-separated paths. 10961.66Sjnemeth 10971.136Suwe -c compiler 10981.136Suwe Select the compiler for the toolchain to build NetBSD and for 10991.136Suwe inclusion in the NetBSD distribution. Supported choices: 11001.136Suwe 11011.136Suwe clang 11021.136Suwe 11031.136Suwe gcc [default] 11041.136Suwe 11051.136Suwe The compiler used to build the toolchain can be different; see 11061.136Suwe HOST_CC and HOST_CXX. 11071.136Suwe 11081.105Swiz -D dest Set the value of DESTDIR to dest. If a relative path is 11091.104Swiz specified, it will be converted to an absolute path before 11101.104Swiz being used. 11111.104Swiz 11121.105Swiz -E Set `expert' mode. This overrides various sanity checks, and 11131.105Swiz allows: DESTDIR does not have to be set to a non-root path for 11141.105Swiz builds, and MKUNPRIVED=yes does not have to be set when 11151.104Swiz building as a non-root user. 11161.23Slukem 11171.105Swiz Note: It is highly recommended that you know what you are doing 11181.23Slukem when you use this option. 11191.19Slukem 11201.148Slukem -h Show a help message, and exit. 11211.51Swiz 11221.105Swiz -j njob Run up to njob make(1) subjobs in parallel; passed through to 11231.74Sapb make(1). If you see failures for reasons other than running 11241.105Swiz out of memory while using build.sh with -j, please save 11251.104Swiz complete build logs so the failures can be analyzed. 11261.74Sapb 11271.105Swiz To achieve the fastest builds, -j values between (1 + the 11281.104Swiz number of CPUs) and (2 * the number of CPUs) are recommended. 11291.104Swiz Use lower values on machines with limited memory or I/O 11301.104Swiz bandwidth. 11311.104Swiz 11321.126Swiz -M obj Set MAKEOBJDIRPREFIX to obj. Unsets MAKEOBJDIR. See "-O obj" 11331.126Swiz for more information. 11341.104Swiz 11351.105Swiz For instance, if the source directory is /usr/src, a setting of 11361.126Swiz "-M /usr/obj" will place build-time files under 11371.105Swiz /usr/obj/usr/src/bin, /usr/obj/usr/src/lib, 11381.105Swiz /usr/obj/usr/src/usr.bin, and so forth. 11391.88Sapb 11401.73Sapb If a relative path is specified, it will be converted to an 11411.105Swiz absolute path before being used. build.sh imposes the 11421.105Swiz restriction that the argument to the -M option must not begin 11431.126Swiz with a "$" (dollar sign) character; otherwise it would be too 11441.104Swiz difficult to determine whether the value is an absolute or a 11451.104Swiz relative path. If the directory does not already exist, 11461.105Swiz build.sh will create it. 11471.18Slukem 11481.109Sapb -m mach Set the value of MACHINE to mach, unless the mach argument is 11491.109Sapb an alias that refers to a MACHINE/MACHINE_ARCH pair, in which 11501.109Sapb case both MACHINE and MACHINE_ARCH are set from the alias. 11511.109Sapb Such aliases are interpreted entirely by build.sh; they are not 11521.109Sapb used by any other part of the build system. The MACHINE_ARCH 11531.109Sapb setting implied by mach will override any value of MACHINE_ARCH 11541.109Sapb in the process environment, but will not override a value set 11551.109Sapb by the -a option. All cross builds require -m, but if unset on 11561.109Sapb a NetBSD host, the host's value of MACHINE will be detected and 11571.109Sapb used automatically. 11581.109Sapb 11591.109Sapb See the list-arch operation for a way to get a list of valid 11601.109Sapb MACHINE and MACHINE_ARCH settings. 11611.1Stv 11621.105Swiz -N noiselevel 11631.126Swiz Set the "noisyness" level of the build, by setting MAKEVERBOSE 11641.126Swiz to noiselevel. 11651.45Slukem 11661.105Swiz -n Show the commands that would be executed by build.sh, but do 11671.126Swiz not make any changes. This is similar in concept to "make -n". 11681.1Stv 11691.105Swiz -O obj Create an appropriate transform macro for MAKEOBJDIR that will 11701.105Swiz place the built object files under obj. Unsets 11711.105Swiz MAKEOBJDIRPREFIX. 11721.88Sapb 11731.126Swiz For instance, a setting of "-O /usr/obj" will place build-time 11741.126Swiz files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and 11751.126Swiz so forth. 11761.88Sapb 11771.88Sapb If a relative path is specified, it will be converted to an 11781.105Swiz absolute path before being used. build.sh imposes the 11791.105Swiz restriction that the argument to the -O option must not contain 11801.126Swiz a "$" (dollar sign) character. If the directory does not 11811.105Swiz already exist, build.sh will create it. 11821.73Sapb 11831.105Swiz In normal use, exactly one of the -M or -O options should be 11841.105Swiz specified. If neither -M nor -O is specified, then a default 11851.78Sapb object directory will be chosen according to rules in 11861.78Sapb <bsd.obj.mk>. Relying on this default is not recommended 11871.78Sapb because it is determined by complex rules that are influenced 11881.78Sapb by the values of several variables and by the location of the 11891.78Sapb source directory. 11901.18Slukem 11911.151Slukem Note: Placing the obj directory location outside of the default 11921.151Slukem source tree hierarchy makes it easier to manually clear out old 11931.151Slukem files in the event the "make cleandir" operation is unable to 11941.151Slukem do so. (See CAVEATS below.) 11951.151Slukem 11961.151Slukem Note: The use of one of -M or -O is the only means of building 11971.151Slukem multiple machine architecture userlands from the same source 11981.151Slukem tree without cleaning between builds (in which case, one would 11991.151Slukem specify distinct obj locations for each). 12001.109Sapb 12011.126Swiz -o Set the value of MKOBJDIRS to "no". Otherwise, it will be 12021.126Swiz automatically set to "yes". This default is opposite to the 12031.105Swiz behaviour when not using build.sh. 12041.1Stv 12051.148Slukem -P Set the value of MKREPRO and MKREPRO_TIMESTAMP to the latest 12061.148Slukem source CVS timestamp for reproducible builds. 12071.148Slukem 12081.105Swiz -R rel Set the value of RELEASEDIR to rel. If a relative path is 12091.59Sapb specified, it will be converted to an absolute path before 12101.59Sapb being used. 12111.18Slukem 12121.105Swiz -r Remove the contents of DESTDIR and TOOLDIR before building 12131.1Stv (provides a clean starting point). This will skip deleting 12141.105Swiz DESTDIR if building on a native system to the root directory. 12151.1Stv 12161.105Swiz -S seed Change the value of BUILDSEED to seed. This should rarely be 12171.72Sperry necessary. 12181.72Sperry 12191.105Swiz -T tools Set the value of TOOLDIR to tools. If a relative path is 12201.104Swiz specified, it will be converted to an absolute path before 12211.126Swiz being used. If set, the bootstrap "make" will only be rebuilt 12221.126Swiz if the source files for make(1) have changed. 12231.104Swiz 12241.105Swiz -U Set MKUNPRIVED=yes. 12251.104Swiz 12261.105Swiz -u Set MKUPDATE=yes. 12271.104Swiz 12281.105Swiz -V var=[value] 12291.105Swiz Set the environment variable var to an optional value. This is 12301.105Swiz propagated to the nbmake wrapper. 12311.105Swiz 12321.105Swiz -w wrapper 12331.105Swiz Create the nbmake wrapper script (see below) in a custom 12341.105Swiz location, specified by wrapper. This allows, for instance, to 12351.151Slukem place the wrapper in PATH automatically. 12361.151Slukem 12371.151Slukem Note: wrapper is the full name of the file, not just a 12381.151Slukem directory name. If a relative path is specified, it will be 12391.151Slukem converted to an absolute path before being used. 12401.1Stv 12411.105Swiz -X x11src 12421.105Swiz Set the value of X11SRCDIR to x11src. If a relative path is 12431.59Sapb specified, it will be converted to an absolute path before 12441.59Sapb being used. 12451.49Slukem 12461.105Swiz -x Set MKX11=yes. 12471.49Slukem 12481.105Swiz -Z var Unset ("zap") the environment variable var. This is propagated 12491.105Swiz to the nbmake wrapper. 12501.40Slukem 12511.148Slukem -? Show a help message, and exit. 12521.148Slukem 12531.105Swiz The "nbmake-MACHINE" wrapper script 12541.105Swiz If using the build.sh script to build NetBSD, a nbmake-MACHINE script 12551.105Swiz will be created in TOOLDIR/bin upon the first build to assist in building 12561.1Stv subtrees on a cross-compile host. 12571.1Stv 12581.105Swiz nbmake-MACHINE can be invoked in lieu of make(1), and will instead call 12591.126Swiz the up-to-date version of "nbmake" installed into TOOLDIR/bin with 12601.105Swiz several key variables pre-set, including MACHINE, MACHINE_ARCH, and 12611.105Swiz TOOLDIR. nbmake-MACHINE will also set variables specified with -V, and 12621.105Swiz unset variables specified with -Z. 12631.40Slukem 12641.105Swiz This script can be symlinked into a directory listed in PATH, or called 12651.1Stv with an absolute path. 12661.1Stv 12671.105SwizEXAMPLES 12681.151Slukem 1. % ./build.sh [OPTIONS] tools kernel=GENERIC 12691.28Slukem 12701.28Slukem Build a new toolchain, and use the new toolchain to configure and 12711.28Slukem build a new GENERIC kernel. 12721.28Slukem 12731.151Slukem 2. % ./build.sh [OPTIONS] -U distribution 12741.28Slukem 12751.105Swiz Using unprivileged mode, build a complete distribution to a DESTDIR 12761.148Slukem directory that build.sh selects (and will show). 12771.28Slukem 12781.151Slukem 3. # ./build.sh [OPTIONS] -U install=/ 12791.28Slukem 12801.105Swiz As root, install to / the distribution that was built by example 2. 12811.105Swiz Even though this is run as root, -U is required so that the 12821.105Swiz permissions stored in DESTDIR/METALOG are correctly applied to the 12831.105Swiz files as they're copied to /. 12841.28Slukem 12851.151Slukem 4. % ./build.sh [OPTIONS] -U -u release 12861.28Slukem 12871.105Swiz Using unprivileged mode, build a complete release to DESTDIR and 12881.148Slukem RELEASEDIR directories that build.sh selects (and will show). 12891.126Swiz MKUPDATE=yes (-u) is set to prevent the "make cleandir", so that if 12901.126Swiz this is run after example 2, it doesn't need to redo that portion of 12911.126Swiz the release build. 12921.16Slukem 12931.105SwizOBSOLETE VARIABLES 12941.154Slukem MKKDEBUG Use MKDEBUGKERNEL. 12951.154Slukem 12961.153Slukem NBUILDJOBS Use the build.sh and make(1) option -j instead. 12971.15Slukem 12981.105Swiz USE_NEW_TOOLCHAIN 12991.15Slukem The new toolchain is now the default. To disable, use 13001.105Swiz TOOLCHAIN_MISSING=yes. 13011.10Ssommerfe 13021.105SwizSEE ALSO 13031.151Slukem ar(1), config(1), ctags(1), cvs(1), cvslatest(1), ex(1), g++(1), gzip(1), 13041.151Slukem ident(1), ld(1), lint(1), make(1), mkisofs(1), sh(1), uname(1), vi(1), 13051.151Slukem options(4), mk.conf(5), atf(7), hier(7), release(7), sysctl(7), 13061.151Slukem etcupdate(8), installboot(8), mount(8), mtree(8), postinstall(8), 13071.151Slukem sysinst(8), pkgsrc/sysutils/cdrtools 13081.1Stv 13091.105SwizHISTORY 13101.105Swiz The build.sh based build scheme was introduced for NetBSD 1.6 as 13111.105Swiz USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that. 13121.1Stv 13131.109SapbCAVEATS 13141.109Sapb After significant updates to third-party components in the source tree, 13151.126Swiz the "make cleandir" operation may be insufficient to clean out old files 13161.126Swiz in object directories. Instead, one may have to manually remove the 13171.126Swiz files. Consult the UPDATING file for notices concerning this. 13181.109Sapb 13191.154SlukemNetBSD June 11, 2023 NetBSD 1320