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
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).
The lib part is a regular
expression which is being looked up in the
ldconfig -r output. Values such as
intl.[5-7] and intl are
allowed. The first pattern,
intl.[5-7], will match any of:
intl.5, intl.6 or
intl.7. The second pattern,
intl, will match any version of the
intl library.
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 search path.
For example,
RUN_DEPENDS= ${LOCALBASE}/etc/innd:${PORTSDIR}/news/inn \
xmlcatmgr:${PORTSDIR}/textproc/xmlcatmgrwill 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 xmlcatmgr is in the search
path, and descend into the textproc/xmlcatmgr
subdirectory of your ports tree to build and install it if it is
not found.
In this case, innd is actually an
executable; if an executable is in a place that is not expected
to be in the search path, you should use the full
pathname.
The official search PATH used on the ports
build cluster is
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin
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.
“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.
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 節 5.7.7, “USE_”.*
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
extract it.
The dependency is checked from within the
patch target. 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. Although their use is
optional, they can help to reduce the verbosity of the port
Makefiles. Each of them is styled
as USE_. The
usage of these variables is restricted to the port
*Makefiles and
ports/Mk/bsd.*.mk and is not designed
to encapsulate user-settable options —— use
WITH_ and
*WITHOUT_
for that purpose.*
It is always incorrect to set
any USE_
in */etc/make.conf. For instance,
setting
USE_GCC=3.2
would adds a dependency on gcc32 for every port, including gcc32 itself!
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_BISON | The port uses bison for
building. |
USE_CDRTOOLS | 該 port 需要 cdrecord, 無論是 sysutils/cdrtools 或 sysutils/cdrtools-cjk 哪一種的 cdrecord 皆可,視使用者偏好而定 。 |
USE_GCC | The port requires a specific version of
gcc to build. The exact version can be
specified with value such as 3.2.
The minimal required version can be specified as
3.2+. The gcc from
the base system is used when it satisfies the requested
version, otherwise an appropriate gcc is
compiled from ports and the CC and
CXX variables are adjusted. |
Variables related to gmake and
the configure script are described in
節 6.3, “Building mechanisms”, while
autoconf,
automake and
libtool are described in
節 6.4, “Using GNU autotools”. Perl
related variables are described in 節 6.6, “Using perl”.
X11 variables are listed in 節 6.7, “Using X11”. 節 6.8, “Using GNOME” deals with GNOME and 節 6.9, “Using KDE” with KDE related variables. 節 6.10, “Using Java” documents Java variables, while 節 6.11, “Web applications, Apache and PHP” contains information on
Apache, PHP
and PEAR modules. Python is discussed
in 節 6.12, “Using Python”, while
Ruby in 節 6.14, “Using Ruby”.
節 6.15, “Using SDL” provides variables used for
SDL applications and finally,
節 6.18, “Using Xfce” contains information on
Xfce.
A minimal version of a dependency can be specified in any
*_DEPENDS variable except
LIB_DEPENDS using the following
syntax:
p5-Spiffy>=0.26:${PORTSDIR}/devel/p5-SpiffyThe first field contains a dependent package name, which must match the entry in the package database, a comparison sign, and a package version. The dependency is satisfied if p5-Spiffy-0.26 or newer is installed on the machine.
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 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.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/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>.