1.\" $NetBSD: BUILDING.mdoc,v 1.95 2013/12/24 20:10:29 uwe Exp $ 2.\" 3.\" Copyright (c) 2001-2011 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Todd Vierling and Luke Mewburn. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.\" NOTE: After changing this file, run "make regen" in the src/doc 31.\" directory, and check in both src/BUILDING and src/doc/BUILDING.mdoc. 32.\" 33.\" Toolchain prefix for commands 34.ds toolprefix nb 35. 36.Dd November 8, 2012 37.Dt BUILDING 8 38.Os NetBSD 39. 40.Sh NAME 41. 42.Nm BUILDING 43.Nd Procedure for building 44.Nx 45from source code. 46. 47.Sh REQUIREMENTS 48. 49.Nx 50is designed to be buildable on most POSIX-compliant host systems. 51The basic build procedure is the same whether compiling 52.Em natively 53(on the same 54.Nx 55architecture) or 56.Em cross compiling 57(on another architecture or OS). 58.Pp 59This source tree contains a special subtree, 60.Dq tools , 61which uses the host system to create a build toolchain for the target 62architecture. 63The host system must have at least C and C++ 64compilers in order to create the toolchain 65.Nm ( make 66is not required); all other tools are created as part of the 67.Nx 68build process. 69(See the environment variables section below if you need 70to override or manually select your compilers.) 71. 72.Sh FILES 73. 74.Ss Source tree layout 75. 76.Bl -tag -width "BUILDING.mdoc" 77.It Sy doc/BUILDING.mdoc 78This document (in -mdoc troff format; the original copy). 79.It Sy BUILDING 80This document (in plaintext). 81.It Sy tools/compat/README 82Special notes for cross-hosting a NetBSD build on non-NetBSD platforms. 83.It Sy Makefile 84The main Makefile for 85.Nx ; 86should only be run for native builds with an appropriately up-to-date 87version of 88.Nx 89.Xr make 1 . 90(For building from out-of-date systems or on a non-native host, see the 91.Nm build.sh 92shell script.) 93.It Sy UPDATING 94Special notes for updating from an earlier revision of 95.Nx . 96It is important to read this file before every build of an updated 97source tree. 98.It Sy build.sh 99Bourne-compatible shell script used for building the host build tools 100and the 101.Nx 102system from scratch. 103Can be used for both native and cross builds, and should be used instead of 104.Xr make 1 105for any source tree that is updated and recompiled regularly. 106.It Sy crypto/dist/ , dist/ , gnu/dist/ 107Sources imported verbatim from third parties, without mangling the 108existing build structure. 109Other source trees in 110.Sy bin 111through 112.Sy usr.sbin 113use the 114.Nx 115.Xr make 1 116.Dq reachover 117Makefile semantics when building these programs for a native host. 118.It Sy distrib/ , etc/ 119Sources for items used when making a full release snapshot, such as 120files installed in 121.Sy DESTDIR Ns Pa /etc 122on the destination system, boot media, and release notes. 123.It Sy tests/ , regress/ 124Regression test harness. 125Can be cross-compiled, but only run natively. 126.Pa tests/ 127uses the 128.Xr atf 7 129test framework; 130.Pa regress/ 131contains older tests that have not yet been migrated to 132.Xr atf 7 . 133.It Sy sys/ 134.Nx 135kernel sources. 136.It Sy tools/ 137.Dq Reachover 138build structure for the host build tools. 139This has a special method of determining out-of-date status. 140.It Sy bin/ ... usr.sbin/ 141Sources to the 142.Nx 143userland (non-kernel) programs. 144If any of these directories are missing, they will be skipped during the build. 145.It Sy x11/ 146.Dq Reachover 147build structure for X11R6; the source is in 148.Sy X11SRCDIR . 149.El 150. 151.Ss Build tree layout 152. 153The 154.Nx 155build tree is described in 156.Xr hier 7 , 157and the release layout is described in 158.Xr release 7 . 159. 160.Sh CONFIGURATION 161. 162.Ss Environment variables 163. 164Several environment variables control the behaviour of 165.Nx 166builds. 167. 168.Bl -tag -width "MAKEOBJDIRPREFIX" 169. 170. 171.It Sy HOST_SH 172Path name to a shell available on the host system 173and suitable for use during the build. 174The 175.Nx 176build system requires a modern Bourne-like shell 177with POSIX-compliant features, 178and also requires support for the 179.Dq local 180keyword to declare local variables in shell functions 181(which is a widely-implemented but non-standardised feature). 182.Pp 183Depending on the host system, a suitable shell may be 184.Pa /bin/sh , 185.Pa /usr/xpg4/bin/sh , 186.Pa /bin/ksh 187(provided it is a variant of ksh that supports the 188.Dq local 189keyword, 190such as ksh88, but not ksh93), 191or 192.Pa /usr/local/bin/bash . 193.Pp 194Most parts of the build require 195.Sy HOST_SH 196to be an absolute path; however, 197.Nm build.sh 198allows it to be a simple command name, which will be converted 199to an absolute path by searching the 200.Sy PATH . 201. 202.It Sy HOST_CC 203Path name to C compiler used to create the toolchain. 204. 205.It Sy HOST_CXX 206Path name to C++ compiler used to create the toolchain. 207. 208.It Sy MACHINE 209Machine type, e.g., 210.Dq macppc . 211. 212.It Sy MACHINE_ARCH 213Machine architecture, e.g., 214.Dq powerpc . 215. 216.It Sy MAKE 217Path name to invoke 218.Xr make 1 219as. 220. 221.It Sy MAKEFLAGS 222Flags to invoke 223.Xr make 1 224with. 225Note that 226.Sy build.sh 227ignores the value of 228.Sy MAKEFLAGS 229passed in the environment, but allows 230.Sy MAKEFLAGS 231to be set via the 232.Fl V 233option. 234. 235.It Sy MAKEOBJDIR 236Directory to use as the 237.Sy .OBJDIR 238for the current directory. 239The value is subjected to variable expansion by 240.Xr make 1 . 241Typical usage is to set this variable to a value involving the use of 242.Sq ${.CURDIR:S...} 243or 244.Sq ${.CURDIR:C...} , 245to derive the value of 246.Sy .OBJDIR 247from the value of 248.Sy .CURDIR . 249Used only if 250.Sy MAKEOBJDIRPREFIX 251is not defined. 252.Sy MAKEOBJDIR 253can be provided only in the environment or via the 254.Fl O 255flag of 256.Nm build.sh ; 257it cannot usefully be set inside a Makefile, including 258.Pa mk.conf 259or 260.Sy ${MAKECONF} . 261. 262.It Sy MAKEOBJDIRPREFIX 263Top level directory of the object directory tree. 264The value is subjected to variable expansion by 265.Xr make 1 . 266.Sy build.sh 267will create the 268${MAKEOBJDIRPREFIX} 269directory if necessary, but if 270.Xr make 1 271is used without 272.Sy build.sh , 273then rules in 274.Aq bsd.obj.mk 275will abort the build if the 276${MAKEOBJDIRPREFIX} 277directory does not exist. 278If the value is defined and valid, then 279${MAKEOBJDIRPREFIX}/${.CURDIR} 280is used as the 281.Sy .OBJDIR 282for the current directory. 283The current directory may be read only. 284.Sy MAKEOBJDIRPREFIX 285can be provided only in the environment or via the 286.Fl M 287flag of 288.Nm build.sh ; 289it cannot usefully be set inside a Makefile, including 290.Pa mk.conf 291or 292.Sy ${MAKECONF} . 293. 294.El 295. 296.Ss \*qmake\*q variables 297. 298.de YorN 299Can be set to 300.Dq yes 301or 302.Dq no . 303.. 304.de DFLT 305.Pp 306.Em Default : 307.. 308.de DFLTu 309.DFLT 310Unset. 311.. 312.de DFLTy 313.DFLT 314.Dq yes 315.. 316.de DFLTn 317.DFLT 318.Dq no 319.. 320Several variables control the behavior of 321.Nx 322builds. 323Unless otherwise specified, these variables may be set in 324either the process environment or the 325.Xr make 1 326configuration file specified by 327.Sy MAKECONF . 328. 329.Bl -tag -width "MKCATPAGES" 330. 331.It Sy BUILDID 332Identifier for the build. 333The identifier will be appended to 334object directory names, and can be consulted in the 335.Xr make 1 336configuration file in order to set additional build parameters, 337such as compiler flags. 338. 339.It Sy BUILDSEED 340GCC uses random numbers when compiling C++ code. 341This variable seeds the gcc random number generator using 342the -frandom-seed flag with this value. 343By default, it is set to NetBSD-(majorversion). 344Using a fixed value causes C++ binaries to be the same when 345built from the same sources, resulting in identical (reproducible) builds. 346Additional information is available in the GCC 347documentation of -frandom-seed. 348. 349.It Sy DESTDIR 350Directory to contain the built 351.Nx 352system. 353If set, special options are passed to the compilation tools to 354prevent their default use of the host system's 355.Sy /usr/include , /usr/lib , 356and so forth. 357This pathname must be an absolute path, and should 358.Em not 359end with a slash 360.Pq / 361character. 362(For installation into the system's root directory, set 363.Sy DESTDIR 364to an empty string, not to 365.Dq / ) . 366The directory must reside on a file system which supports long file 367names and hard links. 368.DFLT 369Empty string if 370.Sy USETOOLS 371is 372.Dq yes ; 373unset otherwise. 374.Pp 375.Em Note : 376.Sy build.sh 377will provide a default of 378.Pa destdir. Ns Sy MACHINE 379(in the top-level 380.Sy .OBJDIR ) 381unless run in 382.Sq expert 383mode. 384. 385.It Sy MAKECONF 386The name of the 387.Xr make 1 388configuration file. 389.Em Only settable in the process environment. 390.DFLT 391.Dq /etc/mk.conf 392. 393.It Sy MAKEVERBOSE 394Level of verbosity of status messages. 395Supported values: 396.Bl -tag -width xxx 397.It 0 398No descriptive messages or commands executed by 399.Xr make 1 400are shown. 401.It 1 402Brief messages are shown describing what is being done, 403but the actual commands executed by 404.Xr make 1 405are not displayed. 406.It 2 407Descriptive messages are shown as above (prefixed with a 408.Sq # ) , 409and ordinary commands performed by 410.Xr make 1 411are displayed. 412.It 3 413In addition to the above, all commands performed by 414.Xr make 1 415are displayed, even if they would ordinarily have been hidden 416through use of the 417.Dq \&@ 418prefix in the relevant makefile. 419.It 4 420In addition to the above, commands executed by 421.Xr make 1 422are traced through use of the 423.Xr sh 1 424.Dq Fl x 425flag. 426.El 427.DFLT 4282 429. 430.It Sy MKCATPAGES 431.YorN 432Indicates whether preformatted plaintext manual pages will be created 433during a build. 434.DFLTn 435. 436.It Sy MKCRYPTO 437.YorN 438Indicates whether cryptographic code will be included in a build; 439provided for the benefit of countries that do not allow strong 440cryptography. 441Will not affect use of the standard low-security password encryption system, 442.Xr crypt 3 . 443.DFLTy 444. 445.It Sy MKDOC 446.YorN 447Indicates whether system documentation destined for 448.Sy DESTDIR Ns Pa /usr/share/doc 449will be installed during a build. 450.DFLTy 451. 452.It Sy MKHTML 453.YorN 454Indicates whether preformatted HTML manual pages will be built 455and installed 456.DFLTy 457. 458.It Sy MKHOSTOBJ 459.YorN 460If set to 461.Dq yes , 462then for programs intended to be run on the compile host, 463the name, release, and architecture of the host operating system 464will be suffixed to the name of the object directory created by 465.Dq make obj . 466(This allows multiple host systems to compile NetBSD for a single target.) 467If set to 468.Dq no , 469then programs built to be run on the compile host will use the same 470object directory names as programs built to be run on the target. 471.DFLTn 472. 473.It Sy MKINFO 474.YorN 475Indicates whether GNU Info files, used for the documentation for 476most of the compilation tools, will be created and installed during a 477build. 478.DFLTy 479. 480.It Sy MKKMOD 481.YorN 482Indicates whether kernel modules are built and installed. 483.DFLTy 484. 485.It Sy MKLINT 486.YorN 487Indicates whether 488.Xr lint 1 489will be run against portions of the 490.Nx 491source code during the build, and whether lint libraries will be 492installed into 493.Sy DESTDIR Ns Pa /usr/libdata/lint . 494.DFLTy 495. 496.It Sy MKMAN 497.YorN 498Indicates whether manual pages will be installed during a build. 499.DFLTy 500. 501.It Sy MKNLS 502.YorN 503Indicates whether Native Language System locale zone files will be 504compiled and installed during a build. 505.DFLTy 506. 507.It Sy MKOBJ 508.YorN 509Indicates whether object directories will be created when running 510.Dq make obj . 511If set to 512.Dq no , 513then all built files will be located inside the regular source tree. 514.DFLTy 515.Pp 516Note that setting 517.Sy MKOBJ 518to 519.Dq no 520is not recommended and may cause problems when updating the tree with 521.Xr cvs 1 . 522. 523.It Sy MKPIC 524.YorN 525Indicates whether shared objects and libraries will be created and 526installed during a build. 527If set to 528.Dq no , 529the entire built system will be statically linked. 530.DFLT 531Platform dependent. 532As of this writing, all platforms except 533.Sy sh3 534default to 535.Dq yes . 536. 537.It Sy MKPICINSTALL 538.YorN 539Indicates whether the 540.Xr ar 1 541format libraries 542.Sy ( lib*_pic.a ) , 543used to generate shared libraries, are installed during a build. 544.DFLTy 545. 546.It Sy MKPROFILE 547.YorN 548Indicates whether profiled libraries 549.Sy ( lib*_p.a ) 550will be built and installed during a build. 551.DFLT 552.Dq yes ; 553however, some platforms turn off 554.Sy MKPROFILE 555by default at times due to toolchain problems with profiled code. 556. 557.It Sy MKREPRO 558.YorN 559Create reproducable builds. 560This enables different switches to make two builds from the same 561source tree result in the same build results. 562.DFLTn 563. 564.It Sy MKSHARE 565.YorN 566Indicates whether files destined to reside in 567.Sy DESTDIR Ns Pa /usr/share 568will be built and installed during a build. 569If set to 570.Dq no , 571then all of 572.Sy MKCATPAGES , MKDOC , MKINFO , MKMAN , 573and 574.Sy MKNLS 575will be set to 576.Dq no 577unconditionally. 578.DFLTy 579. 580.It Sy MKSTRIPIDENT 581.YorN 582Indicates whether RCS IDs, for use with 583.Xr ident 1 , 584should be stripped from program binaries and shared libraries. 585.DFLTn 586. 587.It Sy MKUNPRIVED 588.YorN 589Indicates whether an unprivileged install will occur. 590The user, group, permissions, and file flags, will not be set on 591the installed items; instead the information will be appended to 592a file called 593.Pa METALOG 594in 595.Sy DESTDIR . 596The contents of 597.Pa METALOG 598are used during the generation of the distribution tar files to ensure 599that the appropriate file ownership is stored. 600.DFLTn 601. 602.It Sy MKUPDATE 603.YorN 604Indicates whether all install operations intended to write to 605.Sy DESTDIR 606will compare file timestamps before installing, and skip the install 607phase if the destination files are up-to-date. 608This also has implications on full builds (see next subsection). 609.DFLTn 610. 611.It Sy MKX11 612.YorN 613Indicates whether X11 is built from 614.Sy X11SRCDIR . 615.DFLTn 616. 617.It Sy TOOLDIR 618Directory to hold the host tools, once built. 619If specified, must be an absolute path. 620This directory should be unique to a given host system and 621.Nx 622source tree. 623(However, multiple targets may share the same 624.Sy TOOLDIR ; 625the target-dependent files have unique names.) If unset, a default based 626on the 627.Xr uname 1 628information of the host platform will be created in the 629.Sy .OBJDIR 630of 631.Pa src . 632.DFLTu 633. 634.It Sy USETOOLS 635Indicates whether the tools specified by 636.Sy TOOLDIR 637should be used as part of a build in progress. 638Must be set to 639.Dq yes 640if cross-compiling. 641.Bl -tag -width "never" 642.It Sy yes 643Use the tools from 644.Sy TOOLDIR . 645.It Sy no 646Do not use the tools from 647.Sy TOOLDIR , 648but refuse to build native compilation tool components that are 649version-specific for that tool. 650.It Sy never 651Do not use the tools from 652.Sy TOOLDIR , 653even when building native tool components. 654This is similar to the traditional 655.Nx 656build method, but does 657.Em not 658verify that the compilation tools in use are up-to-date enough in order 659to build the tree successfully. 660This may cause build or runtime problems when building the whole 661.Nx 662source tree. 663.El 664.DFLT 665.Dq yes , 666unless 667.Sy TOOLCHAIN_MISSING 668is set to 669.Dq yes . 670.Pp 671.Sy USETOOLS 672is also set to 673.Dq no 674when using 675.Aq bsd.*.mk 676outside the 677.Nx 678source tree. 679. 680.It Sy X11SRCDIR 681Directory containing the X11R6 source. 682If specified, must be an absolute path. 683The main X11R6 source is found in 684.Sy X11SRCDIR Ns Pa /xfree/xc . 685.DFLT 686.Sy NETBSDRCDIR Ns Pa /../xsrc , 687if that exists; otherwise 688.Pa /usr/xsrc . 689. 690.It Sy X11FLAVOUR 691The style of X11 cross-built, set to either 692.Dq Xorg 693or 694.Dq XFree86 . 695.DFLT 696.Dq Xorg 697on amd64, i386, macppc, shark and sparc64 platforms, 698.Dq XFree86 699on everything else. 700. 701.El 702. 703.Ss \*qmake\*q variables for full builds 704These variables only affect the top level 705.Dq Makefile 706and do not affect manually building subtrees of the 707.Nx 708source code. 709. 710.Bl -tag -width "INSTALLWORLDDIR" 711. 712.It Sy INSTALLWORLDDIR 713Location for the 714.Dq make installworld 715target to install to. 716If specified, must be an absolute path. 717.DFLT 718.Dq / 719. 720.It Sy MKOBJDIRS 721.YorN 722Indicates whether object directories will be created automatically 723(via a 724.Dq make obj 725pass) at the start of a build. 726.DFLTn 727.Pp 728If using 729.Sy build.sh , 730the default is 731.Dq yes . 732This may be set back to 733.Dq no 734by giving 735.Sy build.sh 736the 737.Fl o 738option. 739. 740.It Sy MKUPDATE 741.YorN 742If set, then in addition to the effects described for 743.Sy MKUPDATE=yes 744above, this implies the effects of 745.Sy NOCLEANDIR 746(i.e., 747.Dq make cleandir 748is avoided). 749.DFLTn 750.Pp 751If using 752.Sy build.sh , 753this may be set by giving the 754.Fl u 755option. 756. 757.It Sy NBUILDJOBS 758Now obsolete. 759Use the 760.Xr make 1 761option 762.Fl j , 763instead. 764See below. 765.DFLTu 766. 767.It Sy NOCLEANDIR 768If set, avoids the 769.Dq make cleandir 770phase of a full build. 771This has the effect of allowing only changed 772files in a source tree to be recompiled. 773This can speed up builds when updating only a few files in the tree. 774.DFLTu 775.Pp 776See also 777.Sy MKUPDATE . 778. 779.It Sy NODISTRIBDIRS 780If set, avoids the 781.Dq make distrib-dirs 782phase of a full build. 783This skips running 784.Xr mtree 8 785on 786.Sy DESTDIR , 787useful on systems where building as an unprivileged user, or where it is 788known that the system-wide mtree files have not changed. 789.DFLTu 790. 791.It Sy NOINCLUDES 792If set, avoids the 793.Dq make includes 794phase of a full build. 795This has the effect of preventing 796.Xr make 1 797from thinking that some programs are out-of-date simply because the 798system include files have changed. 799However, this option should not be used when updating the entire 800.Nx 801source tree arbitrarily; it is suggested to use 802.Sy MKUPDATE=yes 803instead in that case. 804.DFLTu 805. 806.It Sy RELEASEDIR 807If set, specifies the directory to which a 808.Xr release 7 809layout will be written at the end of a 810.Dq make release . 811If specified, must be an absolute path. 812.DFLTu 813.Pp 814.Em Note : 815.Sy build.sh 816will provide a default of 817.Pa releasedir 818(in the top-level 819.Sy .OBJDIR ) 820unless run in 821.Sq expert 822mode. 823. 824.El 825. 826.Sh BUILDING 827. 828.Ss \*qmake\*q command line options 829This is not a summary of all the options available to 830.Xr make 1 ; 831only the options used most frequently with 832.Nx 833builds are listed here. 834. 835.Bl -tag -width "var=value" 836. 837.It Fl j Ar njob 838Run up to 839.Ar njob 840.Xr make 1 841subjobs in parallel. 842Makefiles should use .WAIT or have explicit dependencies 843as necessary to enforce build ordering. 844. 845.It Fl m Ar dir 846Specify the default directory for searching for system Makefile 847segments, mainly the 848.Aq bsd.*.mk 849files. 850When building any full 851.Nx 852source tree, this should be set to the 853.Dq share/mk 854directory in the source tree. 855This is set automatically when building from the top level, or when using 856.Sy build.sh . 857. 858.It Fl n 859Display the commands that would have been executed, but do not 860actually execute them. 861This will still cause recursion to take place. 862. 863.It Fl V Ar var 864Print 865.Xr make 1 Ns 's 866idea of the value of 867.Ar var . 868Does not build any targets. 869. 870.It Em var=value 871Set the variable 872.Em var 873to 874.Em value , 875overriding any setting specified by the process environment, the 876.Sy MAKECONF 877configuration file, or the system Makefile segments. 878. 879.El 880. 881.Ss \*qmake\*q targets 882. 883These default targets may be built by running 884.Xr make 1 885in any subtree of the 886.Nx 887source code. 888It is recommended that none of these be used from the top 889level Makefile; as a specific exception, 890.Dq make obj 891and 892.Dq make cleandir 893are useful in that context. 894. 895.Bl -tag -width "dependall" 896. 897.It Sy all 898Build programs, libraries, and preformatted documentation. 899. 900.It Sy clean 901Remove program and library object code files. 902. 903.It Sy cleandir 904Same as 905.Sy clean , 906but also remove preformatted documentation, dependency files generated 907by 908.Dq make depend , 909and any other files known to be created at build time. 910. 911.It Sy depend 912Create dependency files 913.Sy ( .depend ) 914containing more detailed information about the dependencies of source 915code on header files. 916Allows programs to be recompiled automatically when a dependency changes. 917. 918.It Sy dependall 919Does a 920.Dq make depend 921immediately followed by a 922.Dq make all . 923This improves cache locality of the build since both passes read the source 924files in their entirety. 925. 926.It Sy distclean 927Synonym for 928.Sy cleandir . 929. 930.It Sy includes 931Build and install system header files. 932Typically needed before any system libraries or programs can be built. 933. 934.It Sy install 935Install programs, libraries, and documentation into 936.Sy DESTDIR . 937Few files will be installed to 938.Sy DESTDIR Ns Pa /dev , 939.Sy DESTDIR Ns Pa /etc , 940.Sy DESTDIR Ns Pa /root 941or 942.Sy DESTDIR Ns Pa /var 943in order to prevent user supplied configuration data from being overwritten. 944.It Sy lint 945Run 946.Xr lint 1 947against the C source code, where appropriate, and generate 948system-installed lint libraries. 949. 950.It Sy obj 951Create object directories to be used for built files, instead of 952building directly in the source tree. 953. 954.It Sy tags 955Create 956.Xr ctags 1 957searchable function lists usable by the 958.Xr ex 1 959and 960.Xr vi 1 961text editors. 962. 963.El 964. 965.Ss \*qmake\*q targets for the top level 966. 967Additional 968.Xr make 1 969targets are usable specifically from the top source level to facilitate 970building the entire 971.Nx 972source tree. 973. 974.Bl -tag -width "distribution" 975. 976.It Sy build 977Build the entire 978.Nx 979system (except the kernel). 980This orders portions of the source tree such that prerequisites 981will be built in the proper order. 982. 983.It Sy distribution 984Do a 985.Dq make build , 986and then install a full distribution (which does not include a kernel) into 987.Sy DESTDIR , 988including files in 989.Sy DESTDIR Ns Pa /dev , 990.Sy DESTDIR Ns Pa /etc , 991.Sy DESTDIR Ns Pa /root 992and 993.Sy DESTDIR Ns Pa /var . 994. 995.It Sy buildworld 996As per 997.Dq make distribution , 998except that it ensures that 999.Sy DESTDIR 1000is not the root directory. 1001. 1002.It Sy installworld 1003Install the distribution from 1004.Sy DESTDIR 1005to 1006.Sy INSTALLWORLDDIR , 1007which defaults to the root directory. 1008Ensures that 1009.Sy INSTALLWORLDDIR 1010is not the root directory if cross compiling. 1011.Pp 1012The 1013.Sy INSTALLSETS 1014environment variable may be set to a space-separated list of 1015distribution sets to be installed. 1016By default, all sets except 1017.Dq etc 1018and 1019.Dq xetc 1020are installed, so most files in 1021.Sy INSTALLWORLDDIR Ns Pa /etc 1022will not be installed or modified. 1023.Pp 1024.Em Note : 1025Before performing this operation with 1026.Sy INSTALLWORLDDIR Ns = Ns Pa / , 1027it is highly recommended that you upgrade your kernel and reboot. 1028After performing this operation, 1029it is recommended that you use 1030.Xr etcupdate 8 1031to update files in 1032.Sy INSTALLWORLDDIR Ns Pa /etc , 1033and 1034.Xr postinstall 8 1035to check for or fix inconsistencies. 1036.It Sy sets 1037Create distribution sets from 1038.Sy DESTDIR 1039into 1040.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/sets . 1041Should be run after 1042.Dq make distribution , 1043as 1044.Dq make build 1045alone does not install all of the required files. 1046. 1047.It Sy sourcesets 1048Create source sets of the source tree into 1049.Sy RELEASEDIR Ns Pa /source/sets . 1050. 1051.It Sy syspkgs 1052Create syspkgs from 1053.Sy DESTDIR 1054into 1055.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/syspkgs . 1056Should be run after 1057.Dq make distribution , 1058as 1059.Dq make build 1060alone does not install all of the required files. 1061. 1062.It Sy release 1063Do a 1064.Dq make distribution , 1065build kernels, distribution media, and install sets 1066(this as per 1067.Dq make sets ) , 1068and 1069then package the system into a standard release layout as described by 1070.Xr release 7 . 1071This requires that 1072.Sy RELEASEDIR 1073be set (see above). 1074. 1075.It Sy iso-image 1076Create a 1077.Nx 1078installation CD-ROM image in the 1079.Sy RELEASEDIR Ns Pa /iso 1080directory. 1081The CD-ROM file system will have a layout as described in 1082.Xr release 7 . 1083.Pp 1084For most machine types, the CD-ROM will be bootable, and will automatically 1085run the 1086.Xr sysinst 8 1087menu-based installation program, which can be used to install or upgrade a 1088.Nx 1089system. 1090Bootable CD-ROMs also contain tools that may be useful in 1091repairing a damaged 1092.Nx 1093installation. 1094.Pp 1095Before 1096.Dq make iso-image 1097is attempted, RELEASEDIR must be populated by 1098.Dq make release 1099or equivalent. 1100.Pp 1101Note that other, smaller, CD-ROM images may be created in the 1102.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /installation/cdrom 1103directory by 1104.Dq "make release" . 1105These smaller images usually contain the same tools as the larger images in 1106.Sy RELEASEDIR Ns Pa /iso , 1107but do not contain additional content such as the distribution sets. 1108.Pp 1109Note that the mac68k port still uses an older method of creating 1110CD-ROM images. 1111This requires the 1112.Xr mkisofs 1 1113utility, which is not part of 1114.Nx , 1115but which can be installed from 1116.Pa pkgsrc/sysutils/cdrtools . 1117. 1118.It Sy iso-image-source 1119Create a 1120.Nx 1121installation CD-ROM image in the 1122.Sy RELEASEDIR Ns Pa /iso 1123directory. 1124The CD-ROM file system will have a layout as described in 1125.Xr release 7 . 1126It will have top level directories for the machine type and source. 1127.Pp 1128For most machine types, the CD-ROM will be bootable, and will automatically 1129run the 1130.Xr sysinst 8 1131menu-based installation program, which can be used to install or upgrade a 1132.Nx 1133system. 1134Bootable CD-ROMs also contain tools that may be useful in 1135repairing a damaged 1136.Nx 1137installation. 1138.Pp 1139Before 1140.Dq make iso-image-source 1141is attempted, RELEASEDIR must be populated by 1142.Dq make sourcesets release 1143or equivalent. 1144.Pp 1145Note that other, smaller, CD-ROM images may be created in the 1146.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /installation/cdrom 1147directory by 1148.Dq make release . 1149These smaller images usually contain the same tools as the larger images in 1150.Sy RELEASEDIR Ns Pa /iso , 1151but do not contain additional content such as the distribution sets. 1152.Pp 1153Note that the mac68k port still uses an older method of creating 1154CD-ROM images. 1155This requires the 1156.Xr mkisofs 1 1157utility, which is not part of 1158.Nx , 1159but which can be installed from 1160.Pa pkgsrc/sysutils/cdrtools . 1161. 1162.It Sy install-image 1163Create a bootable 1164.Nx 1165installation disk image in the 1166.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /installation/installimage 1167directory. 1168The installation disk image is suitable for copying to 1169bootable USB flash memory sticks, etc., for machines which 1170are able to boot from such devices. 1171The file system in the bootable disk image will have a layout 1172as described in 1173.Xr release 7 . 1174.Pp 1175The installation image is bootable, and will automatically 1176run the 1177.Xr sysinst 8 1178menu-based installation program, which can be used to install or upgrade a 1179.Nx 1180system. 1181The image also contains tools that may be 1182useful in repairing a damaged 1183.Nx 1184installation. 1185.Pp 1186Before 1187.Dq make install-image 1188is attempted, 1189.Sy RELEASEDIR 1190must be populated by 1191.Dq make release 1192or equivalent. 1193The build must have been performed with 1194.Sy MKUNPRIVED=yes 1195because 1196.Dq make install-image 1197relies on information in 1198.Sy DESTDIR Ns Pa /METALOG . 1199. 1200.It live-image 1201Create 1202.Nx 1203live images in the 1204.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /installation/liveimage 1205directory. 1206The live image contains all necessary files 1207to boot 1208.Nx 1209up to multi-user mode, including all files 1210which should be extracted during installation, 1211.Nx 1212disklabel, bootloaders, etc. 1213.Pp 1214The live image is suitable for use as a disk image in 1215virtual machine environments such as QEMU, 1216and also useful to boot 1217.Nx 1218from a USB flash memory stick 1219on a real machine, without the need for installation. 1220.Pp 1221Before 1222.Dq make live-image 1223is attempted, RELEASEDIR must be populated by 1224.Dq make release 1225or equivalent. 1226The build must have been performed with 1227.Sy MKUNPRIVED=yes 1228because 1229.Dq make install-image 1230relies on information in 1231.Sy DESTDIR Ns Pa /METALOG . 1232. 1233.It Sy regression-tests 1234Can only be run after building the regression tests in the directory 1235.Dq regress . 1236Runs those compiled regression tests on the local host. 1237Note that most tests are now managed instead using 1238.Xr atf 7 ; 1239this target should probably run those as well but currently does not. 1240. 1241.El 1242. 1243.Ss The \*qbuild.sh\*q script 1244. 1245This script file is a shell script designed to build the 1246entire 1247.Nx 1248system on any host with a suitable modern shell and some common 1249utilities. 1250The required shell features are described under the 1251.Sy HOST_SH 1252variable. 1253.Pp 1254If a host system's default shell does support the required 1255features, then we suggest that you explicitly specify 1256a suitable shell using a command like 1257.Bd -unfilled -offset indent 1258.Li /path/to/suitable/shell build.sh Op Ar options 1259.Ed 1260.Pp 1261The above command will usually enable 1262.Nm build.sh 1263to automatically set 1264.Sy HOST_SH Ns Cm = Ns Pa /path/to/suitable/shell , 1265but if that fails, then the following set of commands may be used instead: 1266.Bd -unfilled -offset indent 1267.Li HOST_SH= Ns Va /path/to/suitable/shell 1268.Li export HOST_SH 1269.Li ${HOST_SH} build.sh Op Ar options 1270.Ed 1271.Pp 1272If 1273.Sy build.sh 1274detects that it is being executed under an unsuitable shell, it attempts 1275to exec a suitable shell instead, or prints an error message. 1276If 1277.Sy HOST_SH 1278is not set explicitly, then 1279.Nm build.sh 1280sets a default using heuristics dependent on the host platform, 1281or from the shell under which 1282.Nm build.sh 1283is executed (if that can be determined), 1284or using the first copy of 1285.Pa sh 1286found in 1287.Sy PATH . 1288.Pp 1289All cross-compile builds, and most native builds, of the entire system 1290should make use of 1291.Sy build.sh 1292rather than just running 1293.Dq make . 1294This way, the 1295.Xr make 1 1296program will be bootstrapped properly, in case the host system has an 1297older or incompatible 1298.Dq make 1299program. 1300.Pp 1301When compiling the entire system via 1302.Sy build.sh , 1303many 1304.Xr make 1 1305variables are set for you in order to help encapsulate the build 1306process. 1307In the list of options below, variables that are automatically set by 1308.Sy build.sh 1309are noted where applicable. 1310. 1311.Pp 1312The following operations are supported by 1313.Sy build.sh : 1314. 1315.Bl -tag -width "distribution" 1316. 1317.It Sy build 1318Build the system as per 1319.Dq make build . 1320Before the main part of the build commences, this command runs the 1321.Sy obj 1322operation (unless the 1323.Fl o 1324option is given), 1325.Dq make cleandir 1326(unless the 1327.Fl u 1328option is given), 1329and the 1330.Sy tools 1331operation. 1332. 1333.It Sy distribution 1334Build a full distribution as per 1335.Dq make distribution . 1336This command first runs the 1337.Sy build 1338operation. 1339. 1340.It Sy release 1341Build a full release as per 1342.Dq make release . 1343This command first runs the 1344.Sy distribution 1345operation. 1346. 1347.It Sy makewrapper 1348Create the 1349.Sy \*[toolprefix]make-MACHINE 1350wrapper. 1351This operation is automatically performed for any of the other 1352operations. 1353. 1354.It Sy cleandir 1355Perform 1356.Dq make cleandir . 1357. 1358.It Sy obj 1359Perform 1360.Dq make obj . 1361. 1362.It Sy tools 1363Build and install the host tools from 1364.Pa src/tools . 1365This command will first run 1366.Dq make obj 1367and 1368.Dq make cleandir 1369in the 1370.Pa tools 1371subdirectory unless the 1372.Fl o 1373or 1374.Fl u 1375options (respectively) are given. 1376. 1377.It Sy install Ns = Ns Ar idir 1378Install the contents of 1379.Sy DESTDIR 1380to 1381.Ar idir , 1382using 1383.Dq make installworld . 1384Note that files that are part of the 1385.Dq etc 1386or 1387.Dq xetc 1388sets will not be installed, unless overridden by 1389the INSTALLSETS environment variable. 1390. 1391.It Sy kernel Ns = Ns Ar kconf 1392Build a new kernel. 1393The 1394.Ar kconf 1395argument is the name of a configuration file suitable 1396for use by 1397.Xr config 1 . 1398If 1399.Ar kconf 1400does not contain any 1401.Sq / 1402characters, the configuration file is expected to be found in the 1403.Sy KERNCONFDIR 1404directory, which is typically 1405.Sy sys/arch/MACHINE/conf . 1406The new kernel will be built in a subdirectory of 1407.Sy KERNOBJDIR , 1408which is typically 1409.Sy sys/arch/MACHINE/compile 1410or an associated object directory. 1411.Pp 1412This command does 1413.Em not 1414imply the 1415.Sy tools 1416command; run the 1417.Sy tools 1418command first unless it is 1419.Em certain 1420that the tools already exist and are up to date. 1421.Pp 1422This command will run 1423.Dq make cleandir 1424on the kernel in question first unless the 1425.Fl u 1426option is given. 1427. 1428.It Sy modules 1429This command will build kernel modules and install them into 1430.Sy DESTDIR . 1431. 1432.It Sy releasekernel Ns = Ns Ar kconf 1433Install a 1434.Xr gzip 1 Ns ed 1435copy of the kernel previously built by 1436.Sy kernel Ns = Ns Ar kconf 1437into 1438.Sy RELEASEDIR/RELEASEMACHINEDIR Ns Pa /binary/kernel , 1439usually as 1440.Pa netbsd- Ns Ar kconf Ns Pa .gz , 1441although the 1442.Dq Pa netbsd 1443prefix is determined from the 1444.Dq Sy config 1445directives in 1446.Ar kconf . 1447. 1448.It Sy sets 1449Perform 1450.Dq make sets . 1451. 1452.It Sy sourcesets 1453Perform 1454.Dq make sourcesets . 1455. 1456.It Sy syspkgs 1457Perform 1458.Dq make syspkgs . 1459. 1460.It Sy iso-image 1461Perform 1462.Dq make iso-image . 1463. 1464.It Sy iso-image-source 1465Perform 1466.Dq make iso-image-source . 1467. 1468.It Sy install-image 1469Perform 1470.Dq make install-image . 1471. 1472.It Sy live-image 1473Perform 1474.Dq make live-image . 1475. 1476.El 1477. 1478.Pp 1479The following command line options alter the behaviour of the 1480.Sy build.sh 1481operations described above: 1482. 1483.Bl -tag -width "-T tools" 1484. 1485.It Fl a Ar arch 1486Set the value of 1487.Sy MACHINE_ARCH 1488to 1489.Ar arch . 1490. 1491.It Fl B Ar buildid 1492Set the value of 1493.Sy BUILDID 1494to 1495.Ar buildid . 1496This will also append the build identifier to the name of the 1497.Dq make 1498wrapper script so that the resulting name is of the form 1499.Dq Sy \*[toolprefix]make-MACHINE-BUILDID . 1500. 1501.It Fl C Ar cdextras 1502Append 1503.Ar cdextras 1504to the 1505.Sy CDEXTRA 1506variable, 1507which is a space-separated list of files or directories that will be 1508added to the CD-ROM image that may be create by the 1509.Dq iso-image 1510or 1511.Dq iso-image-source 1512operations. 1513Files will be added to the root of the CD-ROM image, whereas directories 1514will be copied recursively. 1515If relative paths are specified, they will be converted to 1516absolute paths before being used. 1517Multiple paths may be specified via multiple 1518.Fl C 1519options, or via a single option whose argument contains multiple 1520space-separated paths. 1521. 1522.It Fl D Ar dest 1523Set the value of 1524.Sy DESTDIR 1525to 1526.Ar dest . 1527If a relative path is specified, it will be converted to an 1528absolute path before being used. 1529. 1530.It Fl E 1531Set 1532.Sq expert 1533mode. 1534This overrides various sanity checks, and allows: 1535.Sy DESTDIR 1536does not have to be set to a non-root path for builds, 1537and 1538.Sy MKUNPRIVED=yes 1539does not have to be set when building as a non-root user. 1540.Pp 1541.Em Note : 1542It is highly recommended that you know what you are doing when 1543you use this option. 1544. 1545.It Fl h 1546Print a help message. 1547. 1548.It Fl j Ar njob 1549Run up to 1550.Ar njob 1551.Xr make 1 1552subjobs in parallel; 1553passed through to 1554.Xr make 1 . 1555If you see failures for reasons other than running out of memory 1556while using 1557.Sy build.sh 1558with 1559.Fl j , 1560please save complete build logs 1561so the failures can be analyzed. 1562.Pp 1563To achieve the fastest builds, 1564.Fl j 1565values between (1 + the number of CPUs) and (2 * the number of CPUs) 1566are recommended. 1567Use lower values on machines with limited memory or I/O bandwidth. 1568. 1569.It Fl M Ar obj 1570Set 1571.Sy MAKEOBJDIRPREFIX 1572to 1573.Ar obj . 1574Unsets 1575.Sy MAKEOBJDIR . 1576See 1577.Dq Fl O Ar obj 1578for more information. 1579.Pp 1580For instance, if the source directory is 1581.Pa /usr/src , 1582a setting of 1583.Dq Fl M Pa /usr/obj 1584will place build-time files under 1585.Pa /usr/obj/usr/src/bin , 1586.Pa /usr/obj/usr/src/lib , 1587.Pa /usr/obj/usr/src/usr.bin , 1588and so forth. 1589.Pp 1590If a relative path is specified, it will be converted to an 1591absolute path before being used. 1592.Sy build.sh 1593imposes the restriction that the argument to the 1594.Fl M 1595option must not begin with a 1596.Dq \&$ 1597(dollar sign) 1598character; otherwise it would be too difficult 1599to determine whether the value is an absolute or a relative path. 1600If the directory does not already exist, 1601.Sy build.sh 1602will create it. 1603. 1604.It Fl m Ar mach 1605Set the value of 1606.Sy MACHINE 1607to 1608.Ar mach , 1609except in some special cases listed below. 1610This will also override any value of 1611.Sy MACHINE_ARCH 1612in the process environment with a value deduced from 1613.Ar mach , 1614unless 1615.Fl a 1616is specified. 1617All cross builds require 1618.Fl m , 1619but if unset on a NetBSD host, the host's value of MACHINE will be 1620detected and used automatically. 1621.Pp 1622Some machines support multiple values for 1623.Sy MACHINE_ARCH . 1624The following special cases for the 1625.Ar mach 1626argument are defined to set the listed values of 1627.Sy MACHINE 1628and 1629.Sy MACHINE_ARCH : 1630.Bl -column "evbmips-el" "MACHINE" "MACHINE_ARCH" -offset indent 1631.It Sy mach Ta Sy "MACHINE" Ta Sy "MACHINE_ARCH" 1632.It evbarm Ta evbarm Ta (not set) 1633.It evbarm-eb Ta evbarm Ta armeb 1634.It evbarm-el Ta evbarm Ta arm 1635.It evbmips Ta evbmips Ta (not set) 1636.It evbmips-eb Ta evbmips Ta mipseb 1637.It evbmips-el Ta evbmips Ta mipsel 1638.It evbsh3 Ta evbsh3 Ta (not set) 1639.It evbsh3-eb Ta evbsh3 Ta sh3eb 1640.It evbsh3-el Ta evbsh3 Ta sh3el 1641.It sbmips Ta sbmips Ta (not set) 1642.It sbmips-eb Ta sbmips Ta mipseb 1643.It sbmips-el Ta sbmips Ta mipsel 1644.El 1645. 1646.It Fl N Ar noiselevel 1647Set the 1648.Dq noisyness 1649level of the build, by setting 1650.Sy MAKEVERBOSE 1651to 1652.Ar noiselevel . 1653. 1654.It Fl n 1655Show the commands that would be executed by 1656.Sy build.sh , 1657but do not make any changes. 1658This is similar in concept to 1659.Dq make -n . 1660. 1661.It Fl O Ar obj 1662Create an appropriate transform macro for 1663.Sy MAKEOBJDIR 1664that will place the built object files under 1665.Ar obj . 1666Unsets 1667.Sy MAKEOBJDIRPREFIX . 1668.Pp 1669For instance, a setting of 1670.Dq Fl O Pa /usr/obj 1671will place build-time files under 1672.Pa /usr/obj/bin , 1673.Pa /usr/obj/lib , 1674.Pa /usr/obj/usr.bin , 1675and so forth. 1676.Pp 1677If a relative path is specified, it will be converted to an 1678absolute path before being used. 1679.Sy build.sh 1680imposes the restriction that the argument to the 1681.Fl O 1682option must not contain a 1683.Dq \&$ 1684(dollar sign) 1685character. 1686If the directory does not already exist, 1687.Sy build.sh 1688will create it. 1689.Pp 1690In normal use, exactly one of the 1691.Fl M 1692or 1693.Fl O 1694options should be specified. 1695If neither 1696.Fl M 1697nor 1698.Fl O 1699is specified, then a default object directory will be chosen 1700according to rules in 1701.Aq bsd.obj.mk . 1702Relying on this default is not recommended because 1703it is determined by complex rules that are influenced 1704by the values of several variables and 1705by the location of the source directory. 1706.It Fl o 1707Set the value of 1708.Sy MKOBJDIRS 1709to 1710.Dq no . 1711Otherwise, it will be automatically set to 1712.Dq yes . 1713This default is opposite to the behaviour when not using 1714.Sy build.sh . 1715. 1716.It Fl R Ar rel 1717Set the value of 1718.Sy RELEASEDIR 1719to 1720.Ar rel . 1721If a relative path is specified, it will be converted to an 1722absolute path before being used. 1723. 1724.It Fl r 1725Remove the contents of 1726.Sy DESTDIR 1727and 1728.Sy TOOLDIR 1729before building (provides a clean starting point). 1730This will skip deleting 1731.Sy DESTDIR 1732if building on a native system to the root directory. 1733. 1734.It Fl S Ar seed 1735Change the value of 1736.Sy BUILDSEED 1737to 1738.Ar seed . 1739This should rarely be necessary. 1740. 1741.It Fl T Ar tools 1742Set the value of 1743.Sy TOOLDIR 1744to 1745.Ar tools . 1746If a relative path is specified, it will be converted to an 1747absolute path before being used. 1748If set, the bootstrap 1749.Dq make 1750will only be rebuilt if the source files for 1751.Xr make 1 1752have changed. 1753. 1754.It Fl U 1755Set 1756.Sy MKUNPRIVED=yes . 1757. 1758.It Fl u 1759Set 1760.Sy MKUPDATE=yes . 1761. 1762.It Xo 1763.Fl V 1764.Sm off 1765.Ar var 1766.Li = 1767.Op Ar value 1768.Sm on 1769.Xc 1770Set the environment variable 1771.Ar var 1772to an optional 1773.Ar value . 1774This is propagated to the 1775.Sy \*[toolprefix]make 1776wrapper. 1777. 1778.It Fl w Ar wrapper 1779Create the 1780.Sy \*[toolprefix]make 1781wrapper script (see below) in a custom location, 1782specified by 1783.Ar wrapper . 1784This allows, for instance, to place the wrapper in 1785.Sy PATH 1786automatically. 1787Note that 1788.Ar wrapper 1789is the full name of the file, not just a directory name. 1790If a relative path is specified, it will be converted to an 1791absolute path before being used. 1792. 1793.It Fl X Ar x11src 1794Set the value of 1795.Sy X11SRCDIR 1796to 1797.Ar x11src . 1798If a relative path is specified, it will be converted to an 1799absolute path before being used. 1800. 1801.It Fl x 1802Set 1803.Sy MKX11=yes . 1804. 1805.It Fl Z Ar var 1806Unset ("zap") the environment variable 1807.Ar var . 1808This is propagated to the 1809.Sy \*[toolprefix]make 1810wrapper. 1811. 1812.El 1813. 1814.Ss The \*q\*[toolprefix]make-MACHINE\*q wrapper script 1815. 1816If using the 1817.Sy build.sh 1818script to build 1819.Nx , 1820a 1821.Sy \*[toolprefix]make-MACHINE 1822script will be created in 1823.Sy TOOLDIR/bin 1824upon the first build to assist in building subtrees on a cross-compile 1825host. 1826.Pp 1827.Sy \*[toolprefix]make-MACHINE 1828can be invoked in lieu of 1829.Xr make 1 , 1830and will instead call the up-to-date version of 1831.Dq \*[toolprefix]make 1832installed into 1833.Sy TOOLDIR/bin 1834with several key variables pre-set, including 1835.Sy MACHINE , MACHINE_ARCH , 1836and 1837.Sy TOOLDIR . 1838.Sy \*[toolprefix]make-MACHINE 1839will also set variables specified with 1840.Fl V , 1841and unset variables specified with 1842.Fl Z . 1843.Pp 1844This script can be symlinked into a directory listed in 1845.Sy PATH , 1846or called with an absolute path. 1847. 1848.Sh EXAMPLES 1849. 1850.Bl -enum 1851. 1852.It 1853.Li "% ./build.sh [options] tools kernel=GENERIC" 1854.Pp 1855Build a new toolchain, and use the new toolchain to 1856configure and build a new GENERIC kernel. 1857. 1858.It 1859.Li "% ./build.sh [options] -U distribution" 1860.Pp 1861Using unprivileged mode, 1862build a complete distribution to a 1863.Sy DESTDIR 1864directory that 1865.Sy build.sh 1866selects (and will display). 1867. 1868.It 1869.Li "# ./build.sh [options] -U install=/" 1870.Pp 1871As root, install to 1872.Pa / 1873the distribution that was built 1874by example 2. 1875Even though this is run as root, 1876.Fl U 1877is required so that the permissions stored in 1878.Sy DESTDIR Ns Pa /METALOG 1879are correctly applied to the files as they're copied to 1880.Pa / . 1881. 1882.It 1883.Li "% ./build.sh [options] -U -u release" 1884.Pp 1885Using unprivileged mode, 1886build a complete release to 1887.Sy DESTDIR 1888and 1889.Sy RELEASEDIR 1890directories that 1891.Sy build.sh 1892selects (and will display). 1893.Sy MKUPDATE=yes 1894.Pq Fl u 1895is set to prevent the 1896.Dq make cleandir , 1897so that if this is run after example 2, it doesn't need to redo that 1898portion of the release build. 1899.El 1900. 1901.Sh OBSOLETE VARIABLES 1902. 1903.Bl -tag -width "NBUILDJOBS" 1904. 1905.It Sy NBUILDJOBS 1906Use the 1907.Xr make 1 1908option 1909.Fl j 1910instead. 1911. 1912.It Sy USE_NEW_TOOLCHAIN 1913The new toolchain is now the default. 1914To disable, use 1915.Sy TOOLCHAIN_MISSING=yes . 1916.El 1917.Sh SEE ALSO 1918.Xr make 1 , 1919.Xr hier 7 , 1920.Xr release 7 , 1921.Xr etcupdate 8 , 1922.Xr postinstall 8 , 1923.Xr sysinst 8 , 1924.Pa pkgsrc/sysutils/cdrtools 1925. 1926.Sh HISTORY 1927. 1928The 1929.Nm build.sh 1930based build scheme was introduced for 1931.Nx 1.6 1932as 1933.Sy USE_NEW_TOOLCHAIN , 1934and re-worked to 1935.Sy TOOLCHAIN_MISSING 1936after that. 1937