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 The canonical object directory is described in the documentation for the
89 The build may be controlled by defining
91 variables described in the
93 section below, and by the variables documented in
96 The following list provides the names and actions for the targets
97 supported by the build system:
98 .Bl -tag -width ".Cm cleandepend"
100 Run Clang static analyzer against all objects and present output on stdout.
102 Run tests for a given subdirectory.
103 The default directory used is
105 but the check directory can be changed with
110 test suite on installed world.
112 Remove any files created during the build process.
115 .Pa ${.OBJDIR}/${DEPENDFILE}*
116 files generated by prior
122 Remove the canonical object directory if it exists, or perform
123 actions equivalent to
124 .Dq Li "make clean cleandepend"
126 This target will also remove an
132 It is advisable to run
133 .Dq Li "make cleandir"
134 twice: the first invocation will remove the canonical object directory
135 and the second one will clean up
138 Generate a list of build dependencies in file
139 .Pa ${.OBJDIR}/${DEPENDFILE} .
140 Per-object dependencies are generated at build time and stored in
141 .Pa ${.OBJDIR}/${DEPENDFILE}.${OBJ} .
143 Install the results of the build to the appropriate location in the
144 installation directory hierarchy specified in variable
147 Create the canonical object directory associated with the current
150 Create a symbolic link to the canonical object directory in
153 Generate a tags file using the program specified in the
157 The build system supports
163 The other supported targets under directory
166 .Bl -tag -width ".Cm distributeworld"
168 Spawn an interactive shell with environment variables set up for
169 cross-building the system.
170 The target architecture needs to be specified with
177 This target is only useful after a complete cross-toolchain including
178 the compiler, linker, assembler, headers and libraries has been
183 Build everything but the kernel, configure files in
187 The object directory can be changed from the default
193 The actual build location prefix used
195 .Va WITH_UNIFIED_OBJDIR
199 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}
202 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
203 for native builds, and
204 .Pa ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}${.CURDIR}
205 for cross builds and native builds with variable
206 .Va CROSS_BUILD_TESTING
209 Attempt to clean up targets built by a preceding
211 or similar step built from this source directory.
214 .Va WITH_UNIFIED_OBJDIR
215 is enabled, attempt to clean up targets built by a preceding
218 or similar step, for any architecture built from this source directory.
219 .It Cm distributeworld
220 Distribute everything compiled by a preceding
223 Files are placed in the directory hierarchy specified by
227 This target is used while building a release; see
230 This target builds a cross-toolchain for the given
234 as well as a select list of static userland tools for the host system.
235 This is intended to be used in a jail where QEMU is used to improve
236 performance by avoiding emulating binaries that do not need to be emulated.
241 .It Cm native-xtools-install
242 Installs the results to
243 .Pa ${DESTDIR}/${NXTP}
253 Archive the results of
254 .Cm distributeworld ,
255 placing the results in
257 This target is used while building a release; see
260 Install everything built by a preceding
262 step into the directory hierarchy pointed to by
267 If installing onto an NFS file system and running
271 option, make sure that
273 is running on both client and server.
276 on how to make it start at boot time.
278 Create the build toolchain needed to build the rest of the system.
279 For cross-architecture builds, this step creates a cross-toolchain.
281 For each architecture,
286 for all kernels for that architecture,
289 This command takes a long time.
291 Get updated sources as configured in
294 Print a list of supported
298 pairs for world and kernel targets.
300 Execute the same targets as
302 In addition print a summary of all failed targets at the end and
303 exit with an error if there were any.
305 Create a build toolchain for each architecture supported by the build system.
307 Builds and installs a cross-toolchain and sysroot for the given
311 The sysroot contains target library and headers.
312 The target is an alias for
316 The location of the files installed can be controlled with
318 The target location in
321 .Pa ${DESTDIR}/${XDTP}
329 .Pa ${TARGET_ARCH}-freebsd .
335 Installs the files for the
339 Installs autoconf-style symlinks to
340 .Pa ${DESTDIR}/usr/bin
341 pointing into the xdev toolchain in
342 .Pa ${DESTDIR}/${XDTP} .
345 Kernel specific build targets in
348 .Bl -tag -width ".Cm distributekernel"
350 Rebuild the kernel and the kernel modules.
351 The object directory can be changed from the default
358 Install the kernel and the kernel modules to directory
359 .Pa ${DESTDIR}/boot/kernel ,
360 renaming any pre-existing directory with this name to
362 if it contained the currently running kernel.
363 The target directory under
365 may be modified using the
371 .It Cm distributekernel
372 Install the kernel to the directory
373 .Pa ${DISTDIR}/kernel/boot/kernel .
374 This target is used while building a release; see
377 Archive the results of
378 .Cm distributekernel ,
379 placing the results in
381 This target is used while building a release; see
388 .It Cm kernel-toolchain
389 Rebuild the tools needed for kernel compilation.
390 Use this if you did not do a
393 .It Cm reinstallkernel
394 Reinstall the kernel and the kernel modules, overwriting the contents
395 of the target directory.
398 target, the target directory can be specified using the
404 Convenience targets for cleaning up the install destination directory
408 .Bl -tag -width ".Cm delete-old-libs"
410 Print a list of old files and directories in the system.
412 Delete obsolete base system files and directories interactively.
414 .Li -DBATCH_DELETE_OLD_FILES
415 is specified at the command line, the delete operation will be
422 should be set as with
423 .Dq Li "make installworld" .
424 .It Cm delete-old-libs
425 Delete obsolete base system libraries interactively.
426 This target should only be used if no third party software uses these
429 .Li -DBATCH_DELETE_OLD_FILES
430 is specified at the command line, the delete operation will be
437 should be set as with
438 .Dq Li "make installworld" .
441 Variables that influence all builds include:
442 .Bl -tag -width ".Va MAKEOBJDIRPREFIX"
444 Defines a set of debugging flags that will be used to build all userland
453 targets install binaries from the current
456 so that debugging information is retained in the installed binaries.
458 The directory hierarchy prefix where built objects will be installed.
461 defaults to the empty string.
462 .It Va MAKEOBJDIRPREFIX
463 Defines the prefix for directory names in the tree of built objects.
467 This variable should only be set in the environment or
468 .Pa /etc/src-env.conf
475 If defined, compiler warnings will not cause the build to halt,
476 even if the makefile says otherwise.
478 If defined, the build process will run the DTrace CTF conversion
479 tools on built objects.
482 Additionally, builds in
484 are influenced by the following
487 .Bl -tag -width ".Va SUBDIR_OVERRIDE"
489 Overrides which kernel to build and install for the various kernel
494 If set, the build target
498 .Va NO_KERNELCONFIG ,
501 When set to a value other than
505 is set to the value of
508 If set, this variable supplies a list of additional directories relative to
509 the root of the source tree to build as part of the
513 If set, this variable supplies a list of additional tools that are used by the
518 .It Va LOCAL_LIB_DIRS
519 If set, this variable supplies a list of additional directories relative to
520 the root of the source tree to build as part of the
524 If set, this variable supplies a list of additional mtrees relative to the
525 root of the source tree to use as part of the
528 .It Va LOCAL_TOOL_DIRS
529 If set, this variable supplies a list of additional directories relative to
530 the root of the source tree to build as part of the
533 .It Va LOCAL_XTOOL_DIRS
534 If set, this variable supplies a list of additional directories relative to
535 the root of the source tree to build as part of the
539 A list of ports with kernel modules that should be built and installed
545 .Bd -literal -offset indent
546 make PORTS_MODULES=emulators/kqemu-kmod kernel
549 Command to use at install time when stripping binaries.
550 Be sure to add any additional tools required to run
555 variable before running the
563 .It Va SUBDIR_OVERRIDE
564 Override the default list of sub-directories and only build the
565 sub-directory named in this variable.
568 then all libraries and includes, and some of the build tools will still build
574 will only build the specified directory as was done historically.
577 it is necesarry to override
579 with any custom directories containing libraries.
580 This allows building a subset of the system in the same way as
582 does using its sysroot handling.
583 This variable can also be useful when debugging failed builds.
584 .Bd -literal -offset indent
585 make some-target SUBDIR_OVERRIDE=foo/bar
588 The target hardware platform.
589 This is analogous to the
592 This is necessary to cross-build some target architectures.
593 For example, cross-building for ARM64 machines requires
594 .Va TARGET_ARCH Ns = Ns Li aarch64
596 .Va TARGET Ns = Ns Li arm64 .
599 defaults to the current hardware platform, unless
601 is also set, in which case it defaults to the appropriate
602 value for that architecture.
604 The target machine processor architecture.
605 This is analogous to the
608 Set this to cross-build for a different architecture.
611 defaults to the current machine architecture, unless
613 is also set, in which case it defaults to the appropriate
614 value for that platform.
615 Typically, one only needs to set
619 Builds under directory
621 are also influenced by defining one or more of the following symbols,
626 .Bl -tag -width ".Va -DNO_KERNELCONFIG"
628 If set, the build targets that clean parts of the object tree use the
634 If set, no object tree files are cleaned at all.
635 This is the default when
649 is set no kernel objects are cleaned either.
651 If set, the build process does not run the DTrace CTF conversion tools
654 If set, the build does not descend into the
656 subdirectory (i.e., manual pages, locale data files, timezone data files and
659 files will not be rebuild from their sources).
660 .It Va NO_KERNELCLEAN
661 If set, the build process does not run
666 .It Va NO_KERNELCONFIG
667 If set, the build process does not run
673 If set, the build process does not run
679 If set, the update process does not update the source of the
681 documentation as part of the
685 If set, the libraries phase will be skipped.
687 If set, no object directories will be created.
688 This should only be used if object directories were created in a
689 previous build and no new directories are connected.
690 .It Va NO_PORTSUPDATE
691 If set, the update process does not update the Ports tree as part of the
695 If set, the update process does not update the www tree as part of the
699 If set, the build target
704 and will skip most bootstrap phases.
705 It will only bootstrap libraries and build all of userland.
706 This option should be used only when it is known that none of the bootstrap
707 needs changed and that no new directories have been connected to the build.
710 Builds under directory
712 are influenced by the following
715 .Bl -tag -width ".Va DOC_LANG"
717 If set, restricts the documentation build to the language subdirectories
718 specified as its content.
719 The default action is to build documentation for all languages.
724 target are influenced by the following
727 .Bl -tag -width ".Va MAKE_JUST_KERNELS"
729 Pass the value of this variable to each
731 invocation used to build worlds and kernels.
732 This can be used to enable multiple jobs within a single architecture's build
733 while still building each architecture serially.
734 .It Va MAKE_JUST_KERNELS
735 Only build kernels for each supported architecture.
736 .It Va MAKE_JUST_WORLDS
737 Only build worlds for each supported architecture.
738 .It Va UNIVERSE_TARGET
739 Execute the specified
741 target for each supported architecture instead of the default action of
742 building a world and one or more kernels.
745 .Bl -tag -width ".Pa /usr/share/examples/etc/make.conf" -compact
746 .It Pa /usr/doc/Makefile
747 .It Pa /usr/doc/share/mk/doc.project.mk
748 .It Pa /usr/ports/Mk/bsd.port.mk
749 .It Pa /usr/ports/Mk/bsd.sites.mk
750 .It Pa /usr/share/examples/etc/make.conf
751 .It Pa /usr/src/Makefile
752 .It Pa /usr/src/Makefile.inc1
757 method of updating your system from the latest sources, please see the
762 The following sequence of commands can be used to cross-build the
763 system for the armv6 architecture on an amd64 host:
764 .Bd -literal -offset indent
766 make TARGET_ARCH=armv6 buildworld buildkernel
767 make TARGET_ARCH=armv6 DESTDIR=/clients/arm64 installworld installkernel
786 .An Mike W. Meyer Aq Mt mwm@mired.org