DependenciesFree and open source software is highly modular, and MacPorts ports
often require that other ports be installed beforehand; these prerequisites
for a given port are called a port's dependencies.The keywords used when specifying dependencies in a Portfile are
related to port install phases, and they refer to what are called library,
build, fetch, extract and run dependencies. Though all of them install dependencies
before a given port is installed, specifying dependencies with the correct keyword
is important for proper port upgrade and uninstall behavior, or when running targets
other than install. For example,
you may not uninstall a port that is a library dependency for another installed port,
though you may remove one that is a build dependency. Likewise, if you run the
fetch target for a port, only the fetch dependencies will be installed first, so
they should be all that is needed for that target.depends_fetchdepends_fetch-appenddepends_fetch-deleteThe list of dependencies to check before phases
, ,
, ,
, ,
, , and
. Fetch dependencies are needed to download
the distfiles for a port, and are not needed at all once the software
is installed.depends_extractdepends_extract-appenddepends_extract-deleteThe list of dependencies to check before phases
, ,
, ,
, , and
. Extract dependencies are needed to unpack a
port's distfiles into the work directory, and are not needed at all once
the software is installed.depends_builddepends_build-appenddepends_build-deleteThe list of dependencies to check before phases
, ,
, , and
. Build dependencies are needed when software
is being built, but not needed at all once it is installed.depends_libdepends_lib-appenddepends_lib-deleteThe list of dependencies to check before phases
, ,
, , and
. Library dependencies are needed both at
build time (for headers and libraries to link against) and at run
time.depends_rundepends_run-appenddepends_run-deleteThe list of dependencies to check before phases
, , and
. Run dependencies are needed when the
software is run, but not to compile it.Port and File DependenciesThere are two types of dependencies: port dependencies and file
dependencies. Port dependencies can be satisfied by reference to a port
(the MacPorts registry is queried), or by reference to a file (whether
provided by a port or not). The most commonly-used type of dependencies in
Portfiles are port dependencies, because dependencies should be provided
by MacPorts ported software whenever possible, and usually only one port
can provide the needed libraries and files.But when satisfying a dependency with vendor-supplied software is
preferred for special reasons, or when it is possible for more than one
port to satisfy a dependency, then file dependencies may be used. An
example of the former is with ubiquitous utilities like awk, grep, make or
sed, where OS X's versions are often sufficient; an example of the latter
is with -devel ports—these ports provide a different
version of the same files (though only one can be activated at a
time).Port dependencies, the preferred type, are specified as shown in
these examples:depends_lib port:rrdtool port:apache2
depends_build port:libtool
depends_run port:apache2 port:php5File dependencies should only be used if one of the reasons listed
above applies. There are three types: for
programs, for libraries, and
for any installed file. File dependencies are specified in the form:
<type>:<filespec>:<port>.For dependencies,
<filespec> is the name of a program in a
bin directory like ${prefix}/bin, /usr/bin, /bin, and
the associated sbin directories.For dependencies,
<filespec> is the name of a library
(but without its extension) in a lib directory like
${prefix}/lib, /usr/lib, /lib, some Framework
directories, and those found in environment variables like DYLD_LIBRARY_PATH.For dependencies,
<filespec> is the complete absolute path
to the file, or more usually, when the file is inside
${prefix}, it is specified relative to
${prefix}.
Since dependencies are the only ones which would find
files only in an absolute path or a path inside ${prefix}
they are - in cases when a port needs to be more restrictive - often used
instead of and dependencies .Note that the <port> specified is
only installed if the specified library, binary, or file is not found. See
the examples below:depends_lib lib:libX11.6:xorg
depends_build bin:glibtool:libtool
depends_run path:lib/libltdl.a:libtool