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
51 sources, which is loosely defined as the things required to rebuild
52 the system to a useful state.
55 contains the source for the system documentation, excluding the manual
59 contains a tree that provides a consistent interface for building and
60 installing third party applications.
61 For more information about the ports build process, see
66 command is used in each of these directories to build and install the
67 things in that directory.
70 command in any directory or
71 subdirectory of those directories has the same effect as issuing the
72 same command in all subdirectories of that directory.
73 With no target specified, the things in that directory are just built.
75 A source tree is allowed to be read-only.
78 objects are usually built in a separate object directory hierarchy
79 specified by the environment variable
80 .Va MAKEOBJDIRPREFIX ,
86 For a given source directory, its canonical object directory
88 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
94 .Pa /usr/obj${.CURDIR}
95 if this variable is not set.
96 Cross-builds set the object directory as described in the
101 The build may be controlled by defining
103 variables described in the
105 section below, and by the variables documented in
108 The following list provides the names and actions for the targets
109 supported by the build system:
110 .Bl -tag -width ".Cm cleandepend"
112 Remove any files created during the build process.
115 .Pa ${.OBJDIR}/${DEPENDFILE}
120 Remove the canonical object directory if it exists, or perform
121 actions equivalent to
122 .Dq Li "make clean cleandepend"
124 This target will also remove an
130 It is advisable to run
131 .Dq Li "make cleandir"
132 twice: the first invocation will remove the canonical object directory
133 and the second one will clean up
136 Generate a list of build dependencies in file
137 .Pa ${.OBJDIR}/${DEPENDFILE} .
139 Install the results of the build to the appropriate location in the
140 installation directory hierarchy specified in variable
143 Create the canonical object directory associated with the current
146 Create a symbolic link to the canonical object directory in
149 Generate a tags file using the program specified in the
153 The build system supports
159 The other supported targets under directory
162 .Bl -tag -width ".Cm distributeworld"
164 Spawn an interactive shell with environment variables set up for
165 cross-building the system.
166 The target architecture needs to be specified with
173 This target is only useful after a complete cross-toolchain including
174 the compiler, linker, assembler, headers and libraries has been
179 Build everything but the kernel, configure files in
183 The actual build location prefix used is
184 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
185 for native builds, and
186 .Pa ${MAKEOBJDIRPREFIX}/${TARGET}${.CURDIR}
187 for cross builds and native builds with variable
188 .Va CROSS_BUILD_TESTING
191 Attempt to clean up targets built by a preceding
194 .It Cm distributeworld
195 Distribute everything compiled by a preceding
198 Files are placed in the directory hierarchy specified by
202 This target is used while building a release; see
205 Archive the results of
206 .Cm distributeworld ,
207 placing the results in
209 This target is used while building a release; see
212 Install everything built by a preceding
214 step into the directory hierarchy pointed to by
219 If installing onto an NFS file system and running
223 option, make sure that
225 is running on both client and server.
228 on how to make it start at boot time.
230 Create the build toolchain needed to build the rest of the system.
231 For cross-architecture builds, this step creates a cross-toolchain.
233 For each architecture,
238 for all kernels for that architecture,
241 This command takes a long time.
243 Get updated sources as configured in
246 Print a list of supported
250 pairs for world and kernel targets.
252 Execute the same targets as
254 In addition print a summary of all failed targets at the end and
255 exit with an error if there were any.
257 Create a build toolchain for each architecture supported by the build system.
260 Kernel specific build targets in
263 .Bl -tag -width ".Cm distributekernel"
265 Rebuild the kernel and the kernel modules.
267 Install the kernel and the kernel modules to directory
268 .Pa ${DESTDIR}/boot/kernel ,
269 renaming any pre-existing directory with this name to
271 if it contained the currently running kernel.
272 The target directory under
274 may be modified using the
280 .It Cm distributekernel
281 Install the kernel to the directory
282 .Pa ${DISTDIR}/kernel/boot/kernel .
283 This target is used while building a release; see
286 Archive the results of
287 .Cm distributekernel ,
288 placing the results in
290 This target is used while building a release; see
297 .It Cm kernel-toolchain
298 Rebuild the tools needed for kernel compilation.
299 Use this if you did not do a
302 .It Cm reinstallkernel
303 Reinstall the kernel and the kernel modules, overwriting the contents
304 of the target directory.
307 target, the target directory can be specified using the
313 Convenience targets for cleaning up the install destination directory
317 .Bl -tag -width ".Cm delete-old-libs"
319 Print a list of old files and directories in the system.
321 Delete obsolete base system files and directories interactively.
323 .Li -DBATCH_DELETE_OLD_FILES
324 is specified at the command line, the delete operation will be
331 should be set as with
332 .Dq Li "make installworld" .
333 .It Cm delete-old-libs
334 Delete obsolete base system libraries interactively.
335 This target should only be used if no 3rd party software uses these
338 .Li -DBATCH_DELETE_OLD_FILES
339 is specified at the command line, the delete operation will be
346 should be set as with
347 .Dq Li "make installworld" .
350 Variables that influence all builds include:
351 .Bl -tag -width ".Va MAKEOBJDIRPREFIX"
353 Defines a set of debugging flags that will be used to build all userland
362 targets install binaries from the current
365 so that debugging information is retained in the installed binaries.
367 The directory hierarchy prefix where built objects will be installed.
370 defaults to the empty string.
371 .It Va MAKEOBJDIRPREFIX
372 Defines the prefix for directory names in the tree of built objects.
376 This variable should only be set in the environment and not via
380 If defined, compiler warnings will not cause the build to halt,
381 even if the makefile says otherwise.
383 If defined, the build process will run the DTrace CTF conversion
384 tools on built objects.
387 Additionally, builds in
389 are influenced by the following
392 .Bl -tag -width ".Va SUBDIR_OVERRIDE"
394 Overrides which kernel to build and install for the various kernel
399 If set, the build target
403 .Va NO_KERNELCONFIG ,
407 When set to a value other than
411 is set to the value of
414 If set, this variable supplies a list of additional directories to
415 build, relative to the root of the source tree.
417 A list of ports with kernel modules that should be built and installed
423 .Bd -literal -offset indent
424 make PORTS_MODULES=emulators/kqemu-kmod kernel
426 .It Va SUBDIR_OVERRIDE
427 Override the default list of sub-directories and only build the
428 sub-directory named in this variable.
429 This variable is useful when debugging failed builds.
430 .Bd -literal -offset indent
431 make some-target SUBDIR_OVERRIDE=foo/bar
434 The target hardware platform.
435 This is analogous to the
438 This is necessary to cross-build some target architectures.
439 For example, cross-building for PC98 machines requires
440 .Va TARGET_ARCH Ns = Ns Li i386
442 .Va TARGET Ns = Ns Li pc98 .
445 defaults to the current hardware platform.
447 The target machine processor architecture.
448 This is analogous to the
451 Set this to cross-build for a different architecture.
454 defaults to the current machine architecture, unless
456 is also set, in which case it defaults to the appropriate
457 value for that platform.
458 Typically, one only needs to set
462 Builds under directory
464 are also influenced by defining one or more of the following symbols,
469 .Bl -tag -width ".Va -DNO_KERNELDEPEND"
471 If set, the build targets that clean parts of the object tree use the
477 If set, no object tree files are cleaned at all.
484 is set no kernel objects are cleaned either.
486 If set, the build process does not run the DTrace CTF conversion tools
489 If set, the build does not descend into the
491 subdirectory (i.e., manpages, locale data files, timezone data files and
494 files will not be rebuild from their sources).
495 .It Va NO_KERNELCLEAN
496 If set, the build process does not run
501 .It Va NO_KERNELCONFIG
502 If set, the build process does not run
507 .It Va NO_KERNELDEPEND
508 If set, the build process does not run
514 If set, the build process does not run
520 If set, the update process does not update the source of the
522 documentation as part of the
525 .It Va NO_PORTSUPDATE
526 If set, the update process does not update the Ports tree as part of the
530 If set, the update process does not update the www tree as part of the
535 Builds under directory
537 are influenced by the following
540 .Bl -tag -width ".Va DOC_LANG"
542 If set, restricts the documentation build to the language subdirectories
543 specified as its content.
544 The default action is to build documentation for all languages.
549 target are influenced by the following
552 .Bl -tag -width ".Va MAKE_JUST_KERNELS"
554 Pass the value of this variable to each
556 invocation used to build worlds and kernels.
557 This can be used to enable multiple jobs within a single architecture's build
558 while still building each architecture serially.
559 .It Va MAKE_JUST_KERNELS
560 Only build kernels for each supported architecture.
561 .It Va MAKE_JUST_WORLDS
562 Only build worlds for each supported architecture.
563 .It Va UNIVERSE_TARGET
564 Execute the specified
566 target for each supported architecture instead of the default action of
567 building a world and one or more kernels.
570 .Bl -tag -width ".Pa /usr/share/examples/etc/make.conf" -compact
571 .It Pa /usr/doc/Makefile
572 .It Pa /usr/doc/share/mk/doc.project.mk
573 .It Pa /usr/ports/Mk/bsd.port.mk
574 .It Pa /usr/ports/Mk/bsd.sites.mk
575 .It Pa /usr/share/examples/etc/make.conf
576 .It Pa /usr/src/Makefile
577 .It Pa /usr/src/Makefile.inc1
582 method of updating your system from the latest sources, please see the
587 The following sequence of commands can be used to cross-build the
588 system for the sparc64 architecture on an i386 host:
589 .Bd -literal -offset indent
591 make TARGET=sparc64 buildworld
592 make TARGET=sparc64 DESTDIR=/clients/sparc64 installworld
610 .An Mike W. Meyer Aq mwm@mired.org .