BUILDING revision 1.94
1BUILDING(8) NetBSD System Manager's Manual BUILDING(8) 2 3NAME 4 BUILDING -- Procedure for building NetBSD from source code. 5 6REQUIREMENTS 7 NetBSD is designed to be buildable on most POSIX-compliant host systems. 8 The basic build procedure is the same whether compiling natively (on the 9 same NetBSD architecture) or cross compiling (on another architecture or 10 OS). 11 12 This source tree contains a special subtree, ``tools'', which uses the 13 host system to create a build toolchain for the target architecture. The 14 host system must have at least C and C++ compilers in order to create the 15 toolchain (make is not required); all other tools are created as part of 16 the NetBSD build process. (See the environment variables section below 17 if you need to override or manually select your compilers.) 18 19FILES 20 Source tree layout 21 doc/BUILDING.mdoc 22 This document (in -mdoc troff format; the original copy). 23 24 BUILDING This document (in plaintext). 25 26 tools/compat/README 27 Special notes for cross-hosting a NetBSD build on non- 28 NetBSD platforms. 29 30 Makefile The main Makefile for NetBSD; should only be run for 31 native builds with an appropriately up-to-date version of 32 NetBSD make(1). (For building from out-of-date systems or 33 on a non-native host, see the build.sh shell script.) 34 35 UPDATING Special notes for updating from an earlier revision of 36 NetBSD. It is important to read this file before every 37 build of an updated source tree. 38 39 build.sh Bourne-compatible shell script used for building the host 40 build tools and the NetBSD system from scratch. Can be 41 used for both native and cross builds, and should be used 42 instead of make(1) for any source tree that is updated and 43 recompiled regularly. 44 45 crypto/dist/, dist/, gnu/dist/ 46 Sources imported verbatim from third parties, without man- 47 gling the existing build structure. Other source trees in 48 bin through usr.sbin use the NetBSD make(1) ``reachover'' 49 Makefile semantics when building these programs for a 50 native host. 51 52 distrib/, etc/ 53 Sources for items used when making a full release snap- 54 shot, such as files installed in DESTDIR/etc on the desti- 55 nation system, boot media, and release notes. 56 57 tests/, regress/ 58 Regression test harness. Can be cross-compiled, but only 59 run natively. tests/ uses the atf(7) test framework; 60 regress/ contains older tests that have not yet been 61 migrated to atf(7). 62 63 sys/ NetBSD kernel sources. 64 65 tools/ ``Reachover'' build structure for the host build tools. 66 This has a special method of determining out-of-date sta- 67 tus. 68 69 bin/ ... usr.sbin/ 70 Sources to the NetBSD userland (non-kernel) programs. If 71 any of these directories are missing, they will be skipped 72 during the build. 73 74 x11/ ``Reachover'' build structure for X11R6; the source is in 75 X11SRCDIR. 76 77 Build tree layout 78 The NetBSD build tree is described in hier(7), and the release layout is 79 described in release(7). 80 81CONFIGURATION 82 Environment variables 83 Several environment variables control the behaviour of NetBSD builds. 84 85 HOST_SH Path name to a POSIX-compliant shell. If this is not 86 set explicitly, then the default is set using heuris- 87 tics dependent on the host platform, or from the shell 88 under which build.sh is executed (if that can be deter- 89 mined), or using the first copy of sh found in PATH. 90 If the host system's /bin/sh is not POSIX-compliant, we 91 suggest that you build using commands like 92 93 HOST_SH=/path/to/working/shell 94 export HOST_SH 95 ${HOST_SH} build.sh [options] 96 97 HOST_CC Path name to C compiler used to create the toolchain. 98 99 HOST_CXX Path name to C++ compiler used to create the toolchain. 100 101 MACHINE Machine type, e.g., ``macppc''. 102 103 MACHINE_ARCH Machine architecture, e.g., ``powerpc''. 104 105 MAKE Path name to invoke make(1) as. 106 107 MAKEFLAGS Flags to invoke make(1) with. Note that build.sh 108 ignores the value of MAKEFLAGS passed in the environ- 109 ment, but allows MAKEFLAGS to be set via the -V option. 110 111 MAKEOBJDIR Directory to use as the .OBJDIR for the current direc- 112 tory. The value is subjected to variable expansion by 113 make(1). Typical usage is to set this variable to a 114 value involving the use of `${.CURDIR:S...}' or 115 `${.CURDIR:C...}', to derive the value of .OBJDIR from 116 the value of .CURDIR. Used only if MAKEOBJDIRPREFIX is 117 not defined. MAKEOBJDIR can be provided only in the 118 environment or via the -O flag of build.sh; it cannot 119 usefully be set inside a Makefile, including mk.conf or 120 ${MAKECONF}. 121 122 MAKEOBJDIRPREFIX Top level directory of the object directory tree. The 123 value is subjected to variable expansion by make(1). 124 build.sh will create the ${MAKEOBJDIRPREFIX} directory 125 if necessary, but if make(1) is used without build.sh, 126 then rules in <bsd.obj.mk> will abort the build if the 127 ${MAKEOBJDIRPREFIX} directory does not exist. If the 128 value is defined and valid, then ${MAKEOBJDIRPRE- 129 FIX}/${.CURDIR} is used as the .OBJDIR for the current 130 directory. The current directory may be read only. 131 MAKEOBJDIRPREFIX can be provided only in the environ- 132 ment or via the -M flag of build.sh; it cannot usefully 133 be set inside a Makefile, including mk.conf or 134 ${MAKECONF}. 135 136 "make" variables 137 Several variables control the behavior of NetBSD builds. Unless other- 138 wise specified, these variables may be set in either the process environ- 139 ment or the make(1) configuration file specified by MAKECONF. 140 141 BUILDID Identifier for the build. The identifier will be appended to 142 object directory names, and can be consulted in the make(1) 143 configuration file in order to set additional build parame- 144 ters, such as compiler flags. 145 146 BUILDSEED GCC uses random numbers when compiling C++ code. This vari- 147 able seeds the gcc random number generator using the -fran- 148 dom-seed flag with this value. By default, it is set to 149 NetBSD-(majorversion). Using a fixed value causes C++ bina- 150 ries to be the same when built from the same sources, result- 151 ing in identical (reproducible) builds. Additional informa- 152 tion is available in the GCC documentation of -frandom-seed. 153 154 DESTDIR Directory to contain the built NetBSD system. If set, spe- 155 cial options are passed to the compilation tools to prevent 156 their default use of the host system's /usr/include, 157 /usr/lib, and so forth. This pathname must be an absolute 158 path, and should not end with a slash (/) character. (For 159 installation into the system's root directory, set DESTDIR to 160 an empty string, not to ``/''). The directory must reside on 161 a file system which supports long file names and hard links. 162 163 Default: Empty string if USETOOLS is ``yes''; unset other- 164 wise. 165 166 Note: build.sh will provide a default of destdir.MACHINE (in 167 the top-level .OBJDIR) unless run in `expert' mode. 168 169 MAKECONF The name of the make(1) configuration file. Only settable in 170 the process environment. 171 172 Default: ``/etc/mk.conf'' 173 174 MAKEVERBOSE 175 Level of verbosity of status messages. Supported values: 176 177 0 No descriptive messages or commands executed by make(1) 178 are shown. 179 180 1 Brief messages are shown describing what is being done, 181 but the actual commands executed by make(1) are not dis- 182 played. 183 184 2 Descriptive messages are shown as above (prefixed with a 185 `#'), and ordinary commands performed by make(1) are 186 displayed. 187 188 3 In addition to the above, all commands performed by 189 make(1) are displayed, even if they would ordinarily 190 have been hidden through use of the ``@'' prefix in the 191 relevant makefile. 192 193 4 In addition to the above, commands executed by make(1) 194 are traced through use of the sh(1) ``-x'' flag. 195 196 Default: 2 197 198 MKCATPAGES Can be set to ``yes'' or ``no''. Indicates whether prefor- 199 matted plaintext manual pages will be created during a build. 200 201 Default: ``yes'' 202 203 MKCRYPTO Can be set to ``yes'' or ``no''. Indicates whether crypto- 204 graphic code will be included in a build; provided for the 205 benefit of countries that do not allow strong cryptography. 206 Will not affect use of the standard low-security password 207 encryption system, crypt(3). 208 209 Default: ``yes'' 210 211 MKDOC Can be set to ``yes'' or ``no''. Indicates whether system 212 documentation destined for DESTDIR/usr/share/doc will be 213 installed during a build. 214 215 Default: ``yes'' 216 217 MKHTML Can be set to ``yes'' or ``no''. Indicates whether prefor- 218 matted HTML manual pages will be built and installed 219 220 Default: ``yes'' 221 222 MKHOSTOBJ Can be set to ``yes'' or ``no''. If set to ``yes'', then for 223 programs intended to be run on the compile host, the name, 224 release, and architecture of the host operating system will 225 be suffixed to the name of the object directory created by 226 ``make obj''. (This allows multiple host systems to compile 227 NetBSD for a single target.) If set to ``no'', then programs 228 built to be run on the compile host will use the same object 229 directory names as programs built to be run on the target. 230 231 Default: ``no'' 232 233 MKINFO Can be set to ``yes'' or ``no''. Indicates whether GNU Info 234 files, used for the documentation for most of the compilation 235 tools, will be created and installed during a build. 236 237 Default: ``yes'' 238 239 MKLINT Can be set to ``yes'' or ``no''. Indicates whether lint(1) 240 will be run against portions of the NetBSD source code during 241 the build, and whether lint libraries will be installed into 242 DESTDIR/usr/libdata/lint. 243 244 Default: ``yes'' 245 246 MKMAN Can be set to ``yes'' or ``no''. Indicates whether manual 247 pages will be installed during a build. 248 249 Default: ``yes'' 250 251 MKNLS Can be set to ``yes'' or ``no''. Indicates whether Native 252 Language System locale zone files will be compiled and 253 installed during a build. 254 255 Default: ``yes'' 256 257 MKOBJ Can be set to ``yes'' or ``no''. Indicates whether object 258 directories will be created when running ``make obj''. If 259 set to ``no'', then all built files will be located inside 260 the regular source tree. 261 262 Default: ``yes'' 263 264 Note that setting MKOBJ to ``no'' is not recommended and may 265 cause problems when updating the tree with cvs(1). 266 267 MKPIC Can be set to ``yes'' or ``no''. Indicates whether shared 268 objects and libraries will be created and installed during a 269 build. If set to ``no'', the entire built system will be 270 statically linked. 271 272 Default: Platform dependent. As of this writing, all plat- 273 forms except sh3 default to ``yes''. 274 275 MKPICINSTALL 276 Can be set to ``yes'' or ``no''. Indicates whether the ar(1) 277 format libraries (lib*_pic.a), used to generate shared 278 libraries, are installed during a build. 279 280 Default: ``yes'' 281 282 MKPROFILE Can be set to ``yes'' or ``no''. Indicates whether profiled 283 libraries (lib*_p.a) will be built and installed during a 284 build. 285 286 Default: ``yes''; however, some platforms turn off MKPROFILE 287 by default at times due to toolchain problems with profiled 288 code. 289 290 MKSHARE Can be set to ``yes'' or ``no''. Indicates whether files 291 destined to reside in DESTDIR/usr/share will be built and 292 installed during a build. If set to ``no'', then all of 293 MKCATPAGES, MKDOC, MKINFO, MKMAN, and MKNLS will be set to 294 ``no'' unconditionally. 295 296 Default: ``yes'' 297 298 MKSTRIPIDENT 299 Can be set to ``yes'' or ``no''. Indicates whether program 300 binaries and shared libraries should be built to include RCS 301 IDs for use with ident(1). 302 303 Default: ``no'' 304 305 MKUNPRIVED Can be set to ``yes'' or ``no''. Indicates whether an 306 unprivileged install will occur. The user, group, permis- 307 sions, and file flags, will not be set on the installed 308 items; instead the information will be appended to a file 309 called METALOG in DESTDIR. The contents of METALOG are used 310 during the generation of the distribution tar files to ensure 311 that the appropriate file ownership is stored. 312 313 Default: ``no'' 314 315 MKUPDATE Can be set to ``yes'' or ``no''. Indicates whether all 316 install operations intended to write to DESTDIR will compare 317 file timestamps before installing, and skip the install phase 318 if the destination files are up-to-date. This also has 319 implications on full builds (see next subsection). 320 321 Default: ``no'' 322 323 MKX11 Can be set to ``yes'' or ``no''. Indicates whether X11 is 324 built from X11SRCDIR. 325 326 Default: ``no'' 327 328 TOOLDIR Directory to hold the host tools, once built. If specified, 329 must be an absolute path. This directory should be unique to 330 a given host system and NetBSD source tree. (However, multi- 331 ple targets may share the same TOOLDIR; the target-dependent 332 files have unique names.) If unset, a default based on the 333 uname(1) information of the host platform will be created in 334 the .OBJDIR of src. 335 336 Default: Unset. 337 338 USETOOLS Indicates whether the tools specified by TOOLDIR should be 339 used as part of a build in progress. Must be set to ``yes'' 340 if cross-compiling. 341 342 yes Use the tools from TOOLDIR. 343 344 no Do not use the tools from TOOLDIR, but refuse to build 345 native compilation tool components that are version- 346 specific for that tool. 347 348 never Do not use the tools from TOOLDIR, even when building 349 native tool components. This is similar to the tradi- 350 tional NetBSD build method, but does not verify that 351 the compilation tools in use are up-to-date enough in 352 order to build the tree successfully. This may cause 353 build or runtime problems when building the whole 354 NetBSD source tree. 355 356 Default: ``yes'', unless TOOLCHAIN_MISSING is set to ``yes''. 357 358 USETOOLS is also set to ``no'' when using <bsd.*.mk> outside 359 the NetBSD source tree. 360 361 X11SRCDIR Directory containing the X11R6 source. If specified, must be 362 an absolute path. The main X11R6 source is found in 363 X11SRCDIR/xfree/xc. 364 365 Default: NETBSDRCDIR/../xsrc, if that exists; otherwise 366 /usr/xsrc. 367 368 X11FLAVOUR The style of X11 cross-built, set to either ``Xorg'' or 369 ``XFree86''. 370 371 Default: ``Xorg'' on amd64, i386, macppc, shark and sparc64 372 platforms, ``XFree86'' on everything else. 373 374 "make" variables for full builds 375 These variables only affect the top level ``Makefile'' and do not affect 376 manually building subtrees of the NetBSD source code. 377 378 INSTALLWORLDDIR Location for the ``make installworld'' target to install 379 to. If specified, must be an absolute path. 380 381 Default: ``/'' 382 383 MKOBJDIRS Can be set to ``yes'' or ``no''. Indicates whether 384 object directories will be created automatically (via a 385 ``make obj'' pass) at the start of a build. 386 387 Default: ``no'' 388 389 If using build.sh, the default is ``yes''. This may be 390 set back to ``no'' by giving build.sh the -o option. 391 392 MKUPDATE Can be set to ``yes'' or ``no''. If set, then in addi- 393 tion to the effects described for MKUPDATE=yes above, 394 this implies the effects of NOCLEANDIR (i.e., ``make 395 cleandir'' is avoided). 396 397 Default: ``no'' 398 399 If using build.sh, this may be set by giving the -u 400 option. 401 402 NBUILDJOBS Now obsolete. Use the make(1) option -j, instead. See 403 below. 404 405 Default: Unset. 406 407 NOCLEANDIR If set, avoids the ``make cleandir'' phase of a full 408 build. This has the effect of allowing only changed 409 files in a source tree to be recompiled. This can speed 410 up builds when updating only a few files in the tree. 411 412 Default: Unset. 413 414 See also MKUPDATE. 415 416 NODISTRIBDIRS If set, avoids the ``make distrib-dirs'' phase of a full 417 build. This skips running mtree(8) on DESTDIR, useful 418 on systems where building as an unprivileged user, or 419 where it is known that the system-wide mtree files have 420 not changed. 421 422 Default: Unset. 423 424 NOINCLUDES If set, avoids the ``make includes'' phase of a full 425 build. This has the effect of preventing make(1) from 426 thinking that some programs are out-of-date simply 427 because the system include files have changed. However, 428 this option should not be used when updating the entire 429 NetBSD source tree arbitrarily; it is suggested to use 430 MKUPDATE=yes instead in that case. 431 432 Default: Unset. 433 434 RELEASEDIR If set, specifies the directory to which a release(7) 435 layout will be written at the end of a ``make release''. 436 If specified, must be an absolute path. 437 438 Default: Unset. 439 440 Note: build.sh will provide a default of releasedir (in 441 the top-level .OBJDIR) unless run in `expert' mode. 442 443BUILDING 444 "make" command line options 445 This is not a summary of all the options available to make(1); only the 446 options used most frequently with NetBSD builds are listed here. 447 448 -j njob Run up to njob make(1) subjobs in parallel. Makefiles should 449 use .WAIT or have explicit dependencies as necessary to 450 enforce build ordering. 451 452 -m dir Specify the default directory for searching for system Make- 453 file segments, mainly the <bsd.*.mk> files. When building any 454 full NetBSD source tree, this should be set to the 455 ``share/mk'' directory in the source tree. This is set auto- 456 matically when building from the top level, or when using 457 build.sh. 458 459 -n Display the commands that would have been executed, but do not 460 actually execute them. This will still cause recursion to 461 take place. 462 463 -V var Print make(1)'s idea of the value of var. Does not build any 464 targets. 465 466 var=value Set the variable var to value, overriding any setting speci- 467 fied by the process environment, the MAKECONF configuration 468 file, or the system Makefile segments. 469 470 "make" targets 471 These default targets may be built by running make(1) in any subtree of 472 the NetBSD source code. It is recommended that none of these be used 473 from the top level Makefile; as a specific exception, ``make obj'' and 474 ``make cleandir'' are useful in that context. 475 476 all Build programs, libraries, and preformatted documentation. 477 478 clean Remove program and library object code files. 479 480 cleandir Same as clean, but also remove preformatted documentation, 481 dependency files generated by ``make depend'', and any other 482 files known to be created at build time. 483 484 depend Create dependency files (.depend) containing more detailed 485 information about the dependencies of source code on header 486 files. Allows programs to be recompiled automatically when a 487 dependency changes. 488 489 dependall Does a ``make depend'' immediately followed by a ``make all''. 490 This improves cache locality of the build since both passes 491 read the source files in their entirety. 492 493 distclean Synonym for cleandir. 494 495 includes Build and install system header files. Typically needed 496 before any system libraries or programs can be built. 497 498 install Install programs, libraries, and documentation into DESTDIR. 499 Few files will be installed to DESTDIR/dev, DESTDIR/etc, 500 DESTDIR/root or DESTDIR/var in order to prevent user supplied 501 configuration data from being overwritten. 502 503 lint Run lint(1) against the C source code, where appropriate, and 504 generate system-installed lint libraries. 505 506 obj Create object directories to be used for built files, instead 507 of building directly in the source tree. 508 509 tags Create ctags(1) searchable function lists usable by the ex(1) 510 and vi(1) text editors. 511 512 "make" targets for the top level 513 Additional make(1) targets are usable specifically from the top source 514 level to facilitate building the entire NetBSD source tree. 515 516 build Build the entire NetBSD system (except the kernel). This 517 orders portions of the source tree such that prerequisites 518 will be built in the proper order. 519 520 distribution Do a ``make build'', and then install a full distribution 521 (which does not include a kernel) into DESTDIR, including 522 files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and 523 DESTDIR/var. 524 525 buildworld As per ``make distribution'', except that it ensures that 526 DESTDIR is not the root directory. 527 528 installworld Install the distribution from DESTDIR to INSTALLWORLDDIR, 529 which defaults to the root directory. Ensures that 530 INSTALLWORLDDIR is not the root directory if cross compil- 531 ing. 532 533 The INSTALLSETS environment variable may be set to a list 534 of distribution sets to be installed. By default, all sets 535 except ``etc'' and ``xetc'' are installed, so most files in 536 INSTALLWORLDDIR/etc will not be installed or modified. 537 538 Note: Before performing this operation with 539 INSTALLWORLDDIR=/, it is highly recommended that you 540 upgrade your kernel and reboot. After performing this 541 operation, it is recommended that you use etcupdate(8) to 542 update files in INSTALLWORLDDIR/etc and that you use 543 postinstall(8) to check for inconsistencies (and possibly 544 to fix them). 545 546 sets Create distribution sets from DESTDIR into 547 RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run 548 after ``make distribution'', as ``make build'' alone does 549 not install all of the required files. 550 551 sourcesets Create source sets of the source tree into 552 RELEASEDIR/source/sets. 553 554 syspkgs Create syspkgs from DESTDIR into 555 RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run 556 after ``make distribution'', as ``make build'' alone does 557 not install all of the required files. 558 559 release Do a ``make distribution'', build kernels, distribution 560 media, and install sets (this as per ``make sets''), and 561 then package the system into a standard release layout as 562 described by release(7). This requires that RELEASEDIR be 563 set (see above). 564 565 iso-image Create a NetBSD installation CD-ROM image in the 566 RELEASEDIR/iso directory. The CD-ROM file system will have 567 a layout as described in release(7). 568 569 For most machine types, the CD-ROM will be bootable, and 570 will automatically run the sysinst(8) menu-based installa- 571 tion program, which can be used to install or upgrade a 572 NetBSD system. Bootable CD-ROMs also contain tools that 573 may be useful in repairing a damaged NetBSD installation. 574 575 Before ``make iso-image'' is attempted, RELEASEDIR must be 576 populated by ``make release'' or equivalent. 577 578 Note that other, smaller, CD-ROM images may be created in 579 the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc- 580 tory by ``make release''. These smaller images usually 581 contain the same tools as the larger images in 582 RELEASEDIR/iso, but do not contain additional content such 583 as the distribution sets. 584 585 Note that the mac68k port still uses an older method of 586 creating CD-ROM images. This requires the mkisofs(1) util- 587 ity, which is not part of NetBSD, but which can be 588 installed from pkgsrc/sysutils/cdrtools. 589 590 iso-image-source 591 Create a NetBSD installation CD-ROM image in the 592 RELEASEDIR/iso directory. The CD-ROM file system will have 593 a layout as described in release(7). It will have top 594 level directories for the machine type and source. 595 596 For most machine types, the CD-ROM will be bootable, and 597 will automatically run the sysinst(8) menu-based installa- 598 tion program, which can be used to install or upgrade a 599 NetBSD system. Bootable CD-ROMs also contain tools that 600 may be useful in repairing a damaged NetBSD installation. 601 602 Before ``make iso-image-source'' is attempted, RELEASEDIR 603 must be populated by ``make sourcesets release'' or equiva- 604 lent. 605 606 Note that other, smaller, CD-ROM images may be created in 607 the RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom direc- 608 tory by ``make release''. These smaller images usually 609 contain the same tools as the larger images in 610 RELEASEDIR/iso, but do not contain additional content such 611 as the distribution sets. 612 613 Note that the mac68k port still uses an older method of 614 creating CD-ROM images. This requires the mkisofs(1) util- 615 ity, which is not part of NetBSD, but which can be 616 installed from pkgsrc/sysutils/cdrtools. 617 618 regression-tests 619 Can only be run after building the regression tests in the 620 directory ``regress''. Runs those compiled regression 621 tests on the local host. Note that most tests are now man- 622 aged instead using atf(7); this target should probably run 623 those as well but currently does not. 624 625 The "build.sh" script 626 This script file is a Bourne shell script designed to build the entire 627 NetBSD system on any host with a Bourne shell in /bin/sh, including many 628 that are not POSIX compliant. Note that if a host system's /bin/sh is 629 unusually old and broken, the Korn Shell (/bin/ksh), if available, may be 630 a usable alternative. 631 632 All cross-compile builds, and most native builds, of the entire system 633 should make use of build.sh rather than just running ``make''. This way, 634 the make(1) program will be bootstrapped properly, in case the host sys- 635 tem has an older or incompatible ``make'' program. 636 637 When compiling the entire system via build.sh, many make(1) variables are 638 set for you in order to help encapsulate the build process. In the list 639 of options below, variables that are automatically set by build.sh are 640 noted where applicable. 641 642 The following operations are supported by build.sh: 643 644 build Build the system as per ``make build''. Before the main 645 part of the build commences, this command runs the obj 646 operation (unless the -o option is given), ``make 647 cleandir'' (unless the -u option is given), and the tools 648 operation. 649 650 distribution Build a full distribution as per ``make distribution''. 651 This command first runs the build operation. 652 653 release Build a full release as per ``make release''. This command 654 first runs the distribution operation. 655 656 makewrapper Create the nbmake-MACHINE wrapper. This operation is auto- 657 matically performed for any of the other operations. 658 659 cleandir Perform ``make cleandir''. 660 661 obj Perform ``make obj''. 662 663 tools Build and install the host tools from src/tools. This com- 664 mand will first run ``make obj'' and ``make cleandir'' in 665 the tools subdirectory unless the -o or -u options (respec- 666 tively) are given. 667 668 install=idir Install the contents of DESTDIR to idir, using ``make 669 installworld''. Note that files that are part of the 670 ``etc'' or ``xetc'' sets will not be installed. 671 672 kernel=kconf Build a new kernel. The kconf argument is the name of a 673 configuration file suitable for use by config(1). If kconf 674 does not contain any `/' characters, the configuration file 675 is expected to be found in the KERNCONFDIR directory, which 676 is typically sys/arch/MACHINE/conf. The new kernel will be 677 built in a subdirectory of KERNOBJDIR, which is typically 678 sys/arch/MACHINE/compile or an associated object directory. 679 680 This command does not imply the tools command; run the 681 tools command first unless it is certain that the tools 682 already exist and are up to date. 683 684 This command will run ``make cleandir'' on the kernel in 685 question first unless the -u option is given. 686 687 modules This command will build kernel modules and install them 688 into DESTDIR. 689 690 releasekernel=kconf 691 Install a gzip(1)ed copy of the kernel previously built by 692 kernel=kconf into 693 RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as 694 netbsd-kconf.gz, although the ``netbsd'' prefix is deter- 695 mined from the ``config'' directives in kconf. 696 697 sets Perform ``make sets''. 698 699 sourcesets Perform ``make sourcesets''. 700 701 syspkgs Perform ``make syspkgs''. 702 703 iso-image Perform ``make iso-image''. 704 705 iso-image-source 706 Perform ``make iso-image-source''. 707 708 The following command line options alter the behaviour of the build.sh 709 operations described above: 710 711 -a arch Set the value of MACHINE_ARCH to arch. 712 713 -B buildid 714 Set the value of BUILDID to buildid. This will also append the 715 build identifier to the name of the ``make'' wrapper script so 716 that the resulting name is of the form 717 ``nbmake-MACHINE-BUILDID''. 718 719 -C cdextras 720 Append cdextras to the CDEXTRA variable, which is a space-sepa- 721 rated list of files or directories that will be added to the 722 CD-ROM image that may be create by the ``iso-image'' or 723 ``iso-image-source'' operations. Files will be added to the 724 root of the CD-ROM image, whereas directories will be copied 725 recursively. If relative paths are specified, they will be 726 converted to absolute paths before being used. Multiple paths 727 may be specified via multiple -C options, or via a single 728 option whose argument contains multiple space-separated paths. 729 730 -D dest Set the value of DESTDIR to dest. If a relative path is speci- 731 fied, it will be converted to an absolute path before being 732 used. 733 734 -E Set `expert' mode. This overrides various sanity checks, and 735 allows: DESTDIR does not have to be set to a non-root path for 736 builds, and MKUNPRIVED=yes does not have to be set when build- 737 ing as a non-root user. 738 739 Note: It is highly recommended that you know what you are doing 740 when you use this option. 741 742 -h Print a help message. 743 744 -j njob Run up to njob make(1) subjobs in parallel; passed through to 745 make(1). If you see failures for reasons other than running 746 out of memory while using build.sh with -j, please save com- 747 plete build logs so the failures can be analyzed. 748 749 To achieve the fastest builds, -j values between (1 + the num- 750 ber of CPUs) and (2 * the number of CPUs) are recommended. Use 751 lower values on machines with limited memory or I/O bandwidth. 752 753 -M obj Set MAKEOBJDIRPREFIX to obj. Unsets MAKEOBJDIR. See ``-O 754 -obj'' for more information. 755 756 For instance, if the source directory is /usr/src, a setting of 757 ``-M /usr/obj'' will place build-time files under 758 /usr/obj/usr/src/bin, /usr/obj/usr/src/lib, 759 /usr/obj/usr/src/usr.bin, and so forth. 760 761 If a relative path is specified, it will be converted to an 762 absolute path before being used. build.sh imposes the restric- 763 tion that the argument to the -M option must not begin with a 764 ``$'' (dollar sign) character; otherwise it would be too diffi- 765 cult to determine whether the value is an absolute or a rela- 766 tive path. If the directory does not already exist, build.sh 767 will create it. 768 769 -m mach Set the value of MACHINE to mach, except in some special cases 770 listed below. This will also override any value of 771 MACHINE_ARCH in the process environment with a value deduced 772 from mach, unless -a is specified. All cross builds require 773 -m, but if unset on a NetBSD host, the host's value of MACHINE 774 will be detected and used automatically. 775 776 Some machines support multiple values for MACHINE_ARCH. The 777 following special cases for the mach argument are defined to 778 set the listed values of MACHINE and MACHINE_ARCH: 779 780 mach MACHINE MACHINE_ARCH 781 evbarm evbarm (not set) 782 evbarm-eb evbarm armeb 783 evbarm-el evbarm arm 784 evbmips evbmips (not set) 785 evbmips-eb evbmips mipseb 786 evbmips-el evbmips mipsel 787 evbsh3 evbsh3 (not set) 788 evbsh3-eb evbsh3 sh3eb 789 evbsh3-el evbsh3 sh3el 790 sbmips sbmips (not set) 791 sbmips-eb sbmips mipseb 792 sbmips-el sbmips mipsel 793 794 -N noiselevel 795 Set the ``noisyness'' level of the build, by setting 796 MAKEVERBOSE to noiselevel. 797 798 -n Show the commands that would be executed by build.sh, but do 799 not make any changes. This is similar in concept to ``make 800 -n''. 801 802 -O obj Create an appropriate transform macro for MAKEOBJDIR that will 803 place the built object files under obj. Unsets 804 MAKEOBJDIRPREFIX. 805 806 For instance, a setting of ``-O /usr/obj'' will place build- 807 time files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, 808 and so forth. 809 810 If a relative path is specified, it will be converted to an 811 absolute path before being used. build.sh imposes the restric- 812 tion that the argument to the -O option must not contain a 813 ``$'' (dollar sign) character. If the directory does not 814 already exist, build.sh will create it. 815 816 In normal use, exactly one of the -M or -O options should be 817 specified. If neither -M nor -O is specified, then a default 818 object directory will be chosen according to rules in 819 <bsd.obj.mk>. Relying on this default is not recommended 820 because it is determined by complex rules that are influenced 821 by the values of several variables and by the location of the 822 source directory. 823 824 -o Set the value of MKOBJDIRS to ``no''. Otherwise, it will be 825 automatically set to ``yes''. This default is opposite to the 826 behaviour when not using build.sh. 827 828 -R rel Set the value of RELEASEDIR to rel. If a relative path is 829 specified, it will be converted to an absolute path before 830 being used. 831 832 -r Remove the contents of DESTDIR and TOOLDIR before building 833 (provides a clean starting point). This will skip deleting 834 DESTDIR if building on a native system to the root directory. 835 836 -S seed Change the value of BUILDSEED to seed. This should rarely be 837 necessary. 838 839 -T tools Set the value of TOOLDIR to tools. If a relative path is spec- 840 ified, it will be converted to an absolute path before being 841 used. If set, the bootstrap ``make'' will only be rebuilt if 842 the source files for make(1) have changed. 843 844 -U Set MKUNPRIVED=yes. 845 846 -u Set MKUPDATE=yes. 847 848 -V var=[value] 849 Set the environment variable var to an optional value. This is 850 propagated to the nbmake wrapper. 851 852 -w wrapper 853 Create the nbmake wrapper script (see below) in a custom loca- 854 tion, specified by wrapper. This allows, for instance, to 855 place the wrapper in PATH automatically. Note that wrapper is 856 the full name of the file, not just a directory name. If a 857 relative path is specified, it will be converted to an absolute 858 path before being used. 859 860 -X x11src 861 Set the value of X11SRCDIR to x11src. If a relative path is 862 specified, it will be converted to an absolute path before 863 being used. 864 865 -x Set MKX11=yes. 866 867 -Z var Unset ("zap") the environment variable var. This is propagated 868 to the nbmake wrapper. 869 870 The "nbmake-MACHINE" wrapper script 871 If using the build.sh script to build NetBSD, a nbmake-MACHINE script 872 will be created in TOOLDIR/bin upon the first build to assist in building 873 subtrees on a cross-compile host. 874 875 nbmake-MACHINE can be invoked in lieu of make(1), and will instead call 876 the up-to-date version of ``nbmake'' installed into TOOLDIR/bin with sev- 877 eral key variables pre-set, including MACHINE, MACHINE_ARCH, and TOOLDIR. 878 nbmake-MACHINE will also set variables specified with -V, and unset vari- 879 ables specified with -Z. 880 881 This script can be symlinked into a directory listed in PATH, or called 882 with an absolute path. 883 884EXAMPLES 885 1. % ./build.sh [options] tools kernel=GENERIC 886 887 Build a new toolchain, and use the new toolchain to configure and 888 build a new GENERIC kernel. 889 890 2. % ./build.sh [options] -U distribution 891 892 Using unprivileged mode, build a complete distribution to a DESTDIR 893 directory that build.sh selects (and will display). 894 895 3. # ./build.sh [options] -U install=/ 896 897 As root, install to / the distribution that was built by example 2. 898 Even though this is run as root, -U is required so that the permis- 899 sions stored in DESTDIR/METALOG are correctly applied to the files 900 as they're copied to /. 901 902 4. % ./build.sh [options] -U -u release 903 904 Using unprivileged mode, build a complete release to DESTDIR and 905 RELEASEDIR directories that build.sh selects (and will display). 906 MKUPDATE=yes (-u) is set to prevent the ``make cleandir'', so that 907 if this is run after example 2, it doesn't need to redo that portion 908 of the release build. 909 910OBSOLETE VARIABLES 911 NBUILDJOBS Use the make(1) option -j instead. 912 913 USE_NEW_TOOLCHAIN 914 The new toolchain is now the default. To disable, use 915 TOOLCHAIN_MISSING=yes. 916 917SEE ALSO 918 make(1), hier(7), release(7), etcupdate(8), postinstall(8), sysinst(8), 919 pkgsrc/sysutils/cdrtools 920 921HISTORY 922 The build.sh based build scheme was introduced for NetBSD 1.6 as 923 USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that. 924 925NetBSD September 9, 2011 NetBSD 926