--- GNUmakefile.in.orig	2006-12-28 12:34:14.000000000 -0600
+++ GNUmakefile.in	2006-12-28 13:15:27.000000000 -0600
@@ -67,6 +67,8 @@
 LOGS_DEST    = $(VAR_DEST)/log/privoxy
 PIDS_DEST    = $(VAR_DEST)/run
 
+DESTDIR=
+
 # if $prefix = /usr/local then the default CONFDEST change from 
 # CONF_DEST = $(CONF_BASE) to CONF_DEST = $(CONF_BASE)/privoxy  
 # by the target rule CONF_DEST
@@ -246,7 +248,7 @@
 CFLAGS = @CFLAGS@ @CPPFLAGS@ $(OTHER_CFLAGS) $(SPECIAL_CFLAGS) -Wall \
          @STATIC_PCRE_ONLY@ -Ipcre 
 
-LDFLAGS = $(DEBUG_CFLAGS) $(SPECIAL_CFLAGS)
+LDFLAGS = @LDFLAGS@ $(DEBUG_CFLAGS) $(SPECIAL_CFLAGS)
 
 
 #############################################################################
@@ -1086,23 +1088,23 @@
 
 	@$(ECHO) "Creating directories, and preparing $(PROGRAM_V) installation"
 	$(CHMOD) $(DIR_MODE) $(MKDIR)
-	@$(MKDIR) $(SBIN_DEST) $(prefix) $(CONF_DEST) $(CONF_DEST)/templates $(SHARE_DEST) \
-		$(LOG_DEST) $(PID_DEST)
+	@$(MKDIR) $(DESTDIR)$(SBIN_DEST) $(DESTDIR)$(prefix) $(DESTDIR)$(CONF_DEST) $(DESTDIR)$(CONF_DEST)/templates $(DESTDIR)$(SHARE_DEST) \
+		$(DESTDIR)$(LOG_DEST) $(DESTDIR)$(PID_DEST)
 	@# Install the executable binary, strip if invoked as install-strip
 	@test -n "$(STRIP)" &&\
-	$(ECHO) Installing $(PROGRAM) stripped executable to $(SBIN_DEST) ||\
-	$(ECHO) Installing $(PROGRAM) executable to $(SBIN_DEST)
-	$(INSTALL) $(INSTALL_P) $(STRIP) $(PROGRAM) $(SBIN_DEST)
+	$(ECHO) Installing $(PROGRAM) stripped executable to $(DESTDIR)$(SBIN_DEST) ||\
+	$(ECHO) Installing $(PROGRAM) executable to $(DESTDIR)$(SBIN_DEST)
+	$(INSTALL) $(INSTALL_P) $(STRIP) $(PROGRAM) $(DESTDIR)$(SBIN_DEST)
      
 	@# Install the DOCS and man page. install-sh only does one file at a time.
 	@# FIXME: only handles jpegs.
 	-@if [ $(check_doc) = 0 ]; then \
-		DOC=$(DOC_DEST) ;\
+		DOC=$(DESTDIR)$(DOC_DEST) ;\
 	else \
-		DOC=$(prefix)/doc/privoxy ;\
+		DOC=$(DESTDIR)$(prefix)/doc/privoxy ;\
 	fi;\
 	$(MKDIR) $$DOC $$DOC/user-manual $$DOC/faq $$DOC/developer-manual \
-	     $$DOC/man-page $$DOC/images $(MAN_DEST) ;\
+	     $$DOC/man-page $$DOC/images $(DESTDIR)$(MAN_DEST) ;\
 	if [ -d "$(DOK_WEB)" ]; then \
 		$(ECHO) Installing FAQ, Manual, and other docs to $$DOC;\
           for i in user-manual developer-manual faq; do \
@@ -1123,8 +1125,8 @@
 		$(INSTALL) $(INSTALL_T) $(DOK_WEB)/p_doc.css $$DOC/user-manual;\
 	fi
 	@# Not all platforms support gzipped man pages.
-	@$(ECHO) Installing man page to $(MAN_DEST)/privoxy.1
-	-$(INSTALL) $(INSTALL_T) privoxy.1  $(MAN_DEST)/privoxy.1
+	@$(ECHO) Installing man page to $(DESTDIR)$(MAN_DEST)/privoxy.1
+	-$(INSTALL) $(INSTALL_T) privoxy.1  $(DESTDIR)$(MAN_DEST)/privoxy.1
 
 	@# Change the config file default directories according to the configured ones
 	@$(ECHO) Rewriting config for this installation
@@ -1145,9 +1147,9 @@
 	@# Install the config support files. Test for root install, and abort 
 	@# if there is no privoxy user, and no other user was enabled during 
 	@# configure. Later, install init script if appropriate.
-	@$(ECHO) Installing templates to $(CONF_DEST)/templates
+	@$(ECHO) Installing templates to $(DESTDIR)$(CONF_DEST)/templates
 	@for i in `find templates -type f`; do \
