Chapter 15. Order of Variables in Port Makefiles

The first sections of the Makefile must always come in the same order. This standard makes it so everyone can easily read any port without having to search for variables in a random order.

The sections and variables described here are mandatory in a ordinary port. In a slave port, many sections and variables can be skipped.

Each following block must be separated from the previous block by a single blank line.

In the following blocks, only set the variables that are required by the port. Define these variables in the order they are shown here.

15.1. PORTNAME Block

This block is the most important. It defines the port name, version, distribution file location, and category. The variables must be in this order:

Only one of PORTVERSION and DISTVERSION can be used.

15.2. PATCHFILES Block

This block is optional. The variables are:

15.3. MAINTAINER Block

This block is mandatory. The variables are:

15.4. LICENSE Block

This block is optional, although it is highly recommended. The variables are:

If there are multiple licenses, sort the different LICENSE_VAR_NAME variables by license name.


This block is optional. The variables are:

BROKEN_* and IGNORE_* can be any generic variables, for example, IGNORE_amd64, BROKEN_FreeBSD_10, etc. With the exception of variables that depend on a USES, place those in USES and USE_x. For instance, IGNORE_WITH_PHP only works if php is set, and BROKEN_SSL only if ssl is set.

If the port is marked BROKEN when some conditions are met, and such conditions can only be tested after including or, then those variables should be set later, in The Rest of the Variables.

15.6. The Dependencies Block

This block is optional. The variables are:

15.7. Flavors

This block is optional.

Start this section with defining FLAVORS. Continue with the possible Flavors helpers. See Using FLAVORS for more Information.

Constructs setting variables not available as helpers using .if ${FLAVOR:U} == foo should go in their respective sections below.

15.8. USES and USE_x

Start this section with defining USES, and then possible USE_x.

Keep related variables close together. For example, if using USE_GITHUB, always put the GH_* variables right after it.

15.9. Standard Variables

This section block is for variables that can be defined in that do not belong in any of the previous section blocks.

Order is not important, however try to keep similar variables together. For example uid and gid variables USERS and GROUPS. Configuration variables CONFIGURE_* and *_CONFIGURE. List of files, and directories PORTDOCS and PORTEXAMPLES.

15.10. Options and Helpers

If the port uses the options framework, define OPTIONS_DEFINE and OPTIONS_DEFAULT first, then the other OPTIONS_* variables first, then the *_DESC descriptions, then the options helpers. Try and sort all of those alphabetically.

Example 1. Options Variables Order Example

The FOO and BAR options do not have a standard description, so one need to be written. The other options already have one in Mk/ so writing one is not needed. The DOCS and EXAMPLES use target helpers to install their files, they are shown here for completeness, though they belong in The Targets, so other variables and targets could be inserted before them.


BAR_DESC=		Enable bar support
FOO_DESC=		Enable foo support

GNUTLS_CONFIGURE_ON=	--with-ssl=gnutls
OPENSSL_CONFIGURE_ON=	--with-ssl=openssl



15.11. The Rest of the Variables

And then, the rest of the variables that are not mentioned in the previous blocks.

15.12. The Targets

After all the variables are defined, the optional make(1) targets can be defined. Keep pre- before post- and in the same order as the different stages run:

  • fetch

  • extract

  • patch

  • configure

  • build

  • install

  • test

When using options helpers target keep them alphabetically sorted, but keep the -on before the -off. When also using the main target, keep the main target before the optional ones:

	# install generic bits

	# Install documentation

	# Install X11 related bits

	# Install bits that should be there if X11 is disabled

All FreeBSD documents are available for download at

Questions that are not answered by the documentation may be sent to <>.
Send questions about this document to <>.