PORTFILE-PHASE7portfile-phaseMacPorts Portfile referenceDescriptionA reference of all available Portfile keywords that relate to port
phases. Portfiles consist of valid TCL and are encoded in UTF-8. They
usually contain only simple keyword/value combinations and Tcl extensions
as described below, though they may also contain arbitrary TCL code. Every
port has a corresponding Portfile, but Portfiles do not completely define
a port's installation behavior since the MacPorts base has default port
installation characteristics coded within it. Therefore Portfiles need
only specify required options and, if necessary, non-default
characteristics for a port.Installation Phase KeywordsMacPorts keywords are used to specify required or optional items
within a Portfile, or to override default options used by MacPorts base
for individual ports. Keywords are to be used within the "global" and
"variant" sections of Portfiles, and not within optional port phase
declarations.In other words, port phase keywords are not located within port
phase declarations, but rather they refer to port
phases and set options for those phases, and they take affect whether or
not phase declarations have been explicitly defined in a Portfile.A Word about Keyword List Modifiers (-append / -delete)It is often necessary to add to a list of keyword values
previously set by a previously executed Portfile keyword or by MacPorts
base. To keep from overwriting a previous keyword list, use a keyword
list modifier. Keywords that support list modifiers are identified under
appropriate reference sections below.The three most common uses for keyword list modifiers are to
preserve configure defaults, to preserve PortGroup dependencies, and to
add or delete items for variants.Common Uses for Keyword List ModifiersThe three most common uses for keyword list modifiers are to
preserve configure defaults, to preserve PortGroup dependencies, and
to add or delete items for variants.Preserve configure DefaultsMacPorts base sets the gcc compiler flags CFLAGS and
LDFLAGS for all ports using configure.cflags
and configure.ldflags, therefore to keep from
overwriting the default compiler flags use
configure.cflags-append and
configure.ldflags-append.configure.cflags-appendconfigure.ldflags-appendPreserve PortGroup DependenciesPorts in a PortGroup have default library dependencies set
by MacPorts base. Therefore, never use
depends_lib in ports belonging to a PortGroup
or it will overwrite the default library dependencies. Instead,
use depends_lib-append.Add or Delete Items for VariantsWhen a variant requires more or fewer dependencies,
distfiles, or patchfiles, when the variant is invoked you want
to add or remove items to the appropriate keyword values list
set in the global section of the Portfile. Use the appropriate
keywords, for example:depends_lib-append or
depends_lib-deletedistfiles-append or
distfile-deletepatchfiles-append or
patchfiles-deleteA Word about Keyword Argument Modifiers (.pre_args /
.post_args)Keywords that support pre_args and post_args are used to assemble
command strings together in a row, as described in the reference
sections below. But it should be noted that all keyword argument
modifiers implicitly support keyword list modifiers. For example, the
keyword configure.pre_args also supports
configure.pre_args-append and
configure.pre_args-delete.Fetch Phase KeywordsThe list of keywords related to the fetch phase.master_sitesA list of URLs from which a port's download file(s) may be
retrieved. For multiple master_sites, they are searched in order
until a file matching ${distfile} is
found.Default: ???Examples:master_sites http://www.somesite.org/files/ \
http://www.somemirror.org/somesite_org/files/
You may also use mirror site lists predefined by
MacPorts. Here the sourceforge and gnu mirrors are
used.master_sites sourceforge gnu
When using mirror master_sites, the subdirectory
${name} is checked on every mirror. If the
mirror subdirectory does not match ${name}, then you may
specify it using after the mirror separated by a colon.master_sites sourceforge:widget \
gnu:widget
For ports that must fetch multiple download files from
different locations, you must label the files with tags and
match the tags in a distfiles statement. The format is
mirror:subdirectory:tag.In the example below, file_one.tar.gz is fetched from
sourceforge mirrors in subdirectory
${name}; file tagtwo.tar.gz is fetched from
the gnu mirrors in subdirectory sources.master_sites sourceforge::tagone \
gnu:sources:tagtwo
distfiles file_one.tar.gz:tagone \
file_two.tar.gz:tagtwopatch_sitesA list of sites from which a port's patchfiles may be
downloaded, where applicable.Default: ${master_sites}Example:patch_sites ftp://ftp.patchcityrepo.com/pub/magic/patchesdistnameThe name of the distribution filename, not including the
extract suffix.Default: ${name}-${version}Example:distname ${name}distfilesThe full distribution filename, including the extract
suffix. Used to specify non-default distribution filenames; this
keyword must be specified (and tags used) when a port has multiple
download files (see master_sites).Default:
${distname}${extract.suffix}Example:distfiles ${name}-dev_src.tgz
distfiles file_one.tar.gz:tagone \
file_two.tar.gz:tagtwoextract.suffixThis keyword is used to specify the extract suffix
type.Default: .tar.gzExample:extract.suffix .tgzextract.mkdirThis option is used to specify if the directory
worksrcdir is part of the distfile or if it
should be created automatically and the distfiles should be
extracted there instead. This is useful for distfiles with a flat
structure which would pollute the worksrcdir
with lots of files.Default: Example:extract.mkdir yesuse_bzip2This keyword is for downloads that are tarred and bzipped.
When invoked, it automatically sets:extract.suffix = .tar.bz
extract.cmd = bzip
Default: Example:use_bzip2 yesuse_zipThis keyword is for downloads are zipped. When invoked, it
automatically sets:extract.suffix = .zip
extract.cmd = unzip
extract.pre_args = -q
extract.post_args = "-d ${portpath}/${workdir}"
Default: Example:use_zip yesFetch from CVSCVS may be used
as an alternative method of fetching distribution files using the
keywords in this section. However, fetching via CVS may cause
non-reproducible builds, so it is strongly discouraged.cvs.rootSpecify the url from which to fetch files.Default: noneExample:cvs.root :pserver:anonymous@cvs.sv.gnu.org:/sources/emacscvs.tagOptional for fetching with CVS, this specifies the code
revision to checkout.Default: noneExample:cvs.tag HEADcvs.dateA date that identifies the CVS code set to
checkout.Default: noneExample:cvs.date "12-April-2007"cvs.moduleA CVS module from which to check out the code.Default: noneExample:cvs.module SourcesFetch from SubversionSubversion
may be used as an alternative method of fetching distribution files
using the keywords in this section. However, fetching via Subversion
may cause non-reproducible builds, so it is strongly
discouraged.svn.urlThis specifies the url from which to fetch files.Default: noneExamples:svn.url http://www.domain.com/svn-repo/mydirectory
svn.url svn://www.domain.com/svn-repo/mydirectory
svn.tagOptional tag for fetching with Subversion, this specifies
the code revision to checkout; it corresponds to the -r option
in the svn cli. You must use backslashes to escape characters
that are meaningful to the Tcl interpreter, such as braces and
double quotes.Default: noneExamples:svn.tag 37192
svn.tag \{\"2006-02-17 15:30 +0230\"\}Checksum Phase KeywordsThe list of keywords related to the checksum phase.checksumsChecksum(s) of the distribution files. For ports with
multiple distribution files, filenames must be included to
associate files with their checksums.Default: ???Examples:checksums md5 dafa161bc9c61e57636a6085c87c1fe8 \
sha1 5da610e1c8bc01b80abc21ab9e98e004363b429c \
rmd160 0c1147242adf476f5e93f4d59b553ee3ea378b23checksums ${distname}${extract.suffix} md5 dafa161bc9c61e57636a6085c87c1fe8 \
sha1 5da610e1c8bc01b80abc21ab9e98e004363b429c \
rmd160 0c1147242adf476f5e93f4d59b553ee3ea378b23 \
hobbit.tar.gz md5 3b8d02c6cf6239b9bdadbc6543c5a683 \
sha1 27874638b23e66d39ed94fe716ca25c967f6e993 \
rmd160 82b9991f3bf0ceedbf74c188c5fa44b98b5e40c9Extract Phase KeywordsThe list of keywords related to the extract phase.extract.onlyextract.only-appendextract.only-deleteList of files to extract into
${worksrcpath}; the default is
${distfiles}. Only use if default extract
behavior is not correct for your port.Default: noneExample:extract.only foo.tar.gz
List modifier examples:extract.only-append bar.tar.gz
extract.only-delete foo.tar.gzextract.cmdCommand to perform extraction.Default: gzipExample:extract.cmd gunzipextract.argsextract.pre_argsextract.post_argsMain arguments to extract.cmd; additional arguments passed
before and after the main arguments.Default: ${distpath}/${distfile}Example:extract.args ${distpath}/${distfile}
The following argument modifiers are available:extract.pre_args default: "-dc"extract.post_args default: " | tar -xf"Examples:extract.pre_args xf
extract.post_args "| gnutar –x"Patch Phase KeywordsThe list of keywords related to the patch phase.patch.dirSpecify the base path for patch files.Default: ${worksrcpath}Example:patch.dir ${worksrcpath}/utilpatch.cmdSpecify the command to be used for patching files.Default: patchExample:patch.cmd catpatchfilespatchfiles-appendpatchfiles-deleteSpecify patch files to be applied for a port; list modifiers
specify patchfiles to be added or removed from a previous
patchfile declaration.Default: noneExample:patchfiles patch-Makefile.in \
patch-source.c
List modifier examples:patchfiles-append patch-configure
patchfiles-delete patch-src-Makefile.in
patch.argspatch.pre_argspatch.post_argsMain arguments to patch.cmd; optional argument modifiers
pass arguments before and after the main arguments.Default: noneExample:patch.args ???
The following argument modifiers are available:patch.pre_args default: -p0patch.post_args default: noneExamples:patch.pre_args -p1
patch.post_args ???Configure Phase KeywordsThe list of keywords related to the configure phase.MacPorts base sets some important default configure options, so
should use the -append version of most configure keywords so you don't
overwrite them. For example, MacPorts base sets default
configure.cflags so you should always use
configure.cflags-append to set additional CFLAGS in
Portfiles.configure.envconfigure.env-appendconfigure.env-deleteSet environment variables for configure; list modifiers add
and delete items from a previous Portfile configure.env keyword,
or a default set by MacPorts base. If available, it is encouraged
to use the predefined options (like configure.cflags) instead of
modifying configure.env directlyDefault: CFLAGS=-I${prefix}/include
LDFLAGS=-L${prefix}/libExample:configure.env QTDIR=${prefix}/lib/qt3
List modifier examples:configure.env-append ABI=32
configure.env-delete TCLROOT=${prefix}configure.cflagsconfigure.cflags-appendconfigure.cflags-deleteSet CFLAGS compiler flags; list modifiers add or delete
items from a previous Portfile configure.cflags keyword or the
default set by MacPorts base.Default: -O2Example:configure.cflags -Os -flat_namespace
List modifier examples:configure.cflags-append "-undefined suppress"
configure.cflags-delete -O2configure.ldflagsconfigure.ldflags-appendconfigure.ldflags-deleteSet LDFLAGS compiler flags; list modifiers add or delete
items from a previous Portfile configure.ldflags keyword or the
default set by MacPorts base.Default: -L${prefix}/libExample:configure.ldflags -L${worksrcpath}/zlib -lz
List modifier examples:configure.ldflags-append "-L/usr/X11R6/lib -L${worksrcpath}/lib"
configure.ldflags-delete -L${prefix}/lib/db44configure.cppflagsconfigure.cppflags-appendconfigure.cppflags-deleteSet CPPFLAGS to be passed to the C processor; list modifiers
add or delete items from a previous Portfile configure.cppflags
keyword or the default set by MacPorts base.Default: -I${prefix}/includeExample:configure.cppflags -I${worksrcpath}/include
List modifier examples:configure.cppflags-append "-I/usr/X11R6/lib -I${worksrcpath}/lib -DHAVE_RRD_12X"
configure.cppflags-delete -I${prefix}/lib/db44configure.fflagsconfigure.fflags-appendconfigure.fflags-deleteSet FFLAGS to be passed to the Fortran compiler; list
modifiers add or delete items from a previous Portfile
configure.fflags keyword or the default set by MacPorts
base.Default: -O2Example:configure.fflags -Os
configure.fcflagsconfigure.fcflags-appendconfigure.fcflags-deleteSet FCFLAGS to be passed to the Fortran compiler; list
modifiers add or delete items from a previous Portfile
configure.fcflags keyword or the default set by MacPorts
base.Default: -O2Example:configure.fcflags -Os
configure.f90flagsconfigure.f90flags-appendconfigure.f90flags-deleteSet F90FLAGS to be passed to the Fortran 90 compiler; list
modifiers add or delete items from a previous Portfile
configure.f90flags keyword or the default set by MacPorts
base.Default: -O2Example:configure.f90flags -Os
configure.ccSet CC compiler flags for selecting a C compiler;Default: Example:configure.cc ${prefix}/bin/gcc-mp-4.2configure.cppSet CPP compiler flags for selecting a C
preprocessor;Default: Example:configure.cpp /usr/bin/cpp-3.3configure.cxxSet CXX compiler flags for selecting a C++ compiler;Default: Example:configure.cpp /usr/bin/g++-4.0configure.objcSet OBJC compiler flags for selecting an Objective-C
compiler;Default: Example:configure.objc /usr/bin/gcc-4.0configure.fcSet FC compiler flags for selecting a Fortran
compiler;Default: Example:configure.fc ${prefix}/bin/gfortran-mp-4.2configure.f77Set F77 compiler flags for selecting a Fortran 77
compiler;Default: Example:configure.f77 ${prefix}/bin/gfortran-mp-4.2configure.f90Set F90 compiler flags for selecting a Fortran 90
compiler;Default: Example:configure.f90 ${prefix}/bin/gfortran-mp-4.2configure.javacSet JAVAC compiler flags for selecting a Java
compiler;Default: Example:configure.javac ${prefix}/bin/jikesconfigure.compilerSelect a compiler suite to fill the compiler environment
variables. All variables/tools a compiler suite can provide are
set. Manually set variables are not overwritten. Dependencies are
not added for you, as they may be just build- or also
run-dependencies. Keep in mind that not all compiler suites might
be available on your platform.Default: gcc-3.3Mac OS X 10.3Default: gcc-4.0Mac OS X 10.4,
10.5Options:gcc-3.3 gcc-4.0 apple-gcc-3.3 apple-gcc-4.0 macports-gcc-3.3 macports-gcc-3.4 macports-gcc-4.0 macports-gcc-4.1 macports-gcc-4.2 macports-gcc-4.3Example:configure.compiler macports-gcc-4.2configure.perlSet PERL flag for selecting a Perl interpreter;Default: Example:configure.perl ${prefix}/bin/perl5.8configure.pythonSet PYTHON flag for selecting a Python interpreter;Default: Example:configure.python ${prefix}/bin/python3.0configure.rubySet RUBY flag for selecting a Ruby interpreter;Default: Example:configure.ruby ${prefix}/bin/rubyconfigure.installSet INSTALL flag for selecting an install tool; used for
copying files and creating directoriesDefault: /usr/bin/installExample:configure.install ${prefix}/bin/ginstallconfigure.awkSet AWK flag for selecting an awk executableDefault: Example:configure.awk ${prefix}/bin/gawkconfigure.bisonSet BISON flag for selecting a bison executable, a parser
generatorDefault: Example:configure.bison /usr/bin/bisonconfigure.pkg_configSet PKG_CONFIG flag for helping find pkg_config, a tool for
retrieving information about installed libraries.Default: Example:configure.pkg_config ${prefix}/bin/pkg-configconfigure.pkg_config_pathSet PKG_CONFIG_PATH flag for telling pkg_config where to
search for information about installed libraries.Default: Example:configure.pkg_config_path ${prefix}/lib/pkgconfig:${x11prefix}/lib/pkgconfigconfigure.argsconfigure.pre_argsconfigure.post_argsMain arguments to configure.cmd; optional argument modifiers
pass arguments before and after the main arguments.Default: noneExample:configure.args --bindir=${prefix}/bin
The following argument modifiers are available:configure.pre_args default: --prefix=${prefix}configure.post_args default: noneExamples:configure.pre_args --prefix=${prefix}/share/bro
configure.post_args OPT="-D__DARWIN_UNIX03"Configure UniversalUniversal keywords are used to make a port compile on the OS X
platform to run on either PPC or Intel.There is a default universal variant made available to all
ports by MacPorts base, so redefining universal keywords should only
be done to make a given port compile if the default options fail to
do so.configure.universal_argsArguments used in the configure script to build the port
universal.Default: --disable-dependency-trackingExample:configure.universal_cflagsArguments appended to the configure script to build the
port universal.Default: -sysroot /Developer/SDKs/MacOSX10.4u.sdk
-arch i386 -arch ppcExample:configure.universal_cppflagsAdditional flags to put in the CPPFLAGS environment
variable when invoking the configure script.Default: ???Example:configure.universal_cxxflagsAdditional flags to put in the CXXFLAGS environment
variable when invoking the configure script.Default: -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-arch i386 -arch ppcExample:configure.universal_ldflagsAdditional flags to put in the LDFLAGS environment
variable when invoking the configure script.Default: -arch i386 -arch ppcExample:Automake and AutoconfThe list of configure keywords available for ports that need
automake and/or autoconf.use_automakeWhether or not to use automake; the default is
"no".use_automake yesautomake.envEnvironment variables to pass to automake.automake.env CFLAGS=-I${prefix}/includeautomake.argsArguments to pass to automake.automake.args --foreignautomake.dirDirectory in which to run
${automake.cmd}; the default is
${worksrcpath}.automake.dir ./srcuse_autoconfWhether or not to use autoconf; the default is
"no".use_autoconf yesautoconf.envEnvironmental variables to pass to autoconf.autoconf.env CFLAGS=-I${prefix}/include/gtk12autoconf.argsArguments to pass to autoconf.autoconf.args -l src/aclocaldirautoconf.dirDirectory in which to run
${autoconf.cmd}; the default is
${worksrcpath}.autoconf.dir srcBuild Phase KeywordsThe list of keywords related to the build phase.build.cmdMake command to run in ${worksrcdir}; the
default is "make".build.cmd pbxbuildbuild.typeDefines which "make" is required: "gnu" or "bsd". Sets
build.cmd to either "gnumake" or "bsdmake" accordingly.build.type gnubuild.argsbuild.pre_argsbuild.post_argsMain arguments to build.cmd; optional argument modifiers
pass arguments before and after the main arguments.Default: noneExample:build.args -DNOWARN
The following argument modifiers are available:build.pre_args default:
${build.target.current}build.post_args default: noneExamples:build.pre_args -project AudioSlicer.xcode
build.post_args CFLAGS_SYS="-DUSE_FREETYPE -DPREFER_FREETYPE"build.targetbuild.target-appendbuild.target-deleteBuild target to pass to ${build.cmd}; list modifiers add or
delete items from a previous Portfile build.target keyword or the
default set by MacPorts base.Default: allExample:build.target all-src
List modifier examples:build.target-append doc extra
build.target-delete compatuse_parallel_buildThis keyword is for specifying whether or not it is safe for
a port to use multiple cpus or multiple cores in parallel during
its build phase. If a port is declared to be builadble this way,
the option may be passed to the
make command if parallel builds are enabled
system-wide. This can be obtained by setting
buildmakejobs in
macports.conf. The integer
refers to the number of parallel build threads.Default: Example:use_parallel_build yesDestroot Phase KeywordsThe list of keywords related to the destroot phase.destroot.cmdInstall command to run relative to
${worksrcdir}; default is
${build.cmd}.destroot.cmd pbxbuilddestroot.typeDefines which "make" is required: either "gnu" or "bsd".
Sets install.cmd to either "gnumake" or "bsdmake"
accordingly.destroot.type gnudestroot.argsdestroot.pre_argsdestroot.post_argsMain arguments to ${destroot.cmd}; optional argument
modifiers pass arguments before and after the main
arguments.Default: noneExample:destroot.args BINDIR=${prefix}/bin
The following argument modifiers are available:destroot.pre_args default:
${destroot.target}destroot.post_args default: noneExamples:destroot.pre_args -project AudioSlicer.xcode
destroot.post_args INSTDIR=${destroot}${prefix}destroot.targetdestroot.target-appenddestroot.target-deleteInstall target to pass to ${destroot.cmd}; list modifiers
add or delete items from a previous Portfile destroot.target
keyword or the default set by MacPorts base.Default: installExample:destroot.target install install-config install-commandmode
List modifier examples:destroot.target-append install-plugins
destroot.target-delete install-commandmodedestroot.destdirArguments passed to ${destroot.cmd} to install correctly
into the destroot.destroot.destdir prefix=${destroot}${prefix}If an application's Makefile properly supports the DESTDIR
variable, MacPorts will automatically destroot the port
properly. A port must destroot properly or the port will not
install correctly, upgrade, or uninstall. If not, you may need
to set this variable, or even patch the application's
Makefile.destroot.keepdirsA list of directories that should not be removed if empty
upon destroot completion.destroot.keepdirs \
${destroot}${prefix}/var/run \
${destroot}${prefix}/var/log \
${destroot}${prefix}/var/cache/mrtgdestroot.violate_mtreeMacPorts tests for compliance to the common directory
structure in ${prefix}; the default is "no". If a port is not
compliant with the standard, set it to "yes".destroot.violate_mtree yesSEE ALSOportfile-global7, portfile-startupitem7, portfile-tcl7AUTHORSLandon Fuller landonf@macports.orgJuan Manuel Palacios jmpp@macports.orgMark Duling markd@macports.orgKevin Van Vechten kevin@opendarwin.orgJordan K. Hubbard jkh@macports.orgChris Ridd cjr@opendarwin.orgKevin Ballard eridius@macports.orgMarkus W. Weissmann mww@macports.org