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