PORTS(7)
π PORTS(7) π
miscellaneous information manual β’ ports β contributed applications
πΈ NAME πΈ
ports β contributed applications.
β¨ DESCRIPTION β¨
okay so the FreeBSD Ports Collection is literally the simple way to compile and install third party applications. It is also used to build packages, to be installed using pkg(8).
The ports tree, typically located at /usr/ports, consists of subdirectories, one for each category; those in turn contain individual ports. Each port is a directory with metadata and patches necessary to make the original application source code compile and run on FreeBSD. Compiling an application is as simple as typing make build in the port directory. The Makefile automatically fetches the application source code, either from a local disk or the network, unpacks it, applies the patches, and compiles it. It also recursively handles dependencies β other pieces of software the port depends on in order to build and work. Afterwards, make install installs the application.
The FreeBSD Ports Collection is maintained in several branches, which differ mostly by versions of software provided: the main branch contains all the latest changes and corresponds to the latest package set, while the quarterly branches only provide critical fixes. The main branch can be cloned and updated from the Git repository located at:
https://git.FreeBSD.org/ports.git
so eg:
git clone https://git.FreeBSD.org/ports.git
The quarterly branches can be found in Git as branches like yyyyQn, where yyyy indicates the year and n indicates the quarter (1 to 4), eg:
git clone -b 2021Q2 https://git.FreeBSD.org/ports.git
It is generally a good idea to use the ports branch that matches the pkg(8) repository being used. By default, for FreeBSD CURRENT the pkg(8) is configured to install packages built from the main branch, while for FreeBSD STABLE or RELEASE versions it is configured to install packages built from the latest quarterly branch. Currently configured pkg(8) repository can be verified by looking at the url field in pkg -vv output. iykyk π
For more information about using ports, see the βPackages and Ports sectionβ in The FreeBSD Handbook:
https://docs.FreeBSD.org/en/books/handbook/ports/
For information about creating new ports, see The Porter's Handbook:
https://docs.FreeBSD.org/en/books/porters-handbook/
π TARGETS π
Some of the make(1) targets work recursively through subdirectories. This lets you, for example, install all of the βbiologyβ ports with one command. The targets that do this are build, checksum, clean, configure, depends, extract, fetch, install, and package.
The following targets will be run automatically by each proceeding target in order. That is, build will be run (if necessary) by install, and so on all the way to fetch. Usually, you will only use the install target.
π the auto-run chain
configβ ConfigureOPTIONSfor this port usingportconfig(1)(ports/ports-mgmt/portconfig).fetchβ Fetch all of the files needed to build this port from the sites listed inMASTER_SITESandPATCH_SITES. SeeFETCH_CMD,MASTER_SITE_OVERRIDEandMASTER_SITE_BACKUP.checksumβ Verify that the fetched distfile's checksum matches the one the port was tested against. If the distfile's checksum does not match, it also fetches the distfiles which are missing or failed the checksum calculation. DefiningNO_CHECKSUMwill skip this step.dependsβ Install (or compile if only compilation is necessary) any dependencies of the current port. When called by theextractorfetchtargets, this is run in piecemeal asfetch-depends,build-depends, etc. DefiningNO_DEPENDSwill skip this step.extractβ Expand the distfile into a work directory.patchβ Apply any patches that are necessary for the port.configureβ Configure the port. Some ports will ask you questions during this stage. SeeINTERACTIVEandBATCH.buildβ Build the port. This is the same as calling thealltarget.installβ Install the port and register it with the package system. This is all you really need to do.install-missing-packagesβ Install missing dependencies from packages instead of building them.
π« not run during the normal install process
The following targets are not run during the normal install process.
showconfigβ DisplayOPTIONSconfig for this port.showconfig-recursiveβ DisplayOPTIONSconfig for this port and all its dependencies.rmconfigβ RemoveOPTIONSconfig for this port.rmconfig-recursiveβ RemoveOPTIONSconfig for this port and all its dependencies.config-conditionalβ Skip the ports which have already had theirOPTIONSconfigured.config-recursiveβ ConfigureOPTIONSfor this port and all its dependencies usingportconfig(1)(ports/ports-mgmt/portconfig).fetch-listβ Show the list of files to fetch in order to build the port (but not its dependencies).fetch-recursiveβ Fetch the distfiles of the port and all its dependencies.fetch-recursive-listβ Show list of files that would be retrieved byfetch-recursive.build-depends-list,run-depends-listβ Print a list of all the direct compile or run dependencies for this port.all-depends-listβ Print a list of all recursive dependencies for this port.pretty-print-build-depends-list,pretty-print-run-depends-listβ Print a list of all the recursive compile or run dependencies for this port by port name and version.missingβ Print a list of missing dependencies to be installed for the port.cleanβ Remove the expanded source code. This recurses to dependencies unlessNOCLEANDEPENDSis defined.distcleanβ Remove the port's distfiles and perform thecleantarget. Thecleanportion recurses to dependencies unlessNOCLEANDEPENDSis defined, but thedistcleanportion never recurses (this is perhaps a bug).reinstallβ Use this to restore a port after usingpkg-delete(8)when you should have useddeinstall.deinstallβ Remove an installed port from the system, similar topkg-delete(8).deinstall-allβ Remove all installed ports with the samePKGORIGINfrom the system.packageβ Make a binary package for the port. The port will be installed if it has not already been. The package is a.pkgfile that you can use to install the port on other machines withpkg-add(8). If the directory specified byPACKAGESdoes not exist, the package will be put in/usr/ports/category/port/work/pkg. SeePKGREPOSITORYandPKGFILEfor more information.package-recursiveβ Likepackage, but makes a package for each depending port as well.package-nameβ Prints the name with version of the port.readmesβ Create a port'sREADME.html. This can be used from/usr/portsto create a browsable web of all ports on your system!searchβ Search theINDEXfile for the pattern specified by thekey(searches the port name, comment, and dependencies),name(searches the port name only),path(searches the port path),info(searches the port info),maint(searches the port maintainer),cat(searches the port category),bdeps(searches the port build-time dependency),rdeps(searches the port run-time dependency),www(searches the port web site)make(1)variables, and their exclusion counterparts:xname,xkeyetc.
For example, one would type:
cd /usr/ports && make search name=query
to find all ports whose name matches βqueryβ. Results include the matching ports' path, comment, maintainer, build dependencies, and run dependencies.
cd /usr/ports && make search name=pear- \
xbdeps=apache
To find all ports whose names contain βpear-β and which do not have apache listed in build-time dependencies.
cd /usr/ports && make search name=pear- \
xname='ht(tp|ml)'
To find all ports whose names contain βpear-β, but not βhtmlβ or βhttpβ.
make search key=apache display=name,path,info keylim=1
To find ports that contain βapacheβ in either of the name, path, info fields, ignore the rest of the record.
By default the search is not case-sensitive. In order to make it case-sensitive you can use the icase variable:
make search name=p5-R icase=0
quicksearchβ Reduced search output. Only display name, path and info.describeβ Generate a one-line description of each port for use in theINDEXfile.maintainerβ Display the port maintainer's email address.indexβ Create/usr/ports/INDEX, which is used by thepretty-print-*andsearchtargets. Running theindextarget will ensure yourINDEXfile is up to date with your ports tree.fetchindexβ Fetch theINDEXfile from the FreeBSD cluster.
π ENVIRONMENT π
Okay so you can change literally all of these, bestie β no cap.
PORTSDIRβ where the ports tree lives. Defaults to/usr/ports. β¨WRKDIRPREFIXβ where temporary files get created. Super useful whenPORTSDIRis read-only (like maybe it's mounted from a CD-ROM, iconic but restrictive).DISTDIRβ where to find/put distfiles, normallydistfiles/insidePORTSDIR.SU_CMDβ the command used to elevate privilege so you can configure and install a port. The unprivileged user must have write access toWRKDIRPREFIXandDISTDIR. Default is/usr/bin/su root -c. Lots of people set it to/usr/local/bin/sudo -E sh -cbecause convenience slays.PACKAGESβ only used for thepackagetarget; base directory for the packages tree, normallypackages/inPORTSDIR. If this directory exists, the package tree will be (partially) constructed. It does not have to exist; if it doesn't, packages go into the current directory, or you can define one of:PKGREPOSITORYβ directory to put the package in.PKGFILEβ the full path to the package.
LOCALBASEβ where existing things are installed and where to search for files when resolving dependencies (usually/usr/local).PREFIXβ where to install this port (usually set to the same asLOCALBASE).MASTER_SITESβ primary sites for distribution files if they're not found locally.PATCH_SITESβ primary locations for distribution patch files if they're not found locally.MASTER_SITE_FREEBSDβ if set, go to the master FreeBSD site for all files.MASTER_SITE_OVERRIDEβ try going to these sites for all files and patches, first.MASTER_SITE_BACKUPβ try going to these sites for all files and patches, last.RANDOMIZE_MASTER_SITESβ try the download locations in a random order.MASTER_SORTβ sort the download locations according to a user-supplied pattern. Example:
.dk .sunet.se .se dk.php.net .no .de
heanet.dl.sourceforge.net
MASTER_SITE_INDEXβ where to get theINDEXsource built on the FreeBSD cluster (for thefetchindextarget). Defaults tohttps://download.FreeBSD.org/ports/index/.FETCHINDEXβ command to getINDEX(for thefetchindextarget). Defaults tofetch -am.NOCLEANDEPENDSβ if defined, do not letcleanrecurse to dependencies.FETCH_CMDβ command to use to fetch files. Normallyfetch(1).FORCE_PKG_REGISTERβ if set, overwrite any existing package registration on the system.INTERACTIVEβ if defined, only operate on a port if it requires interaction.BATCHβ if defined, only operate on a port if it can be installed 100% automatically.DISABLE_VULNERABILITIESβ if defined, disable the check for security vulnerabilities usingpkg-audit(8)when installing new ports.NO_IGNOREβ if defined, allow installation of ports marked as β¨FORBIDDENβ©. The default behavior of the Ports framework is to abort when someone tries to install a forbidden port. Of course, these ports may not work as expected, but if you really know what you're doing and are sure about installing a forbidden port, thenNO_IGNORElets you do it. πNO_CHECKSUMβ if defined, skip verifying the port's checksum.TRYBROKENβ if defined, attempt to build a port even if it's marked as β¨BROKENβ©.PORT_DBDIRβ directory where the results of configuringOPTIONSare stored. Defaults to/var/db/ports. Each port whereOPTIONShave been configured gets a uniquely named sub-directory containing a single file calledoptions.
β¨ MAKE VARIABLES β¨
The following list gives a name and short description for many of the variables used when building ports. More info on these and other related variables can be found in ${PORTSDIR}/Mk/* and the FreeBSD Porter's Handbook. π
WITH_DEBUGβ (bool) if set, debugging symbols are installed for ports binaries.WITH_DEBUG_PORTSβ a list of origins for which to setWITH_DEBUG.DEBUG_FLAGSβ (Default:-g) additionalCFLAGSto set whenWITH_DEBUGis set.DEFAULT_VERSIONSβ override the default variant used for ports with multiple concurrent versions in the tree, such as database or compiler versions.WITH_CCACHE_BUILDβ (bool) if set, enables the use ofccache(1)for building ports.CCACHE_DIRβ which directory to use for theccache(1)data.
π FILES π
These are the spots you'll be poking around in, bestie:
ports/CHANGESβ BREAKING NEWS to read before creating ports!ports/CONTRIBUTING.mdβ instructions for contributing to the ports tree.ports/Mk/bsd.port.mkβ the inner workings of the ports framework.ports/Tools/scripts/β grab bag of tools for maintaining ports.ports/UPDATINGβ BREAKING NEWS to read before upgrading ports!ports/distfiles/β directory where fetched files are stored.
Inside a specific port, ${PORT}:
${PORT}/Makefileβ specification for building the port.${PORT}/distinfoβ checksums generated withmake makesum.${PORT}/files/β directory for patches or any additional files.${PORT}/pkg-descrβ long description of the port.${PORT}/pkg-plistβ list of all files installed by the port.${PORT}/work/β the port's building and staging directory.
System spots:
/etc/make.confβ settings for the port-building framework./usr/ports/β canonical ports tree location./var/db/ports/β directory for storing configuredOPTIONS.
π¦ EXAMPLES π¦
Example 1: Building and Installing a Port
The following command builds and installs Emacs. π«Ά
# cd /usr/ports/editors/emacs
# make install
Example 2: Installing Dependencies with pkg(8)
This example shows how to build and install a port without having to build its dependencies. Instead, the dependencies are downloaded via pkg(8). Literally so convenient.
# make install-missing-packages
# make install
It's especially useful when the dependencies are costly in time and resources to build (like lang/rust). The drawback is that pkg(8) offers only packages built with the default set of OPTIONS. π
Example 3: Building a Non-Default Flavor of a Port
The following command builds a non-default flavor of a port. (In this case devel/py-pip is going to be built with Python 3.7 support.)
# cd /usr/ports/devel/py-pip
# env FLAVOR=py37 make build
Example 4: Setting Ports Options via make.conf(5)
The following lines present various ways of configuring ports options via make.conf(5) (as an alternative to, e.g., running make config):
# Enable NLS for all ports unless configured otherwise
# using the options dialog.
OPTIONS_SET= NLS
# Disable DOCS for all ports overriding the options set
# via the options dialog.
OPTIONS_UNSET_FORCE= DOCS
# Disable DOCS and EXAMPLES for the shells/zsh port.
shells_zsh_UNSET= DOCS EXAMPLES
These and other options-related variables are documented in /usr/ports/Mk/bsd.options.mk.
Example 5: Setting make(1) Variables for Specific Ports via make.conf(5)
The following example shows how to set arbitrary make(1) variables only for specific ports:
# Set DISABLE_MAKE_JOBS for the lang/rust port:
.if ${.CURDIR:M*/lang/rust}
DISABLE_MAKE_JOBS= yes
TRYBROKEN= yes
.endif
Example 6: Debugging Ports
By default, ports are built and packaged without debugging support (e.g., debugging symbols are stripped from binaries, optimization flags are used for compiling, verbose logging is disabled). Whether ports are built with debugging symbols can be controlled by the settings in make.conf(5), e.g.:
# Enable debugging for all ports.
WITH_DEBUG= yes
# Enable debugging for selected ports.
WITH_DEBUG_PORTS= mail/dovecot security/krb5
It's also possible to use the debug variables on the command line:
# make WITH_DEBUG DEBUG_FLAGS="-g -O0" build
See the βMAKE VARIABLESβ section to learn more about the debug variables.
To understand the details of what happens when the debug variables are set, it's best to consult the files located at ${PORTSDIR}/Mk/* (bsd.port.mk in particular).
If debugging is enabled for a specific port, the ports framework will:
- Add
DEBUG_FLAGS(defaults to-g) toCFLAGS. - Try to prevent the binaries from being stripped (including checking the install target to replace
install-stripwithinstall). Whether a binary has been stripped can be checked withfile(1). - Try to enable other debugging features like debug build type or verbose logging. However, this is port-specific and the ports framework might not be aware of each supported debugging feature a given piece of software has to offer. π«
π SEE ALSO π
Additional developer documentation:
portlint(1)/usr/ports/Mk/bsd.port.mk
Additional user documentation:
pkg(8)- Searchable index of all ports:
https://ports.FreeBSD.org
π HISTORY π
The Ports Collection appeared in FreeBSD 1.0. It has since spread to NetBSD, OpenBSD, and macOS. Iconic behavior, honestly. π
π AUTHORS π
This manual page was originated by David O'Brien.
π BUGS π
Ports documentation is split over four places β /usr/ports/Mk/bsd.port.mk, The Porter's Handbook, the βPackages and Portsβ chapter of The FreeBSD Handbook, and this manual page. Not me having to check four places, bestie π
That's the vibe check, bestie π
β signed off by Debian, dated February 24, 2026, on page PORTS(7) π«Άβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 1997 David E. O'Brien
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms