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
512 The directories are built in parallel with each other,
513 and with the base system directories.
516 directive at the beginning of the
518 list to ensure all base system directories are built first.
520 may also be used as needed elsewhere within the list.
522 If set, this variable supplies a list of additional tools that are used by the
527 .It Va LOCAL_LIB_DIRS
528 If set, this variable supplies a list of additional directories relative to
529 the root of the source tree to build as part of the
532 The directories are built in parallel with each other,
533 and with the base system libraries.
536 directive at the beginning of the
538 list to ensure all base system libraries are built first.
540 may also be used as needed elsewhere within the list.
542 If set, this variable supplies a list of additional mtrees relative to the
543 root of the source tree to use as part of the
546 .It Va LOCAL_TOOL_DIRS
547 If set, this variable supplies a list of additional directories relative to
548 the root of the source tree to build as part of the
551 .It Va LOCAL_XTOOL_DIRS
552 If set, this variable supplies a list of additional directories relative to
553 the root of the source tree to build as part of the
557 A list of ports with kernel modules that should be built and installed
563 .Bd -literal -offset indent
564 make PORTS_MODULES=emulators/kqemu-kmod kernel
567 Command to use at install time when stripping binaries.
568 Be sure to add any additional tools required to run
573 variable before running the
581 .It Va SUBDIR_OVERRIDE
582 Override the default list of sub-directories and only build the
583 sub-directory named in this variable.
586 then all libraries and includes, and some of the build tools will still build
592 will only build the specified directory as was done historically.
595 it is necesarry to override
597 with any custom directories containing libraries.
598 This allows building a subset of the system in the same way as
600 does using its sysroot handling.
601 This variable can also be useful when debugging failed builds.
602 .Bd -literal -offset indent
603 make some-target SUBDIR_OVERRIDE=foo/bar
606 The target hardware platform.
607 This is analogous to the
610 This is necessary to cross-build some target architectures.
611 For example, cross-building for ARM64 machines requires
612 .Va TARGET_ARCH Ns = Ns Li aarch64
614 .Va TARGET Ns = Ns Li arm64 .
617 defaults to the current hardware platform, unless
619 is also set, in which case it defaults to the appropriate
620 value for that architecture.
622 The target machine processor architecture.
623 This is analogous to the
626 Set this to cross-build for a different architecture.
629 defaults to the current machine architecture, unless
631 is also set, in which case it defaults to the appropriate
632 value for that platform.
633 Typically, one only needs to set
637 Builds under directory
639 are also influenced by defining one or more of the following symbols,
644 .Bl -tag -width ".Va -DNO_KERNELCONFIG"
646 If set, the build targets that clean parts of the object tree use the
652 If set, no object tree files are cleaned at all.
653 This is the default when
667 is set no kernel objects are cleaned either.
669 If set, the build process does not run the DTrace CTF conversion tools
672 If set, the build does not descend into the
674 subdirectory (i.e., manual pages, locale data files, timezone data files and
677 files will not be rebuild from their sources).
678 .It Va NO_KERNELCLEAN
679 If set, the build process does not run
684 .It Va NO_KERNELCONFIG
685 If set, the build process does not run
691 If set, the build process does not run
697 If set, the update process does not update the source of the
699 documentation as part of the
703 If set, the libraries phase will be skipped.
705 If set, no object directories will be created.
706 This should only be used if object directories were created in a
707 previous build and no new directories are connected.
708 .It Va NO_PORTSUPDATE
709 If set, the update process does not update the Ports tree as part of the
713 If set, the update process does not update the www tree as part of the
717 If set, the build target
722 and will skip most bootstrap phases.
723 It will only bootstrap libraries and build all of userland.
724 This option should be used only when it is known that none of the bootstrap
725 needs changed and that no new directories have been connected to the build.
728 Builds under directory
730 are influenced by the following
733 .Bl -tag -width ".Va DOC_LANG"
735 If set, restricts the documentation build to the language subdirectories
736 specified as its content.
737 The default action is to build documentation for all languages.
742 target are influenced by the following
745 .Bl -tag -width ".Va MAKE_JUST_KERNELS"
747 Pass the value of this variable to each
749 invocation used to build worlds and kernels.
750 This can be used to enable multiple jobs within a single architecture's build
751 while still building each architecture serially.
752 .It Va MAKE_JUST_KERNELS
753 Only build kernels for each supported architecture.
754 .It Va MAKE_JUST_WORLDS
755 Only build worlds for each supported architecture.
756 .It Va UNIVERSE_TARGET
757 Execute the specified
759 target for each supported architecture instead of the default action of
760 building a world and one or more kernels.
763 .Bl -tag -width ".Pa /usr/share/examples/etc/make.conf" -compact
764 .It Pa /usr/doc/Makefile
765 .It Pa /usr/doc/share/mk/doc.project.mk
766 .It Pa /usr/ports/Mk/bsd.port.mk
767 .It Pa /usr/ports/Mk/bsd.sites.mk
768 .It Pa /usr/share/examples/etc/make.conf
769 .It Pa /usr/src/Makefile
770 .It Pa /usr/src/Makefile.inc1
775 method of updating your system from the latest sources, please see the
780 The following sequence of commands can be used to cross-build the
781 system for the armv6 architecture on an amd64 host:
782 .Bd -literal -offset indent
784 make TARGET_ARCH=armv6 buildworld buildkernel
785 make TARGET_ARCH=armv6 DESTDIR=/clients/arm64 installworld installkernel
804 .An Mike W. Meyer Aq Mt mwm@mired.org