1. Introduction
2. Installing MacPorts
2.1. Install X11
2.2. Install Xcode
2.3. Install MacPorts
2.4. MacPorts Upgrade
2.5. Uninstall
2.6. 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
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
7. MacPorts Project
7.1. Using Trac for tickets
7.2. Contributing to MacPorts
7.3. Port Update Policies
7.4. MacPorts Membership
7.5. The PortMgr Team
8. MacPorts Guide Terms
Glossary
Single Page Chunked

If you are using Mac OS X, you should install MacPorts using the Mac OS X package installer unless you do not wish to install it to /opt/local/, the default MacPorts location, or if you wish to install a pre-release version of MacPorts base. However, if you wish to install multiple copies of MacPorts or install MacPorts on another OS platform, you must install MacPorts from the source code.

Note

Though a distinction is made between pre-release and release versions of MacPorts base, the ports collection supports no such distinction or versioning. The selfupdate command installs the latest port revisions from Subversion (at a slight delay), and updates MacPorts base to the latest released version.

The Mac OS X package installer automatically installs MacPorts, sets the shell environment, and runs a selfupdate operation to update the ports tree and MacPorts base with the latest release.

  1. Download the latest MacPorts-x.x.x.dmg disk image (whose name does not contain -beta or -rc) from the MacPorts download directory.

  2. Double-click the MacPorts-x.x.x.pkg package installer on the disk image.

  3. Perform the default easy install.

If you installed MacPorts using the package installer, skip this section. To install MacPorts from the source code, follow the steps below.

  1. Download and unzip the latest MacPorts tarball from the MacPorts download directory.

  2. Perform the commands shown in a terminal window. If you wish to use a path other than /opt/local, use the option --prefix and substitute a path for NEW_PREFIX.

    %% cd ~/MacPorts-x.x.x/
    %% ./configure --prefix=NEW_PREFIX  (setting prefix is optional)
    %% make
    %% sudo make install

If you installed MacPorts using the package installer, skip this section.

There are times when some may want to run MacPorts from a version newer than the current stable release. Maybe there's a new feature that you'd like to use, or it fixes an issue you've encountered, or you just like to be on the cutting edge. These steps explain how to run completely from trunk, using only Subversion to keep MacPorts up to date.

  1. Check out MacPorts source

    Pick a location to store a working copy of the MacPorts code. For this example, /opt/mports will be used, but you can put the source anywhere. This example will create /opt/mports/trunk containing everything needed for MacPorts.

    %% mkdir -p /opt/mports
    %% cd /opt/mports
    %% svn checkout https://svn.macports.org/repository/macports/trunk

    Note

    You only really need the base subdirectory to run MacPorts, so you can avoid checking out the rest if you don't want to use a Subversion-based ports tree (see Step 3 below). To just get the base directory, append /base to the end of the svn checkout command above. The resulting directory will then be /opt/mports/base

  2. Build and Install MacPorts

    MacPorts uses autoconf and makefiles for installation. These commands will build and install MacPorts to /opt/local. You can add the --prefix option to ./configure to relocate MacPorts to another directory if needed.

    %% cd /opt/mports/trunk/base
    %% ./configure --enable-readline
    %% make
    %% sudo make install
    %% make distclean
  3. (Optional) Configure MacPorts to use port information from Subversion

    This step is useful if you want to do port development. Open /opt/local/etc/macports/sources.conf in a text editor. The last line which should look like this:

    rsync://rsync.macports.org/release/tarballs/ports.tar [default]

    Change it to point to the working copy you checked out:

    file:///opt/mports/trunk/dports [default]

    Now MacPorts will look for portfiles in the working copy.

  4. Environment

    You should setup your PATH and other environment options according to the following section.

Occasionally a MacPorts developer may wish to install more than one MacPorts instance on the same host. Only one copy of MacPorts may use the default prefix /opt/local, so for additional installations use the option --prefix as shown below. It's also recommended to change the applications dir using --with-applications-dir to avoid conflicts in /Applications/MacPorts.

Note

The first command temporarily removes the standard MacPorts binary paths because they must not be present while installing a second instance.

%% export PATH=/bin:/sbin:/usr/bin:/usr/sbin
%% MP_PREFIX=/opt/macports-test
%% ./configure --prefix=$MP_PREFIX --with-applications-dir=$MP_PREFIX/Applications
%% make
%% sudo make install