Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2006 18:12:36 +0200 (CEST)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Gabor Kovesdan <gabor@t-hosting.hu>
Subject:   ports/100555: [patch] bsd.port.mk - DESTDIR support
Message-ID:  <20060719161236.9FD18289D74@catv-50635cb6.catv.broadband.hu>
Resent-Message-ID: <200607191620.k6JGKFd1073544@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         100555
>Category:       ports
>Synopsis:       [patch] bsd.port.mk - DESTDIR support
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 19 16:20:14 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Gabor Kovesdan
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
n/a
>Environment:
System: FreeBSD spitfire 6.1-STABLE FreeBSD 6.1-STABLE #0: Sun Jul 2 19:31:12 CEST 2006 gabor@spitfire:/usr/src/sys/i386/compile/SPITFIRE i386

>Description:

The attached patches implement DESTDIR support in the ports infrastructure, which can be
used to install ports into separate jail environments.  Besides, some ports need a slight
modification to work with DESTDIR.  I did a lot of effort so that individual ports
need the least modification, but I had to change the behaviour of LOCALBASE, LINUXBASE,
X11BASE a bit.  They contain DESTDIR in itself, thus we can just leave lines like
BUILD_DEPENDS= ${LOCALBASE}/bin/foo:${PORTSDIR}/misc/foo alone.  I introduced
LOCALBASE_REL, LINUXBASE_REL and X11BASE_REL for the old functionality.  Note, that
LOCALBASE, LINUXBASE and X11BASE are still overrideable with my workaround, so this change
doesn't break compatibility!  Simpler ports like net/csup already work with this
implementation, but e.g. shells/bash needs just a little bit of modification.

This PR supersedes ports/28155.

Sponsored by: Google Summer of Code 2006
Reviewed by: erwin
Wiki: http://wikitest.freebsd.org/DESTDIR
See also: http://perforce.freebsd.org/depotTreeBrowser.cgi?FSPC=//depot/projects/soc2006/gabor%5fdocs/porters%2dhandbook&HIDEDEL=NO
	(I wrote some sentences for porters-handbook, how one can write DESTDIR-respective ports)

>How-To-Repeat:
>Fix:

--- destdir_mk.diff begins here ---
diff -Nur /usr/ports/Mk/bsd.apache.mk ../Mk/bsd.apache.mk
--- /usr/ports/Mk/bsd.apache.mk	Tue Jun 20 06:58:12 2006
+++ ../Mk/bsd.apache.mk	Sat Jul 15 22:39:38 2006
@@ -175,7 +175,7 @@
 				--${SUEXEC_CONFARGS}-safepath="${SUEXEC_SAFEPATH}" \
 				--${SUEXEC_CONFARGS}-logfile="${SUEXEC_LOGFILE}"
 .if ${USE_APACHE:Mcommon2*} != ""
-CONFIGURE_ARGS+=	--${SUEXEC_CONFARGS}-bin="${PREFIX}/sbin/suexec"
+CONFIGURE_ARGS+=	--${SUEXEC_CONFARGS}-bin="${DESTDIR}${PREFIX}/sbin/suexec"
 .endif
 
 .   if defined(WITH_SUEXEC_UMASK)
diff -Nur /usr/ports/Mk/bsd.emacs.mk ../Mk/bsd.emacs.mk
--- /usr/ports/Mk/bsd.emacs.mk	Tue May 16 19:11:20 2006
+++ ../Mk/bsd.emacs.mk	Sat Jul 15 22:39:38 2006
@@ -236,8 +236,8 @@
 
 # find where emacsen is installed
 # look for it in PREEFIX first and fall back to LOCALBASE then
-.if exists(${PREFIX}/bin/${EMACS_NAME}-${EMACS_VER})
-EMACS_BASE?=			${PREFIX}
+.if exists(${DESTDIR}${PREFIX}/bin/${EMACS_NAME}-${EMACS_VER})
+EMACS_BASE?=			${DESTDIR}${PREFIX}
 .else
 EMACS_BASE?=			${LOCALBASE}
 .endif
diff -Nur /usr/ports/Mk/bsd.gnome.mk ../Mk/bsd.gnome.mk
--- /usr/ports/Mk/bsd.gnome.mk	Wed Jul  5 04:18:08 2006
+++ ../Mk/bsd.gnome.mk	Sat Jul 15 22:39:38 2006
@@ -106,13 +106,13 @@
 GNOME_HTML_DIR?=	${PREFIX}/share/doc
 GCONF_CONFIG_OPTIONS?=	merged
 GCONF_CONFIG_DIRECTORY?=etc/gconf/gconf.xml.defaults
-GCONF_CONFIG_SOURCE?=xml:${GCONF_CONFIG_OPTIONS}:${PREFIX}/${GCONF_CONFIG_DIRECTORY}
+GCONF_CONFIG_SOURCE?=xml:${GCONF_CONFIG_OPTIONS}:${DESTDIR}${PREFIX}/${GCONF_CONFIG_DIRECTORY}
 GNOME_LOCALSTATEDIR?=	${PREFIX}/share/gnome
 gnomeprefix_CONFIGURE_ENV=GTKDOC="false"
-gnomeprefix_CONFIGURE_ARGS=--localstatedir=${GNOME_LOCALSTATEDIR} \
-			   --datadir=${PREFIX}/share/gnome \
-			   --with-html-dir=${GNOME_HTML_DIR} \
-			   --with-help-dir=${PREFIX}/share/gnome/help \
+gnomeprefix_CONFIGURE_ARGS=--localstatedir=${DESTDIR}${GNOME_LOCALSTATEDIR} \
+			   --datadir=${DESTDIR}${PREFIX}/share/gnome \
+			   --with-html-dir=${DESTDIR}${GNOME_HTML_DIR} \
+			   --with-help-dir=${DESTDIR}${PREFIX}/share/gnome/help \
 			   --disable-gtk-doc \
 			   --with-gconf-source=${GCONF_CONFIG_SOURCE}
 gnomeprefix_USE_GNOME_IMPL=gnomehier
@@ -725,10 +725,10 @@
 
 gnome-pre-su-install:
 .if defined(_USE_GNOME) && ${_USE_GNOME:Mgnomeprefix}!="" && !defined(NO_MTREE)
-	@${MTREE_CMD} ${MTREE_ARGS:S/${MTREE_FILE}/${GNOME_MTREE_FILE}/} ${PREFIX}/ >/dev/null
+	@${MTREE_CMD} ${MTREE_ARGS:S/${MTREE_FILE}/${GNOME_MTREE_FILE}/} ${DESTDIR}${PREFIX}/ >/dev/null
 .endif
 .if defined(GCONF_SCHEMAS)
-	@${MKDIR} ${PREFIX}/etc/gconf/gconf.xml.defaults/
+	@${MKDIR} ${DESTDIR}${PREFIX}/etc/gconf/gconf.xml.defaults/
 .else
 	@${DO_NADA}
 .endif
diff -Nur /usr/ports/Mk/bsd.mail.mk ../Mk/bsd.mail.mk
--- /usr/ports/Mk/bsd.mail.mk	Sat Jan 21 18:37:01 2006
+++ ../Mk/bsd.mail.mk	Sat Jul 15 22:39:38 2006
@@ -51,9 +51,9 @@
 .endif
 
 .if defined(QMAIL_SLAVEPORT)
-QMAIL_DEPENDS=	${QMAIL_PREFIX}/bin/qmail-send:${PORTSDIR}/mail/qmail-${QMAIL_SLAVEPORT:L}
+QMAIL_DEPENDS=	${DESTDIR}${QMAIL_PREFIX}/bin/qmail-send:${PORTSDIR}/mail/qmail-${QMAIL_SLAVEPORT:L}
 .else
-QMAIL_DEPENDS=	${QMAIL_PREFIX}/bin/qmail-send:${PORTSDIR}/mail/qmail
+QMAIL_DEPENDS=	${DESTDIR}${QMAIL_PREFIX}/bin/qmail-send:${PORTSDIR}/mail/qmail
 .endif
 
 .if defined(USE_QMAIL) || defined(USE_QMAIL_RUN)
diff -Nur /usr/ports/Mk/bsd.openssl.mk ../Mk/bsd.openssl.mk
--- /usr/ports/Mk/bsd.openssl.mk	Thu May 25 17:17:34 2006
+++ ../Mk/bsd.openssl.mk	Sat Jul 15 22:39:38 2006
@@ -59,10 +59,10 @@
 .endif
 
 .if defined(WITH_OPENSSL_BASE)
-OPENSSLBASE=		/usr
-OPENSSLDIR=		/etc/ssl
+OPENSSLBASE=		${DESTDIR}/usr
+OPENSSLDIR=		${DESTDIR}/etc/ssl
 
-.if !exists(/usr/lib/libcrypto.so)
+.if !exists(${DESTDIR}/usr/lib/libcrypto.so)
 check-depends::
 	@${ECHO_CMD} "Dependency error: this port requires the OpenSSL library, which is part of"
 	@${ECHO_CMD} "the FreeBSD crypto distribution but not installed on your"
