Chapter 13. A Sample Makefile

Here is a sample Makefile that can be used to create a new port. Make sure to remove all the extra comments (ones between brackets).

The format shown is the recommended one for ordering variables, empty lines between sections, and so on. This format is designed so that the most important information is easy to locate. We recommend using portlint to check the Makefile.

[the header...just to make it easier for us to identify the ports.]
# Created by: Satoshi Asami <>
[The optional Created by: line names the person who originally
created the port.  Note that the : is followed by a space
and not a tab character.
If this line is present, future maintainers must
not change or remove it except at the original author's request.]

# $FreeBSD$
[ ^^^^^^^^^ This will be automatically replaced with RCS ID string by SVN
when it is committed to our repository.  If upgrading a port, do not alter
this line back to "$FreeBSD$".  SVN deals with it automatically.]

[section to describe the port itself and the master site - PORTNAME
 and PORTVERSION are always first, followed by CATEGORIES,
 and then MASTER_SITES, which can be followed by MASTER_SITE_SUBDIR.
 PKGNAMEPREFIX and PKGNAMESUFFIX, if needed, will be after that.
 Then comes DISTNAME, EXTRACT_SUFX and/or DISTFILES, and then
 EXTRACT_ONLY, as necessary.]
[do not forget the trailing slash ("/")!
 if not using MASTER_SITE_* macros]
MASTER_SITE_SUBDIR=	applications
DISTNAME=	xdvi-pl18
[set this if the source is not in the standard ".tar.gz" form]

[section for distributed patches -- can be empty]
PATCHFILES=	xdvi-18.patch1.gz xdvi-18.patch2.gz

[maintainer; *mandatory*!  This is the person who is volunteering to
 handle port updates, build breakages, and to whom a users can direct
 questions and bug reports.  To keep the quality of the Ports Collection
 as high as possible, we no longer accept new ports that are assigned to
COMMENT=	DVI Previewer for the X Window System

[dependencies -- can be empty]
RUN_DEPENDS=	gs:print/ghostscript

[this section is for other standard variables that do not
 belong to any of the above]
[If it asks questions during configure, build, install...]
[If it extracts to a directory other than ${DISTNAME}...]
WRKSRC=		${WRKDIR}/xdvi-new
[If the distributed patches were not made relative to ${WRKSRC},
 this may need to be tweaked]
[If it requires a "configure" script generated by GNU autoconf to be run]
[If it requires GNU make, not /usr/bin/make, to build...]
USES= gmake
[If it is an X application and requires "xmkmf -a" to be run...]
USES= imake
[et cetera.]

[non-standard variables to be used in the rules below]

[then the special rules, in the order they are called]
	i go fetch something, yeah

	i need to do something after patch, great

	and then some more stuff before installing, wow

[and then the epilogue]

.include <>

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 <>.