Many ports depend on other ports. There are seven variables that you can use to ensure
that all the required bits will be on the user's machine. There are also some
pre-supported dependency variables for common cases, plus a few more to control the
behavior of dependencies.
This variable specifies the shared libraries this port depends on. It is a list of
lib:dir[:target] tuples where lib is the name of the shared library, dir is the directory in which to find it in case it is not
available, and target is the target to call in that
directory. For example,
LIB_DEPENDS=
jpeg.9:${PORTSDIR}/graphics/jpeg:install
will check for a shared jpeg library with major version 9, and descend into the graphics/jpeg subdirectory of your ports tree to build and install
it if it is not found. The target part can be omitted if
it is equal to DEPENDS_TARGET (which defaults to install).
Note: The lib part is an argument given to ldconfig -r | grep -wF. There shall be no regular expressions in
this variable.
The dependency is checked twice, once from within the extract target and then from within the install target. Also, the name of the dependency is put into the
package so that pkg_add(1) will
automatically install it if it is not on the user's system.
This variable specifies executables or files this port depends on during run-time. It
is a list of path:dir[:target] tuples where path is the name of the executable or file, dir is the directory in which to find it in case it is not
available, and target is the target to call in that
directory. If path starts with a slash (/), it is treated as a file and its existence is tested with test -e; otherwise, it is assumed to be an executable, and which -s is used to determine if the program exists in the user's
search path.
For example,
RUN_DEPENDS= ${LOCALBASE}/etc/innd:${PORTSDIR}/news/inn \
wish8.0:${PORTSDIR}/x11-toolkits/tk80
will check if the file or directory /usr/local/etc/innd
exists, and build and install it from the news/inn subdirectory
of the ports tree if it is not found. It will also see if an executable called wish8.0 is in your search path, and descend into the x11-toolkits/tk80 subdirectory of your ports tree to build and
install it if it is not found.
Note: In this case, innd is actually an executable; if
an executable is in a place that is not expected to be in a normal user's search path,
you should use the full pathname.
The dependency is checked from within the install target.
Also, the name of the dependency is put into the package so that pkg_add(1) will
automatically install it if it is not on the user's system. The target part can be omitted if it is the same as DEPENDS_TARGET.
This variable specifies executables or files this port requires to build. Like RUN_DEPENDS, it is a list of path:dir[:target] tuples. For example,
BUILD_DEPENDS=
unzip:${PORTSDIR}/archivers/unzip
will check for an executable called unzip, and descend into the
archivers/unzip subdirectory of your ports tree to build and
install it if it is not found.
Note: ``build'' here means everything from extraction to compilation. The
dependency is checked from within the extract target. The
target part can be omitted if it is the same as DEPENDS_TARGET
This variable specifies executables or files this port requires to fetch. Like the
previous two, it is a list of path:dir[:target] tuples. For example,
FETCH_DEPENDS=
ncftp2:${PORTSDIR}/net/ncftp2
will check for an executable called ncftp2, and descend into the
net/ncftp2 subdirectory of your ports tree to build and install
it if it is not found.
The dependency is checked from within the fetch target.
The target part can be omitted if it is the same as DEPENDS_TARGET.
This variable specifies executables or files this port requires for extraction. Like
the previous, it is a list of path:dir[:target] tuples. For example,
EXTRACT_DEPENDS=
unzip:${PORTSDIR}/archivers/unzip
will check for an executable called unzip, and descend into the
archivers/unzip subdirectory of your ports tree to build and
install it if it is not found.
The dependency is checked from within the extract target.
The target part can be omitted if it is the same as DEPENDS_TARGET.
Note: Use this variable only if the extraction does not already work (the
default assumes gzip) and cannot be made to work using USE_ZIP or USE_BZIP2 described in Section 5.7.8.
This variable specifies executables or files this port requires to patch. Like the
previous, it is a list of path:dir[:target] tuples. For example,
PATCH_DEPENDS=
${NONEXISTENT}:${PORTSDIR}/java/jfc:extract
will descend into the java/jfc subdirectory of your ports tree
to build and install it if it is not found.
The dependency is checked from within the patch target.
The target part can be omitted if it is the same as DEPENDS_TARGET.
If there is a dependency that does not fall into either of the above categories, or
your port requires having the source of the other port extracted in addition to having it
installed, then use this variable. This is a list of dir[:target], as there is nothing to check, unlike the
previous four. The target part can be omitted if it is the
same as DEPENDS_TARGET.
A number of variables exist in order to encapsulate common dependencies that many
ports have.
Table 5-1. The USE_*
variables
| Variable |
Means |
| USE_BZIP2 |
The port's tarballs are compressed with bzip2. |
| USE_ZIP |
The port's tarballs are compressed with zip. |
| USE_GMAKE |
The port requires gmake to build. |
| USE_PERL5 |
The port requires perl 5 to build and install. See Section 6.3 for additional variables that can be set relating
to perl. |
| USE_X_PREFIX |
The port installs in to X11BASE rather than PREFIX. See Section 6.4 for additional
variables that can be set relating to X11. |
| USE_AUTOMAKE_VER |
The port uses GNU automake as part of its build process. See
Section 6.5 for additional variables that can be set
relating to automake. |
| USE_AUTOCONF_VER |
The port uses GNU autoconf as part of its build process. See
Section 6.5 for additional variables that can be set
relating to autoconf. |
| USE_LIBTOOL_VER |
The port uses GNU libtool as part of its build process. See
Section 6.5 for additional variables that can be set
relating to libtool. |
| GMAKE |
The full path for gmake if it is not in the PATH. |
| USE_BISON |
The port uses bison for building. |
| USE_SDL |
The port uses SDL for building and running. See Section 6.13 on how to use USE_SDL. |
| NO_INSTALL_MANPAGES |
Do not use the install.man target. |
Define USE_XLIB=yes if your port requires the X Window
System to be installed (it is implied by USE_IMAKE). Define USE_GMAKE=yes if your port requires GNU make instead of BSD make. Define USE_AUTOCONF_VER=213 if your port requires GNU autoconf to be run.
Define USE_QT=yes if your port uses the latest qt toolkit. Use
USE_PERL5=yes if your port requires version 5 of the perl language. (The last is especially important since some
versions of FreeBSD have perl5 as part of the base system
while others do not.)
As mentioned above, the default target to call when a dependency is required is DEPENDS_TARGET. It defaults to install. This is a user variable; it is never defined in a port's
Makefile. If your port needs a special way to handle a
dependency, use the :target part of the *_DEPENDS variables instead of redefining DEPENDS_TARGET.
When you type make clean, its dependencies are automatically
cleaned too. If you do not wish this to happen, define the variable NOCLEANDEPENDS in your environment. This may be particularly
desirable if the port has something that takes a long time to rebuild in its dependency
list, such as KDE, GNOME or Mozilla.
To depend on another port unconditionally, use the variable ${NONEXISTENT} as the first field of BUILD_DEPENDS or RUN_DEPENDS. Use this only
when you need to get the source of the other port. You can often save compilation time by
specifying the target too. For instance
BUILD_DEPENDS= ${NONEXISTENT}:${PORTSDIR}/graphics/jpeg:extract
will always descend to the jpeg port and extract it.
Do not use DEPENDS unless there is no other way the behavior
you want can be accomplished. It will cause the other port to always be built (and
installed, by default), and the dependency will go into the packages as well. If this is
really what you need, you should probably write it as BUILD_DEPENDS and RUN_DEPENDS
instead--at least the intention will be clear.
Some large applications can be built in a number of configurations, adding
functionality if one of a number of libraries or applications is available. Since not all
users want those libraries or applications, the ports system provides hooks that the port
author can use to decide which configuration should be built. Supporting these properly
will make users happy, and effectively provide 2 or more ports for the price of one.
The easiest of these to use is WITHOUT_X11. If the port can
be built both with and without X support, then it should normally be built with X
support. If WITHOUT_X11 is defined, then the version that does
not have X support should be built.
Various parts of GNOME have such knobs, though they are slightly more difficult to
use. The variables to use in the Makefile are WANT_* and HAVE_*. If the application can
be built both with or without one of the dependencies listed below, then the Makefile should set WANT_PKG, and should
build the version that uses PKG if HAVE_PKG is defined.
The WANT_* variables currently supported this way are WANT_GLIB, WANT_GTK, WANT_ESOUND, WANT_IMLIB, and WANT_GNOME.
Important: Do not introduce any circular dependencies into the ports tree!
The ports building technology does not tolerate circular dependencies. If you
introduce one, you will have someone, somewhere in the world, whose FreeBSD installation
will break almost immediately, with many others quickly to follow. These can really be
hard to detect; if in doubt, before you make that change, make sure you have done the
following: cd /usr/ports; make index. That process can be quite
slow on older machines, but you may be able to save a large number of people--including
yourself-- a lot of grief in the process.