--- Python-2.2.3.orig/Makefile.pre.in	2003-01-19 18:13:45.000000000 -0800
+++ Python-2.2.3/Makefile.pre.in	2004-10-18 14:11:43.000000000 -0700
@@ -521,7 +521,7 @@
 		@for i in X $(SHAREDMODS); do \
 		  if test $$i != X; then \
 		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
-		    $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
+		    $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
 		  fi; \
 		done
 
@@ -530,7 +530,7 @@
 		do \
 			if test ! -d $$i; then \
 				echo "Creating directory $$i"; \
-				$(INSTALL) -d -m $(DIRMODE) $$i; \
+				$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
 			else    true; \
 			fi; \
 		done
@@ -538,11 +538,11 @@
 
 # Install the interpreter (by creating a hard link to python$(VERSION))
 bininstall:	altbininstall
-	-if test -f $(BINDIR)/$(PYTHON); \
-	then rm -f $(BINDIR)/$(PYTHON); \
+	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
+	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
 	else true; \
 	fi
-	(cd $(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
+	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
 
 # Install the interpreter with $(VERSION) affixed
 # This goes into $(exec_prefix)
@@ -550,18 +550,18 @@
 	@for i in $(BINDIR) $(LIBDIR); \
 	do \
 		if test ! -d $$i; then \
-			echo "Creating directory $$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $$i; \
+			echo "Creating directory $(DESTDIR)$$i"; \
+			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
 		else	true; \
 		fi; \
 	done
-	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(BINDIR)/python$(VERSION)$(EXE)
+	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
 	if test -f libpython$(VERSION).so; then \
-		$(INSTALL_DATA) libpython$(VERSION).so $(LIBDIR); \
+		$(INSTALL_DATA) libpython$(VERSION).so $(DESTDIR)$(LIBDIR); \
 	else	true; \
 	fi
 	if test -f "$(DLLLIBRARY)"; then \
-		$(INSTALL_SHARED) $(DLLLIBRARY) $(BINDIR); \
+		$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
 	else	true; \
 	fi
 
@@ -571,12 +571,12 @@
 	do \
 		if test ! -d $$i; then \
 			echo "Creating directory $$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $$i; \
+			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
 		else	true; \
 		fi; \
 	done
 	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
-		$(MANDIR)/man1/python.1
+		$(DESTDIR)$(MANDIR)/man1/python.1
 
 # Install the library
 PLATDIR=	plat-$(MACHDEP)
@@ -590,7 +590,7 @@
 	do \
 		if test ! -d $$i; then \
 			echo "Creating directory $$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $$i; \
+			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
 		else	true; \
 		fi; \
 	done
@@ -601,17 +601,17 @@
 		b=$(LIBDEST)/$$d; \
 		if test ! -d $$b; then \
 			echo "Creating directory $$b"; \
-			$(INSTALL) -d -m $(DIRMODE) $$b; \
+			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
 		else	true; \
 		fi; \
 	done
 	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc; \
 	do \
 		if test -x $$i; then \
-			$(INSTALL_SCRIPT) $$i $(LIBDEST); \
+			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
 			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
 		else \
-			$(INSTALL_DATA) $$i $(LIBDEST); \
+			$(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
 			echo $(INSTALL_DATA) $$i $(LIBDEST); \
 		fi; \
 	done
@@ -631,20 +631,20 @@
 				if test -d $$i; then continue; fi; \
 				if test -x $$i; then \
 				    echo $(INSTALL_SCRIPT) $$i $$b; \
-				    $(INSTALL_SCRIPT) $$i $$b; \
+				    $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
 				else \
 				    echo $(INSTALL_DATA) $$i $$b; \
-				    $(INSTALL_DATA) $$i $$b; \
+				    $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
 				fi;; \
 			esac; \
 		done; \
 	done
-	$(INSTALL_DATA) $(srcdir)/LICENSE $(LIBDEST)/LICENSE.txt
+	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
 	PYTHONPATH=$(LIBDEST) \
-		./$(BUILDPYTHON) -tt $(LIBDEST)/compileall.py -x badsyntax \
-	        $(LIBDEST)
+		./$(BUILDPYTHON) -tt $(DESTDIR)$(LIBDEST)/compileall.py -x badsyntax \
+	        $(DESTDIR)$(LIBDEST)
 	PYTHONPATH=$(LIBDEST) \
-		./$(BUILDPYTHON) -O $(LIBDEST)/compileall.py -x badsyntax $(LIBDEST)
+		./$(BUILDPYTHON) -O $(DESTDIR)$(LIBDEST)/compileall.py -x badsyntax $(DESTDIR)$(LIBDEST)
 
 # Create the PLATDIR source directory, if one wasn't distributed..
 $(srcdir)/Lib/$(PLATDIR):
@@ -663,16 +663,16 @@
 	do \
 		if test ! -d $$i; then \
 			echo "Creating directory $$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $$i; \
+			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
 		else	true; \
 		fi; \
 	done
 	@for i in $(srcdir)/Include/*.h; \
 	do \
 		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
-		$(INSTALL_DATA) $$i $(INCLUDEPY); \
+		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
 	done
-	$(INSTALL_DATA) pyconfig.h $(CONFINCLUDEPY)/pyconfig.h
+	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
 
 # Install the library and miscellaneous stuff needed for extending/embedding
 # This goes into $(exec_prefix)
@@ -682,49 +682,49 @@
 	do \
 		if test ! -d $$i; then \
 			echo "Creating directory $$i"; \
-			$(INSTALL) -d -m $(DIRMODE) $$i; \
+			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
 		else	true; \
 		fi; \
 	done
 	@if test -d $(LDLIBRARY); then :; else \
 		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
-			$(INSTALL_DATA) $(LDLIBRARY) $(LIBPL)/$(LDLIBRARY) ; \
-			$(RANLIB) $(LIBPL)/$(LDLIBRARY) ; \
+			$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL)/$(LDLIBRARY) ; \
+			$(RANLIB) $(DESTDIR)$(LIBPL)/$(LDLIBRARY) ; \
 		else \
 			echo Skip install of $(LDLIBRARY) - use make frameworkinstall; \
 		fi; \
 	fi
-	$(INSTALL_DATA) Modules/config.c $(LIBPL)/config.c
-	$(INSTALL_DATA) Modules/$(MAINOBJ) $(LIBPL)/$(MAINOBJ)
-	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(LIBPL)/config.c.in
-	$(INSTALL_DATA) Makefile $(LIBPL)/Makefile
-	$(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup
-	$(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local
-	$(INSTALL_DATA) Modules/Setup.config $(LIBPL)/Setup.config
-	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup
-	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(LIBPL)/install-sh
+	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
+	$(INSTALL_DATA) Modules/$(MAINOBJ) $(DESTDIR)$(LIBPL)/$(MAINOBJ)
+	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
+	$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
+	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
+	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
+	$(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
+	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
+	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
 	@if [ -s Modules/python.exp -a \
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
 		echo; echo "Installing support files for building shared extension modules on AIX:"; \
 		$(INSTALL_DATA) Modules/python.exp		\
-				$(LIBPL)/python.exp;		\
+				$(DESTDIR)$(LIBPL)/python.exp;		\
 		echo; echo "$(LIBPL)/python.exp";		\
 		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
-				$(LIBPL)/makexp_aix;		\
+				$(DESTDIR)$(LIBPL)/makexp_aix;		\
 		echo "$(LIBPL)/makexp_aix";			\
 		$(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix	\
-				$(LIBPL)/ld_so_aix;		\
+				$(DESTDIR)$(LIBPL)/ld_so_aix;		\
 		echo "$(LIBPL)/ld_so_aix";			\
 		echo; echo "See Misc/AIX-NOTES for details.";	\
 	else true; \
 	fi
 	@case "$(MACHDEP)" in beos*) \
 		echo; echo "Installing support files for building shared extension modules on BeOS:"; \
-		$(INSTALL_DATA) Misc/BeOS-NOTES $(LIBPL)/README;	\
+		$(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README;	\
 		echo; echo "$(LIBPL)/README";			\
-		$(INSTALL_SCRIPT) Modules/ar_beos $(LIBPL)/ar_beos; \
+		$(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
 		echo "$(LIBPL)/ar_beos";			\
-		$(INSTALL_SCRIPT) Modules/ld_so_beos $(LIBPL)/ld_so_beos; \
+		$(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
 		echo "$(LIBPL)/ld_so_beos";			\
 		echo; echo "See Misc/BeOS-NOTES for details.";	\
 		;; \
@@ -735,7 +735,8 @@
 sharedinstall:
 	./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
 		--install-scripts=$(BINDIR) \
-		--install-platlib=$(DESTSHARED)
+		--install-platlib=$(DESTSHARED) \
+		--root=/$(DESTDIR)
 
 # Install a MacOSX framework During build (before
 # setup.py), make a minimal Python.framework directory structure in the build
