--- Makefile.in.orig	2007-01-06 18:14:10.000000000 +0000
+++ Makefile.in	2007-02-08 19:07:23.000000000 +0000
@@ -26,7 +26,7 @@
 libdir = $(exec_prefix)/lib
 incdir = $(exec_prefix)/include
 manext = 1
-mandir = $(prefix)/man/man$(manext)
+mandir = @mandir@/man$(manext)
 
 # HP 9000 series, if you don't have gcc
 #   CC = cc
@@ -300,40 +300,40 @@
 	 inst-script-interpreters
 
 inst-vm:
-	$(INSTALL_PROGRAM) $(VM) $(LIB)
+	$(INSTALL_PROGRAM) $(VM) $(DESTDIR)$(LIB)
 
 inst-image:
 	rm -f '/tmp/$(IMAGE)' &&					\
 	$(srcdir)/build/build-usual-image $(srcdir) '$(LIB)'            \
 	         '/tmp/$(IMAGE)' './$(VM)' '$(INITIAL)' &&		\
-	$(INSTALL_DATA) /tmp/$(IMAGE) $(LIB) &&				\
+	$(INSTALL_DATA) /tmp/$(IMAGE) $(DESTDIR)$(LIB) &&				\
 	rm /tmp/$(IMAGE)
 
 inst-man:
-	$(srcdir)/mkinstalldirs $(mandir)
+	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
 	sed 's=LBIN=$(bindir)=g' $(srcdir)/doc/scheme48.man |	   \
 		sed 's=LLIB=$(LIB)=g' |				   \
 		sed 's=LS48=$(RUNNABLE)=g' >$(MANPAGE) &&	   \
-	$(INSTALL_DATA) $(MANPAGE) $(mandir) &&			   \
+	$(INSTALL_DATA) $(MANPAGE) $(DESTDIR)$(mandir) &&			   \
 	rm $(MANPAGE);						   \
 
 inst-inc:
-	$(INSTALL_DATA) $(srcdir)/c/scheme48.h $(incdir)
-	$(INSTALL_DATA) $(srcdir)/c/scheme48write-barrier.h $(incdir)
+	$(INSTALL_DATA) $(srcdir)/c/scheme48.h $(DESTDIR)$(incdir)
+	$(INSTALL_DATA) $(srcdir)/c/scheme48write-barrier.h $(DESTDIR)$(incdir)
 
 inst-misc:
 	for stub in env big sort opt misc link posix cml srfi; do	\
 		for f in $(srcdir)/scheme/$$stub/*.scm; do		\
-			$(INSTALL_DATA) $$f $(LIB)/$$stub || exit 1;	\
+			$(INSTALL_DATA) $$f $(DESTDIR)$(LIB)/$$stub || exit 1;	\
 		done;							\
 	done &&								\
 	for f in $(srcdir)/scheme/rts/*num.scm 				\
 		 $(srcdir)/scheme/rts/jar-defrecord.scm; do		\
-		$(INSTALL_DATA) $$f $(LIB)/rts || exit 1;		\
+		$(INSTALL_DATA) $$f $(DESTDIR)$(LIB)/rts || exit 1;		\
 	done
 
 inst-script:
-	script=$(bindir)/$(RUNNABLE) &&					\
+	script=$(DESTDIR)$(bindir)/$(RUNNABLE) &&					\
 	echo '#!/bin/sh'	>$$script &&				\
 	echo			>>$$script &&				\
 	echo 'lib=$(LIB)'	>>$$script &&				\
@@ -343,7 +343,7 @@
 
 inst-script-interpreters:
 	for dialect in r5rs srfi-7; do					\
-		$(INSTALL_PROGRAM) script-interpreter $(bindir)/scheme-$$dialect; \
+		$(INSTALL_PROGRAM) script-interpreter $(DESTDIR)$(bindir)/scheme-$$dialect; \
 	done
 
 # Script to run scheme48 in this directory.
@@ -357,11 +357,11 @@
 
 dirs:
 	for dir in $(libdir) $(bindir) $(incdir); do			 \
-		$(srcdir)/mkinstalldirs $$dir || exit 1;	 		 \
+		$(srcdir)/mkinstalldirs $(DESTDIR)$$dir || exit 1;	 		 \
 	done
-	$(srcdir)/mkinstalldirs $(LIB)
+	$(srcdir)/mkinstalldirs $(DESTDIR)$(LIB)
 	for dir in rts env big sort opt misc link posix cml srfi; do	  \
-		$(srcdir)/mkinstalldirs $(LIB)/$$dir || exit 1;	 	  \
+		$(srcdir)/mkinstalldirs $(DESTDIR)$(LIB)/$$dir || exit 1;	 	  \
 	done
 
 configure: configure.in