@@ -98,7 +98,7 @@
 .endif
 MAKE_ARGS+=		OPENSSL_CFLAGS="${OPENSSL_CFLAGS}"
 .endif
-OPENSSLRPATH=		/usr/lib:${LOCALBASE}/lib
+OPENSSLRPATH=		${DESTDIR}$/usr/lib:${LOCALBASE}/lib
 
 .else
 
diff -Nur /usr/ports/Mk/bsd.port.mk ../Mk/bsd.port.mk
--- /usr/ports/Mk/bsd.port.mk	Tue Jul 18 06:12:51 2006
+++ ../Mk/bsd.port.mk	Wed Jul 19 17:40:51 2006
@@ -472,7 +472,7 @@
 #				  If this is set to a list of files, these files will be
 #				  automatically added to ${SUB_FILES}, some %%VAR%%'s will
 #				  automatically be expanded, they will be installed in
-#				  ${PREFIX}/etc/rc.d and added to the packing list.
+#				  ${DESTDIR}${PREFIX}/etc/rc.d and added to the packing list.
 # USE_RCORDER	- List of rc.d startup scripts to be called early in the boot
 #				  process. This acts exactly like USE_RC_SUBR except that
 #				  scripts are installed in /etc/rc.d.
@@ -492,15 +492,31 @@
 # Various directory definitions and variables to control them.
 # You rarely need to redefine any of these except WRKSRC and NO_WRKSUBDIR.
 #
+# DESTDIR		- The path to the environment we are installing to.  Define
+#				  this if you want to install packages into a jail
+#				  or into an another FreeBSD environment mounted
+#				  elsewhere than /.  ${PREFIX} is relative to
+#				  ${DESTDIR}.  E.g. setting DESTDIR=/bla PREFIX=/opt will
+#				  result packages installed under /bla/opt and registered
+#				  under /bla/var/db/pkg.
+#				  Default: not set (means /)
+#
 # X11BASE		- Where X11 ports install things.
+#				  Default: ${DESTDIR}/usr/X11R6
+# X11BASE_REL		- Same as X11BASE, but relative to DESTDIR
 #				  Default: /usr/X11R6
 # LOCALBASE		- Where non-X11 ports install things.
+#				  Default: ${DESTDIR}/usr/local
+# LOCALBASE_REL		- Same as LOCALBASE, but relative to DESTDIR
 #				  Default: /usr/local
 # LINUXBASE		- Where Linux ports install things.
+#				  Default: ${DESTDIR}/compat/linux
+# LINUXBASE_REL		- Same as LINUXBASE, but relative to DESTDIR
 #				  Default: /compat/linux
 # PREFIX		- Where *this* port installs its files.
-#				  Default: ${X11BASE} if USE_X_PREFIX is set, ${LINUXBASE} if
-#				  USE_LINUX_PREFIX is set, otherwise ${LOCALBASE}
+#				  Default: ${X11BASE_REL} if USE_X_PREFIX is set,
+#				   ${LINUXBASE_REL} if  USE_LINUX_PREFIX is set,
+#				   otherwise ${LOCALBASE_REL}
 # MASTERDIR		- Where the port finds patches, package files, etc.  Define
 #				  this is you have two or more ports that share most of the
 #				  files.
@@ -567,7 +583,7 @@
 #				  installs its own manpage links so they will show up
 #				  correctly in ${PLIST}.)
 # MANPREFIX		- The directory prefix for ${MAN<sect>} and ${MLINKS}.
-#				  Default: ${PREFIX}
+#				  Default: ${DESTDIR}${PREFIX}
 # MAN<sect>PREFIX
 #				- If manual pages of some sections install in different
 #				  locations than others, use these.
@@ -854,7 +870,7 @@
 #				  rest of PLIST, so ${PLIST_SUB} substitutions also
 #				  apply here.  It is recommended that you use
 #				  %%PREFIX%% for ${PREFIX}, %%LOCALBASE%% for
-#				  ${LOCALBASE} and %%X11BASE%% for ${X11BASE}.
+#				  ${LOCALBASE_REL} and %%X11BASE%% for ${X11BASE_REL}.
 #				  Default: %%PREFIX%%/lib
 # USE_LDCONFIG  - If set to "yes", it replaces the old variable INSTALLS_SHLIB.
 # 				  Otherwise, it can be set to a list of directories to be added to
@@ -868,14 +884,14 @@
 # 				  Note: that should only be used on 64-bit architectures.
 #
 # DOCSDIR		- Name of the directory to install the packages docs in.
-#				  Default: ${PREFIX}/share/doc/${PORTNAME}
+#				  Default: ${DESTDIR}${PREFIX}/share/doc/${PORTNAME}
 # EXAMPLESDIR	- Name of the directory to install the packages examples in.
-#				  Default: ${PREFIX}/share/examples/${PORTNAME}
+#				  Default: ${DESTDIR}${PREFIX}/share/examples/${PORTNAME}
 # DATADIR		- Name of the directory to install the packages shared data in.
-#				  Default: ${PREFIX}/share/${PORTNAME}
+#				  Default: ${DESTDIR}${PREFIX}/share/${PORTNAME}
 #
 # DESKTOPDIR	- Name of the directory to install ${DESKTOP_ENTRIES} in.
-#				  Default: ${PREFIX}/share/applications
+#				  Default: ${DESTDIR}${PREFIX}/share/applications
 # DESKTOP_ENTRIES
 #				- List of desktop entry files to generate and install in
 #				  ${DESKTOPDIR}. The format is
@@ -944,9 +960,9 @@
 #				  it attempts to apply them.
 # PKG_DBDIR		- Where package installation is recorded; this directory
 #				  must not contain anything else.
-#				  Default: /var/db/pkg
+#				  Default: ${DESTDIR}/var/db/pkg
 # PORT_DBDIR	- Where port configuration options are recorded.
-#				  Default: /var/db/ports
+#				  Default: ${DESTDIR}/var/db/ports
 # NO_PKG_REGISTER
 #				- Don't register a port installation as a package.
 # FORCE_PKG_REGISTER
@@ -1022,6 +1038,7 @@
 CHGRP?=		/usr/bin/chgrp
 CHMOD?=		/bin/chmod
 CHOWN?=		/usr/sbin/chown
+CHROOT?=	/usr/sbin/chroot
 COMM?=		/usr/bin/comm
 CP?=		/bin/cp
 CPIO?=		/usr/bin/cpio
@@ -1094,6 +1111,30 @@
 # Kludge for pre-3.0 systems
 MACHINE_ARCH?=	i386
 
+# Check the compatibility layer for amd64/ia64
+
+.if ${ARCH} == "amd64" || ${ARCH} =="ia64"
+.if exists(/usr/lib32)
+HAVE_COMPAT_IA32_LIBS?=  YES
+.endif
+.if !defined(HAVE_COMPAT_IA32_KERN)
+HAVE_COMPAT_IA32_KERN!= if ${SYSCTL} -a compat.ia32.maxvmem >/dev/null 2>&1; then echo YES; fi
+.endif
+.endif
+
+.if defined(IA32_BINARY_PORT) && ${ARCH} != "i386"
+.if ${ARCH} == "amd64" || ${ARCH} == "ia64"
+.if !defined(HAVE_COMPAT_IA32_KERN)
+IGNORE= you need a kernel with compiled-in IA32 compatibility to use this port.
+.elif !defined(HAVE_COMPAT_IA32_LIBS)
+IGNORE= you need the 32-bit libraries installed under /usr/lib32 to use this port.
+.endif
+.else
+IGNORE= you have to use i386 (or compatible) platform to use this port.
+.endif
+.endif
+
+
 # Get the operating system type
 .if !defined(OPSYS)
 OPSYS!=	${UNAME} -s
@@ -1106,8 +1147,14 @@
 
 # Get __FreeBSD_version
 .if !defined(OSVERSION)
+.if exists(${DESTDIR}/usr/include/sys/param.h)
+OSVERSION!=	${AWK} '/^\#define __FreeBSD_version/ {print $$3}' < ${DESTDIR}/usr/include/sys/param.h
+.elif exists(${DESTDIR}/usr/src/sys/sys/param.h)
+OSVERSION!=	${AWK} '/^\#define __FreeBSD_version/ {print $$3}' < ${DESTDIR}/usr/src/sys/sys/param.h
+.else
 OSVERSION!=	${SYSCTL} -n kern.osreldate
 .endif
+.endif
 
 # Get the object format.
 .if !defined(PORTOBJFORMAT)
@@ -1177,7 +1224,7 @@
 .endif
 
 # where 'make config' records user configuration options
-PORT_DBDIR?=	/var/db/ports
+PORT_DBDIR?=	${DESTDIR}/var/db/ports
 
 LDCONFIG_DIR=	libdata/ldconfig
 LDCONFIG32_DIR=	libdata/ldconfig32
