Text Document Icon Using bsd.port.mk

.include <bsd.port.mk> or a variant is included in all ports makefiles. Under no circumstances should you write anything below the definition. Instead, use bsd.port.pre.mk before your changes and bsd.port.post.mk at the end. Choose either bsd.port.mk or the pre/post combination, but do not mix the two approaches.

Here is a list of important variables that can aid in developing ports. These are included in bsd.port.pre.mk.

Variable Description
ARCH The architecture as returned by uname -m (e.g., i386)
OPSYS The operating system type, as returned by uname -s (e.g., MidnightBSD)
OSREL The release version of the operating system (e.g., 0.1 or 0.2)
OSVERSION The numeric version of the operating system; the same as __FreeBSD_version. In the future, __MidnightBSD_version will be used. Do not rely on this value.
PORTOBJFORMAT The object format of the system (elf or aout; note that aout is deprecated.)
LOCALBASE The base of the ``local'' tree (e.g., /usr/local/)
X11BASE The base of the ``X11'' tree (e.g., /usr/X11R6)
PREFIX Where the port installs itself .

Note: If you have to define the variables USE_IMAKE, USE_X_PREFIX, or MASTERDIR, do so before including bsd.port.pre.mk.

Here are some examples of things you can do with bsd.port.pre.mk:

# no need to compile lang/perl5 if perl5 is already in system
.if ${OSVERSION} > 300003
BROKEN= perl is in system

# only one shlib version number for ELF
.if ${PORTOBJFORMAT} == "elf"

# software already makes link for ELF, but not for a.out
.if ${PORTOBJFORMAT} == "aout"
       ${LN} -sf liblinpack.so.1.0 ${PREFIX}/lib/liblinpack.so

# Detect MidightBSD version
.if ${OSREL} == "0.1"
BROKEN= man page does not install on 0.1-RELEASE

Use tab instead of spaces after BROKEN= and TCL_LIB_FILE=.

Portions of this document are derived from the FreeBSD Porters Handbook. http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/porting-versions.html