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