FreeBSD Porter's Handbook
Prev | Chapter 6 Special considerations | Next

# 6.3 Building mechanisms

## 6.3.1 Parallel ports building

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. Unfortunately, not all ports handle parallel building well. Therefore it is required to explicitly enable this feature by adding `MAKE_JOBS_SAFE=yes` somewhere below the dependency declaration section of the `Makefile`.

Another option for controlling this feature from the maintainer's point of view is the `MAKE_JOBS_UNSAFE=yes` variable. It is used when a port is known to be broken with `-jX` and a user forces the use of multi processor compilations for all ports in `/etc/make.conf` with the `FORCE_MAKE_JOBS=yes` variable.

## 6.3.2 `make`, `gmake`, and `imake`

If your port uses GNU make, set `USE_GMAKE=yes`.

Table 6-1. Variables for ports related to gmake

Variable | Means
--- | ---
`USE_GMAKE` | The port requires `gmake` to build.
`GMAKE` | The full path for `gmake` if it is not in the `PATH`.

If your port is an X application that creates `Makefile` files from `Imakefile` files using imake, then set `USE_IMAKE=yes`. This will cause the configure stage to automatically do an `xmkmf -a`. If the `-a` flag is a problem for your port, set `XMKMF=xmkmf`. If the port uses imake but does not understand the `install.man` target, `NO_INSTALL_MANPAGES=yes` should be set.

If your port's source `Makefile` has something else than `all` as the main build target, set `ALL_TARGET` accordingly. Same goes for `install` and `INSTALL_TARGET`.

## 6.3.3 `configure` script

If your port uses the `configure` script to generate `Makefile` files from `Makefile.in` files, set `GNU_CONFIGURE=yes`. If you want 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` variable.

Table 6-2. Variables for ports that use 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}`.

## 6.3.4 Using `scons`

If your port uses SCons, define `USE_SCONS=yes`.

Table 6-3. Variables for ports that use `scons`

Variable | Means
--- | ---
`SCONS_ARGS` | Port specific SCons flags passed to the SCons environment.
`SCONS_BUILDENV` | Variables to be set in system environment.
`SCONS_ENV` | Variables to be set in SCons environment.
`SCONS_TARGET` | Last argument passed to SCons, similar to `MAKE_TARGET`.

To make third party `SConstruct` respect everything that is passed to SCons in `SCONS_ENV` (that is, most importantly, `CC/CXX/CFLAGS/CXXFLAGS`), patch the `SConstruct` so build `Environment` is constructed like this:

    env = Environment(**ARGUMENTS)

It may be then modified with `env.Append` and `env.Replace`.

Prev | Home | Next
Ports with distribution restrictions | Up | Using GNU autotools

For questions about the FreeBSD ports system, e-mail <ports@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.