1. Introduction
2. Installing MacPorts
2.1. Install Xcode
2.2. Install MacPorts
2.3. Upgrade MacPorts
2.4. Uninstall MacPorts
2.5. MacPorts and the Shell
3. Using MacPorts
3.1. The port Command
3.2. Port Variants
3.3. Common Tasks
3.4. Port Binaries
4. Portfile Development
4.1. Portfile Introduction
4.2. Creating a Portfile
4.3. Example Portfiles
4.4. Port Variants
4.5. Patch Files
4.6. Local Portfile Repositories
4.7. Portfile Best Practices
4.8. MacPorts' buildbot
5. Portfile Reference
5.1. Global Keywords
5.2. Global Variables
5.3. Port Phases
5.4. Dependencies
5.5. Variants
5.6. Tcl Extensions & Useful Tcl Commands
5.7. StartupItems
5.8. Livecheck / Distcheck
5.9. PortGroups
6. MacPorts Internals
6.1. File Hierarchy
6.2. Configuration Files
6.3. Port Images
6.4. APIs and Libs
6.5. The MacPorts Registry
6.6. Tests
7. MacPorts Project
7.1. Using Trac for Tickets
7.2. Using Git and GitHub
7.3. Contributing to MacPorts
7.4. Port Update Policies
7.5. Updating Documentation
7.6. MacPorts Membership
7.7. The PortMgr Team
8. MacPorts Guide Glossary
Glossary

5.2. Global Variables

Global variables are variables available to any Portfile. For a list of additional variables available to ports that are assigned to a MacPorts Portgroup, see portgroup(7).

All of these variables except prefix are read-only!

prefix

Installation prefix, set at compile time and displayed in ${prefix}/etc/macports/macports.conf —- may be overridden on a per-port basis, for example to install into a wholly-contained subdirectory of ${prefix}, but most ports should have no reason to do so.

Default: /opt/local

libpath

Path to the MacPorts Tcl libraries.

portpath

Full path to the Portfile of the port being executed. Portfile repositories are defined in the file sources.conf.

Default: ${prefix}/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/<category>/<portname>/

filesdir

Path to files directory relative to ${portpath}.

Value: files

filespath

Full path to files directory.

Value: ${portpath}/${filesdir}

workpath

Full path to work directory.

Value: ${portbuildpath}/work

worksrcpath

Full path to extracted source code.

Value: ${workpath}/${worksrcdir}

destroot

Full path into which software will be destrooted.

Value: ${workpath}/destroot

distpath

Location to store downloaded distfiles.

Value: ${portdbpath}/distfiles/${dist_subdir}

install.user

The Unix user at the time of port installation.

install.group

The Unix group at the time of port installation.

os.platform

The underlying operating system platform (e.g., darwin on macOS, freebsd, etc.).

os.arch

The hardware architecture -- either powerpc, i386, or arm.

os.version

The version number of the host operating system (e.g., 12.3.0 for Darwin 12.3.0 a.k.a. OS X 10.8.3).

os.endian

Endianness of the processor -- either big (on PowerPC systems) or little (on Intel and Apple Silicon systems).

os.major

The major version number of the host operating system (e.g., 12 for Darwin 12.x).

macos_version

The full macOS version number of the host operating system, if applicable (e.g., 10.15.7).

macos_version_major

The major macOS version number of the host operating system, if applicable (e.g., 12 for Monterey or 10.15 for Catalina).

xcodeversion

The installed version of Xcode, if any (e.g., 14.0.1).

xcodecltversion

(Added: MacPorts 2.8) The installed version of the Command Line Tools for Xcode, if any (e.g., 14.0.0.0.1.1661618636).

universal_possible

Boolean value indicating whether it is possible to build universal binaries given the configured SDK and universal_archs and the port's supported_archs.