The FreeBSD ports framework supports parallel building
using multiple make sub-processes, which
allows SMP systems to utilize all of
their available CPU power, allowing port
builds to be faster and more effective.
This is achieved by passing -jX flag
to make(1) running on vendor code. This is the default
build behavior of ports. Unfortunately, not all ports
handle parallel building well and it may be required to
explicitly disable this feature by adding the
MAKE_JOBS_UNSAFE=yes variable. It is
used when a port is known to be broken with
-jX.
Several differing make
implementations exist. Ported software often requires a
particular implementation, like GNU
make, known in FreeBSD as
gmake.
If the port uses GNU make,
add gmake to
USES.
MAKE_CMD can be used to reference the
specific command configured by the USES
setting in the port's Makefile.
Only use MAKE_CMD within the
application Makefiles in
WRKSRC to call the
make implementation expected by the
ported software.
If the port is an X application that uses
imake to create
Makefiles from
Imakefiles, set USES=
imake.. See the USES=imake
section of Chapter 17, Using USES
Macros for more details.
If the port's source Makefile has
something other than all as the
main build target, set ALL_TARGET
accordingly. The same goes for
install and
INSTALL_TARGET.
If the port uses the configure
script to generate Makefile from
Makefile.in, set
GNU_CONFIGURE=yes. To give
extra arguments to the configure script
(the default argument is --prefix=${PREFIX}
--infodir=${PREFIX}/${INFO_PATH}
--mandir=${MANPREFIX}/man
--build=${CONFIGURE_TARGET}), set those
extra arguments in CONFIGURE_ARGS. Extra
environment variables can be passed using
CONFIGURE_ENV.
configure| Variable | Means |
|---|---|
GNU_CONFIGURE | The port uses configure
script to prepare build. |
HAS_CONFIGURE | Same as GNU_CONFIGURE,
except default configure target is not added to
CONFIGURE_ARGS. |
CONFIGURE_ARGS | Additional arguments passed to
configure script. |
CONFIGURE_ENV | Additional environment variables to be set
for configure script run. |
CONFIGURE_TARGET | Override default configure target. Default
value is
${MACHINE_ARCH}-portbld-freebsd${OSREL}. |
For ports that use CMake,
define USES= cmake, or
USES= cmake:outsource to build in a
separate directory (see below).
cmake| Variable | Means |
|---|---|
CMAKE_ARGS | Port specific CMake
flags to be passed to the cmake
binary. |
CMAKE_ON | For each entry in CMAKE_ON, an
enabled boolean value is added to
CMAKE_ARGS. See Example 6.4, “CMAKE_ON and
CMAKE_OFF”. |
CMAKE_OFF | For each entry in CMAKE_OFF, a
disabled boolean value is added to
CMAKE_ARGS. See Example 6.4, “CMAKE_ON and
CMAKE_OFF”. |
CMAKE_BUILD_TYPE | Type of build (CMake
predefined build profiles). Default is
Release, or
Debug if
WITH_DEBUG is set. |
CMAKE_ENV | Environment variables to be set for the
cmake binary. Default is
${CONFIGURE_ENV}. |
CMAKE_SOURCE_PATH | Path to the source directory. Default is
${WRKSRC}. |
cmake Builds| Variable | Means |
|---|---|
CMAKE_VERBOSE | Enable verbose build output. Default not set,
unless BATCH or
PACKAGE_BUILDING are set. |
CMAKE_NOCOLOR | Disables color build output. Default not set,
unless BATCH or
PACKAGE_BUILDING are set. |
CMake supports these
build profiles: Debug,
Release,
RelWithDebInfo and
MinSizeRel. Debug and
Release profiles respect system
*FLAGS, RelWithDebInfo
and MinSizeRel will set
CFLAGS to -O2 -g and
-Os -DNDEBUG correspondingly. The
lower-cased value of CMAKE_BUILD_TYPE is
exported to PLIST_SUB and must be
used if the port installs
depending on the build type (see
deskutils/strigi for an
example). Please note that some projects may define their own
build profiles and/or force particular build type by setting
*.cmakeCMAKE_BUILD_TYPE in
CMakeLists.txt. To make a port for such
a project respect CFLAGS and
WITH_DEBUG, the
CMAKE_BUILD_TYPE definitions must be
removed from those files.
Most CMake-based projects
support an out-of-source method of building. The
out-of-source build for a port can be requested by using the
:outsource suffix. When enabled,
CONFIGURE_WRKSRC,
BUILD_WRKSRC and
INSTALL_WRKSRC will be set to
${WRKDIR}/.build and this
directory will be used to keep all files generated during
configuration and build stages, leaving the source directory
intact.
USES= cmake ExampleThis snippet demonstrates the use of
CMake for a port.
CMAKE_SOURCE_PATH is not usually
required, but can be set when the sources are not located
in the top directory, or if only a subset of the project
is intended to be built by the port.
USES= cmake:outsource
CMAKE_SOURCE_PATH= ${WRKSRC}/subprojectCMAKE_ON and
CMAKE_OFFWhen adding boolean values to
CMAKE_ARGS, it is easier to use the
CMAKE_ON and CMAKE_OFF
variables instead. This:
CMAKE_ON= VAR1 VAR2 CMAKE_OFF= VAR3
Is equivalent to:
CMAKE_ARGS= -DVAR1:BOOL=TRUE -DVAR2:BOOL=TRUE -DVAR3:BOOL=FALSE
This is only for the default values off
CMAKE_ARGS. The helpers described in
Section 5.13.3.4.2, “
and
OPT_CMAKE_BOOL” use the same
semantics, but for optional values.OPT_CMAKE_BOOL_OFF
If the port uses SCons,
define USES=scons.
To make third party SConstruct
respect everything that is passed to SCons in
the environment (that is, most importantly,
CC/CXX/CFLAGS/CXXFLAGS), patch
SConstruct so build
Environment is constructed like
this:
env = Environment(**ARGUMENTS)
It may be then modified with
env.Append and
env.Replace.
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.