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