If the port needs to build slightly different versions of
packages by having a variable (for instance, resolution, or
paper size) take different values, create one subdirectory per
package to make it easier for users to see what to do, but try
to share as many files as possible between ports. Typically, by
using variables cleverly, only a very short
Makefile is needed in all but one of the
directories. In the sole Makefile, use
MASTERDIR to specify the directory where the
rest of the files are. Also, use a variable as part of PKGNAMESUFFIX
so the packages will have different names.
This will be best demonstrated by an example. This is part
of print/pkfonts300/Makefile;
PORTNAME= pkfonts${RESOLUTION}
PORTVERSION= 1.0
DISTFILES= pk${RESOLUTION}.tar.gz
PLIST= ${PKGDIR}/pkg-plist.${RESOLUTION}
.if !defined(RESOLUTION)
RESOLUTION= 300
.else
.if ${RESOLUTION} != 118 && ${RESOLUTION} != 240 && \
${RESOLUTION} != 300 && ${RESOLUTION} != 360 && \
${RESOLUTION} != 400 && ${RESOLUTION} != 600
.BEGIN:
@${ECHO_MSG} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\""
@${ECHO_MSG} "Possible values are: 118, 240, 300, 360, 400 and 600."
@${FALSE}
.endif
.endifprint/pkfonts300 also has all
the regular patches, package files, etc. Running
make there, it will take the default value
for the resolution (300) and build the port normally.
As for other resolutions, this is the
entire
print/pkfonts360/Makefile:
RESOLUTION= 360
MASTERDIR= ${.CURDIR}/../pkfonts300
.include "${MASTERDIR}/Makefile"(print/pkfonts118/Makefile,
print/pkfonts600/Makefile, and all the
other are similar).
MASTERDIR definition tells
bsd.port.mk that the regular set of
subdirectories like FILESDIR and
SCRIPTDIR are to be found under
pkfonts300. The
RESOLUTION=360 line will override the
RESOLUTION=300 line in
pkfonts300/Makefile and the port will be
built with resolution set to 360.
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.