4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd information on how to build the system
36 system and its applications are contained in three different directories,
42 These directories may be initially empty or non-existent until updated with
50 sources, which is loosely defined as the things required to rebuild
51 the system to a useful state.
54 contains the source for the system documentation, excluding the manual
58 contains a tree that provides a consistent interface for building and
59 installing third party applications.
60 For more information about the ports build process, see
65 command is used in each of these directories to build and install the
66 things in that directory.
69 command in any directory or
70 subdirectory of those directories has the same effect as issuing the
71 same command in all subdirectories of that directory.
72 With no target specified, the things in that directory are just built.
74 A source tree is allowed to be read-only.
77 objects are usually built in a separate object directory hierarchy
78 specified by the environment variable
79 .Va MAKEOBJDIRPREFIX ,
85 For a given source directory, its canonical object directory
87 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
93 .Pa /usr/obj${.CURDIR}
94 if this variable is not set.
95 Cross-builds set the object directory as described in the
100 The build may be controlled by defining
102 variables described in the
104 section below, and by the variables documented in
107 The following list provides the names and actions for the targets
108 supported by the build system:
109 .Bl -tag -width ".Cm cleandepend"
111 Run tests for a given subdirectory.
112 The default directory used is
114 but the check directory can be changed with
119 test suite on installed world.
121 Remove any files created during the build process.
124 .Pa ${.OBJDIR}/${DEPENDFILE}
129 Remove the canonical object directory if it exists, or perform
130 actions equivalent to
131 .Dq Li "make clean cleandepend"
133 This target will also remove an
139 It is advisable to run
140 .Dq Li "make cleandir"
141 twice: the first invocation will remove the canonical object directory
142 and the second one will clean up
145 Generate a list of build dependencies in file
146 .Pa ${.OBJDIR}/${DEPENDFILE} .
148 Install the results of the build to the appropriate location in the
149 installation directory hierarchy specified in variable
152 Create the canonical object directory associated with the current
155 Create a symbolic link to the canonical object directory in
158 Generate a tags file using the program specified in the
162 The build system supports
168 The other supported targets under directory
171 .Bl -tag -width ".Cm distributeworld"
173 Spawn an interactive shell with environment variables set up for
174 cross-building the system.
175 The target architecture needs to be specified with
182 This target is only useful after a complete cross-toolchain including
183 the compiler, linker, assembler, headers and libraries has been
188 Build everything but the kernel, configure files in
192 The object directory can be changed from the default
198 The actual build location prefix used is
199 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
200 for native builds, and
201 .Pa ${MAKEOBJDIRPREFIX}/${TARGET}${.CURDIR}
202 for cross builds and native builds with variable
203 .Va CROSS_BUILD_TESTING
206 Attempt to clean up targets built by a preceding
209 .It Cm distributeworld
210 Distribute everything compiled by a preceding
213 Files are placed in the directory hierarchy specified by
217 This target is used while building a release; see
220 Archive the results of
221 .Cm distributeworld ,
222 placing the results in
224 This target is used while building a release; see
227 Install everything built by a preceding
229 step into the directory hierarchy pointed to by
234 If installing onto an NFS file system and running
238 option, make sure that
240 is running on both client and server.
243 on how to make it start at boot time.
245 Create the build toolchain needed to build the rest of the system.
246 For cross-architecture builds, this step creates a cross-toolchain.
248 For each architecture,
253 for all kernels for that architecture,
256 This command takes a long time.
258 Get updated sources as configured in
261 Print a list of supported
265 pairs for world and kernel targets.
267 Execute the same targets as
269 In addition print a summary of all failed targets at the end and
270 exit with an error if there were any.
272 Create a build toolchain for each architecture supported by the build system.
275 Kernel specific build targets in
278 .Bl -tag -width ".Cm distributekernel"
280 Rebuild the kernel and the kernel modules.
281 The object directory can be changed from the default
288 Install the kernel and the kernel modules to directory
289 .Pa ${DESTDIR}/boot/kernel ,
290 renaming any pre-existing directory with this name to
292 if it contained the currently running kernel.
293 The target directory under
295 may be modified using the
301 .It Cm distributekernel
302 Install the kernel to the directory
303 .Pa ${DISTDIR}/kernel/boot/kernel .
304 This target is used while building a release; see
307 Archive the results of
308 .Cm distributekernel ,
309 placing the results in
311 This target is used while building a release; see
318 .It Cm kernel-toolchain
319 Rebuild the tools needed for kernel compilation.
320 Use this if you did not do a
323 .It Cm reinstallkernel
324 Reinstall the kernel and the kernel modules, overwriting the contents
325 of the target directory.
328 target, the target directory can be specified using the
334 Convenience targets for cleaning up the install destination directory
338 .Bl -tag -width ".Cm delete-old-libs"
340 Print a list of old files and directories in the system.
342 Delete obsolete base system files and directories interactively.
344 .Li -DBATCH_DELETE_OLD_FILES
345 is specified at the command line, the delete operation will be
352 should be set as with
353 .Dq Li "make installworld" .
354 .It Cm delete-old-libs
355 Delete obsolete base system libraries interactively.
356 This target should only be used if no third party software uses these
359 .Li -DBATCH_DELETE_OLD_FILES
360 is specified at the command line, the delete operation will be
367 should be set as with
368 .Dq Li "make installworld" .
371 Variables that influence all builds include:
372 .Bl -tag -width ".Va MAKEOBJDIRPREFIX"
374 Defines a set of debugging flags that will be used to build all userland
383 targets install binaries from the current
386 so that debugging information is retained in the installed binaries.
388 The directory hierarchy prefix where built objects will be installed.
391 defaults to the empty string.
392 .It Va MAKEOBJDIRPREFIX
393 Defines the prefix for directory names in the tree of built objects.
397 This variable should only be set in the environment and not via
401 If defined, compiler warnings will not cause the build to halt,
402 even if the makefile says otherwise.
404 If defined, the build process will run the DTrace CTF conversion
405 tools on built objects.
408 Additionally, builds in
410 are influenced by the following
413 .Bl -tag -width ".Va SUBDIR_OVERRIDE"
415 Overrides which kernel to build and install for the various kernel
420 If set, the build target
424 .Va NO_KERNELCONFIG ,
428 When set to a value other than
432 is set to the value of
435 If set, this variable supplies a list of additional directories relative to
436 the root of the source tree to build as part of the
440 If set, this variable supplies a list of additional tools that are used by the
445 .It Va LOCAL_LIB_DIRS
446 If set, this variable supplies a list of additional directories relative to
447 the root of the source tree to build as part of the
451 If set, this variable supplies a list of additional mtrees relative to the
452 root of the source tree to use as part of the
455 .It Va LOCAL_TOOL_DIRS
456 If set, this variable supplies a list of additional directories relative to
457 the root of the source tree to build as part of the
461 A list of ports with kernel modules that should be built and installed
467 .Bd -literal -offset indent
468 make PORTS_MODULES=emulators/kqemu-kmod kernel
471 Command to use at install time when stripping binaries.
472 Be sure to add any additional tools required to run
477 variable before running the
485 .It Va SUBDIR_OVERRIDE
486 Override the default list of sub-directories and only build the
487 sub-directory named in this variable.
488 This variable is useful when debugging failed builds.
489 .Bd -literal -offset indent
490 make some-target SUBDIR_OVERRIDE=foo/bar
493 The target hardware platform.
494 This is analogous to the
497 This is necessary to cross-build some target architectures.
498 For example, cross-building for PC98 machines requires
499 .Va TARGET_ARCH Ns = Ns Li i386
501 .Va TARGET Ns = Ns Li pc98 .
504 defaults to the current hardware platform.
506 The target machine processor architecture.
507 This is analogous to the
510 Set this to cross-build for a different architecture.
513 defaults to the current machine architecture, unless
515 is also set, in which case it defaults to the appropriate
516 value for that platform.
517 Typically, one only needs to set
521 Builds under directory
523 are also influenced by defining one or more of the following symbols,
528 .Bl -tag -width ".Va -DNO_KERNELDEPEND"
530 If set, the build targets that clean parts of the object tree use the
536 If set, no object tree files are cleaned at all.
543 is set no kernel objects are cleaned either.
545 If set, the build process does not run the DTrace CTF conversion tools
548 If set, the build does not descend into the
550 subdirectory (i.e., manual pages, locale data files, timezone data files and
553 files will not be rebuild from their sources).
554 .It Va NO_KERNELCLEAN
555 If set, the build process does not run
560 .It Va NO_KERNELCONFIG
561 If set, the build process does not run
566 .It Va NO_KERNELDEPEND
567 If set, the build process does not run
573 If set, the build process does not run
579 If set, the update process does not update the source of the
581 documentation as part of the
584 .It Va NO_PORTSUPDATE
585 If set, the update process does not update the Ports tree as part of the
589 If set, the update process does not update the www tree as part of the
594 Builds under directory
596 are influenced by the following
599 .Bl -tag -width ".Va DOC_LANG"
601 If set, restricts the documentation build to the language subdirectories
602 specified as its content.
603 The default action is to build documentation for all languages.
608 target are influenced by the following
611 .Bl -tag -width ".Va MAKE_JUST_KERNELS"
613 Pass the value of this variable to each
615 invocation used to build worlds and kernels.
616 This can be used to enable multiple jobs within a single architecture's build
617 while still building each architecture serially.
618 .It Va MAKE_JUST_KERNELS
619 Only build kernels for each supported architecture.
620 .It Va MAKE_JUST_WORLDS
621 Only build worlds for each supported architecture.
622 .It Va UNIVERSE_TARGET
623 Execute the specified
625 target for each supported architecture instead of the default action of
626 building a world and one or more kernels.
629 .Bl -tag -width ".Pa /usr/share/examples/etc/make.conf" -compact
630 .It Pa /usr/doc/Makefile
631 .It Pa /usr/doc/share/mk/doc.project.mk
632 .It Pa /usr/ports/Mk/bsd.port.mk
633 .It Pa /usr/ports/Mk/bsd.sites.mk
634 .It Pa /usr/share/examples/etc/make.conf
635 .It Pa /usr/src/Makefile
636 .It Pa /usr/src/Makefile.inc1
641 method of updating your system from the latest sources, please see the
646 The following sequence of commands can be used to cross-build the
647 system for the sparc64 architecture on an i386 host:
648 .Bd -literal -offset indent
650 make TARGET=sparc64 buildworld
651 make TARGET=sparc64 DESTDIR=/clients/sparc64 installworld
669 .An Mike W. Meyer Aq mwm@mired.org .