BUILD(7) | MidnightBSD Miscellaneous Information Manual | BUILD(7) |
build
— General
instructions on how to build the system
The sources for the FreeBSD system and its applications are contained in three different directories, normally /usr/src, /usr/doc, and /usr/ports. These directories may be initially empty or non-existent until updated with svn(1) or svnlite(1) or portsnap(8). Directory /usr/src contains the “base system” sources, which is loosely defined as the things required to rebuild the system to a useful state. Directory /usr/doc contains the source for the system documentation, excluding the manual pages. Directory /usr/ports contains a tree that provides a consistent interface for building and installing third party applications. For more information about the ports build process, see ports(7).
The make(1) command is used in each of these directories to build and install the things in that directory. Issuing the make(1) command in any directory issues the make(1) command recursively in all subdirectories. With no target specified, the items in the directories are built and no further action is taken.
A source tree is allowed to be read-only. As described in
make(1), objects are
usually built in a separate object directory hierarchy specified by the
environment variable MAKEOBJDIRPREFIX, or under
/usr/obj if variable
MAKEOBJDIRPREFIX is not set. The canonical object
directory is described in the documentation for the
buildworld
target below.
The build may be controlled by defining make(1) variables described in the ENVIRONMENT section below, and by the variables documented in make.conf(5).
The default components included in the build are specified in the file /etc/src.conf in the source tree. To override the default file, include the SRCCONF option in the make steps, pointing to a custom src.conf file. For more information see src.conf(5).
The following list provides the names and actions for the targets supported by the build system:
analyze
check
checkworld
clean
cleandepend
make
” and
“make depend
” steps.cleandir
make clean
cleandepend
” if it does not. This target will also remove an
obj link in ${.CURDIR} if
that exists.
It is advisable to run “make
cleandir
” twice: the first invocation will remove the
canonical object directory and the second one will clean up
${.CURDIR}.
depend
install
obj
objlink
GNU Global
.The other supported targets under directory /usr/src are:
buildenv
This target is only useful after a complete toolchain
(including the compiler, linker, assembler, headers and libraries) has
been built; see the toolchain
target below.
buildworld
cleanworld
buildworld
, or similar step built from this source
directory.cleanuniverse
buildworld
,
universe
, or similar step, for any architecture
built from this source directory.distributeworld
buildworld
step. Files are placed in the directory
hierarchy specified by
make(1) variable
DISTDIR. This target is used while building a
release; see
release(7).native-xtools
native-xtools-install
packageworld
distributeworld
, placing
the results in DISTDIR. This target is used while
building a release; see
release(7).installworld
buildworld
step into the directory hierarchy pointed to by
make(1) variable
DESTDIR.
If installing onto an NFS file system and running
make(1) with the
-j
option, make sure that
rpc.lockd(8) is
running on both client and server. See
rc.conf(5) on how to
make it start at boot time.
toolchain
universe
buildworld
followed by a buildkernel
for all kernels for that
architecture, including LINT. This command takes a
long time.update
targets
tinderbox
universe
. In addition
print a summary of all failed targets at the end and exit with an error if
there were any.toolchains
xdev
xdev-build
and
xdev-install
. The location of the files installed
can be controlled with DESTDIR. The target location
in DESTDIR is
${DESTDIR}/${XDTP} where
XDTP defaults to
/usr/${XDDIR} and XDDIR
defaults to ${TARGET_ARCH}-freebsd.xdev-build
xdev
target.xdev-install
xdev
target.xdev-links
Kernel specific build targets in /usr/src are:
buildkernel
installkernel
distributekernel
packagekernel
distributekernel
, placing
the results in DISTDIR. This target is used while
building a release; see
release(7).kernel
buildkernel
followed by
installkernel
kernel-toolchain
buildworld
first.reinstallkernel
installkernel
target, the target directory can be specified using the
make(1) variable
INSTKERNNAME.Convenience targets for cleaning up the install destination directory denoted by variable DESTDIR include:
check-old
delete-old
-DBATCH_DELETE_OLD_FILES
is specified at the
command line, the delete operation will be non-interactive. The variables
DESTDIR, TARGET_ARCH and
TARGET should be set as with
“make installworld
”.delete-old-libs
-DBATCH_DELETE_OLD_FILES
is specified at the
command line, the delete operation will be non-interactive. The variables
DESTDIR, TARGET_ARCH and
TARGET should be set as with
“make installworld
”.Variables that influence all builds include:
install
and installworld
targets install binaries from the current
MAKEOBJDIRPREFIX without stripping, so that
debugging information is retained in the installed binaries.Additionally, builds in /usr/src are influenced by the following make(1) variables:
GENERIC
.buildkernel
defaults to
setting NO_KERNELCLEAN,
NO_KERNELCONFIG, and
NO_KERNELOBJ. When set to a value other than
1
then KERNCONF is set to
the value of KERNFAST.everything
target. The directories are built in
parallel with each other, and with the base system directories. Insert a
.WAIT directive at the beginning of the
LOCAL_DIRS list to ensure all base system
directories are built first. .WAIT may also be used
as needed elsewhere within the list.installworld
and
distributeworld
targets.libraries
target. The directories are built in
parallel with each other, and with the base system libraries. Insert a
.WAIT directive at the beginning of the
LOCAL_DIRS list to ensure all base system libraries
are built first. .WAIT may also be used as needed
elsewhere within the list.hierarchy
target.build-tools
target.cross-tools
target.buildkernel
and
installkernel
process.
make PORTS_MODULES=emulators/virtualbox-ose-kmod kernel
distributeworld
or
installworld
targets. See
install(1) for more
details.buildworld
then all libraries and includes, and
some of the build tools will still build as well. Specifying
-DNO_LIBS
, and -DWORLDFAST
will only build the specified directory as was done historically. When
combined with buildworld
it is necesarry to
override LOCAL_LIB_DIRS with any custom directories
containing libraries. This allows building a subset of the system in the
same way as buildworld
does using its sysroot
handling. This variable can also be useful when debugging failed builds.
make some-target SUBDIR_OVERRIDE=foo/bar
uname
-m
”
output. This is necessary to cross-build some target architectures. For
example, cross-building for ARM64 machines requires
TARGET_ARCH=aarch64
and
TARGET=arm64
. If not set,
TARGET defaults to the current hardware platform,
unless TARGET_ARCH is also set, in which case it
defaults to the appropriate value for that architecture.uname
-p
”
output. Set this to cross-build for a different architecture. If not set,
TARGET_ARCH defaults to the current machine
architecture, unless TARGET is also set, in which
case it defaults to the appropriate value for that platform. Typically,
one only needs to set TARGET.Builds under directory /usr/src are also
influenced by defining one or more of the following symbols, using the
-D
option of
make(1):
buildkernel
target.buildkernel
target.buildkernel
target.buildworld
defaults to
setting NO_CLEAN, NO_OBJWALK,
and will skip most bootstrap phases. It will only bootstrap libraries and
build all of userland. This option should be used only when it is known
that none of the bootstrap needs changed and that no new directories have
been connected to the build.Builds under directory /usr/doc are influenced by the following make(1) variables:
Builds using the universe
target are
influenced by the following
make(1) variables:
For an “approved” method of updating your system from the latest sources, please see the COMMON ITEMS section in src/UPDATING.
The following sequence of commands can be used to cross-build the system for the armv6 architecture on an amd64 host:
cd /usr/src make TARGET_ARCH=armv6 buildworld buildkernel make TARGET_ARCH=armv6 DESTDIR=/clients/arm64 installworld installkernel
cc(1), install(1), make(1), svn(1), svnlite(1), make.conf(5), src.conf(5), arch(7), ports(7), release(7), tests(7), config(8), etcupdate(8), mergemaster(8), portsnap(8), reboot(8), shutdown(8)
Mike W. Meyer <mwm@mired.org>
May 15, 2021 | midnightbsd-3.1 |