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 Clang static analyzer against all objects and present output on stdout.
113 Run tests for a given subdirectory.
114 The default directory used is
116 but the check directory can be changed with
121 test suite on installed world.
123 Remove any files created during the build process.
126 .Pa ${.OBJDIR}/${DEPENDFILE}*
127 files generated by prior
133 Remove the canonical object directory if it exists, or perform
134 actions equivalent to
135 .Dq Li "make clean cleandepend"
137 This target will also remove an
143 It is advisable to run
144 .Dq Li "make cleandir"
145 twice: the first invocation will remove the canonical object directory
146 and the second one will clean up
149 Generate a list of build dependencies in file
150 .Pa ${.OBJDIR}/${DEPENDFILE} .
151 Per-object dependencies are generated at build time and stored in
152 .Pa ${.OBJDIR}/${DEPENDFILE}.${OBJ} .
154 Install the results of the build to the appropriate location in the
155 installation directory hierarchy specified in variable
158 Create the canonical object directory associated with the current
161 Create a symbolic link to the canonical object directory in
164 Generate a tags file using the program specified in the
168 The build system supports
174 The other supported targets under directory
177 .Bl -tag -width ".Cm distributeworld"
179 Spawn an interactive shell with environment variables set up for
180 building the system or individual components.
181 For cross-building the target architecture needs to be specified with
188 This target is only useful after a complete toolchain (including
189 the compiler, linker, assembler, headers and libraries) has been
194 Build everything but the kernel, configure files in
198 The object directory can be changed from the default
204 The actual build location prefix used is
205 .Pa ${MAKEOBJDIRPREFIX}${.CURDIR}
206 for native builds, and
207 .Pa ${MAKEOBJDIRPREFIX}/${TARGET}${.CURDIR}
208 for cross builds and native builds with variable
209 .Va CROSS_BUILD_TESTING
212 Attempt to clean up targets built by a preceding
215 .It Cm distributeworld
216 Distribute everything compiled by a preceding
219 Files are placed in the directory hierarchy specified by
223 This target is used while building a release; see
226 Archive the results of
227 .Cm distributeworld ,
228 placing the results in
230 This target is used while building a release; see
233 Install everything built by a preceding
235 step into the directory hierarchy pointed to by
240 If installing onto an NFS file system and running
244 option, make sure that
246 is running on both client and server.
249 on how to make it start at boot time.
251 Create the build toolchain needed to build the rest of the system.
252 For cross-architecture builds, this step creates a cross-toolchain.
254 For each architecture,
259 for all kernels for that architecture,
262 This command takes a long time.
264 Get updated sources as configured in
267 Print a list of supported
271 pairs for world and kernel targets.
273 Execute the same targets as
275 In addition print a summary of all failed targets at the end and
276 exit with an error if there were any.
278 Create a build toolchain for each architecture supported by the build system.
281 Kernel specific build targets in
284 .Bl -tag -width ".Cm distributekernel"
286 Rebuild the kernel and the kernel modules.
287 The object directory can be changed from the default
294 Install the kernel and the kernel modules to directory
295 .Pa ${DESTDIR}/boot/kernel ,
296 renaming any pre-existing directory with this name to
298 if it contained the currently running kernel.
299 The target directory under
301 may be modified using the
307 .It Cm distributekernel
308 Install the kernel to the directory
309 .Pa ${DISTDIR}/kernel/boot/kernel .
310 This target is used while building a release; see
313 Archive the results of
314 .Cm distributekernel ,
315 placing the results in
317 This target is used while building a release; see
324 .It Cm kernel-toolchain
325 Rebuild the tools needed for kernel compilation.
326 Use this if you did not do a
329 .It Cm reinstallkernel
330 Reinstall the kernel and the kernel modules, overwriting the contents
331 of the target directory.
334 target, the target directory can be specified using the
340 Convenience targets for cleaning up the install destination directory
344 .Bl -tag -width ".Cm delete-old-libs"
346 Print a list of old files and directories in the system.
348 Delete obsolete base system files and directories interactively.
350 .Li -DBATCH_DELETE_OLD_FILES
351 is specified at the command line, the delete operation will be
358 should be set as with
359 .Dq Li "make installworld" .
360 .It Cm delete-old-libs
361 Delete obsolete base system libraries interactively.
362 This target should only be used if no third party software uses these
365 .Li -DBATCH_DELETE_OLD_FILES
366 is specified at the command line, the delete operation will be
373 should be set as with
374 .Dq Li "make installworld" .
377 Variables that influence all builds include:
378 .Bl -tag -width ".Va MAKEOBJDIRPREFIX"
380 Defines a set of debugging flags that will be used to build all userland
389 targets install binaries from the current
392 so that debugging information is retained in the installed binaries.
394 The directory hierarchy prefix where built objects will be installed.
397 defaults to the empty string.
398 .It Va MAKEOBJDIRPREFIX
399 Defines the prefix for directory names in the tree of built objects.
403 This variable should only be set in the environment and not via
407 If defined, compiler warnings will not cause the build to halt,
408 even if the makefile says otherwise.
410 If defined, the build process will run the DTrace CTF conversion
411 tools on built objects.
414 Additionally, builds in
416 are influenced by the following
419 .Bl -tag -width ".Va SUBDIR_OVERRIDE"
421 Overrides which kernel to build and install for the various kernel
426 Overrides the directory in which
428 and any files included by
432 .Pa sys/${ARCH}/conf .
434 If set, the build target
438 .Va NO_KERNELCONFIG ,
441 When set to a value other than
445 is set to the value of
448 If set, this variable supplies a list of additional directories relative to
449 the root of the source tree to build as part of the
452 The directories are built in parallel with each other,
453 and with the base system directories.
456 directive at the beginning of the
458 list to ensure all base system directories are built first.
460 may also be used as needed elsewhere within the list.
462 If set, this variable supplies a list of additional tools that are used by the
467 .It Va LOCAL_LIB_DIRS
468 If set, this variable supplies a list of additional directories relative to
469 the root of the source tree to build as part of the
472 The directories are built in parallel with each other,
473 and with the base system libraries.
476 directive at the beginning of the
478 list to ensure all base system libraries are built first.
480 may also be used as needed elsewhere within the list.
482 If set, this variable supplies a list of additional mtrees relative to the
483 root of the source tree to use as part of the
486 .It Va LOCAL_TOOL_DIRS
487 If set, this variable supplies a list of additional directories relative to
488 the root of the source tree to build as part of the
492 A list of ports with kernel modules that should be built and installed
498 .Bd -literal -offset indent
499 make PORTS_MODULES=emulators/kqemu-kmod kernel
502 Command to use at install time when stripping binaries.
503 Be sure to add any additional tools required to run
508 variable before running the
516 .It Va SUBDIR_OVERRIDE
517 Override the default list of sub-directories and only build the
518 sub-directory named in this variable.
521 then all libraries and includes, and some of the build tools will still build
525 it is necesarry to override
527 with any custom directories containing libraries.
528 This allows building a subset of the system in the same way as
530 does using its sysroot handling.
531 This variable can also be useful when debugging failed builds.
532 .Bd -literal -offset indent
533 make some-target SUBDIR_OVERRIDE=foo/bar
536 The target hardware platform.
537 This is analogous to the
540 This is necessary to cross-build some target architectures.
541 For example, cross-building for PC98 machines requires
542 .Va TARGET_ARCH Ns = Ns Li i386
544 .Va TARGET Ns = Ns Li pc98 .
547 defaults to the current hardware platform, unless
549 is also set, in which case it defaults to the appropriate
550 value for that architecture.
552 The target machine processor architecture.
553 This is analogous to the
556 Set this to cross-build for a different architecture.
559 defaults to the current machine architecture, unless
561 is also set, in which case it defaults to the appropriate
562 value for that platform.
563 Typically, one only needs to set
567 Builds under directory
569 are also influenced by defining one or more of the following symbols,
574 .Bl -tag -width ".Va -DNO_KERNELCONFIG"
575 .It Va LOADER_DEFAULT_INTERP
576 Defines what interpreter the default loader program will have.
582 This creates the default link for
584 to the loader with that interpreter.
585 It also determines what interpreter is compiled into
588 If set, the build targets that clean parts of the object tree use the
594 If set, no object tree files are cleaned at all.
595 This is the default when
609 is set no kernel objects are cleaned either.
611 If set, the build process does not run the DTrace CTF conversion tools
614 If set, the build does not descend into the
616 subdirectory (i.e., manual pages, locale data files, timezone data files and
619 files will not be rebuild from their sources).
620 .It Va NO_KERNELCLEAN
621 If set, the build process does not run
626 .It Va NO_KERNELCONFIG
627 If set, the build process does not run
633 If set, the build process does not run
639 If set, the update process does not update the source of the
641 documentation as part of the
644 .It Va NO_PORTSUPDATE
645 If set, the update process does not update the Ports tree as part of the
649 If set, the update process does not update the www tree as part of the
654 Builds under directory
656 are influenced by the following
659 .Bl -tag -width ".Va DOC_LANG"
661 If set, restricts the documentation build to the language subdirectories
662 specified as its content.
663 The default action is to build documentation for all languages.
668 target are influenced by the following
671 .Bl -tag -width ".Va MAKE_JUST_KERNELS"
673 Pass the value of this variable to each
675 invocation used to build worlds and kernels.
676 This can be used to enable multiple jobs within a single architecture's build
677 while still building each architecture serially.
678 .It Va MAKE_JUST_KERNELS
679 Only build kernels for each supported architecture.
680 .It Va MAKE_JUST_WORLDS
681 Only build worlds for each supported architecture.
682 .It Va UNIVERSE_TARGET
683 Execute the specified
685 target for each supported architecture instead of the default action of
686 building a world and one or more kernels.
689 .Bl -tag -width ".Pa /usr/share/examples/etc/make.conf" -compact
690 .It Pa /usr/doc/Makefile
691 .It Pa /usr/doc/share/mk/doc.project.mk
692 .It Pa /usr/ports/Mk/bsd.port.mk
693 .It Pa /usr/ports/Mk/bsd.sites.mk
694 .It Pa /usr/share/examples/etc/make.conf
695 .It Pa /usr/src/Makefile
696 .It Pa /usr/src/Makefile.inc1
701 method of updating your system from the latest sources, please see the
706 The following sequence of commands can be used to cross-build the
707 system for the armv6 architecture on an amd64 host:
708 .Bd -literal -offset indent
710 make TARGET_ARCH=armv6 buildworld buildkernel
711 make TARGET_ARCH=armv6 DESTDIR=/clients/arm64 installworld installkernel
730 .An Mike W. Meyer Aq Mt mwm@mired.org