-		$(INSTALL) $(INSTALL_T) $$i $(CONF_DEST)/templates ;\
+		$(INSTALL) $(INSTALL_T) $$i $(DESTDIR)$(CONF_DEST)/templates ;\
 	done
 
 	@# FIXME: group/user validation is overly convoluted.
@@ -1185,36 +1187,36 @@
 		fi ;\
 		INSTALL_CONF="$(INSTALL_R)" ;\
 	fi ;\
-	$(ECHO) Installing configuration files to $(CONF_DEST);\
+	$(ECHO) Installing configuration files to $(DESTDIR)$(CONF_DEST);\
 	for i in $(CONFIGS); do \
 		if [ "$$i" = "default.action" ] || [ "$$i" = "default.filter" ] || [ "$$i" = "standard.action" ]; then \
-			$(RM) $(CONF_DEST)/$$i ;\
+			$(RM) $(DESTDIR)$(CONF_DEST)/$$i ;\
 			$(ECHO) Installing fresh $$i;\
-			$(INSTALL) $$INSTALL_CONF $$i $(CONF_DEST) || exit 1;\
-		elif [ -s "$(CONF_DEST)/$$i" ]; then \
+			$(INSTALL) $$INSTALL_CONF $$i $(DESTDIR)$(CONF_DEST) || exit 1;\
+		elif [ -s "$(DESTDIR)$(CONF_DEST)/$$i" ]; then \
 			$(ECHO) Installing $$i as $$i.new ;\
-			$(INSTALL) $$INSTALL_CONF $$i $(CONF_DEST)/$$i.new || exit 1;\
+			$(INSTALL) $$INSTALL_CONF $$i $(DESTDIR)$(CONF_DEST)/$$i.new || exit 1;\
 			NEW=1;\
 		else \
-			$(INSTALL) $$INSTALL_CONF $$i $(CONF_DEST) || exit 1;\
+			$(INSTALL) $$INSTALL_CONF $$i $(DESTDIR)$(CONF_DEST) || exit 1;\
 		fi ;\
 	done ;\
 	if [ -n "$$NEW" ]; then \
-		$(CHMOD) $(RWD_MODE) $(CONF_DEST)/*.new || exit 1 ;\
+		$(CHMOD) $(RWD_MODE) $(DESTDIR)$(CONF_DEST)/*.new || exit 1 ;\
 		$(ECHO) "Warning: Older config files are preserved. Check new versions for changes!" ;\
 	fi ;\
-	[ ! -f $(LOG_DEST)/logfile ] && $(ECHO) Creating logfiles in $(LOG_DEST) || \
-		$(ECHO) Checking logfiles in $(LOG_DEST) ;\
-		$(TOUCH) $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || exit 1 ;\
+	[ ! -f $(DESTDIR)$(LOG_DEST)/logfile ] && $(ECHO) Creating logfiles in $(DESTDIR)$(LOG_DEST) || \
+		$(ECHO) Checking logfiles in $(DESTDIR)$(LOG_DEST) ;\
+		$(TOUCH) $(DESTDIR)$(LOG_DEST)/logfile $(DESTDIR)$(LOG_DEST)/jarfile || exit 1 ;\
 	if [ x$$USER != x ]; then \
-		$(CHOWN) $$USER $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || \
+		$(CHOWN) $$USER $(DESTDIR)$(LOG_DEST)/logfile $(DESTDIR)$(LOG_DEST)/jarfile || \
 		$(ECHO) "** WARNING ** current install user different from configured user. Logging may fail!!" ;\
 	fi ;\
 	if [ x$$GROUP_T != x ]; then \
-		$(CHGRP) $$GROUP_T $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || \
+		$(CHGRP) $$GROUP_T $(DESTDIR)$(LOG_DEST)/logfile $(DESTDIR)$(LOG_DEST)/jarfile || \
 		$(ECHO) "** WARNING ** current install user different from configured user. Logging may fail!!" ;\
 	fi ;\
-	$(CHMOD) $(RWD_MODE) $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || exit 1 ;\
+	$(CHMOD) $(RWD_MODE) $(DESTDIR)$(LOG_DEST)/logfile $(DESTDIR)$(LOG_DEST)/jarfile || exit 1 ;\
 	if [ "$(prefix)" = "/usr/local" ] || [ "$(prefix)" = "/usr" ]; then \
 		if [ -f /etc/slackware-version ] && [ -d /etc/rc.d/ ] && [ -w /etc/rc.d/ ] ; then \
                $(SED) 's+%PROGRAM%+$(PROGRAM)+' slackware/rc.privoxy.orig | \
@@ -1245,7 +1247,7 @@
 	$(RM) config.base config.tmp
 	@# mmmmm, good.
 	@$(ECHO) "$(PROGRAM_V) installation succeeded!"
-	@$(ECHO) "The Privoxy configuration files have been installed in $(CONF_DEST)"
+	@$(ECHO) "The Privoxy configuration files have been installed in $(DESTDIR)$(CONF_DEST)"
 
 # rmdir is used as a precaution since it will not remove non-empty
 # directories. RH init script creates lock file and pid file.
