Configuring the Makefile is pretty simple, and again we suggest that you look at existing examples before starting. Consider the following problems in sequence as you design your new Makefile:
Does it live in ${DISTDIR} as a standard
gzip'd tarball? If so, you can go on to the next step. If
not, you should look at overriding any of the
${EXTRACT_CMD},
${EXTRACT_BEFORE_ARGS},
${EXTRACT_AFTER_ARGS},
${EXTRACT_SUFX}, or
${DISTFILE} variables, depending on how
alien a format your port's distribution file is. (The most
common case is `EXTRACT_SUFX=.tar.Z', when the
tarball is condensed by regular compress, not gzip.)
In the worst case, you can simply create your own
`do-extract' target to override the default, though
this should be rarely, if ever, necessary.
You should set ${DISTNAME} to be the base
name of your port. The default rules expect the
distribution file list (${DISTFILES}) to be
named
${DISTFILE}${EXTRACT_SUFX}
by default which, if it's a normal tarball, is going to be
something like:
foozolix-1.0.tar.gz
for a setting of `DISTNAME=foozolix-1.0'.
The default rules also expect the tarball(s) to extract into
a subdirectory called work/${DISTNAME}, e.g.
work/foozolix-1.0/
All this behavior can be overridden, of course, it simply
represents the most common time-saving defaults. For a port
requiring multiple distribution files, simply set
${DISTFILES} explicitly. If only a subset
of ${DISTFILES} are actual extractable
archives, then set them up in
${EXTRACT_ONLY}, which will override the
${DISTFILES} list when it comes to
extraction, and the rest will be just left in
${DISTDIR} for later use.
When a package is created, it is put under
/usr/ports/packages/All and links are made from one
or more subdirectories of /usr/ports/packages. The
names of these subdirectories are specified by the variable
${CATEGORIES}. It is intended to make life
easier for the user when he is wading through the pile of
packages on the ftp site or the CD-ROM. Please take a look
at the existing categories (some of them have different
names from subdirectories of /usr/ports) and pick
the ones that are suitable for your port. If your port
truly belongs to something that is different from all the
existing ones, you can even create a new category name.
If you want to add more information than just the category
names, add them to ${KEYWORDS}. The value
of this variable defaults to that of
${CATEGORIES}. This is currently used only
as a field of the /usr/ports/INDEX file.
If you have a ftp-URL pointing at the the original tarball,
record the directory containing the tarball in
${MASTER_SITES}. This will provide a backup
site, as well as a direct pointer to the original source
location. Don't forget the trailing slash (/)!
The make macros will try to use this specification for
grabbing the distribution file with ${NCFTP}
if they can't find it already on the system.
It is recommended that you put multiple sites on this list, preferably from different continents. This will safeguard against wide-area network problems, and we are even planning to add support for automatically determining the closest master site and fetching from there!
If your port requires some additional patches that are
available by ftp, set ${PATCHFILES} to the
names of the files and ${PATCH_SITES} to the
URL of the directory that contains them (the format is the
same as ${MASTER_SITES}).
If the patch is not relative to the top of the source tree
(i.e., ${WKRSRC}) because it contains some
extra pathnames, set ${PATCH_DIST_STRIP}
accordingly. For instance, if all the pathnames in the
patch has an extra `foozolix-1.0/' in front of the
filenames, then set `PATCH_DIST_STRIP=-p1'.
Don't worry if the patches are compressed, they will be
decompressed automatically if the filenames end with
`.gz' or `.Z'.
Set your mail-address here. Please. :)
Many ports depend on other ports. There are five variables that you can use to ensure that all the required bits will be on the user's machine.
This variable specifies the shared libraries this port
depends on. It is a list of `lib:dir' pairs
where lib is the name of the shared library, and
dir is the directory in which to find it in case
it's not available. For example,
LIB_DEPENDS= tcl\\.7\\.:${PORTSDIR}/lang/tcl
will check for a shared tcl library with major version 7,
and descend into the lang/tcl subdirectory of
your ports tree to build and install it if it's not found.
Note that the lib part is just an argument given
to `ldconfig -r | grep', so periods should be
escaped by two backslashes like in the example above.
This variable specifies executables this port depends on
during run-time. It is a list of `exec:dir'
pairs where exec is the name of the executable,
and dir is the directory in which to find it in
case it's not available. For example,
RUN_DEPENDS= wish:${PORTSDIR}/x11/tk
will check for an executable called `wish', and
descend into the x11/tk subdirectory of your
ports tree to build and install it if it's not found.
The dependency is checked from within the install
target. Also, the name of the dependency is put in to the
package so that pkg_add will automatically
install it if it is not on the user's system.
This variable specifies executables this port requires to
build. Like RUN_DEPENDS, it is a list of
`exec:dir' pairs. For example,
BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip
will check for an executable called `unzip', and
descend into the archivers/unzip subdirectory of
your ports tree to build and install it if it's not found.
Note that `build' here means everything from extracting to
compilation. The dependency is checked from within the
extract target.
This variable specifies executables this port requires to
fetch. Like the previous two, it is a list of
`exec:dir' pairs. For example,
FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2
will check for an executable called `ncftp2', and
descend into the net/ncftp2 subdirectory of
your ports tree to build and install it if it's not found.
The dependency is checked from within the fetch
target.
If there is a dependency that doesn't fall into either of the above four categories, or your port requires to have the source of the other port extracted (i.e., having them installed is not enough), then use this variable. This is just a list of directories, as there is nothing to check, unlike the previous two.
If your package uses GNU make, set
`USE_GMAKE=yes'. If your package uses GNU
configure, set `GNU_CONFIGURE=yes'. If
you want to override the default GNU configure
arguments from `--prefix=${PREFIX}' to
something else, set those arguments in
${CONFIGURE_ARGS}.
If your package uses imake (e.g. is an X
application that has an Imakefile), then set
`USE_IMAKE=yes'. This will cause the configure
stage to automatically do an xmkmf -a. If the
`-a' flag is a problem for your port, set
`XMKMF=xmkmf'.
If your port's source Makefile has something else than
`all' as the main build target, set
${ALL_TARGET} accordingly. Same goes for
`install' and ${INSTALL_TARGET}.
If the port uses imake but doesn't understand the
`install.man' target,
`NO_INSTALL_MANPAGES=yes' should be set. In
addition, the author of the original port should be shot.