--- GNUmakefile.in.orig	Tue Feb 17 07:13:27 2004
+++ GNUmakefile.in	Sat May  1 20:30:55 2004
@@ -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)
 
 
 #############################################################################
@@ -1087,22 +1089,22 @@
 
 	@$(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.
 	-@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 \
@@ -1122,8 +1124,8 @@
 		$(INSTALL) $(INSTALL_T) $(DOK_WEB)/p_doc.css $$DOC;\
 	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
@@ -1139,9 +1141,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.
@@ -1179,32 +1181,32 @@
 		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 [ -s "$(CONF_DEST)/$$i" ] ; then \
+		if [ -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 | \
@@ -1234,7 +1236,7 @@
 	fi
 	@# 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.