@@ -1264,9 +1311,15 @@
 # tree we are and thus can't go relative.  They can, of course, be overridden
 # by individual Makefiles or local system make configuration.
 PORTSDIR?=		/usr/ports
-LOCALBASE?=		${DESTDIR}/usr/local
-X11BASE?=		${DESTDIR}/usr/X11R6
-LINUXBASE?=		${DESTDIR}/compat/linux
+LOCALBASE?=		/usr/local
+X11BASE?=		/usr/X11R6
+LINUXBASE?=		/compat/linux
+LOCALBASE_REL:=		${LOCALBASE}
+X11BASE_REL:=		${X11BASE}
+LINUXBASE_REL:=		${LINUXBASE}
+LOCALBASE:=		${DESTDIR}${LOCALBASE_REL}
+X11BASE:=		${DESTDIR}${X11BASE_REL}
+LINUXBASE:=		${DESTDIR}${LINUXBASE_REL}
 DISTDIR?=		${PORTSDIR}/distfiles
 _DISTDIR?=		${DISTDIR}/${DIST_SUBDIR}
 INDEXDIR?=		${PORTSDIR}
@@ -1311,22 +1364,64 @@
 USE_XLIB=		yes
 .endif
 .if defined(USE_X_PREFIX)
-PREFIX?=		${X11BASE}
+PREFIX?=		${X11BASE_REL}
 .elif defined(USE_LINUX_PREFIX)
-PREFIX?=		${LINUXBASE}
+PREFIX?=		${LINUXBASE_REL}
 NO_MTREE=		yes
 .else
-PREFIX?=		${LOCALBASE}
+PREFIX?=		${LOCALBASE_REL}
 .endif
 
 .if defined(USE_LINUX_PREFIX)
-LDCONFIG_CMD?=			${LINUXBASE}/sbin/ldconfig -r ${LINUXBASE}
+.if !defined(DESTDIR)
+LDCONFIG_CMD?=			${LINUXBASE_REL}/sbin/ldconfig -r ${LINUXBASE_REL}
+.else
+LDCONFIG_CMD?=			${CHROOT} ${DESTDIR} ${LINUXBASE_REL}/sbin/ldconfig -r ${LINUXBASE_REL}
+.endif
 LDCONFIG_PLIST_EXEC_CMD?=	${LDCONFIG_CMD}
 LDCONFIG_PLIST_UNEXEC_CMD?=	${LDCONFIG_CMD}
 .else
-LDCONFIG_CMD?=				${LDCONFIG} -m ${LDCONFIG_RUNLIST}
+.if !defined(DESTDIR)
+LDCONFIG_CMD?=			${LDCONFIG} -m ${LDCONFIG_RUNLIST}
 LDCONFIG_PLIST_EXEC_CMD?=	${LDCONFIG} -m ${LDCONFIG_PLIST}
 LDCONFIG_PLIST_UNEXEC_CMD?=	${LDCONFIG} -R
+.else
+LDCONFIG_CMD?=			${CHROOT} ${DESTDIR} ${LDCONFIG} -m ${LDCONFIG_RUNLIST}
+LDCONFIG_PLIST_EXEC_CMD?=	${CHROOT} ${DESTDIR} ${LDCONFIG} -m ${LDCONFIG_PLIST}
+LDCONFIG_PLIST_UNEXEC_CMD?=	${CHROOT} ${DESTDIR} ${LDCONFIG} -R
+.endif
+.endif
+
+# These do some path checks if DESTDIR is set correctly.
+# You can force skipping these test by defining IGNORE_PATH_CHECKS
+.if !defined(IGNORE_PATH_CHECKS)
+.if (${PREFIX:C,(^.).*,\1,} != "/")
+.BEGIN:
+	@${ECHO_MSG} "PREFIX must be defined as an absolute path so that when 'make'"
+	@${ECHO_MSG} "is invoked in the work area PREFIX points to the right place."
+	@${FALSE}
+.endif
+.if defined(DESTDIR)
+.if (${DESTDIR:C,(^.).*,\1,} != "/")
+.if ${DESTDIR} == "/"
+.BEGIN:
+	@${ECHO_MSG} "You can't set DESTDIR to /. Please re-run make with"
+	@${ECHO_MSG} "DESTDIR unset."
+	@${FALSE}
+.else
+.BEGIN:
+	@${ECHO_MSG} "DESTDIR must be defined as an absolute path so that when 'make'"
+	@${ECHO_MSG} "is invoked in the work area DESTDIR points to the right place."
+	@${FALSE}
+.endif
+.endif
+.if (${DESTDIR:C,^.*(/)$$,\1,} == "/")
+.BEGIN:
+	@${ECHO_MSG} "DESTDIR can't have a trailing slash. Please remove the trailing"
+	@${ECHO_MSG} "slash and re-run 'make'"
+	@${FALSE}
+.endif
+.endif
 .endif
 
 PKGCOMPATDIR?=		${LOCALBASE}/lib/compat/pkg
@@ -1381,8 +1476,8 @@
 SITE_PERL?=	${LOCALBASE}/${SITE_PERL_REL}
 
 .if ${PERL_LEVEL} < 500600
-PERL5=		/usr/bin/perl${PERL_VERSION}
-PERL=		/usr/bin/perl
+PERL5=		${DESTDIR}/usr/bin/perl${PERL_VERSION}
+PERL=		${DESTDIR}/usr/bin/perl
 .else
 PERL5=		${LOCALBASE}/bin/perl${PERL_VERSION}
 PERL=		${LOCALBASE}/bin/perl
@@ -1496,8 +1591,8 @@
 BUILD_WRKSRC?=	${WRKSRC}
 INSTALL_WRKSRC?=${WRKSRC}
 
-PLIST_SUB+=	OSREL=${OSREL} PREFIX=%D LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
-SUB_LIST+=	PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}	\
+PLIST_SUB+=	OSREL=${OSREL} PREFIX=%D LOCALBASE=${LOCALBASE_REL} X11BASE=${X11BASE_REL}
+SUB_LIST+=	PREFIX=${PREFIX} LOCALBASE=${LOCALBASE_REL} X11BASE=${X11BASE_REL}	\
 			DATADIR=${DATADIR} DOCSDIR=${DOCSDIR} EXAMPLESDIR=${EXAMPLESDIR}
 
 PLIST_REINPLACE+=	dirrmtry
@@ -1838,10 +1933,10 @@
 PL_BUILD?=		Build
 CONFIGURE_ARGS+= \
 	create_packlist=0 \
-	install_path=lib="${PREFIX}/${SITE_PERL_REL}" \
-	install_path=arch="${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH}" \
-	install_path=script="${PREFIX}/bin" \
-	install_path=bin="${PREFIX}/bin" \
+	install_path=lib="${DESTDIR}${PREFIX}/${SITE_PERL_REL}" \
+	install_path=arch="${DESTDIR}${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH}" \
+	install_path=script="${DESTDIR}${PREFIX}/bin" \
+	install_path=bin="${DESTDIR}${PREFIX}/bin" \
 	install_path=libdoc="${MAN3PREFIX}/man/man3" \
 	install_path=bindoc="${MAN1PREFIX}/man/man1"
 .elif defined(PERL_CONFIGURE)
@@ -1986,7 +2081,7 @@
 NONEXISTENT?=	/nonexistent
 
 # Miscellaneous overridable commands:
-GMAKE?=			gmake
+GMAKE?=			${LOCALBASE}/bin/gmake
 XMKMF?=			xmkmf -a
 .if exists(/sbin/md5)
 MD5?=			/sbin/md5
@@ -1995,8 +2090,8 @@
 .endif
 .if exists(/sbin/sha256)
 SHA256?=		/sbin/sha256
-.elif exists(${LOCALBASE}/sbin/sha256)
-SHA256?=		${LOCALBASE}/sbin/sha256
+.elif exists(${LOCALBASE_REL}/sbin/sha256)
+SHA256?=		${LOCALBASE_REL}/sbin/sha256
 .else
 SHA256?=		NO
 .endif
@@ -2007,7 +2102,7 @@
 
 MAKE_FLAGS?=	-f
 MAKEFILE?=		Makefile
-MAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} MOTIFLIB="${MOTIFLIB}" LIBDIR="${LIBDIR}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" MANPREFIX="${MANPREFIX}"
+MAKE_ENV+=		DESTDIR=${DESTDIR} PREFIX=${PREFIX} LOCALBASE=${LOCALBASE_REL} X11BASE=${X11BASE_REL} MOTIFLIB="${MOTIFLIB}" LIBDIR="${LIBDIR}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" MANPREFIX="${MANPREFIX}"
 
 .if ${OSVERSION} < 500016
 PTHREAD_CFLAGS?=	-D_THREAD_SAFE
