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