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