Installing MacPortsThis chapter shows you how to install MacPorts and its prerequisites
step-by-step. Note that sections 1 through 3 are Mac OS X specific. If you
wish to install MacPorts on another platform, first make sure you have X11
and gcc installed, and then perform a MacPorts install from source code.Install X11It is recommended that you install the X Window System (X11) even if
you don't plan to run X11 applications immediately. Apple's X11 is
preferred over the MacPorts X11 port, and ports with an X11 dependency
will be satisfied by Apple's X11. If Apple's X11 wasn't installed at the
same time Mac OS X was installed, follow these steps.Insert the "Mac OS X Install Disk" and run the package named
"Optional Installs".At the software selection window expand the Applications
category and click the check box beside X11 (and nothing else).Click Install to install X11.Drag the /Applications/Utilities/X11 icon
to your dock —you must open X11 before launching an X11
application.If you're using Mac OS X 10.3 then you can download the X11
installer from the Apple download
page.X11 and the X11SDK (from Xcode Tools) are both required for X11
apps. To verify the presence of both, check for files
com.apple.pkg.X11User.bom &
com.apple.pkg.X11SDKLeo.bom in
/Library/Receipts/boms/. On Mac OS X 10.4, look for
files X11User.pkg &
X11SDK.pkg in
/Library/Receipts/.Optional X11 SettingsTo launch X11 applications directly from an X11 window (instead of
a terminal window), you need to have the MacPorts paths imported into
X11 sessions when they are opened. This is a two step process.First, tell X11 about the ~/.profile file
that will be created after you install MacPorts. Do this by editing the
file /etc/X11/xinit/xinitrc and adding this line
near the top.source ~/.profileNow finish the process by making subsequent X11 sessions opened
using the menu bar respect your .profile
file.Open X11 and select "Customize Menu ..." from the Applications
menu.Double-click the menu item "Terminal" and change: "xterm" to
"xterm -ls"Click "Done" to save the change.Install Xcode ToolsTo install Xcode Tools and the X11 SDK, follow these steps.Download and install the latest version of Xcode Tools from
Apple's developer site—do not install it from a Mac OS X install disk
unless you've already checked for a more recent version on Apple's
site; older versions of Xcode Tools often cause port install
failures.Run the Xcode Tools package installer.Click the button Customize, expand the
Applications category and click the check box beside X11
SDK to add it to the default items.Click Install to install Xcode Tools and
the X11 SDK.Xcode Tools are not updated via Mac OS X's Software Update
utility.Install MacPortsIf 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.Though a distinction is made between pre-release and release
versions of MacPorts base, the ports collection supports no versioning;
a selfupdate installs the
latest commits from subversion (at a slight delay).Mac OS X Package InstallThe Mac OS X package installer automatically installs MacPorts,
sets the shell environment, and
runs a selfupdate operation
to download the ports tree with the latest versions and upgrade MacPorts
base to the latest point release.Download the latest MacPorts-1.x.x.dmg
disk image from the MacPorts
download directory.Double-click the MacPorts-1.x.x.pkg
package installer on the disk image.Perform the default “easy” install.Source InstallIf you installed MacPorts using the package installer, skip this
section. To install MacPorts from the source code, follow the steps
below.Download and unzip the latest MacPorts tarball from the MacPorts
download directory.Perform the commands shown in a terminal window. If you wish
to use a path other than /opt/local, use the
option and substitute a path for
NEW_PREFIX.%%cd ~/MacPorts-1.x.x/%%./configure --prefix=NEW_PREFIX (setting prefix is optional)
%%make%%sudo make installInstall Multiple MacPorts CopiesOccasionally 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 Tcl library path /Library/Tcl/,
so for additional installations use the option
as shown below and substitute
NEW_TCL_PACKAGE with any empty directory, for example
/Library/Tcl/macports-new/.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%%cd ~/MacPorts-1.x.x/%%./configure --prefix=NEW_PREFIX --with-tcl-package=NEW_TCLPACKAGE%%make%%sudo make installUninstallTo uninstall MacPorts from the default location
/opt/local/, perform these commands from a terminal
window.%%sudo rm -rf /opt/local/%%sudo rm -rf /Applications/MacPorts/%%sudo rm -rf /Library/Tcl/macports1.0/%%sudo rm -rf /Library/LaunchDaemons/org.macports.*MacPorts and the ShellMacPorts requires changes to the shell environment. If MacPorts was
installed using the Mac OS X package installer, a
postflight script was run after installation that places a
.profile file in your home directory and populates it
with environmental variables according to the detected Mac OS X version
and environment. See details below.If a previous .profile is present it is
renamed to "mpsaved_$timestamp" before the new .profileThe postflight script sets environmental variables in
the .profile file as shown.A PATH variable is set to append the MacPorts file paths in
front of the default file paths so MacPorts libraries will take
precedence over vendor-supplied libraries.export PATH=/opt/local/bin:/opt/local/sbin:$PATHA MANPATH variable is set in .profile by
the postflight script as shown only if a MANPATH
variable was already set in a previous .profile
that does not include the value
${prefix}/share/man, nor any empty values.
Otherwise it is omitted.export MANPATH=/opt/local/share/man:$MANPATHHere are examples of paths that contain empty values:/usr/share/man::/usr/share/man/usr/share/man::/usr/X11R6/manA DISPLAY variable is set in .profile by
the postflight script as shown only for X11 application
support in Mac OS X versions 10.4 (Tiger) and earlier (unless DISPLAY
is already set in a .profile). A DISPLAY variable
is not set for Mac OS X 10.5 (Leopard) or higher.export DISPLAY=:0.0Changes to ~/.profile do not take effect until
a new terminal session is opened. Type env in the
terminal to verify the current environment settings. Example output for
the env command is shown below.MANPATH=
TERM_PROGRAM=Apple_Terminal
TERM=xterm-color
SHELL=/bin/bash
TERM_PROGRAM_VERSION=237
USER=joebob
__CF_USER_TEXT_ENCODING=0x1FC:0:0
PATH=/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
PWD=/Users/joebob
EDITOR=/usr/bin/pico
SHLVL=1
HOME=/Users/joebob
LOGNAME=joebob
DISPLAY=:0.0
SECURITYSESSIONID=b0cea0
_=/usr/bin/envIf you have either a .bash_login or a
.bash_profile file in your home directory, they may
take precedence over .profile. You may either
remove the previously used file, or add the contents of
.profile to it.