PREFIX
determines where the port will
be installed. It defaults to /usr/local
,
but can be set by the user to a custom path like
/opt
. Your port must respect the value
of this variable.
DESTDIR
, if set by the user, determines
the complete alternative environment, usually a jail or an
installed system mounted somewhere other than
/
. A port will actually install into
,
and register with the package database in
DESTDIR
/PREFIX
.
As DESTDIR
/var/db/pkgDESTDIR
is handled automatically by the
ports infrastructure with chroot(8), you do not need any
modifications or any extra care to write
DESTDIR
-compliant ports.
The value of PREFIX
will be set to
LOCALBASE
(defaulting to
/usr/local
). If
USE_LINUX_PREFIX
is set,
PREFIX
will be LINUXBASE
(defaulting to /compat/linux
).
Avoiding hard-coded /usr/local
paths
in the source makes the port much more flexible and able to
cater to the needs of other sites. Often, this can be
accomplished by simply replacing occurrences of
/usr/local
in the port's various
Makefile
s with
${PREFIX}
. This variable is
automatically passed down to every stage of the build and
install processes.
Make sure your application is not installing things in
/usr/local
instead of
PREFIX
. A quick test for such hard-coded
paths is:
#
make clean; make package PREFIX=/var/tmp/`make -V PORTNAME`
If anything is installed outside of
PREFIX
, the package creation process will
complain that it cannot find the files.
In addition, it is worthwhile to check the same via the stage directory support (see Section 6.1, “Staging”):
#
make stage && make check-orphans && make package
These tests will not find hard-coded paths inside the
port's files, nor will it verify that
LOCALBASE
is being used to correctly refer
to files from other ports. The temporarily-installed port in
/var/tmp/`make -V PORTNAME`
should be
tested for proper operation to make sure there
are no problems with paths.
PREFIX
should not be set explicitly
in a port's Makefile
. Users installing
the port may have set PREFIX
to a custom
location, and the port should respect that setting.
Refer to programs and files from other ports with the
variables mentioned above, not explicit pathnames. For
instance, if your port requires a macro
PAGER
to have the full pathname of
less
, do not use a literal path of
/usr/local/bin/less
. Instead, use
${LOCALBASE}
:
The path with LOCALBASE
is more likely
to still work if the system administrator has moved the whole
/usr/local
tree somewhere else.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/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>.