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