BUILDING revision 1.154 1 1.104 wiz BUILDING(8) System Manager's Manual BUILDING(8)
2 1.1 tv
3 1.105 wiz NAME
4 1.150 lukem BUILDING - Procedure for building NetBSD from source code
5 1.1 tv
6 1.105 wiz REQUIREMENTS
7 1.1 tv NetBSD is designed to be buildable on most POSIX-compliant host systems.
8 1.105 wiz The basic build procedure is the same whether compiling natively (on the
9 1.105 wiz same NetBSD architecture) or cross compiling (on another architecture or
10 1.1 tv OS).
11 1.1 tv
12 1.126 wiz This source tree contains a special subtree, "tools", which uses the host
13 1.126 wiz system to create a build toolchain for the target architecture. The host
14 1.126 wiz system must have at least C and C++ compilers in order to create the
15 1.105 wiz toolchain (make is not required); all other tools are created as part of
16 1.147 lukem the NetBSD build process. (See the Environment variables section below
17 1.53 reed if you need to override or manually select your compilers.)
18 1.1 tv
19 1.105 wiz FILES
20 1.105 wiz Source tree layout
21 1.151 lukem BUILDING This document (in plaintext). Generated from
22 1.151 lukem doc/BUILDING.mdoc.
23 1.48 jmc
24 1.105 wiz Makefile The main Makefile for NetBSD; should only be run for
25 1.44 lukem native builds with an appropriately up-to-date version of
26 1.142 andvar NetBSD make(1). Intended for expert use with knowledge of
27 1.129 sevan its shortcomings, it has been superseded by the build.sh
28 1.129 sevan shell script as the recommended means for building NetBSD.
29 1.1 tv
30 1.105 wiz UPDATING Special notes for updating from an earlier revision of
31 1.1 tv NetBSD. It is important to read this file before every
32 1.1 tv build of an updated source tree.
33 1.1 tv
34 1.105 wiz build.sh Bourne-compatible shell script used for building the host
35 1.1 tv build tools and the NetBSD system from scratch. Can be
36 1.1 tv used for both native and cross builds, and should be used
37 1.129 sevan instead of make(1) as it performs additional checks to
38 1.129 sevan prevent common issues going undetected, such as building
39 1.129 sevan with an outdated version of make(1).
40 1.1 tv
41 1.105 wiz crypto/dist/, dist/, gnu/dist/
42 1.104 wiz Sources imported verbatim from third parties, without
43 1.104 wiz mangling the existing build structure. Other source trees
44 1.126 wiz in bin through usr.sbin use the NetBSD make(1) "reachover"
45 1.126 wiz Makefile semantics when building these programs for a
46 1.126 wiz native host.
47 1.104 wiz
48 1.151 lukem distrib/, etc/
49 1.151 lukem Sources for items used when making a full release
50 1.151 lukem snapshot, such as files installed in DESTDIR/etc on the
51 1.151 lukem destination system, boot media, and release notes.
52 1.151 lukem
53 1.151 lukem doc/BUILDING.mdoc
54 1.151 lukem This document, in -mdoc troff format; the original copy.
55 1.151 lukem Used to generate BUILDING.
56 1.151 lukem
57 1.106 wiz external, sys/external
58 1.106 wiz Sources and build infrastructure for components imported
59 1.106 wiz (mostly) unchanged from upstream maintainers, sorted by
60 1.106 wiz applicable license. This is (slowly) replacing the
61 1.106 wiz crypto/dist, dist, and gnu/dist directories.
62 1.106 wiz
63 1.151 lukem external/mit/xorg/
64 1.151 lukem "Reachover" build structure for modular Xorg; the source
65 1.151 lukem is in X11SRCDIR.
66 1.1 tv
67 1.151 lukem regress/, tests/
68 1.70 dholland Regression test harness. Can be cross-compiled, but only
69 1.105 wiz run natively. tests/ uses the atf(7) test framework;
70 1.105 wiz regress/ contains older tests that have not yet been
71 1.70 dholland migrated to atf(7).
72 1.1 tv
73 1.105 wiz sys/ NetBSD kernel sources.
74 1.1 tv
75 1.126 wiz tools/ "Reachover" build structure for the host build tools.
76 1.104 wiz This has a special method of determining out-of-date
77 1.104 wiz status.
78 1.1 tv
79 1.151 lukem tools/compat/README
80 1.151 lukem Special notes for cross-hosting a NetBSD build on non-
81 1.151 lukem NetBSD platforms.
82 1.151 lukem
83 1.151 lukem Other directories including bin/ ... usr.sbin/
84 1.1 tv Sources to the NetBSD userland (non-kernel) programs. If
85 1.1 tv any of these directories are missing, they will be skipped
86 1.1 tv during the build.
87 1.1 tv
88 1.105 wiz Build tree layout
89 1.1 tv The NetBSD build tree is described in hier(7), and the release layout is
90 1.1 tv described in release(7).
91 1.1 tv
92 1.105 wiz CONFIGURATION
93 1.105 wiz Environment variables
94 1.8 lukem Several environment variables control the behaviour of NetBSD builds.
95 1.8 lukem
96 1.152 lukem HOST_CC Path name to C compiler used to create the toolchain.
97 1.58 apb
98 1.152 lukem HOST_CFLAGS Flags passed to the host C compiler.
99 1.53 reed
100 1.152 lukem HOST_CXX Path name to C++ compiler used to create the toolchain.
101 1.137 uwe
102 1.152 lukem HOST_CXXFLAGS Flags passed to the host C++ compiler.
103 1.53 reed
104 1.152 lukem HOST_SH Path name to a shell available on the host system and
105 1.152 lukem suitable for use during the build. The NetBSD build
106 1.152 lukem system requires a modern Bourne-like shell with POSIX-
107 1.152 lukem compliant features, and also requires support for the
108 1.152 lukem "local" keyword to declare local variables in shell
109 1.152 lukem functions (which is a widely-implemented but non-
110 1.152 lukem standardised feature).
111 1.152 lukem
112 1.152 lukem Depending on the host system, a suitable shell may be
113 1.152 lukem /bin/sh, /usr/xpg4/bin/sh, /bin/ksh (provided it is a
114 1.152 lukem variant of ksh that supports the "local" keyword, such as
115 1.152 lukem ksh88, but not ksh93), or /usr/local/bin/bash.
116 1.152 lukem
117 1.152 lukem Most parts of the build require HOST_SH to be an absolute
118 1.152 lukem path; however, build.sh allows it to be a simple command
119 1.152 lukem name, which will be converted to an absolute path by
120 1.152 lukem searching the PATH.
121 1.137 uwe
122 1.147 lukem INSTALLBOOT_UBOOT_PATHS
123 1.152 lukem A colon-separated list of search paths used by
124 1.152 lukem installboot(8) to find U-Boot packages.
125 1.147 lukem
126 1.152 lukem MACHINE Machine type, e.g., "macppc".
127 1.8 lukem
128 1.152 lukem MACHINE_ARCH Machine architecture, e.g., "powerpc".
129 1.8 lukem
130 1.152 lukem MAKE Path name to invoke make(1) as.
131 1.8 lukem
132 1.152 lukem MAKECONF The name of the make(1) configuration file. See "make"
133 1.152 lukem variables and mk.conf(5).
134 1.151 lukem
135 1.152 lukem Note: Only settable in the process environment.
136 1.151 lukem
137 1.152 lukem Default: "/etc/mk.conf"
138 1.151 lukem
139 1.152 lukem MAKEFLAGS Flags to invoke make(1) with.
140 1.151 lukem
141 1.152 lukem Note: build.sh ignores the value of MAKEFLAGS passed in
142 1.152 lukem the environment, but allows MAKEFLAGS to be set via the
143 1.152 lukem -V option.
144 1.151 lukem
145 1.152 lukem MAKEOBJDIR Directory to use as the .OBJDIR for the current
146 1.152 lukem directory. The value is subjected to variable expansion
147 1.152 lukem by make(1). Typical usage is to set this variable to a
148 1.152 lukem value involving the use of `${.CURDIR:S...}' or
149 1.152 lukem `${.CURDIR:C...}', to derive the value of .OBJDIR from
150 1.152 lukem the value of .CURDIR. Used only if MAKEOBJDIRPREFIX is
151 1.152 lukem not defined.
152 1.151 lukem
153 1.152 lukem Note: MAKEOBJDIR can be provided only in the environment
154 1.152 lukem or via the -O flag of build.sh; it cannot usefully be set
155 1.152 lukem inside a Makefile, including in mk.conf(5) or MAKECONF.
156 1.151 lukem
157 1.151 lukem MAKEOBJDIRPREFIX
158 1.152 lukem Top level directory of the object directory tree. The
159 1.152 lukem value is subjected to variable expansion by make(1).
160 1.152 lukem build.sh will create the ${MAKEOBJDIRPREFIX} directory if
161 1.152 lukem necessary, but if make(1) is used without build.sh, then
162 1.152 lukem rules in <bsd.obj.mk> will abort the build if the
163 1.152 lukem ${MAKEOBJDIRPREFIX} directory does not exist. If the
164 1.152 lukem value is defined and valid, then
165 1.152 lukem ${MAKEOBJDIRPREFIX}/${.CURDIR} is used as the .OBJDIR for
166 1.152 lukem the current directory. The current directory may be read
167 1.152 lukem only.
168 1.152 lukem
169 1.152 lukem Note: MAKEOBJDIRPREFIX can be provided only in the
170 1.152 lukem environment or via the -M flag of build.sh; it cannot
171 1.152 lukem usefully be set inside a Makefile, including in
172 1.152 lukem mk.conf(5) or MAKECONF.
173 1.152 lukem
174 1.152 lukem TMPDIR Top-level directory to store temporary directories used
175 1.152 lukem by build.sh before paths to other directories such as
176 1.152 lukem .OBJDIR can be determined.
177 1.149 lukem
178 1.152 lukem Note: Must support execution of binaries. I.e., without
179 1.152 lukem mount(8)'s -o noexec option.
180 1.149 lukem
181 1.152 lukem Default: "/tmp".
182 1.149 lukem
183 1.105 wiz "make" variables
184 1.104 wiz Several variables control the behavior of NetBSD builds. Unless
185 1.104 wiz otherwise specified, these variables may be set in either the process
186 1.150 lukem environment or the make(1) configuration file mk.conf(5) specified by
187 1.151 lukem MAKECONF.
188 1.151 lukem
189 1.151 lukem This list is not comprehensive; all supported variables and their
190 1.151 lukem defaults are documented in mk.conf(5).
191 1.151 lukem
192 1.152 lukem BSDOBJDIR The real path to the object directory tree for the NetBSD
193 1.152 lukem source tree.
194 1.151 lukem
195 1.152 lukem Default: "/usr/obj"
196 1.151 lukem
197 1.152 lukem BSDSRCDIR The real path to the NetBSD source tree, if NETBSDSRCDIR
198 1.152 lukem isn't defined.
199 1.151 lukem
200 1.152 lukem Default: "/usr/src"
201 1.152 lukem
202 1.152 lukem BUILDID Identifier for the build. If set, this should be a short
203 1.152 lukem string that is suitable for use as part of a file or
204 1.152 lukem directory name. The identifier will be appended to
205 1.152 lukem object directory names, and can be consulted in the
206 1.152 lukem make(1) configuration file in order to set additional
207 1.152 lukem build parameters, such as compiler flags. It will also
208 1.152 lukem be used as part of the kernel version string, which can
209 1.152 lukem be shown by "uname -v".
210 1.152 lukem
211 1.152 lukem Default: Unset.
212 1.152 lukem
213 1.152 lukem BUILDINFO Optional multi-line string containing information about
214 1.152 lukem the build. This will appear in DESTDIR/etc/release, and
215 1.152 lukem it will be stored in the buildinfo variable in any
216 1.152 lukem kernels that are built. When such kernels are booted,
217 1.152 lukem the sysctl(7) kern.buildinfo variable will report this
218 1.152 lukem value. The string may contain backslash escape
219 1.152 lukem sequences, such as "\\" (representing a backslash
220 1.152 lukem character) and "\n" (representing a newline).
221 1.152 lukem
222 1.152 lukem Default: Unset.
223 1.152 lukem
224 1.152 lukem BUILDSEED g++(1) uses random numbers when compiling C++ code. This
225 1.152 lukem variable seeds the g++(1) random number generator using
226 1.152 lukem -frandom-seed with this value. By default, it is set to
227 1.152 lukem "NetBSD-(majorversion)". Using a fixed value causes C++
228 1.152 lukem binaries to be the same when built from the same sources,
229 1.152 lukem resulting in identical (reproducible) builds. Additional
230 1.152 lukem information is available in the g++(1) documentation of
231 1.152 lukem -frandom-seed.
232 1.152 lukem
233 1.152 lukem Default: Unset.
234 1.152 lukem
235 1.154 lukem COPTS Extra options for the C compiler. Should be appended to
236 1.154 lukem (e.g., COPTS+=-g), rather than explicitly set.
237 1.154 lukem
238 1.154 lukem Note: CPUFLAGS, not COPTS, should be used for compiler
239 1.154 lukem flags that select CPU-related options.
240 1.154 lukem
241 1.154 lukem Note: CFLAGS should never be set in mk.conf(5).
242 1.154 lukem
243 1.154 lukem CPUFLAGS Additional options passed to the compiler/assembler to
244 1.154 lukem select CPU instruction set options, CPU tuning options,
245 1.154 lukem etc.
246 1.154 lukem
247 1.154 lukem Note: Such options should not be specified in COPTS,
248 1.154 lukem because some parts of the build process need to override
249 1.154 lukem CPU-related compiler options.
250 1.152 lukem
251 1.152 lukem Default: Unset.
252 1.152 lukem
253 1.152 lukem DESTDIR Directory to contain the built NetBSD system. If set,
254 1.152 lukem special options are passed to the compilation tools to
255 1.152 lukem prevent their default use of the host system's
256 1.152 lukem /usr/include, /usr/lib, and so forth. This pathname must
257 1.152 lukem be an absolute path, and should not end with a slash (/)
258 1.152 lukem character. (For installation into the system's root
259 1.152 lukem directory, set DESTDIR to an empty string, not to "/").
260 1.152 lukem The directory must reside on a file system which supports
261 1.152 lukem long file names and hard links.
262 1.151 lukem
263 1.154 lukem Note: build.sh will provide a default of
264 1.154 lukem "destdir.MACHINE" (in the top-level .OBJDIR) unless run
265 1.154 lukem in `expert' mode.
266 1.151 lukem
267 1.154 lukem Default: Empty string if USETOOLS=yes; unset otherwise.
268 1.151 lukem
269 1.151 lukem EXTERNAL_TOOLCHAIN
270 1.152 lukem If defined, this variable indicates the root directory of
271 1.152 lukem an external toolchain which will be used to build the
272 1.152 lukem tree. For example, if a platform is a TOOLCHAIN_MISSING
273 1.152 lukem platform, EXTERNAL_TOOLCHAIN can be used to re-enable the
274 1.152 lukem cross-compile framework.
275 1.151 lukem
276 1.152 lukem If EXTERNAL_TOOLCHAIN is defined, act as MKGCC=no, since
277 1.152 lukem the external version of the compiler may not be able to
278 1.152 lukem build the library components of the in-tree compiler.
279 1.151 lukem
280 1.152 lukem This variable should be used in conjunction with an
281 1.152 lukem appropriate HAVE_GCC or HAVE_LLVM setting to control the
282 1.152 lukem compiler flags.
283 1.151 lukem
284 1.152 lukem Note: This variable is not yet used in as many places as
285 1.152 lukem it should be. Expect the exact semantics of this
286 1.152 lukem variable to change in the short term as parts of the
287 1.152 lukem cross-compile framework continue to be cleaned up.
288 1.151 lukem
289 1.152 lukem Default: Unset.
290 1.151 lukem
291 1.154 lukem INSTALLBOOT_BOARDS
292 1.154 lukem A list of evbarm boards to create bootable images for.
293 1.154 lukem If corresponding U-Boot packages are installed, bootable
294 1.154 lukem images are created as part of a release. See the
295 1.154 lukem -o board=name option of installboot(8).
296 1.154 lukem
297 1.154 lukem INSTALLWORLDDIR
298 1.154 lukem Location for the top-level "make installworld" target to
299 1.154 lukem install to. If specified, must be an absolute path.
300 1.154 lukem
301 1.154 lukem Default: "/"
302 1.154 lukem
303 1.152 lukem MAKEVERBOSE Level of verbosity of status messages. Supported values:
304 1.151 lukem
305 1.152 lukem 0 No descriptive messages or commands executed by
306 1.152 lukem make(1) are shown.
307 1.151 lukem
308 1.152 lukem 1 Brief messages are shown describing what is being
309 1.152 lukem done, but the actual commands executed by make(1) are
310 1.152 lukem not shown.
311 1.151 lukem
312 1.152 lukem 2 Descriptive messages are shown as above (prefixed
313 1.152 lukem with a `#'), and ordinary commands performed by
314 1.152 lukem make(1) are shown.
315 1.151 lukem
316 1.152 lukem 3 In addition to the above, all commands performed by
317 1.152 lukem make(1) are shown, even if they would ordinarily have
318 1.152 lukem been hidden through use of the "@" prefix in the
319 1.152 lukem relevant makefile.
320 1.151 lukem
321 1.152 lukem 4 In addition to the above, commands executed by
322 1.152 lukem make(1) are traced through use of the sh(1) "-x"
323 1.152 lukem flag.
324 1.151 lukem
325 1.152 lukem Default: 2
326 1.151 lukem
327 1.152 lukem MKCATPAGES Can be set to "yes" or "no". Indicates whether
328 1.152 lukem preformatted plaintext manual pages will be created and
329 1.152 lukem installed.
330 1.151 lukem
331 1.152 lukem Forced to "no" if MKMAN=no or MKSHARE=no.
332 1.151 lukem
333 1.152 lukem Default: "no"
334 1.151 lukem
335 1.152 lukem MKCROSSGDB Can be set to "yes" or "no". Create a cross-gdb as a
336 1.152 lukem host tool.
337 1.1 tv
338 1.152 lukem Default: "no"
339 1.151 lukem
340 1.152 lukem MKDEBUG Can be set to "yes" or "no". Indicates whether debug
341 1.152 lukem information should be generated for all userland
342 1.152 lukem binaries. The result is collected as an additional
343 1.152 lukem debug.tgz and xdebug.tgz set and installed in
344 1.152 lukem DESTDIR/usr/libdata/debug.
345 1.151 lukem
346 1.152 lukem Forced to "no" if NODEBUG is defined, usually in the
347 1.152 lukem Makefile before any make(1) .include directives.
348 1.151 lukem
349 1.152 lukem Default: "no"
350 1.151 lukem
351 1.152 lukem MKDEBUGKERNEL Can be set to "yes" or "no". Indicates whether debugging
352 1.152 lukem symbols will be built for kernels by default; pretend as
353 1.152 lukem if makeoptions DEBUG="-g" is specified in kernel
354 1.152 lukem configuration files. This will also put the debug kernel
355 1.152 lukem netbsd.gdb in the kernel sets. See options(4) for
356 1.152 lukem details. This is useful if a cross-gdb is built as well
357 1.152 lukem (see MKCROSSGDB).
358 1.151 lukem
359 1.152 lukem Default: "no"
360 1.151 lukem
361 1.152 lukem MKDEBUGLIB Can be set to "yes" or "no". Indicates whether debug
362 1.152 lukem libraries (lib*_g.a) will be built and installed. Debug
363 1.152 lukem libraries are compiled with "-g -DDEBUG".
364 1.151 lukem
365 1.152 lukem Forced to "no" if NODEBUGLIB is defined, usually in the
366 1.152 lukem Makefile before any make(1) .include directives.
367 1.151 lukem
368 1.152 lukem Default: "no"
369 1.151 lukem
370 1.152 lukem MKDEBUGTOOLS Can be set to "yes" or "no". Indicates whether debug
371 1.152 lukem information (lib*_g.a) will be included in the build
372 1.152 lukem toolchain.
373 1.151 lukem
374 1.152 lukem Default: "no"
375 1.107 apb
376 1.152 lukem MKDOC Can be set to "yes" or "no". Indicates whether system
377 1.152 lukem documentation destined for DESTDIR/usr/share/doc will be
378 1.152 lukem installed.
379 1.151 lukem
380 1.152 lukem Forced to "no" if NODOC is defined, usually in the
381 1.152 lukem Makefile before any make(1) .include directives.
382 1.151 lukem
383 1.152 lukem Forced to "no" if MKSHARE=no.
384 1.151 lukem
385 1.152 lukem Default: "yes"
386 1.151 lukem
387 1.154 lukem MKHOSTOBJ Can be set to "yes" or "no". If "yes", then for programs
388 1.154 lukem intended to be run on the compile host, the name,
389 1.154 lukem release, and architecture of the host operating system
390 1.154 lukem will be suffixed to the name of the object directory
391 1.154 lukem created by "make obj". (This allows multiple host
392 1.154 lukem systems to compile NetBSD for a single target
393 1.154 lukem architecture.) If "no", then programs built to be run on
394 1.154 lukem the compile host will use the same object directory names
395 1.154 lukem as programs built to be run on the target architecture.
396 1.9 thorpej
397 1.152 lukem Default: "no"
398 1.108 apb
399 1.152 lukem MKHTML Can be set to "yes" or "no". Indicates whether the HTML
400 1.154 lukem manual pages are created and installed.
401 1.108 apb
402 1.152 lukem Forced to "no" if NOHTML is defined, usually in the
403 1.152 lukem Makefile before any make(1) .include directives.
404 1.104 wiz
405 1.152 lukem Forced to "no" if MKMAN=no or MKSHARE=no.
406 1.138 thorpej
407 1.152 lukem Default: "yes"
408 1.138 thorpej
409 1.152 lukem MKINFO Can be set to "yes" or "no". Indicates whether GNU Info
410 1.152 lukem files, used for the documentation for most of the
411 1.152 lukem compilation tools, will be built and installed.
412 1.1 tv
413 1.152 lukem Forced to "no" if NOINFO is defined, usually in the
414 1.152 lukem Makefile before any make(1) .include directives.
415 1.1 tv
416 1.152 lukem Forced to "no" if MKSHARE=no.
417 1.30 lukem
418 1.152 lukem Default: "yes"
419 1.45 lukem
420 1.152 lukem MKKMOD Can be set to "yes" or "no". Indicates whether kernel
421 1.154 lukem modules will be built and installed.
422 1.80 apb
423 1.152 lukem Default: "no" on or1k; "yes" on other platforms.
424 1.80 apb
425 1.152 lukem MKLINKLIB Can be set to "yes" or "no". Indicates whether all of
426 1.152 lukem the shared library infrastructure will be built and
427 1.154 lukem installed.
428 1.154 lukem
429 1.154 lukem If "no", prevents:
430 1.154 lukem - installation of the *.a libraries
431 1.154 lukem - installation of the *_pic.a libraries on PIC systems
432 1.154 lukem - building of *.a libraries on PIC systems
433 1.154 lukem - installation of .so symlinks on ELF systems
434 1.154 lukem
435 1.154 lukem I.e, only install the shared library (and the .so.major
436 1.154 lukem symlink on ELF).
437 1.45 lukem
438 1.152 lukem Forced to "no" if NOLINKLIB is defined, usually in the
439 1.152 lukem Makefile before any make(1) .include directives.
440 1.45 lukem
441 1.152 lukem If "no", acts as MKLINT=no MKPICINSTALL=no MKPROFILE=no.
442 1.45 lukem
443 1.152 lukem Default: "yes"
444 1.140 kamil
445 1.152 lukem MKLINT Can be set to "yes" or "no". Indicates whether lint(1)
446 1.152 lukem will be run against portions of the NetBSD source code
447 1.152 lukem during the build, and whether lint libraries will be
448 1.152 lukem installed into DESTDIR/usr/libdata/lint.
449 1.140 kamil
450 1.152 lukem Forced to "no" if NOLINT is defined, usually in the
451 1.152 lukem Makefile before any make(1) .include directives.
452 1.106 wiz
453 1.152 lukem Forced to "no" if MKLINKLIB=no.
454 1.106 wiz
455 1.152 lukem Default: "no"
456 1.106 wiz
457 1.152 lukem MKMAN Can be set to "yes" or "no". Indicates whether manual
458 1.152 lukem pages will be installed.
459 1.106 wiz
460 1.152 lukem Forced to "no" if NOMAN is defined, usually in the
461 1.152 lukem Makefile before any make(1) .include directives.
462 1.106 wiz
463 1.152 lukem Forced to "no" if MKSHARE=no.
464 1.106 wiz
465 1.152 lukem If "no", acts as MKCATPAGES=no MKHTML=no.
466 1.1 tv
467 1.152 lukem Default: "yes"
468 1.1 tv
469 1.152 lukem MKNLS Can be set to "yes" or "no". Indicates whether Native
470 1.152 lukem Language System (NLS) locale zone files will be built and
471 1.152 lukem installed.
472 1.77 lukem
473 1.152 lukem Forced to "no" if NONLS is defined, usually in the
474 1.152 lukem Makefile before any make(1) .include directives.
475 1.77 lukem
476 1.152 lukem Forced to "no" if MKSHARE=no.
477 1.4 tv
478 1.152 lukem Default: "yes"
479 1.4 tv
480 1.152 lukem MKOBJ Can be set to "yes" or "no". Indicates whether object
481 1.152 lukem directories will be created when running "make obj". If
482 1.154 lukem "no", then all built files will be located inside the
483 1.154 lukem regular source tree.
484 1.1 tv
485 1.152 lukem Forced to "no" if NOOBJ is defined, usually in the
486 1.152 lukem Makefile before any make(1) .include directives.
487 1.1 tv
488 1.152 lukem If "no", acts as MKOBJDIRS=no.
489 1.143 lukem
490 1.152 lukem Note: Setting MKOBJ to "no" is not recommended and may
491 1.152 lukem cause problems when updating the tree with cvs(1).
492 1.143 lukem
493 1.152 lukem Default: "yes"
494 1.95 apb
495 1.152 lukem MKOBJDIRS Can be set to "yes" or "no". Indicates whether object
496 1.152 lukem directories will be created automatically (via a "make
497 1.152 lukem obj" pass) at the start of a build.
498 1.95 apb
499 1.152 lukem Forced to "no" if MKOBJ=no.
500 1.1 tv
501 1.154 lukem Note: If using build.sh, the default is "yes". This may
502 1.154 lukem be set back to "no" by giving build.sh the -o option.
503 1.154 lukem
504 1.152 lukem Default: "no"
505 1.1 tv
506 1.152 lukem MKPIC Can be set to "yes" or "no". Indicates whether shared
507 1.152 lukem objects and libraries will be created and installed. If
508 1.152 lukem "no", the entire built system will be statically linked.
509 1.1 tv
510 1.152 lukem Forced to "no" if NOPIC is defined, usually in the
511 1.152 lukem Makefile before any make(1) .include directives.
512 1.1 tv
513 1.152 lukem If "no", acts as MKPICLIB=no.
514 1.1 tv
515 1.152 lukem Default: "no" on m68000; "yes" on other platforms.
516 1.1 tv
517 1.152 lukem MKPICINSTALL Can be set to "yes" or "no". Indicates whether the ar(1)
518 1.152 lukem format libraries (lib*_pic.a), used to generate shared
519 1.152 lukem libraries, are installed.
520 1.1 tv
521 1.152 lukem Forced to "no" if NOPICINSTALL is defined, usually in the
522 1.152 lukem Makefile before any make(1) .include directives.
523 1.1 tv
524 1.152 lukem Forced to "no" if MKLINKLIB=no.
525 1.70 dholland
526 1.152 lukem Default: "no"
527 1.1 tv
528 1.152 lukem MKPROFILE Can be set to "yes" or "no". Indicates whether profiled
529 1.152 lukem libraries (lib*_p.a) will be built and installed.
530 1.1 tv
531 1.152 lukem Forced to "no" if NOPROFILE is defined, usually in the
532 1.152 lukem Makefile before any make(1) .include directives.
533 1.1 tv
534 1.152 lukem Forced to "no" if MKLINKLIB=no.
535 1.1 tv
536 1.152 lukem Default: "no" on or1k, riscv32, and riscv64 (due to
537 1.152 lukem toolchain problems with profiled code); "yes" on other
538 1.152 lukem platforms.
539 1.1 tv
540 1.152 lukem MKREPRO Can be set to "yes" or "no". Indicates whether builds
541 1.152 lukem are to be reproducible. If "yes", two builds from the
542 1.152 lukem same source tree will produce the same build results.
543 1.1 tv
544 1.152 lukem Used as the default for MKARZERO.
545 1.100 wiz
546 1.154 lukem Note: This may be set to "yes" by giving build.sh the -P
547 1.152 lukem option.
548 1.151 lukem
549 1.154 lukem Default: "no"
550 1.100 wiz
551 1.122 wiz MKREPRO_TIMESTAMP
552 1.152 lukem Unix timestamp. When MKREPRO is set, the timestamp of
553 1.152 lukem all files in the sets will be set to this value.
554 1.151 lukem
555 1.154 lukem Note: This may be set automatically to the latest source
556 1.154 lukem tree timestamp using cvslatest(1) by giving build.sh the
557 1.154 lukem -P option.
558 1.151 lukem
559 1.152 lukem Default: Unset.
560 1.151 lukem
561 1.152 lukem MKSHARE Can be set to "yes" or "no". Indicates whether files
562 1.152 lukem destined to reside in DESTDIR/usr/share will be built and
563 1.152 lukem installed.
564 1.151 lukem
565 1.152 lukem Forced to "no" if NOSHARE is defined, usually in the
566 1.152 lukem Makefile before any make(1) .include directives.
567 1.122 wiz
568 1.152 lukem If "no", acts as MKCATPAGES=no MKDOC=no MKINFO=no
569 1.152 lukem MKHTML=no MKMAN=no MKNLS=no.
570 1.49 lukem
571 1.152 lukem Default: "yes"
572 1.151 lukem
573 1.152 lukem MKSTRIPIDENT Can be set to "yes" or "no". Indicates whether RCS IDs,
574 1.152 lukem for use with ident(1), should be stripped from program
575 1.152 lukem binaries and shared libraries.
576 1.151 lukem
577 1.152 lukem Default: "no"
578 1.151 lukem
579 1.152 lukem MKSTRIPSYM Can be set to "yes" or "no". Indicates whether all local
580 1.152 lukem symbols should be stripped from shared libraries. If
581 1.152 lukem "yes", strip all local symbols from shared libraries; the
582 1.154 lukem effect is equivalent to the -x option of ld(1). If "no",
583 1.154 lukem strip only temporary local symbols; the effect is
584 1.152 lukem equivalent to the -X option of ld(1). Keeping non-
585 1.152 lukem temporary local symbols such as static function names is
586 1.152 lukem useful on using DTrace for userland libraries and getting
587 1.152 lukem a backtrace from a rump kernel loading shared libraries.
588 1.151 lukem
589 1.152 lukem Default: "yes"
590 1.151 lukem
591 1.152 lukem MKUNPRIVED Can be set to "yes" or "no". Indicates whether an
592 1.152 lukem unprivileged install will occur. The user, group,
593 1.152 lukem permissions, and file flags, will not be set on the
594 1.152 lukem installed items; instead the information will be appended
595 1.154 lukem to a file called METALOG in DESTDIR. The METALOG
596 1.154 lukem contents are used during the generation of the
597 1.152 lukem distribution tar files to ensure that the appropriate
598 1.154 lukem file ownership is stored. This allows a non-root `make
599 1.154 lukem install'.
600 1.151 lukem
601 1.152 lukem Default: "no"
602 1.151 lukem
603 1.152 lukem MKUPDATE Can be set to "yes" or "no". Indicates whether all
604 1.152 lukem install operations intended to write to DESTDIR will
605 1.152 lukem compare file timestamps before installing, and skip the
606 1.152 lukem install phase if the destination files are up-to-date.
607 1.151 lukem
608 1.154 lukem For top-level builds this this implies the effects of
609 1.154 lukem NOCLEANDIR (i.e., "make cleandir" is avoided).
610 1.154 lukem
611 1.154 lukem Note: If using build.sh, this may be set by giving the -u
612 1.154 lukem option.
613 1.151 lukem
614 1.152 lukem Default: "no"
615 1.151 lukem
616 1.154 lukem MKX11 Can be set to "yes" or "no". Indicates whether X11 will
617 1.154 lukem be built and installed from X11SRCDIR, and whether the X
618 1.152 lukem sets will be created.
619 1.151 lukem
620 1.152 lukem Note: If "yes", requires MKINET6=yes.
621 1.151 lukem
622 1.152 lukem Default: "no"
623 1.151 lukem
624 1.152 lukem NETBSDSRCDIR The path to the top level of the NetBSD sources.
625 1.152 lukem
626 1.152 lukem Default: Top level of the NetBSD source tree (as
627 1.152 lukem determined by the presence of build.sh and tools/) if
628 1.152 lukem make(1) is run from within that tree; otherwise BSDSRCDIR
629 1.152 lukem will be used.
630 1.151 lukem
631 1.154 lukem NOCLEANDIR If set, avoids the "make cleandir" phase of a full build.
632 1.154 lukem This has the effect of allowing only changed files in a
633 1.154 lukem source tree to be recompiled. This can speed up builds
634 1.154 lukem when updating only a few files in the tree.
635 1.154 lukem
636 1.154 lukem See also MKUPDATE.
637 1.154 lukem
638 1.154 lukem Default: Unset.
639 1.154 lukem
640 1.154 lukem NODISTRIBDIRS If set, avoids the "make distrib-dirs" phase of a full
641 1.154 lukem build. This skips running mtree(8) on DESTDIR, useful on
642 1.154 lukem systems where building as an unprivileged user, or where
643 1.154 lukem it is known that the system-wide mtree(8) files have not
644 1.154 lukem changed.
645 1.154 lukem
646 1.154 lukem Default: Unset.
647 1.154 lukem
648 1.154 lukem NOINCLUDES If set, avoids the "make includes" phase of a full build.
649 1.154 lukem This has the effect of preventing make(1) from thinking
650 1.154 lukem that some programs are out-of-date simply because the
651 1.154 lukem system include files have changed. However, this option
652 1.154 lukem should not be used when updating the entire NetBSD source
653 1.154 lukem tree arbitrarily; it is suggested to use MKUPDATE=yes
654 1.154 lukem instead in that case.
655 1.154 lukem
656 1.154 lukem Default: Unset.
657 1.154 lukem
658 1.154 lukem RELEASEDIR If set, specifies the directory to which a release(7)
659 1.154 lukem layout will be written at the end of a "make release".
660 1.154 lukem If specified, must be an absolute path.
661 1.154 lukem
662 1.154 lukem Note: build.sh will provide a default of "releasedir" (in
663 1.154 lukem the top-level .OBJDIR) unless run in `expert' mode.
664 1.154 lukem
665 1.154 lukem Default: Unset.
666 1.154 lukem
667 1.151 lukem TOOLCHAIN_MISSING
668 1.152 lukem Can be set to "yes" or "no". If not "no", this indicates
669 1.152 lukem that the platform "MACHINE_ARCH" being built does not
670 1.152 lukem have a working in-tree toolchain.
671 1.152 lukem
672 1.152 lukem If not "no", acts as MKBINUTILS=no MKGCC=no MKGDB=no.
673 1.152 lukem
674 1.152 lukem Default: "no"
675 1.152 lukem
676 1.152 lukem TOOLDIR Directory to hold the host tools, once built. If
677 1.152 lukem specified, must be an absolute path. This directory
678 1.152 lukem should be unique to a given host system and NetBSD source
679 1.154 lukem tree. (However, multiple target architectures may share
680 1.154 lukem the same TOOLDIR; the target-architecture-dependent files
681 1.154 lukem have unique names.) If unset, a default based on the
682 1.154 lukem uname(1) information of the host platform will be created
683 1.154 lukem in the .OBJDIR of src.
684 1.152 lukem
685 1.152 lukem Default: Unset.
686 1.152 lukem
687 1.152 lukem USETOOLS Can be set to "yes" or "no". Indicates whether the tools
688 1.152 lukem specified by TOOLDIR should be used as part of a build in
689 1.152 lukem progress. Must be set to "yes" if cross-compiling.
690 1.154 lukem Supported values:
691 1.152 lukem
692 1.152 lukem yes Use the tools from TOOLDIR.
693 1.152 lukem
694 1.152 lukem no Do not use the tools from TOOLDIR, but refuse to
695 1.152 lukem build native compilation tool components that are
696 1.152 lukem version-specific for that tool.
697 1.152 lukem
698 1.152 lukem never Do not use the tools from TOOLDIR, even when
699 1.152 lukem building native tool components. This is similar
700 1.152 lukem to the traditional NetBSD build method, but does
701 1.152 lukem not verify that the compilation tools in use are
702 1.152 lukem up-to-date enough in order to build the tree
703 1.152 lukem successfully. This may cause build or runtime
704 1.152 lukem problems when building the whole NetBSD source
705 1.152 lukem tree.
706 1.152 lukem
707 1.152 lukem Default: "no" when using <bsd.*.mk> outside the NetBSD
708 1.152 lukem source tree (detected automatically) or if
709 1.152 lukem TOOLCHAIN_MISSING=yes; "yes" otherwise.
710 1.152 lukem
711 1.152 lukem X11SRCDIR Directory containing the modular Xorg source. If
712 1.152 lukem specified, must be an absolute path. The main modular
713 1.152 lukem Xorg source is found in X11SRCDIR/external/mit.
714 1.151 lukem
715 1.152 lukem Default: NETBSDSRCDIR/../xsrc, if that exists; otherwise
716 1.152 lukem /usr/xsrc.
717 1.49 lukem
718 1.105 wiz BUILDING
719 1.105 wiz "make" command line options
720 1.52 jmc This is not a summary of all the options available to make(1); only the
721 1.52 jmc options used most frequently with NetBSD builds are listed here.
722 1.1 tv
723 1.105 wiz -j njob Run up to njob make(1) subjobs in parallel. Makefiles should
724 1.52 jmc use .WAIT or have explicit dependencies as necessary to
725 1.74 apb enforce build ordering.
726 1.10 sommerfe
727 1.105 wiz -m dir Specify the default directory for searching for system
728 1.104 wiz Makefile segments, mainly the <bsd.*.mk> files. When building
729 1.104 wiz any full NetBSD source tree, this should be set to the
730 1.126 wiz "share/mk" directory in the source tree. This is set
731 1.104 wiz automatically when building from the top level, or when using
732 1.105 wiz build.sh.
733 1.1 tv
734 1.148 lukem -n Show the commands that would have been executed, but do not
735 1.1 tv actually execute them. This will still cause recursion to
736 1.1 tv take place.
737 1.1 tv
738 1.148 lukem -V var Show make(1)'s idea of the value of var. Does not build any
739 1.1 tv targets.
740 1.1 tv
741 1.105 wiz var=value Set the variable var to value, overriding any setting
742 1.105 wiz specified by the process environment, the MAKECONF
743 1.104 wiz configuration file, or the system Makefile segments.
744 1.1 tv
745 1.105 wiz "make" targets
746 1.1 tv These default targets may be built by running make(1) in any subtree of
747 1.1 tv the NetBSD source code. It is recommended that none of these be used
748 1.126 wiz from the top level Makefile; as a specific exception, "make obj" and
749 1.126 wiz "make cleandir" are useful in that context.
750 1.1 tv
751 1.105 wiz all Build programs, libraries, and preformatted documentation.
752 1.1 tv
753 1.105 wiz clean Remove program and library object code files.
754 1.1 tv
755 1.105 wiz cleandir Same as clean, but also remove preformatted documentation,
756 1.126 wiz dependency files generated by "make depend", and any other
757 1.49 lukem files known to be created at build time.
758 1.1 tv
759 1.105 wiz depend Create dependency files (.depend) containing more detailed
760 1.44 lukem information about the dependencies of source code on header
761 1.1 tv files. Allows programs to be recompiled automatically when a
762 1.1 tv dependency changes.
763 1.1 tv
764 1.126 wiz dependall Does a "make depend" immediately followed by a "make all".
765 1.10 sommerfe This improves cache locality of the build since both passes
766 1.10 sommerfe read the source files in their entirety.
767 1.1 tv
768 1.105 wiz distclean Synonym for cleandir.
769 1.49 lukem
770 1.105 wiz includes Build and install system header files. Typically needed
771 1.44 lukem before any system libraries or programs can be built.
772 1.1 tv
773 1.105 wiz install Install programs, libraries, and documentation into DESTDIR.
774 1.105 wiz Few files will be installed to DESTDIR/dev, DESTDIR/etc,
775 1.105 wiz DESTDIR/root or DESTDIR/var in order to prevent user supplied
776 1.27 lukem configuration data from being overwritten.
777 1.1 tv
778 1.105 wiz lint Run lint(1) against the C source code, where appropriate, and
779 1.1 tv generate system-installed lint libraries.
780 1.1 tv
781 1.105 wiz obj Create object directories to be used for built files, instead
782 1.1 tv of building directly in the source tree.
783 1.1 tv
784 1.105 wiz tags Create ctags(1) searchable function lists usable by the ex(1)
785 1.1 tv and vi(1) text editors.
786 1.1 tv
787 1.105 wiz "make" targets for the top level
788 1.1 tv Additional make(1) targets are usable specifically from the top source
789 1.1 tv level to facilitate building the entire NetBSD source tree.
790 1.1 tv
791 1.105 wiz build Build the entire NetBSD system (except the kernel). This
792 1.68 reed orders portions of the source tree such that prerequisites
793 1.68 reed will be built in the proper order.
794 1.20 lukem
795 1.126 wiz distribution Do a "make build", and then install a full distribution
796 1.105 wiz (which does not include a kernel) into DESTDIR, including
797 1.105 wiz files in DESTDIR/dev, DESTDIR/etc, DESTDIR/root and
798 1.105 wiz DESTDIR/var.
799 1.20 lukem
800 1.126 wiz buildworld As per "make distribution", except that it ensures that
801 1.105 wiz DESTDIR is not the root directory.
802 1.20 lukem
803 1.105 wiz installworld Install the distribution from DESTDIR to INSTALLWORLDDIR,
804 1.70 dholland which defaults to the root directory. Ensures that
805 1.105 wiz INSTALLWORLDDIR is not the root directory if cross
806 1.104 wiz compiling.
807 1.20 lukem
808 1.105 wiz The INSTALLSETS environment variable may be set to a space-
809 1.95 apb separated list of distribution sets to be installed. By
810 1.126 wiz default, all sets except "etc" and "xetc" are installed, so
811 1.126 wiz most files in INSTALLWORLDDIR/etc will not be installed or
812 1.126 wiz modified.
813 1.61 apb
814 1.105 wiz Note: Before performing this operation with
815 1.105 wiz INSTALLWORLDDIR=/, it is highly recommended that you
816 1.61 apb upgrade your kernel and reboot. After performing this
817 1.61 apb operation, it is recommended that you use etcupdate(8) to
818 1.105 wiz update files in INSTALLWORLDDIR/etc, and postinstall(8) to
819 1.102 abs check for or fix inconsistencies.
820 1.20 lukem
821 1.105 wiz sets Create distribution sets from DESTDIR into
822 1.105 wiz RELEASEDIR/RELEASEMACHINEDIR/binary/sets. Should be run
823 1.126 wiz after "make distribution", as "make build" alone does not
824 1.126 wiz install all of the required files.
825 1.25 lukem
826 1.105 wiz sourcesets Create source sets of the source tree into
827 1.105 wiz RELEASEDIR/source/sets.
828 1.31 lukem
829 1.105 wiz syspkgs Create syspkgs from DESTDIR into
830 1.105 wiz RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. Should be run
831 1.126 wiz after "make distribution", as "make build" alone does not
832 1.126 wiz install all of the required files.
833 1.54 apb
834 1.126 wiz release Do a "make distribution", build kernels, distribution
835 1.126 wiz media, and install sets (this as per "make sets"), and then
836 1.126 wiz package the system into a standard release layout as
837 1.105 wiz described by release(7). This requires that RELEASEDIR be
838 1.25 lukem set (see above).
839 1.1 tv
840 1.105 wiz iso-image Create a NetBSD installation CD-ROM image in the
841 1.114 snj RELEASEDIR/images directory. The CD-ROM file system will
842 1.114 snj have a layout as described in release(7).
843 1.62 apb
844 1.62 apb For most machine types, the CD-ROM will be bootable, and
845 1.104 wiz will automatically run the sysinst(8) menu-based
846 1.104 wiz installation program, which can be used to install or
847 1.104 wiz upgrade a NetBSD system. Bootable CD-ROMs also contain
848 1.104 wiz tools that may be useful in repairing a damaged NetBSD
849 1.104 wiz installation.
850 1.62 apb
851 1.126 wiz Before "make iso-image" is attempted, RELEASEDIR must be
852 1.126 wiz populated by "make release" or equivalent.
853 1.62 apb
854 1.151 lukem Note: Other, smaller, CD-ROM images may be created in the
855 1.151 lukem RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom directory
856 1.151 lukem by "make release". These smaller images usually contain
857 1.151 lukem the same tools as the larger images in RELEASEDIR/images,
858 1.151 lukem but do not contain additional content such as the
859 1.151 lukem distribution sets.
860 1.62 apb
861 1.151 lukem Note: The mac68k port still uses an older method of
862 1.104 wiz creating CD-ROM images. This requires the mkisofs(1)
863 1.104 wiz utility, which is not part of NetBSD, but which can be
864 1.105 wiz installed from pkgsrc/sysutils/cdrtools.
865 1.56 apb
866 1.105 wiz iso-image-source
867 1.64 jnemeth Create a NetBSD installation CD-ROM image in the
868 1.114 snj RELEASEDIR/images directory. The CD-ROM file system will
869 1.114 snj have a layout as described in release(7). It will have top
870 1.64 jnemeth level directories for the machine type and source.
871 1.64 jnemeth
872 1.64 jnemeth For most machine types, the CD-ROM will be bootable, and
873 1.104 wiz will automatically run the sysinst(8) menu-based
874 1.104 wiz installation program, which can be used to install or
875 1.104 wiz upgrade a NetBSD system. Bootable CD-ROMs also contain
876 1.104 wiz tools that may be useful in repairing a damaged NetBSD
877 1.104 wiz installation.
878 1.64 jnemeth
879 1.126 wiz Before "make iso-image-source" is attempted, RELEASEDIR
880 1.126 wiz must be populated by "make sourcesets release" or
881 1.104 wiz equivalent.
882 1.64 jnemeth
883 1.151 lukem Note: Other, smaller, CD-ROM images may be created in the
884 1.151 lukem RELEASEDIR/RELEASEMACHINEDIR/installation/cdrom directory
885 1.151 lukem by "make release". These smaller images usually contain
886 1.151 lukem the same tools as the larger images in RELEASEDIR/images,
887 1.151 lukem but do not contain additional content such as the
888 1.151 lukem distribution sets.
889 1.64 jnemeth
890 1.151 lukem Note: The mac68k port still uses an older method of
891 1.104 wiz creating CD-ROM images. This requires the mkisofs(1)
892 1.104 wiz utility, which is not part of NetBSD, but which can be
893 1.105 wiz installed from pkgsrc/sysutils/cdrtools.
894 1.64 jnemeth
895 1.105 wiz install-image
896 1.98 apb Create a bootable NetBSD installation disk image in the
897 1.127 plunky RELEASEDIR/images directory. The installation disk image
898 1.127 plunky is suitable for copying to bootable USB flash memory
899 1.127 plunky sticks, etc., for machines which are able to boot from such
900 1.127 plunky devices. The file system in the bootable disk image will
901 1.127 plunky have a layout as described in release(7).
902 1.97 tsutsui
903 1.97 tsutsui The installation image is bootable, and will automatically
904 1.97 tsutsui run the sysinst(8) menu-based installation program, which
905 1.98 apb can be used to install or upgrade a NetBSD system. The
906 1.98 apb image also contains tools that may be useful in repairing a
907 1.98 apb damaged NetBSD installation.
908 1.97 tsutsui
909 1.126 wiz Before "make install-image" is attempted, RELEASEDIR must
910 1.126 wiz be populated by "make release" or equivalent. The build
911 1.126 wiz must have been performed with MKUNPRIVED=yes because "make
912 1.126 wiz install-image" relies on information in DESTDIR/METALOG.
913 1.97 tsutsui
914 1.120 pgoyette live-image Create NetBSD live images in the RELEASEDIR/images
915 1.104 wiz directory. The live image contains all necessary files to
916 1.104 wiz boot NetBSD up to multi-user mode, including all files
917 1.104 wiz which should be extracted during installation, NetBSD
918 1.104 wiz disklabel, bootloaders, etc.
919 1.104 wiz
920 1.104 wiz The live image is suitable for use as a disk image in
921 1.104 wiz virtual machine environments such as QEMU, and also useful
922 1.104 wiz to boot NetBSD from a USB flash memory stick on a real
923 1.98 apb machine, without the need for installation.
924 1.97 tsutsui
925 1.126 wiz Before "make live-image" is attempted, RELEASEDIR must be
926 1.126 wiz populated by "make release" or equivalent. The build must
927 1.126 wiz have been performed with MKUNPRIVED=yes because "make
928 1.126 wiz install-image" relies on information in DESTDIR/METALOG.
929 1.97 tsutsui
930 1.105 wiz regression-tests
931 1.20 lukem Can only be run after building the regression tests in the
932 1.126 wiz directory "regress". Runs those compiled regression tests
933 1.151 lukem on the local host.
934 1.151 lukem
935 1.151 lukem Note: Most tests are now managed instead using atf(7); this
936 1.151 lukem target should probably run those as well but currently does
937 1.151 lukem not.
938 1.1 tv
939 1.105 wiz The "build.sh" script
940 1.96 apb This script file is a shell script designed to build the entire NetBSD
941 1.104 wiz system on any host with a suitable modern shell and some common
942 1.105 wiz utilities. The required shell features are described under the HOST_SH
943 1.104 wiz variable.
944 1.96 apb
945 1.96 apb If a host system's default shell does support the required features, then
946 1.96 apb we suggest that you explicitly specify a suitable shell using a command
947 1.96 apb like
948 1.96 apb
949 1.105 wiz /path/to/suitable/shell build.sh [options]
950 1.96 apb
951 1.105 wiz The above command will usually enable build.sh to automatically set
952 1.105 wiz HOST_SH=/path/to/suitable/shell, but if that fails, then the following
953 1.96 apb set of commands may be used instead:
954 1.96 apb
955 1.105 wiz HOST_SH=/path/to/suitable/shell
956 1.96 apb export HOST_SH
957 1.105 wiz ${HOST_SH} build.sh [options]
958 1.96 apb
959 1.105 wiz If build.sh detects that it is being executed under an unsuitable shell,
960 1.148 lukem it attempts to exec a suitable shell instead, or shows an error message.
961 1.105 wiz If HOST_SH is not set explicitly, then build.sh sets a default using
962 1.96 apb heuristics dependent on the host platform, or from the shell under which
963 1.105 wiz build.sh is executed (if that can be determined), or using the first copy
964 1.105 wiz of sh found in PATH.
965 1.1 tv
966 1.1 tv All cross-compile builds, and most native builds, of the entire system
967 1.126 wiz should make use of build.sh rather than just running "make". This way,
968 1.104 wiz the make(1) program will be bootstrapped properly, in case the host
969 1.126 wiz system has an older or incompatible "make" program.
970 1.1 tv
971 1.105 wiz When compiling the entire system via build.sh, many make(1) variables are
972 1.1 tv set for you in order to help encapsulate the build process. In the list
973 1.105 wiz of options below, variables that are automatically set by build.sh are
974 1.1 tv noted where applicable.
975 1.1 tv
976 1.105 wiz The following operations are supported by build.sh:
977 1.22 lukem
978 1.126 wiz build Build the system as per "make build". Before the main part
979 1.126 wiz of the build commences, this command runs the obj operation
980 1.126 wiz (unless the -o option is given), "make cleandir" (unless
981 1.126 wiz the -u option is given), and the tools operation.
982 1.22 lukem
983 1.126 wiz distribution Build a full distribution as per "make distribution". This
984 1.126 wiz command first runs the build operation.
985 1.22 lukem
986 1.126 wiz release Build a full release as per "make release". This command
987 1.105 wiz first runs the distribution operation.
988 1.22 lukem
989 1.148 lukem help Show a help message, and exit.
990 1.148 lukem
991 1.105 wiz makewrapper Create the nbmake-MACHINE wrapper. This operation is
992 1.104 wiz automatically performed for any of the other operations.
993 1.23 lukem
994 1.126 wiz cleandir Perform "make cleandir".
995 1.75 lukem
996 1.126 wiz obj Perform "make obj".
997 1.22 lukem
998 1.105 wiz tools Build and install the host tools from src/tools. This
999 1.126 wiz command will first run "make obj" and "make cleandir" in
1000 1.126 wiz the tools subdirectory unless the -o or -u options
1001 1.104 wiz (respectively) are given.
1002 1.22 lukem
1003 1.126 wiz install=idir Install the contents of DESTDIR to idir, using "make
1004 1.151 lukem installworld".
1005 1.151 lukem
1006 1.151 lukem Note: Files that are part of the "etc" or "xetc" sets will
1007 1.151 lukem not be installed, unless overridden by the INSTALLSETS
1008 1.151 lukem environment variable.
1009 1.35 lukem
1010 1.105 wiz kernel=kconf Build a new kernel. The kconf argument is the name of a
1011 1.105 wiz configuration file suitable for use by config(1). If kconf
1012 1.22 lukem does not contain any `/' characters, the configuration file
1013 1.105 wiz is expected to be found in the KERNCONFDIR directory, which
1014 1.105 wiz is typically sys/arch/MACHINE/conf. The new kernel will be
1015 1.105 wiz built in a subdirectory of KERNOBJDIR, which is typically
1016 1.105 wiz sys/arch/MACHINE/compile or an associated object directory.
1017 1.70 dholland
1018 1.105 wiz This command does not imply the tools command; run the
1019 1.105 wiz tools command first unless it is certain that the tools
1020 1.70 dholland already exist and are up to date.
1021 1.70 dholland
1022 1.126 wiz This command will run "make cleandir" on the kernel in
1023 1.105 wiz question first unless the -u option is given.
1024 1.22 lukem
1025 1.106 wiz kernel.gdb=kconf
1026 1.106 wiz Build a new kernel with debug information. Similar to the
1027 1.106 wiz above kernel=kconf operation, but creates a netbsd.gdb file
1028 1.106 wiz alongside of the kernel netbsd, which contains a full
1029 1.106 wiz symbol table and can be used for debugging (for example
1030 1.106 wiz with a cross-gdb built by MKCROSSGDB).
1031 1.106 wiz
1032 1.113 uebayasi kernels This command will build all kernels defined in port
1033 1.113 uebayasi specific release build procedure.
1034 1.111 uebayasi
1035 1.112 uebayasi This command internally calls the kernel=kconf operation
1036 1.112 uebayasi for each found kernel configuration file.
1037 1.111 uebayasi
1038 1.105 wiz modules This command will build kernel modules and install them
1039 1.105 wiz into DESTDIR.
1040 1.86 jnemeth
1041 1.105 wiz releasekernel=kconf
1042 1.70 dholland Install a gzip(1)ed copy of the kernel previously built by
1043 1.105 wiz kernel=kconf into
1044 1.105 wiz RELEASEDIR/RELEASEMACHINEDIR/binary/kernel, usually as
1045 1.126 wiz netbsd-kconf.gz, although the "netbsd" prefix is determined
1046 1.126 wiz from the "config" directives in kconf.
1047 1.24 lukem
1048 1.126 wiz sets Perform "make sets".
1049 1.31 lukem
1050 1.126 wiz sourcesets Perform "make sourcesets".
1051 1.22 lukem
1052 1.126 wiz syspkgs Perform "make syspkgs".
1053 1.54 apb
1054 1.126 wiz iso-image Perform "make iso-image".
1055 1.56 apb
1056 1.105 wiz iso-image-source
1057 1.126 wiz Perform "make iso-image-source".
1058 1.65 jnemeth
1059 1.105 wiz install-image
1060 1.126 wiz Perform "make install-image".
1061 1.97 tsutsui
1062 1.126 wiz live-image Perform "make live-image".
1063 1.97 tsutsui
1064 1.148 lukem list-arch Show a list of valid MACHINE and MACHINE_ARCH settings, the
1065 1.148 lukem default MACHINE_ARCH for each MACHINE, and aliases for
1066 1.109 apb MACHINE/MACHINE_ARCH pairs, and then exits. The -m or -a
1067 1.109 apb options (or both) may be used to specify glob patterns that
1068 1.109 apb will be used to narrow the list of results; for example,
1069 1.131 leot "build.sh -m 'evb*' -a '*arm*' list-arch" will list all
1070 1.109 apb known MACHINE/MACHINE_ARCH values in which either MACHINE
1071 1.109 apb or ALIAS matches the pattern `evb*', and MACHINE_ARCH
1072 1.109 apb matches the pattern `*arm*'.
1073 1.109 apb
1074 1.105 wiz The following command line options alter the behaviour of the build.sh
1075 1.51 wiz operations described above:
1076 1.1 tv
1077 1.109 apb -a arch Set the value of MACHINE_ARCH to arch. See the -m option for
1078 1.109 apb more information.
1079 1.9 thorpej
1080 1.105 wiz -B buildid
1081 1.105 wiz Set the value of BUILDID to buildid. This will also append the
1082 1.126 wiz build identifier to the name of the "make" wrapper script so
1083 1.37 lukem that the resulting name is of the form
1084 1.126 wiz "nbmake-MACHINE-BUILDID".
1085 1.1 tv
1086 1.105 wiz -C cdextras
1087 1.105 wiz Append cdextras to the CDEXTRA variable, which is a space-
1088 1.104 wiz separated list of files or directories that will be added to
1089 1.126 wiz the CD-ROM image that may be create by the "iso-image" or
1090 1.126 wiz "iso-image-source" operations. Files will be added to the root
1091 1.126 wiz of the CD-ROM image, whereas directories will be copied
1092 1.87 apb recursively. If relative paths are specified, they will be
1093 1.87 apb converted to absolute paths before being used. Multiple paths
1094 1.105 wiz may be specified via multiple -C options, or via a single
1095 1.87 apb option whose argument contains multiple space-separated paths.
1096 1.66 jnemeth
1097 1.136 uwe -c compiler
1098 1.136 uwe Select the compiler for the toolchain to build NetBSD and for
1099 1.136 uwe inclusion in the NetBSD distribution. Supported choices:
1100 1.136 uwe
1101 1.136 uwe clang
1102 1.136 uwe
1103 1.136 uwe gcc [default]
1104 1.136 uwe
1105 1.136 uwe The compiler used to build the toolchain can be different; see
1106 1.136 uwe HOST_CC and HOST_CXX.
1107 1.136 uwe
1108 1.105 wiz -D dest Set the value of DESTDIR to dest. If a relative path is
1109 1.104 wiz specified, it will be converted to an absolute path before
1110 1.104 wiz being used.
1111 1.104 wiz
1112 1.105 wiz -E Set `expert' mode. This overrides various sanity checks, and
1113 1.105 wiz allows: DESTDIR does not have to be set to a non-root path for
1114 1.105 wiz builds, and MKUNPRIVED=yes does not have to be set when
1115 1.104 wiz building as a non-root user.
1116 1.23 lukem
1117 1.105 wiz Note: It is highly recommended that you know what you are doing
1118 1.23 lukem when you use this option.
1119 1.19 lukem
1120 1.148 lukem -h Show a help message, and exit.
1121 1.51 wiz
1122 1.105 wiz -j njob Run up to njob make(1) subjobs in parallel; passed through to
1123 1.74 apb make(1). If you see failures for reasons other than running
1124 1.105 wiz out of memory while using build.sh with -j, please save
1125 1.104 wiz complete build logs so the failures can be analyzed.
1126 1.74 apb
1127 1.105 wiz To achieve the fastest builds, -j values between (1 + the
1128 1.104 wiz number of CPUs) and (2 * the number of CPUs) are recommended.
1129 1.104 wiz Use lower values on machines with limited memory or I/O
1130 1.104 wiz bandwidth.
1131 1.104 wiz
1132 1.126 wiz -M obj Set MAKEOBJDIRPREFIX to obj. Unsets MAKEOBJDIR. See "-O obj"
1133 1.126 wiz for more information.
1134 1.104 wiz
1135 1.105 wiz For instance, if the source directory is /usr/src, a setting of
1136 1.126 wiz "-M /usr/obj" will place build-time files under
1137 1.105 wiz /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
1138 1.105 wiz /usr/obj/usr/src/usr.bin, and so forth.
1139 1.88 apb
1140 1.73 apb If a relative path is specified, it will be converted to an
1141 1.105 wiz absolute path before being used. build.sh imposes the
1142 1.105 wiz restriction that the argument to the -M option must not begin
1143 1.126 wiz with a "$" (dollar sign) character; otherwise it would be too
1144 1.104 wiz difficult to determine whether the value is an absolute or a
1145 1.104 wiz relative path. If the directory does not already exist,
1146 1.105 wiz build.sh will create it.
1147 1.18 lukem
1148 1.109 apb -m mach Set the value of MACHINE to mach, unless the mach argument is
1149 1.109 apb an alias that refers to a MACHINE/MACHINE_ARCH pair, in which
1150 1.109 apb case both MACHINE and MACHINE_ARCH are set from the alias.
1151 1.109 apb Such aliases are interpreted entirely by build.sh; they are not
1152 1.109 apb used by any other part of the build system. The MACHINE_ARCH
1153 1.109 apb setting implied by mach will override any value of MACHINE_ARCH
1154 1.109 apb in the process environment, but will not override a value set
1155 1.109 apb by the -a option. All cross builds require -m, but if unset on
1156 1.109 apb a NetBSD host, the host's value of MACHINE will be detected and
1157 1.109 apb used automatically.
1158 1.109 apb
1159 1.109 apb See the list-arch operation for a way to get a list of valid
1160 1.109 apb MACHINE and MACHINE_ARCH settings.
1161 1.1 tv
1162 1.105 wiz -N noiselevel
1163 1.126 wiz Set the "noisyness" level of the build, by setting MAKEVERBOSE
1164 1.126 wiz to noiselevel.
1165 1.45 lukem
1166 1.105 wiz -n Show the commands that would be executed by build.sh, but do
1167 1.126 wiz not make any changes. This is similar in concept to "make -n".
1168 1.1 tv
1169 1.105 wiz -O obj Create an appropriate transform macro for MAKEOBJDIR that will
1170 1.105 wiz place the built object files under obj. Unsets
1171 1.105 wiz MAKEOBJDIRPREFIX.
1172 1.88 apb
1173 1.126 wiz For instance, a setting of "-O /usr/obj" will place build-time
1174 1.126 wiz files under /usr/obj/bin, /usr/obj/lib, /usr/obj/usr.bin, and
1175 1.126 wiz so forth.
1176 1.88 apb
1177 1.88 apb If a relative path is specified, it will be converted to an
1178 1.105 wiz absolute path before being used. build.sh imposes the
1179 1.105 wiz restriction that the argument to the -O option must not contain
1180 1.126 wiz a "$" (dollar sign) character. If the directory does not
1181 1.105 wiz already exist, build.sh will create it.
1182 1.73 apb
1183 1.105 wiz In normal use, exactly one of the -M or -O options should be
1184 1.105 wiz specified. If neither -M nor -O is specified, then a default
1185 1.78 apb object directory will be chosen according to rules in
1186 1.78 apb <bsd.obj.mk>. Relying on this default is not recommended
1187 1.78 apb because it is determined by complex rules that are influenced
1188 1.78 apb by the values of several variables and by the location of the
1189 1.78 apb source directory.
1190 1.18 lukem
1191 1.151 lukem Note: Placing the obj directory location outside of the default
1192 1.151 lukem source tree hierarchy makes it easier to manually clear out old
1193 1.151 lukem files in the event the "make cleandir" operation is unable to
1194 1.151 lukem do so. (See CAVEATS below.)
1195 1.151 lukem
1196 1.151 lukem Note: The use of one of -M or -O is the only means of building
1197 1.151 lukem multiple machine architecture userlands from the same source
1198 1.151 lukem tree without cleaning between builds (in which case, one would
1199 1.151 lukem specify distinct obj locations for each).
1200 1.109 apb
1201 1.126 wiz -o Set the value of MKOBJDIRS to "no". Otherwise, it will be
1202 1.126 wiz automatically set to "yes". This default is opposite to the
1203 1.105 wiz behaviour when not using build.sh.
1204 1.1 tv
1205 1.148 lukem -P Set the value of MKREPRO and MKREPRO_TIMESTAMP to the latest
1206 1.148 lukem source CVS timestamp for reproducible builds.
1207 1.148 lukem
1208 1.105 wiz -R rel Set the value of RELEASEDIR to rel. If a relative path is
1209 1.59 apb specified, it will be converted to an absolute path before
1210 1.59 apb being used.
1211 1.18 lukem
1212 1.105 wiz -r Remove the contents of DESTDIR and TOOLDIR before building
1213 1.1 tv (provides a clean starting point). This will skip deleting
1214 1.105 wiz DESTDIR if building on a native system to the root directory.
1215 1.1 tv
1216 1.105 wiz -S seed Change the value of BUILDSEED to seed. This should rarely be
1217 1.72 perry necessary.
1218 1.72 perry
1219 1.105 wiz -T tools Set the value of TOOLDIR to tools. If a relative path is
1220 1.104 wiz specified, it will be converted to an absolute path before
1221 1.126 wiz being used. If set, the bootstrap "make" will only be rebuilt
1222 1.126 wiz if the source files for make(1) have changed.
1223 1.104 wiz
1224 1.105 wiz -U Set MKUNPRIVED=yes.
1225 1.104 wiz
1226 1.105 wiz -u Set MKUPDATE=yes.
1227 1.104 wiz
1228 1.105 wiz -V var=[value]
1229 1.105 wiz Set the environment variable var to an optional value. This is
1230 1.105 wiz propagated to the nbmake wrapper.
1231 1.105 wiz
1232 1.105 wiz -w wrapper
1233 1.105 wiz Create the nbmake wrapper script (see below) in a custom
1234 1.105 wiz location, specified by wrapper. This allows, for instance, to
1235 1.151 lukem place the wrapper in PATH automatically.
1236 1.151 lukem
1237 1.151 lukem Note: wrapper is the full name of the file, not just a
1238 1.151 lukem directory name. If a relative path is specified, it will be
1239 1.151 lukem converted to an absolute path before being used.
1240 1.1 tv
1241 1.105 wiz -X x11src
1242 1.105 wiz Set the value of X11SRCDIR to x11src. If a relative path is
1243 1.59 apb specified, it will be converted to an absolute path before
1244 1.59 apb being used.
1245 1.49 lukem
1246 1.105 wiz -x Set MKX11=yes.
1247 1.49 lukem
1248 1.105 wiz -Z var Unset ("zap") the environment variable var. This is propagated
1249 1.105 wiz to the nbmake wrapper.
1250 1.40 lukem
1251 1.148 lukem -? Show a help message, and exit.
1252 1.148 lukem
1253 1.105 wiz The "nbmake-MACHINE" wrapper script
1254 1.105 wiz If using the build.sh script to build NetBSD, a nbmake-MACHINE script
1255 1.105 wiz will be created in TOOLDIR/bin upon the first build to assist in building
1256 1.1 tv subtrees on a cross-compile host.
1257 1.1 tv
1258 1.105 wiz nbmake-MACHINE can be invoked in lieu of make(1), and will instead call
1259 1.126 wiz the up-to-date version of "nbmake" installed into TOOLDIR/bin with
1260 1.105 wiz several key variables pre-set, including MACHINE, MACHINE_ARCH, and
1261 1.105 wiz TOOLDIR. nbmake-MACHINE will also set variables specified with -V, and
1262 1.105 wiz unset variables specified with -Z.
1263 1.40 lukem
1264 1.105 wiz This script can be symlinked into a directory listed in PATH, or called
1265 1.1 tv with an absolute path.
1266 1.1 tv
1267 1.105 wiz EXAMPLES
1268 1.151 lukem 1. % ./build.sh [OPTIONS] tools kernel=GENERIC
1269 1.28 lukem
1270 1.28 lukem Build a new toolchain, and use the new toolchain to configure and
1271 1.28 lukem build a new GENERIC kernel.
1272 1.28 lukem
1273 1.151 lukem 2. % ./build.sh [OPTIONS] -U distribution
1274 1.28 lukem
1275 1.105 wiz Using unprivileged mode, build a complete distribution to a DESTDIR
1276 1.148 lukem directory that build.sh selects (and will show).
1277 1.28 lukem
1278 1.151 lukem 3. # ./build.sh [OPTIONS] -U install=/
1279 1.28 lukem
1280 1.105 wiz As root, install to / the distribution that was built by example 2.
1281 1.105 wiz Even though this is run as root, -U is required so that the
1282 1.105 wiz permissions stored in DESTDIR/METALOG are correctly applied to the
1283 1.105 wiz files as they're copied to /.
1284 1.28 lukem
1285 1.151 lukem 4. % ./build.sh [OPTIONS] -U -u release
1286 1.28 lukem
1287 1.105 wiz Using unprivileged mode, build a complete release to DESTDIR and
1288 1.148 lukem RELEASEDIR directories that build.sh selects (and will show).
1289 1.126 wiz MKUPDATE=yes (-u) is set to prevent the "make cleandir", so that if
1290 1.126 wiz this is run after example 2, it doesn't need to redo that portion of
1291 1.126 wiz the release build.
1292 1.16 lukem
1293 1.105 wiz OBSOLETE VARIABLES
1294 1.154 lukem MKKDEBUG Use MKDEBUGKERNEL.
1295 1.154 lukem
1296 1.153 lukem NBUILDJOBS Use the build.sh and make(1) option -j instead.
1297 1.15 lukem
1298 1.105 wiz USE_NEW_TOOLCHAIN
1299 1.15 lukem The new toolchain is now the default. To disable, use
1300 1.105 wiz TOOLCHAIN_MISSING=yes.
1301 1.10 sommerfe
1302 1.105 wiz SEE ALSO
1303 1.151 lukem ar(1), config(1), ctags(1), cvs(1), cvslatest(1), ex(1), g++(1), gzip(1),
1304 1.151 lukem ident(1), ld(1), lint(1), make(1), mkisofs(1), sh(1), uname(1), vi(1),
1305 1.151 lukem options(4), mk.conf(5), atf(7), hier(7), release(7), sysctl(7),
1306 1.151 lukem etcupdate(8), installboot(8), mount(8), mtree(8), postinstall(8),
1307 1.151 lukem sysinst(8), pkgsrc/sysutils/cdrtools
1308 1.1 tv
1309 1.105 wiz HISTORY
1310 1.105 wiz The build.sh based build scheme was introduced for NetBSD 1.6 as
1311 1.105 wiz USE_NEW_TOOLCHAIN, and re-worked to TOOLCHAIN_MISSING after that.
1312 1.1 tv
1313 1.109 apb CAVEATS
1314 1.109 apb After significant updates to third-party components in the source tree,
1315 1.126 wiz the "make cleandir" operation may be insufficient to clean out old files
1316 1.126 wiz in object directories. Instead, one may have to manually remove the
1317 1.126 wiz files. Consult the UPDATING file for notices concerning this.
1318 1.109 apb
1319 1.154 lukem NetBSD June 11, 2023 NetBSD
1320