diff --git a/en_US.ISO8859-1/books/porters-handbook/book.sgml b/en_US.ISO8859-1/books/porters-handbook/book.sgml
index df8de365d4..0085756eaf 100644
--- a/en_US.ISO8859-1/books/porters-handbook/book.sgml
+++ b/en_US.ISO8859-1/books/porters-handbook/book.sgml
@@ -4758,7 +4758,7 @@ PORTVERSION= 1.0
USE_X_PREFIX
- The port installs in X11BASE, not
+ The port installs in X11BASE_REL, not
PREFIX.
@@ -6779,17 +6779,30 @@ as .putsy.conf and edit it.
- PREFIX
+ PREFIX and DESTDIR
- Do try to make your port install relative to
- PREFIX. The value of this variable will be set
- to LOCALBASE (default
+ PREFIX determines the location where
+ the port will install. It is usually /usr/local,
+ or /opt. User can set PREFIX
+ to anything he wants. Your port must respect this variable.
+
+ DESTDIR, if set by user, determines the
+ complete alternative environment, usually a jail, or an installed
+ system mounted elsewhere than /.
+ A port will actually install into
+ DESTDIR/PREFIX, and register
+ with the package database in DESTDIR/var/db/pkg.
+ It is very important to write ports that respect
+ DESTDIR.
+
+ The value of PREFIX will be set
+ to LOCALBASE_REL (default
/usr/local). If
USE_X_PREFIX or USE_IMAKE is
- set, PREFIX will be X11BASE (default
+ set, PREFIX will be X11BASE_REL (default
/usr/X11R6). If
USE_LINUX_PREFIX is set, PREFIX
- will be LINUXBASE (default
+ will be LINUXBASE_REL (default
/compat/linux).
Avoiding the hard-coding of /usr/local or
@@ -6840,6 +6853,48 @@ as .putsy.conf and edit it.
-DPAGER=\"/usr/local/bin/less\". This way it will
have a better chance of working if the system administrator has
moved the whole /usr/local tree somewhere else.
+
+ Note that LOCALBASE,
+ LINUXBASE, X11BASE,
+ DOCSDIR, EXAMPLESDIR,
+ DATADIR, DESKTOPDIR variables
+ already contain DESTDIR. Using
+ DESTDIR/LOCALBASE is
+ wrong. Use LOCALBASE_REL,
+ LINUXBASE_REL, X11BASE_REL
+ if you need a variable relative to DESTDIR.
+ To keep things terse, TARGETDIR can be used to
+ replace DESTDIR/PREFIX.
+
+ Example of correct usage:
+
+ post-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/helper ${TARGETDIR}/bin/helper
+ ${INSTALL_DATA} ${WRKSRC}/guide.txt ${DOCSDIR}
+
+ When referencing dependencies in the port, the
+ LOCALBASE is used, as we are working with
+ dependencies inside the target environment. For hardcoding file
+ paths in the software, LOCALBASE_REL must
+ be used, because the software wil run inside the target
+ environment.
+
+ Example of correct usage:
+
+ RUN_DEPENDS= ${LOCALBASE}/share/gonzo/launch.dat:${PORTSDIR}/games/gonzo
+
+post-patch:
+ @${REINPLACE_CMD} -e 's|/usr/gonzo/launch.dat|${LOCALBASE_REL}/share/gonzo/launch.dat}' ${WRKSRC}/main.c
+ @${REINPLACE_CMD} -e 's|/etc/game.conf|${PREFIX}/etc/game.conf|' ${WRKSRC}/loader.c
+
+post-install:
+ @${INSTALL_DATA} ${WRKSRC}/example/conf ${TARGETDIR}/etc/game.conf
+
+ In packing lists and in pkg-* scripts,
+ %%LOCALBASE%%, %%LINUXBASE%%
+ and %%X11BASE%% expansions will contain paths
+ stripped of DESTDIR, as all these files are
+ processed of a context of target environment.