@@ -2101,7 +2196,7 @@
 
 # Figure out where the local mtree file is
 .if !defined(MTREE_FILE) && !defined(NO_MTREE)
-.if ${PREFIX} == ${X11BASE} || defined(USE_X_PREFIX)
+.if ${PREFIX} == ${X11BASE_REL} || defined(USE_X_PREFIX)
 # User may have specified non-standard PREFIX for installing a port that
 # uses X
 .if ${X_WINDOW_SYSTEM:L} == xfree86-3
@@ -2177,23 +2272,38 @@
 .if ${OSVERSION} < 491101 && ${PKGORIGIN} != "sysutils/pkg_install"
 EXTRACT_DEPENDS+=	${LOCALBASE}/sbin/pkg_info:${PORTSDIR}/sysutils/pkg_install
 .endif
-PKG_CMD?=		${LOCALBASE}/sbin/pkg_create
-PKG_ADD?=		${LOCALBASE}/sbin/pkg_add
-PKG_DELETE?=	${LOCALBASE}/sbin/pkg_delete
-PKG_INFO?=		${LOCALBASE}/sbin/pkg_info
-PKG_VERSION?=		${LOCALBASE}/sbin/pkg_version
+.if !defined(DESTDIR)
+PKG_CMD?=		${LOCALBASE_REL}/sbin/pkg_create
+PKG_ADD?=		${LOCALBASE_REL}/sbin/pkg_add
+PKG_DELETE?=	${LOCALBASE_REL}/sbin/pkg_delete
+PKG_INFO?=		${LOCALBASE_REL}/sbin/pkg_info
+PKG_VERSION?=		${LOCALBASE_REL}/sbin/pkg_version
+.else
+PKG_CMD?=		${LOCALBASE_REL}/sbin/pkg_create
+PKG_ADD?=		${CHROOT} ${DESTDIR} ${LOCALBASE_REL}/sbin/pkg_add
+PKG_DELETE?=		${CHROOT} ${DESTDIR} ${LOCALBASE_REL}/sbin/pkg_delete
+PKG_INFO?=		${CHROOT} ${DESTDIR} ${LOCALBASE_REL}/sbin/pkg_info
+.endif
 .else
+.if !defined(DESTDIR)
 PKG_CMD?=		/usr/sbin/pkg_create
 PKG_ADD?=		/usr/sbin/pkg_add
 PKG_DELETE?=	/usr/sbin/pkg_delete
 PKG_INFO?=		/usr/sbin/pkg_info
 PKG_VERSION?=		/usr/sbin/pkg_version
+.else
+PKG_CMD?=		/usr/sbin/pkg_create
+PKG_ADD?=		${CHROOT} ${DESTDIR} /usr/sbin/pkg_add
+PKG_DELETE?=		${CHROOT} ${DESTDIR} /usr/sbin/pkg_delete
+PKG_INFO?=		${CHROOT} ${DESTDIR} /usr/sbin/pkg_info
+PKG_VERSION?=		${CHROOT} ${DESTDIR} /usr/sbin/pkg_version
+.endif
 .endif
 
 # Does the pkg_create tool support conflict checking?
 # XXX Slow?
 .if !defined(PKGINSTALLVER)
-PKGINSTALLVER!= ${PKG_INFO} -P 2>/dev/null | ${SED} -e 's/.*: //'
+PKGINSTALLVER!= ${CHROOT} ${DESTDIR} ${PKG_INFO} -P 2>/dev/null | ${SED} -e 's/.*: //'
 .endif
 .if ${PKGINSTALLVER} < 20030417
 DISABLE_CONFLICTS=	YES
@@ -2220,7 +2330,7 @@
 .endif
 .endif
 # where pkg_add records its dirty deeds.
-PKG_DBDIR?=		/var/db/pkg
+PKG_DBDIR?=		${DESTDIR}/var/db/pkg
 
 MOTIFLIB?=	-L${X11BASE}/lib -lXm -lXp
 
@@ -2714,10 +2824,10 @@
 PKGLATESTFILE=		${PKGLATESTREPOSITORY}/${LATEST_LINK}${PKG_SUFX}
 
 .if defined(PERL_CONFIGURE)
-CONFIGURE_ARGS+=	CC="${CC}" CCFLAGS="${CFLAGS}" PREFIX="${PREFIX}" \
-			INSTALLPRIVLIB="${PREFIX}/lib" INSTALLARCHLIB="${PREFIX}/lib"
+CONFIGURE_ARGS+=	CC="${CC}" CCFLAGS="${CFLAGS}" PREFIX="${DESTDIR}${PREFIX}" \
+			INSTALLPRIVLIB="${DESTDIR}${PREFIX}/lib" INSTALLARCHLIB="${DESTDIR}${PREFIX}/lib"
 CONFIGURE_SCRIPT?=	Makefile.PL
-MAN3PREFIX?=		${PREFIX}/lib/perl5/${PERL_VERSION}
+MAN3PREFIX?=		${DESTDIR}${PREFIX}/lib/perl5/${PERL_VERSION}
 .undef HAS_CONFIGURE
 .endif
 
@@ -2743,16 +2853,17 @@
 		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
 		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
 		  PORTSDIR=${PORTSDIR} DEPENDS="${DEPENDS}" \
-		  PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
+		  PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} \
+		  DESTDIR=${DESTDIR}
 
 .if defined(BATCH)
 SCRIPTS_ENV+=	BATCH=yes
 .endif
 
 .if ${PREFIX} == /usr
-MANPREFIX?=	/usr/share
+MANPREFIX?=	${DESTDIR}/usr/share
 .else
-MANPREFIX?=	${PREFIX}
+MANPREFIX?=	${DESTDIR}${PREFIX}
 .endif
 
 .for sect in 1 2 3 4 5 6 7 8 9
@@ -2830,9 +2941,9 @@
 .if defined(_MANPAGES)
 
 .if defined(NOMANCOMPRESS)
-__MANPAGES:=	${_MANPAGES:S%^${PREFIX}/%%}
+__MANPAGES:=	${_MANPAGES:S%^${DESTDIR}${PREFIX}/%%}
 .else
-__MANPAGES:=	${_MANPAGES:S%^${PREFIX}/%%:S%$%.gz%}
+__MANPAGES:=	${_MANPAGES:S%^${DESTDIR}${PREFIX}/%%:S%$%.gz%}
 .endif
 
 .if ${MANCOMPRESSED} == "yes"
@@ -2847,16 +2958,16 @@
 INFO_PATH?=	info
 .endif
 
-DOCSDIR?=	${PREFIX}/share/doc/${PORTNAME}
-EXAMPLESDIR?=	${PREFIX}/share/examples/${PORTNAME}
-DATADIR?=	${PREFIX}/share/${PORTNAME}
-
-PLIST_SUB+=	DOCSDIR="${DOCSDIR:S,^${PREFIX}/,,}" \
-		EXAMPLESDIR="${EXAMPLESDIR:S,^${PREFIX}/,,}" \
-		DATADIR="${DATADIR:S,^${PREFIX}/,,}"
+DOCSDIR?=	${DESTDIR}${PREFIX}/share/doc/${PORTNAME}
+EXAMPLESDIR?=	${DESTDIR}${PREFIX}/share/examples/${PORTNAME}
+DATADIR?=	${DESTDIR}${PREFIX}/share/${PORTNAME}
+
+PLIST_SUB+=	DOCSDIR="${DOCSDIR:S,^${DESTDIR}${PREFIX}/,,}" \
+		EXAMPLESDIR="${EXAMPLESDIR:S,^${DESTDIR}${PREFIX}/,,}" \
+		DATADIR="${DATADIR:S,^${DESTDIR}${PREFIX}/,,}"
 
-DESKTOPDIR?=		${PREFIX}/share/applications
-_DESKTOPDIR_REL=	${DESKTOPDIR:S,^${PREFIX}/,,}/
+DESKTOPDIR?=		${DESTDIR}${PREFIX}/share/applications
+_DESKTOPDIR_REL=	${DESKTOPDIR:S,^${DESTDIR}${PREFIX}/,,}/
 
 .if ${_DESKTOPDIR_REL} == ${DESKTOPDIR}/
 # DESKTOPDIR is not beneath PREFIX
@@ -3016,7 +3127,7 @@
 	@cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
 	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
 	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
+	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} DESTDIR=${DESTDIR} PREFIX=${PREFIX} \
 	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
 	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
 	  CONFLICTS="${CONFLICTS}" \
@@ -3500,7 +3611,11 @@
 	done; \
 	if [ -n "$${conflicts_with}" ]; then \
 		${ECHO_MSG}; \
