A port is a distribution of software that can be compiled and installed using MacPorts.
A Portfile
describes all the required steps such as where to get the source code from upstream, which patches have to be applied and which other tools and commands are required to build the source code.
Each port consists of multiple files in a directory, usually within a category subdirectory of the root of a ports tree.
The MacPorts Project distributes the main ports tree that is by default configured in all installations of MacPorts.
This section serves as a reference for the directory structure of a single port and the layout of the files within.
The only required file in a port is the Portfile
.
A MacPorts Portfile is a Tcl script that usually contains only the simple keyword/value combinations and Tcl extensions as described in the Portfile Reference chapter, though it may also contain arbitrary Tcl code. Every port has a corresponding Portfile, but Portfiles do not completely define a port’s installation behavior since MacPorts base has default port installation characteristics coded within it. Therefore Portfiles need only specify required options, though some ports may require non-default options.
A common way for Portfiles to augment or override MacPorts base default installation phase characteristics is by using Portfile
phase declaration(s). If you use Portfile phase declaration(s), you should know how to identify the “global” section of a Portfile.
Any statements not contained within a phase declaration, no matter where they are located in a Portfile, are said to be in the global section of the Portfile; therefore the global section need not be contiguous.
Likewise, to remove statements from the global section they must be placed within a phase declaration.
The main phases you need to be aware of when making a Portfile are these:
The default installation phase behavior performed by the MacPorts base works fine for applications that use the standard +configure+
, +make+
, and +make
install+
steps, which conform to phases configure, build, and destroot respectively.
For applications that do not conform to this standard behavior, any installation phase may be augmented using pre- and/or post- phases, or even overridden or eliminated.
See Example Portfiles below.
For a detailed description of all port phases, see the Portfile Reference chapter.