-		${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
+		if [ -z "${DESTDIR}" ] ; then \
+			${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
+		else \
+			${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s) in ${DESTDIR}: "; \
+		fi; \
 		for entry in $${conflicts_with}; do \
 			${ECHO_MSG} "      $${entry}"; \
 		done; \
@@ -3628,9 +3743,13 @@
 .if !target(check-already-installed)
 check-already-installed:
 .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
+.if !defined(DESTDIR)
 		@${ECHO_MSG} "===>  Checking if ${PKGORIGIN} already installed"
-		@${MKDIR} ${PKG_DBDIR}
-		@already_installed=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
+.else
+		@${ECHO_MSG} "===>  Checking if ${PKGORIGIN} already installed in ${DESTDIR}"
+.endif
+		@${MKDIR} ${PKG_DBDIR}; \
+		already_installed=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
 		if [ -n "$${already_installed}" ]; then \
 				for p in $${already_installed}; do \
 						prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -ne '1s|^@cwd ||p'`; \
@@ -3642,12 +3761,20 @@
 								fi; \
 						fi; \
 				done; \
-		fi; \
-		if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
+		fi
+		@if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
 				if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
+					if [ -z "${DESTDIR}" ] ; then \
 						${ECHO_CMD} "===>   ${PKGNAME} is already installed"; \
+					else \
+						${ECHO_CMD} "===>   ${PKGNAME} is already installed in ${DESTDIR}"; \
+					fi; \
 				else \
+					if [ -z "${DESTDIR}" ] ; then \
 						${ECHO_CMD} "===>   An older version of ${PKGORIGIN} is already installed ($${found_package})"; \
+					else \
+						${ECHO_CMD} "===>   An older version of ${PKGORIGIN} is already installed in ${DESTDIR}  ($${found_package})"; \
+					fi; \
 				fi; \
 				${ECHO_CMD} "      You may wish to \`\`make deinstall'' and install this port again"; \
 				${ECHO_CMD} "      by \`\`make reinstall'' to upgrade it properly."; \
@@ -3672,12 +3799,12 @@
 
 .if !target(install-mtree)
 install-mtree:
-	@${MKDIR} ${PREFIX}
+	@${MKDIR} ${DESTDIR}${PREFIX}
 	@if [ `${ID} -u` != 0 ]; then \
-		if [ -w ${PREFIX}/ ]; then \
+		if [ -w ${DESTDIR}${PREFIX}/ ]; then \
 			${ECHO_MSG} "Warning: not superuser, you may get some errors during installation."; \
 		else \
-			${ECHO_MSG} "Error: ${PREFIX}/ not writable."; \
+			${ECHO_MSG} "Error: ${DESTDIR}${PREFIX}/ not writable."; \
 			${FALSE}; \
 		fi; \
 	fi
@@ -3688,9 +3815,9 @@
 			${ECHO_CMD} "Copy it from a suitable location (e.g., /usr/src/etc/mtree) and try again."; \
 			exit 1; \
 		else \
-			${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/ >/dev/null; \
+			${MTREE_CMD} ${MTREE_ARGS} ${DESTDIR}${PREFIX}/ >/dev/null; \
 			if [ ${MTREE_FILE} = "/etc/mtree/BSD.local.dist" ]; then \
-				cd ${PREFIX}/share/nls; \
+				cd ${DESTDIR}${PREFIX}/share/nls; \
 				${LN} -shf C POSIX; \
 				${LN} -shf C en_US.US-ASCII; \
 			fi; \
@@ -3707,11 +3834,21 @@
 .if defined(USE_LDCONFIG) || defined(USE_LDCONFIG32) || defined(INSTALLS_SHLIB)
 .if defined(USE_LDCONFIG)
 .if !defined(INSTALL_AS_USER)
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -m ${USE_LDCONFIG}
 .else
+	@${ECHO_MSG} "===>   Running ldconfig in ${DESTDIR}"
+	${CHROOT} ${DESTDIR} ${LDCONFIG} -m ${USE_LDCONFIG}
+.endif
+.else
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -m ${USE_LDCONFIG}
+.else
+	@${ECHO_MSG} "===>   Running ldconfig in ${DESTDIR} (errors are ignored)"
+	${CHROOT} ${DESTDIR} -${LDCONFIG} -m ${USE_LDCONFIG}
+.endif
 .endif
 .if ${USE_LDCONFIG:L} != "${PREFIX}/lib"
 	@${ECHO_MSG} "===>   Installing ldconfig configuration file"
@@ -3728,11 +3865,21 @@
 .endif
 .if defined(USE_LDCONFIG32)
 .if !defined(INSTALL_AS_USER)
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -32 -m ${USE_LDCONFIG32}
 .else
+	@${ECHO_MSG} "===>   Running ldconfig in ${DESTDIR}"
+	${CHROOT} ${DESTDIR} ${LDCONFIG} -32 -m ${USE_LDCONFIG32}
+.endif
+.else
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -32 -m ${USE_LDCONFIG32}
+.else
+	@${ECHO_MSG} "===>   Running ldconfig in ${DESTDIR} (errors are ignored)"
+	${CHROOT} ${DESTDIR} -${LDCONFIG} -32 -m ${USE_LDCONFIG32}
+.endif
 .endif
 	@${ECHO_MSG} "===>   Installing 32-bit ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
@@ -3748,10 +3895,18 @@
 # This can be removed once, all ports have been converted to USE_LDCONFIG.
 .if defined(INSTALLS_SHLIB)
 .if !defined(INSTALL_AS_USER)
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>   Running ldconfig"
+.else
+	@${ECHO_MSG} "===>   Running ldconfig in ${DESTDIR}"
+.endif
 	${LDCONFIG_CMD}
 .else
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
+.else
+	@${ECHO_MSG} "===>   Running ldconfig in ${DESTDIR} (errors are ignored)"
+.endif
 	-${LDCONFIG_CMD}
 .endif
 .endif
@@ -3786,7 +3941,7 @@
 	| ${XARGS} -0 -J % ${FIND} % -prune ! -type l -type f -print0 2> /dev/null \
 	| ${XARGS} -0 -n 1 ${OBJDUMP} -R 2> /dev/null > ${WRKDIR}/.PLIST.objdump; \
 	if \
-		! ${AWK} -v audit="$${PORTS_AUDIT}" -f ${PORTSDIR}/Tools/scripts/security-check.awk \
+		! ${AWK} -v audit="$${PORTS_AUDIT}" -v destdir="${DESTDIR}" -f ${PORTSDIR}/Tools/scripts/security-check.awk \
 		  ${WRKDIR}/.PLIST.flattened ${WRKDIR}/.PLIST.objdump ${WRKDIR}/.PLIST.setuid ${WRKDIR}/.PLIST.writable; \
 	then \
 		www_site=$$(cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} www-site); \
@@ -3853,30 +4008,57 @@
 	${GREP} '^etc/rc.d/' ${TMPPLIST} > ${WRKDIR}/.PLIST.startup; \
 	if [ -s ${WRKDIR}/.PLIST.setuid -o -s ${WRKDIR}/.PLIST.network -o -s ${WRKDIR}/.PLIST.writable ]; then \
 		if [ -n "$$PORTS_AUDIT" ]; then \
-			${ECHO_MSG} "===>  SECURITY REPORT (PARANOID MODE): "; \
+			if [ -z "${DESTDIR}" ] ; then \
+				${ECHO_MSG} "===>  SECURITY REPORT (PARANOID MODE): "; \
+			else \
+				${ECHO_MSG} "===>  SECURITY REPORT FOR ${DESTDIR} (PARANOID MODE): "; \
+			fi; \
 		else \
-			${ECHO_MSG} "===>  SECURITY REPORT: "; \
+			if [ -z "${DESTDIR}" ] ; then \
+				${ECHO_MSG} "===>  SECURITY REPORT: "; \
+			else \
+				${ECHO_MSG} "===>  SECURITY REPORT FOR ${DESTDIR}: "; \
+			fi; \
 		fi; \
 		if [ -s ${WRKDIR}/.PLIST.setuid ] ; then \
-			${ECHO_MSG} "      This port has installed the following binaries which execute with"; \
-			${ECHO_MSG} "      increased privileges."; \
+			if [ -z "${DESTDIR}" ] ; then \
+				${ECHO_MSG} "      This port has installed the following binaries,"; \
+			else \
+				${ECHO_MSG} "      This port has installed the following binaries into ${DESTDIR},"; \
+			fi; \
+			${ECHO_MSG} "      which execute with increased privileges."; \
 			${CAT} ${WRKDIR}/.PLIST.setuid; \
 			${ECHO_MSG}; \
 		fi; \
 		if [ -s ${WRKDIR}/.PLIST.network ] ; then \
-			${ECHO_MSG} "      This port has installed the following files which may act as network"; \
-			${ECHO_MSG} "      servers and may therefore pose a remote security risk to the system."; \
+			if [ -z "${DESTDIR}" ] ; then \
+				${ECHO_MSG} "      This port has installed the following files, which may act as network"; \
+				${ECHO_MSG} "      servers and may therefore pose a remote security risk to the system."; \
+			else \
+				${ECHO_MSG} "      This port has installed the following files into ${DESTDIR}, which may"; \
+				${ECHO_MSG} "      act as network servers and may therefore pose a remote security risk to"; \
+				${ECHO_MSG} "      the system."; \
+			fi; \
 			${CAT} ${WRKDIR}/.PLIST.network; \
 			${ECHO_MSG}; \
 			if [ -s ${WRKDIR}/.PLIST.startup ] ; then \
-				${ECHO_MSG} "      This port has installed the following startup scripts which may cause"; \
-				${ECHO_MSG} "      these network services to be started at boot time."; \
+				if [ -z "${DESTDIR}" ] ; then \
+					${ECHO_MSG} "      This port has installed the following startup scripts,"; \
+				else \
+					${ECHO_MSG} "      This port has installed the following startup scripts into ${DESTDIR},"; \
+				fi; \
+				${ECHO_MSG} "      which may cause these network services to be started at boot time."; \
 				${SED} s,^,${PREFIX}/, < ${WRKDIR}/.PLIST.startup; \
 				${ECHO_MSG}; \
 			fi; \
 		fi; \
 		if [ -s ${WRKDIR}/.PLIST.writable ] ; then \
-			${ECHO_MSG} "      This port has installed the following world-writable files/directories."; \
+			if [ -z "${DESTDIR}" ] ; then \
+				${ECHO_MSG} "      This port has installed the following world-writable files/directories."; \
+			else \
+				${ECHO_MSG} "      This port has installed the following world-writable files/directories"; \
+				${ECHO_MSG} "      into ${DESTDIR}."; \
+			fi; \
 			${CAT} ${WRKDIR}/.PLIST.writable; \
 			${ECHO_MSG}; \
 		fi; \
@@ -4018,7 +4200,11 @@
 build-message:
 	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
 install-message:
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
+.else
+	@${ECHO_MSG} "===>  Installing for ${PKGNAME} into ${DESTDIR}"
+.endif
 package-message:
 	@${ECHO_MSG} "===>  Building package for ${PKGNAME}"
 
@@ -4100,14 +4286,22 @@
 		${SU_CMD} "${MAKE} ${__softMAKEFLAGS} ${.TARGET}"
 	@${ECHO_MSG} "===>  Returning to user credentials"
 .else
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>  Deinstalling for ${PKGORIGIN}"
+.else
+	@${ECHO_MSG} "===>  Deinstalling for ${PKGORIGIN} from ${DESTDIR}"
+.endif
 	@found_names=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
 	for p in $${found_names}; do \
 			check_name=`${ECHO_CMD} $${p} | ${SED} -e 's/-[^-]*$$//'`; \
 			if [ "$${check_name}" = "${PKGBASE}" ]; then \
 					prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -ne '1s|^@cwd ||p'`; \
 					if [ "x${PREFIX}" = "x$${prfx}" ]; then \
-							${ECHO_MSG} "===>   Deinstalling $${p}"; \
+							if [ -z "${DESTDIR}" ] ; then \
+									${ECHO_MSG} "===>   Deinstalling $${p}"; \
+							else \
+									${ECHO_MSG} "===>   Deinstalling $${p} from ${DESTDIR}"; \
+							fi; \
 							${PKG_DELETE} -f $${p}; \
 					else \
 							${ECHO_MSG} "===>   $${p} has a different PREFIX: $${prfx}, skipping"; \
@@ -4115,7 +4309,11 @@
 			fi; \
 	done; \
 	if [ -z "$${found_names}" ]; then \
-			${ECHO_MSG} "===>   ${PKGBASE} not installed, skipping"; \
+			if [ -z "${DESTDIR}" ] ; then \
+					${ECHO_MSG} "===>   ${PKGBASE} not installed, skipping"; \
+			else \
+					${ECHO_MSG} "===>   ${PKGBASE} not installed in ${DESTDIR}, skipping"; \
+			fi; \
 	fi
 	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 .endif
@@ -4133,17 +4331,29 @@
 		${SU_CMD} "${MAKE} ${__softMAKEFLAGS} ${.TARGET}"
 	@${ECHO_MSG} "===>  Returning to user credentials"
 .else
+.if !defined(DESTDIR)
 	@${ECHO_MSG} "===>  Deinstalling for ${PKGORIGIN}"
+.else
+	@${ECHO_MSG} "===>  Deinstalling for ${PKGORIGIN} from ${DESTDIR}"
+.endif
 	@deinstall_names=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
 	if [ -n "$${deinstall_names}" ]; then \
 		for d in $${deinstall_names}; do \
-			${ECHO_MSG} "===>   Deinstalling $${d}"; \
+			if [ -z "${DESTDIR}" ] ; then \
+				${ECHO_MSG} "===>   Deinstalling $${d}"; \
+			else \
+				${ECHO_MSG} "===>   Deinstalling $${d} from ${DESTDIR}"; \
+			fi; \
 			${PKG_DELETE} -f $${d}; \
 		done; \
 	else \
-		${ECHO_MSG} "===>   ${PKGORIGIN} not installed, skipping"; \
-	fi
-	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+		if [ -z "${DESTDIR}" ] ; then \
+			${ECHO_MSG} "===>   ${PKGORIGIN} not installed, skipping"; \
+		else \
+			${ECHO_MSG} "===>   ${PKGORIGIN} not installed in ${DESTDIR}, skipping"; \
+		fi; \
+	fi; \
+	${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 .endif
 .endif
 
@@ -4534,16 +4744,24 @@
 		if [ X${USE_PACKAGE_DEPENDS} != "X" ]; then \
 			subpkgfile=`(cd $$dir; ${MAKE} $$depends_args -V PKGFILE)`; \
 			if [ -r "$${subpkgfile}" -a "$$target" = "${DEPENDS_TARGET}" ]; then \
-				${ECHO_MSG} "===>   Installing existing package $${subpkgfile}"; \
-				${PKG_ADD} $${subpkgfile}; \
+				if [ -z "${DESTDIR}" ] ; then \
+					${ECHO_MSG} "===>   Installing existing package $${subpkgfile}"; \
+					${PKG_ADD} $${subpkgfile}; \
+				else \
+					${ECHO_MSG} "===>   Installing existing package $${subpkgfile} into ${DESTDIR}"; \
+					${PKG_ADD} -C ${DESTDIR} $${subpkgfile}; \
+				fi; \
 			else \
 			  (cd $$dir; ${MAKE} -DINSTALLS_DEPENDS $$target $$depends_args) ; \
 			fi; \
 		else \
 			(cd $$dir; ${MAKE} -DINSTALLS_DEPENDS $$target $$depends_args) ; \
-		fi ; \
-		${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
-
+		fi; \
+		if [ -z "${DESTDIR}" ] ; then \
+			${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
+		else \
+			${ECHO_MSG} "===>   Returning to build of ${PKGNAME} for ${DESTDIR}"; \
+		fi;
 
 .for deptype in EXTRACT PATCH FETCH BUILD RUN
 ${deptype:L}-depends:
@@ -4565,7 +4783,11 @@
 					${ECHO_MSG} "Error: ${NONEXISTENT} exists.  Please remove it, and restart the build."; \
 					${FALSE}; \
 				else \
-					${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - found"; \
+					if [ -z "${DESTDIR}" ] ; then \
+						${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - found"; \
+					else \
+						${ECHO_MSG} "===>   ${PKGNAME} depends on file in ${DESTDIR}: $$prog - found"; \
+					fi; \
 					if [ ${_DEPEND_ALWAYS} = 1 ]; then \
 						${ECHO_MSG} "       (but building it anyway)"; \
 						notfound=1; \
@@ -4574,7 +4796,11 @@
 					fi; \
 				fi; \
 			else \
-				${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - not found"; \
+				if [ -z "${DESTDIR}" ] ; then \
+					${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - not found"; \
+				else \
+					${ECHO_MSG} "===>   ${PKGNAME} depends on file in ${DESTDIR}: $$prog - not found"; \
+				fi; \
 				notfound=1; \
 			fi; \
 		else \
@@ -4584,7 +4810,11 @@
 			esac; \
 			if [ "$$pkg" != "" ]; then \
 				if ${PKG_INFO} "$$prog" > /dev/null 2>&1 ; then \
-					${ECHO_MSG} "===>   ${PKGNAME} depends on package: $$prog - found"; \
+					if [ -z "${DESTDIR}" ] ; then \
+						${ECHO_MSG} "===>   ${PKGNAME} depends on package: $$prog - found"; \
+					else \
+						${ECHO_MSG} "===>   ${PKGNAME} depends on package in ${DESTDIR}: $$prog - found"; \
+					fi; \
 					if [ ${_DEPEND_ALWAYS} = 1 ]; then \
 						${ECHO_MSG} "       (but building it anyway)"; \
 						notfound=1; \
@@ -4592,7 +4822,11 @@
 						notfound=0; \
 					fi; \
 				else \
-					${ECHO_MSG} "===>   ${PKGNAME} depends on package: $$prog - not found"; \
+					if [ -z "${DESTDIR}" ] ; then \
+						${ECHO_MSG} "===>   ${PKGNAME} depends on package: $$prog - not found"; \
+					else \
+						${ECHO_MSG} "===>   ${PKGNAME} depends on package in ${DESTDIR}: $$prog - not found"; \
+					fi; \
 					notfound=1; \
 				fi; \
 				if [ $$notfound != 0 ]; then \
@@ -4606,7 +4840,11 @@
 					fi; \
 				fi; \
 			elif ${WHICH} "$$prog" > /dev/null 2>&1 ; then \
-				${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - found"; \
+				if [ -z "${PREFIX}" ] ; then \
+					${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - found"; \
+				else \
+					${ECHO_MSG} "===>   ${PKGNAME} depends on executable in ${DESTDIR}: $$prog - found"; \
+				fi; \
 				if [ ${_DEPEND_ALWAYS} = 1 ]; then \
 					${ECHO_MSG} "       (but building it anyway)"; \
 					notfound=1; \
@@ -4614,7 +4852,11 @@
 					notfound=0; \
 				fi; \
 			else \
-				${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - not found"; \
+				if [ -z "${DESTDIR}" ] ; then \
+					${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - not found"; \
+				else \
+					${ECHO_MSG} "===>   ${PKGNAME} depends on executable in ${DESTDIR}: $$prog - not found"; \
+				fi; \
 				notfound=1; \
 			fi; \
 		fi; \
@@ -4650,18 +4892,34 @@
 		else \
 			dir=$${dir%%:*}; \
 		fi; \
-		${ECHO_MSG} -n "===>   ${PKGNAME} depends on shared library: $$lib"; \
-		if ${LDCONFIG} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \
-			${ECHO_MSG} " - found"; \
-			if [ ${_DEPEND_ALWAYS} = 1 ]; then \
-				${ECHO_MSG} "       (but building it anyway)"; \
-				notfound=1; \
+		if [ -z "${DESTDIR}" ] ; then \
+			${ECHO_MSG} -n "===>   ${PKGNAME} depends on shared library: $$lib"; \
+			if ${LDCONFIG} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \
+				${ECHO_MSG} " - found"; \
+				if [ ${_DEPEND_ALWAYS} = 1 ]; then \
+					${ECHO_MSG} "       (but building it anyway)"; \
+					notfound=1; \
+				else \
+					notfound=0; \
+				fi; \
 			else \
-				notfound=0; \
+				${ECHO_MSG} " - not found"; \
+				notfound=1; \
 			fi; \
 		else \
-			${ECHO_MSG} " - not found"; \
-			notfound=1; \
+			${ECHO_MSG} -n "===>   ${PKGNAME} depends on shared library in ${DESTDIR}: $$lib"; \
+			if ${CHROOT} ${DESTDIR} ${LDCONFIG} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \
+				${ECHO_MSG} " - found"; \
+				if [ ${_DEPEND_ALWAYS} = 1 ]; then \
+					${ECHO_MSG} "       (but building it anyway)"; \
+					notfound=1; \
+				else \
+					notfound=0; \
+				fi; \
+			else \
+				${ECHO_MSG} " - not found"; \
+				notfound=1; \
+			fi; \
 		fi; \
 		if [ $$notfound != 0 ]; then \
 			${ECHO_MSG} "===>    Verifying $$target for $$lib in $$dir"; \
@@ -4697,7 +4955,11 @@
 			(cd $$dir; ${MAKE} $$target $$depends_args) ; \
 		fi \
 	done
-	@${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"
+	@if [ -z "${DESTDIR}" ] ; then \
+		${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
+	else \
+		${ECHO_MSG} "===>   Returning to build of ${PKGNAME} for ${DESTDIR}"; \
+	fi
 .endif
 .else
 	@${DO_NADA}
@@ -5196,14 +5458,14 @@
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
 		if [ ! -e ${DOCSDIR}/${x} ]; then \
 		${ECHO_CMD} ${DOCSDIR}/${x} | \
-			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
+			${SED} -e 's,^${DESTDIR}${PREFIX}/,,' >> ${TMPPLIST}; \
 	fi;fi
 .endfor
 	@${FIND} -P ${PORTDOCS:S/^/${DOCSDIR}\//} ! -type d 2>/dev/null | \
-		${SED} -ne 's,^${PREFIX}/,,p' >> ${TMPPLIST}
+		${SED} -ne 's,^${DESTDIR}${PREFIX}/,,p' >> ${TMPPLIST}
 	@${FIND} -P -d ${PORTDOCS:S/^/${DOCSDIR}\//} -type d 2>/dev/null | \
-		${SED} -ne 's,^${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
-	@${ECHO_CMD} "@dirrm ${DOCSDIR:S,^${PREFIX}/,,}" >> ${TMPPLIST}
+		${SED} -ne 's,^${DESTDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${DOCSDIR:S,^${DESTDIR}${PREFIX}/,,}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5214,10 +5476,10 @@
 # Process GNU INFO files at package install/deinstall time
 .if defined(INFO)
 .for i in ${INFO}
-	install-info --quiet ${PREFIX}/${INFO_PATH}/$i.info ${PREFIX}/${INFO_PATH}/dir
+	install-info --quiet ${DESTDIR}${PREFIX}/${INFO_PATH}/$i.info ${DESTDIR}${PREFIX}/${INFO_PATH}/dir
 	@${ECHO_CMD} "@unexec install-info --quiet --delete %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
 		>> ${TMPPLIST}
-	@${LS} ${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${PREFIX}/::g >> ${TMPPLIST}
+	@${LS} ${DESTDIR}${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${DESTDIR}${PREFIX}/::g >> ${TMPPLIST}
 	@${ECHO_CMD} "@exec install-info --quiet %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
 		>> ${TMPPLIST}
 	@if [ "`${DIRNAME} $i`" != "." ]; then \
@@ -5226,7 +5488,7 @@
 .endfor
 .if (${PREFIX} != "/usr")
 	@${ECHO_CMD} "@unexec if [ -f %D/${INFO_PATH}/dir ]; then if sed -e '1,/Menu:/d' %D/${INFO_PATH}/dir | grep -q '^[*] '; then true; else rm %D/${INFO_PATH}/dir; fi; fi" >> ${TMPPLIST}
-.if (${PREFIX} != ${LOCALBASE} && ${PREFIX} != ${X11BASE} && ${PREFIX} != ${LINUXBASE})
+.if (${PREFIX} != ${LOCALBASE_REL} && ${PREFIX} != ${X11BASE_REL} && ${PREFIX} != ${LINUXBASE_REL})
 	@${ECHO_CMD} "@unexec rmdir %D/info 2> /dev/null || true" >> ${TMPPLIST}
 .endif
 .endif
@@ -5237,7 +5499,7 @@
 # deinstall-time
 .if !target(add-plist-post)
 add-plist-post:
-.if (${PREFIX} != ${LOCALBASE} && ${PREFIX} != ${X11BASE} && ${PREFIX} != ${LINUXBASE} && ${PREFIX} != "/usr")
+.if (${PREFIX} != ${LOCALBASE_REL} && ${PREFIX} != ${X11BASE_REL} && ${PREFIX} != ${LINUXBASE_REL} && ${PREFIX} != "/usr")
 	@${ECHO_CMD} "@unexec rmdir %D 2> /dev/null || true" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
@@ -5261,12 +5523,12 @@
 	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
 .if (${OSVERSION} >= 700007 || ( ${OSVERSION} < 700000 && ${OSVERSION} >= 600101 ))
 	@for i in ${USE_RC_SUBR}; do \
-		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d/$${i%.sh}; \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${DESTDIR}${PREFIX}/etc/rc.d/$${i%.sh}; \
 		${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
 	done
 .else
 	@for i in ${USE_RC_SUBR}; do \
-		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d/$${i%.sh}.sh; \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${DESTDIR}${PREFIX}/etc/rc.d/$${i%.sh}.sh; \
 		${ECHO_CMD} "etc/rc.d/$${i%.sh}.sh" >> ${TMPPLIST}; \
 	done
 .endif
@@ -5320,9 +5582,13 @@
 	fi
 	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
 .endif
-	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
-		${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"; \
-		${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
+.if !exists(${PKG_DBDIR}/${PKGNAME})
+.if !defined(DESTDIR)
+		@${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"
+.else
+		@${ECHO_MSG} "===>   Registering installation for ${PKGNAME} in ${DESTDIR}"
+.endif
+		@${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
 		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
 		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \
 		${ECHO_CMD} ${COMMENT:Q} > ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
@@ -5345,8 +5611,8 @@
 					${ECHO_CMD} ${PKGNAME} >> ${PKG_DBDIR}/$$dep/+REQUIRED_BY; \
 				fi; \
 			fi; \
-		done; \
-	fi
+		done
+.endif
 .if !defined(NO_MTREE)
 	@if [ -f ${MTREE_FILE} ]; then \
 		${CP} ${MTREE_FILE} ${PKG_DBDIR}/${PKGNAME}/+MTREE_DIRS; \
diff -Nur /usr/ports/Mk/bsd.port.subdir.mk ../Mk/bsd.port.subdir.mk
--- /usr/ports/Mk/bsd.port.subdir.mk	Sat Jan 28 03:11:05 2006
+++ ../Mk/bsd.port.subdir.mk	Sat Jul 15 22:39:39 2006
@@ -48,10 +48,10 @@
 
 .if !defined(NOPRECIOUSMAKEVARS)
 .if !defined(ARCH)
-ARCH!=	/usr/bin/uname -p
+ARCH!=	${DESTDIR}/usr/bin/uname -p
 .endif
 .if !defined(OSREL)
-OSREL!=	/usr/bin/uname -r | sed -e 's/[-(].*//'
+OSREL!=	${DESTDIR}/usr/bin/uname -r | sed -e 's/[-(].*//'
 .endif
 .if !defined(OSVERSION)
 .if exists(/sbin/sysctl)
@@ -61,23 +61,23 @@
 .endif
 .endif
 .if !defined(PORTOBJFORMAT)
-PORTOBJFORMAT!= test -x /usr/bin/objformat && /usr/bin/objformat || echo aout
+PORTOBJFORMAT!= test -x ${DESTDIR}/usr/bin/objformat && ${DESTDIR}/usr/bin/objformat || echo aout
 .endif
 .endif
 
-ID?=	/usr/bin/id
+ID?=	${DESTDIR}/usr/bin/id
 UID!=	${ID} -u
-LOCALBASE?=	${DESTDIR}/usr/local
+LOCALBASE?=	${DESTDIR}${LOCALBASE_REL}
 .if exists(${LOCALBASE}/sbin/pkg_info)
 PKG_INFO?=	${LOCALBASE}/sbin/pkg_info
 .else
-PKG_INFO?=	/usr/sbin/pkg_info
+PKG_INFO?=	${DESTDIR}/usr/sbin/pkg_info
 .endif
-SED?=		/usr/bin/sed
+SED?=		${DESTDIR}/usr/bin/sed
 PKGINSTALLVER!=	${PKG_INFO} -P 2>/dev/null | ${SED} -e 's/.*: //'
 
 .if !defined(OPSYS)
-OPSYS!=	/usr/bin/uname -s
+OPSYS!=	${DESTDIR}/usr/bin/uname -s
 .endif
 
 ECHO_MSG?=	echo
diff -Nur /usr/ports/Mk/bsd.python.mk ../Mk/bsd.python.mk
--- /usr/ports/Mk/bsd.python.mk	Fri Jun 23 05:35:14 2006
+++ ../Mk/bsd.python.mk	Sat Jul 15 22:39:39 2006
@@ -404,7 +404,7 @@
 	@${ECHO} "Legal values are:	2.7 (default), 2.8, 2.9, 3.2"
 	@${FALSE}
 .endif
-ZOPEBASEDIR?=			${PREFIX}/${SZOPEBASEDIR}
+ZOPEBASEDIR?=			${DESTDIR}${PREFIX}/${SZOPEBASEDIR}
 ZOPEPRODUCTDIR?=		Products
 .endif
 
diff -Nur /usr/ports/Mk/bsd.ruby.mk ../Mk/bsd.ruby.mk
--- /usr/ports/Mk/bsd.ruby.mk	Wed Jul  5 04:18:09 2006
+++ ../Mk/bsd.ruby.mk	Sat Jul 15 22:39:39 2006
@@ -113,7 +113,7 @@
 RUBY_VER?=		${RUBY_DEFAULT_VER}
 
 .if defined(RUBY)
-.if !exists(${RUBY})
+.if !exists(${DESTDIR}${RUBY})
 IGNORE=	cannot install: you set the variable RUBY to "${RUBY}", but it does not seem to exist.  Please specify an already installed ruby executable.
 .endif
 
@@ -122,7 +122,7 @@
 IGNORE=	cannot install: you set the variable RUBY to "${RUBY}", but it failed to include rbconfig.  Please specify a properly installed ruby executable.
 .endif
 
-_RUBY_CONFIG=		${RUBY} -r rbconfig -e 'C = Config::CONFIG' -e
+_RUBY_CONFIG=		${DESTDIR}${RUBY} -r rbconfig -e 'C = Config::CONFIG' -e
 
 RUBY_VERSION!=		${_RUBY_CONFIG} 'puts VERSION'
 RUBY_SUFFIX?=		# empty
diff -Nur /usr/ports/Mk/bsd.scons.mk ../Mk/bsd.scons.mk
--- /usr/ports/Mk/bsd.scons.mk	Fri Jul 14 00:10:39 2006
+++ ../Mk/bsd.scons.mk	Tue Jul 18 17:41:15 2006
@@ -57,7 +57,7 @@
 SCONS_ENV?=	CCFLAGS="${CCFLAGS}" CXXFLAGS="${CXXFLAGS}" \
 		LINKFLAGS="${LINKFLAGS}" PKGCONFIGDIR="${PKGCONFIGDIR}"  \
 		CPPPATH="${CPPPATH}" LIBPATH="${LIBPATH}" PREFIX="${PREFIX}" \
-		CC="${CC}" CXX="${CXX}"
+		DESTDIR="${DESTDIR}" CC="${CC}" CXX="${CXX}"
 SCONS_ARGS?=
 SCONS_BUILDENV?=
 SCONS_TARGET?=
--- destdir_mk.diff ends here ---

--- destdir_tools.diff begins here ---
diff -Nur /usr/ports/Tools/scripts/security-check.awk ../Tools/scripts/security-check.awk
--- /usr/ports/Tools/scripts/security-check.awk	Mon Jan 19 23:19:00 2004
+++ ../Tools/scripts/security-check.awk	Wed Jul 19 15:10:04 2006
@@ -34,10 +34,18 @@
 function print_header() {
 	if (header_printed)
 		return;
-	if (audit != "")
-		print "===> SECURITY REPORT (PARANOID MODE): ";
-	else
-		print "===> SECURITY REPORT: ";
+	if (audit != "") {
+		if (destdir == "")
+			print "===> SECURITY REPORT (PARANOID MODE): ";
+		else
+			print "===> SECURITY REPORT FOR", destdir, "(PARANOID MODE): ";
+		}
+	else {
+		if (destdir == "")
+			print "===> SECURITY REPORT: ";
+		else
+			print "===> SECURITY REPORT FOR", destdir, ": ";
+		}
 	header_printed = 1;
 }
 function note_for_the_stupid(file) { return (file in stupid_binaries) ? (" (USES POSSIBLY INSECURE FUNCTIONS:" stupid_binaries[file] ")") : ""; }
@@ -46,8 +54,14 @@
 	for (file in setuid_binaries) {
 		if (!note_printed) {
 			print_header();
-			print "      This port has installed the following binaries which execute with";
-			print "      increased privileges.";
+			if (destdir == "") {
+				print "      This port has installed the following binaries, which execute with";
+				print "      increased privileges.";
+				}
+			else {
+				print "      This port has installed the following binaries into", destdir, ", which";
+				print "      execute with increased privileges.";
+				}
 			note_printed = 1;
 		}
 		print file note_for_the_stupid(file);
@@ -58,8 +72,15 @@
 	for (file in network_binaries) {
 		if (!note_printed) {
 			print_header();
-			print "      This port has installed the following files which may act as network";
-			print "      servers and may therefore pose a remote security risk to the system.";
+			if (destdir == "") {
+				print "      This port has installed the following files, which may act as network";
+				print "      servers and may therefore pose a remote security risk to the system.";
+				}
+			else {
+				print "      This port has installed the following files into", destdir, ", which may";
+				print "      act as network servers and may therefore pose a remote security risk to";
+				print "      the system.";
+				}
 			note_printed = 1;
 		}
 		print file note_for_the_stupid(file);
@@ -70,8 +91,14 @@
 		for (file in startup_scripts) {
 			if (!note_printed) {
 				print_header();
-				print "      This port has installed the following startup scripts which may cause";
+			if (destdir == "") {
+				print "      This port has installed the following startup scripts, which may cause";
 				print "      these network services to be started at boot time.";
+				}
+			else {
+				print "      This port has installed the following startup scripts into", destdir, ", which";
+				print "      may cause these network services to be started at boot time.";
+				}
 				note_printed = 1;
 			}
 			print file;
@@ -83,7 +110,10 @@
 	for (file in writable_files) {
 		if (!note_printed) {
 			print_header();
-			print "      This port has installed the following world-writable files/directories.";
+			if (destdir == "")
+				print "      This port has installed the following world-writable files/directories.";
+			else
+				print "      This port has installed the following world-writable files/directories into", destdir, ".";
 			note_printed = 1;
 		}
 		print file;
--- destdir_tools.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060719161236.9FD18289D74>