--- Makefile.dynamic.in.orig	2006-01-04 13:20:59.000000000 -0700
+++ Makefile.dynamic.in	2006-01-26 12:58:26.000000000 -0700
@@ -15,6 +15,8 @@
 LIBTOOL = @LIBTOOL@
 INSTALL = @INSTALL@
 
+DESTDIR=
+
 all: fontforge
 
 libs: libgunicode libgdraw
@@ -47,58 +49,58 @@
 
 install_libs: libs
 # You may need to be root to do the install
-	mkdir -p $(libdir)
+	mkdir -p $(DESTDIR)$(libdir)
 	#-rm $(libdir)/libgdraw.so* $(libdir)/libgunicode.so.*
-	$(LIBTOOL) --mode=install $(INSTALL) -c libgdraw.la $(libdir)/libgdraw.la
-	$(LIBTOOL) --mode=install $(INSTALL) -c libgunicode.la $(libdir)/libgunicode.la
+	$(LIBTOOL) --mode=install $(INSTALL) -c libgdraw.la $(DESTDIR)$(libdir)/libgdraw.la
+	$(LIBTOOL) --mode=install $(INSTALL) -c libgunicode.la $(DESTDIR)$(libdir)/libgunicode.la
 	#cp .libs/*.so.*.* $(libdir)
-	$(LIBTOOL) --mode=finish $(libdir)
-	mkdir -p $(libdir)/pkgconfig
-	$(LIBTOOL) --mode=install $(INSTALL) -c fontforge.pc $(libdir)/pkgconfig
+	$(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
+	mkdir -p $(DESTDIR)$(libdir)/pkgconfig
+	$(LIBTOOL) --mode=install $(INSTALL) -c fontforge.pc $(DESTDIR)$(libdir)/pkgconfig
 
 install_docs:
-	mkdir -p $(docdir)
-	mkdir -p $(docdir)/flags $(docdir)/ja
+	mkdir -p $(DESTDIR)$(docdir)
+	mkdir -p $(DESTDIR)$(docdir)/flags $(DESTDIR)$(docdir)/ja
 #explicit use of sh to make sure we don't invoke csh with different "if" syntax
-	-sh -c "if test -d htdocs/ja >/dev/null ; then mkdir -p $(docdir)/ja ; fi"
-	-cp htdocs/*.{html,png,gif,pdf} $(docdir)
-	-cp htdocs/flags/* $(docdir)/flags
-	-cp htdocs/ja/* $(docdir)/ja
+	-sh -c "if test -d htdocs/ja >/dev/null ; then mkdir -p $(DESTDIR)$(docdir)/ja ; fi"
+	-cp htdocs/*.{html,png,gif,pdf} $(DESTDIR)$(docdir)
+	-cp htdocs/flags/* $(DESTDIR)$(docdir)/flags
+	-cp htdocs/ja/* $(DESTDIR)$(docdir)/ja
 
 install_po:
 	( cd po ; make install )
 
-install: $(sharedir) all install_libs install_po
+install: $(DESTDIR)$(sharedir) all install_libs install_po
 # You may need to be root to do the install
-	mkdir -p $(bindir)
-	mkdir -p $(mandir)/man1
-	mkdir -p $(sharedir)
-	$(LIBTOOL) --mode=install $(INSTALL) -c fontforge/fontforge $(bindir)
-	-$(LIBTOOL) --mode=install $(INSTALL) -c fontforge/sfddiff $(bindir)
+	mkdir -p $(DESTDIR)$(bindir)
+	mkdir -p $(DESTDIR)$(mandir)/man1
+	mkdir -p $(DESTDIR)$(sharedir)
+	$(LIBTOOL) --mode=install $(INSTALL) -c fontforge/fontforge $(DESTDIR)$(bindir)
+	-$(LIBTOOL) --mode=install $(INSTALL) -c fontforge/sfddiff $(DESTDIR)$(bindir)
 #	-rm -f $(bindir)/pfaedit
 #	(cd $(bindir) ; ln -s fontforge pfaedit)
 #	cp fontforge/pfaedit-*.ui $(sharedir)
 #The next line will fail for most installs. If you have downloaded the cidmaps
 # this will install them. If you haven't it won't. You only need the cidmaps
 # if you are editing CID keyed files (and even then you can live without them
-	-cp $(srcdir)/cidmap/*.cidmap $(sharedir) >/dev/null 2>&1
-	cp $(srcdir)/fontforge/fontforge.1 $(mandir)/man1
-	-cp $(srcdir)/fontforge/sfddiff.1 $(mandir)/man1
+	-cp $(srcdir)/cidmap/*.cidmap $(DESTDIR)$(sharedir) >/dev/null 2>&1
+	cp $(srcdir)/fontforge/fontforge.1 $(DESTDIR)$(mandir)/man1
+	-cp $(srcdir)/fontforge/sfddiff.1 $(DESTDIR)$(mandir)/man1
 #explicit use of sh to make sure we don't invoke csh with different "if" syntax
 	sh -c "if test -d htdocs >/dev/null ; then $(MAKE) install_docs ; fi"
 	sh < systemspecific
 
 uninstall:
-	-rm $(bindir)/fontforge
-	-rm $(bindir)/sfddiff
-	-rm $(sharedir)/pfaedit-*.ui
-	-rm $(localedir)/*/LC_MESSAGES/FontForge.mo
-	-rm $(mandir)/man1/fontforge.1
-	-rm $(mandir)/man1/sfddiff.1
-	-rm $(libdir)/libgdraw.so*
-	-rm $(libdir)/libgunicode.so*
-	-rm $(sharedir)/*.cidmap
-	-rm -rf $(docdir)/*
+	-rm $(DESTDIR)$(bindir)/fontforge
+	-rm $(DESTDIR)$(bindir)/sfddiff
+	-rm $(DESTDIR)$(sharedir)/pfaedit-*.ui
+	-rm $(DESTDIR)$(localedir)/*/LC_MESSAGES/FontForge.mo
+	-rm $(DESTDIR)$(mandir)/man1/fontforge.1
+	-rm $(DESTDIR)$(mandir)/man1/sfddiff.1
+	-rm $(DESTDIR)$(libdir)/libgdraw.so*
+	-rm $(DESTDIR)$(libdir)/libgunicode.so*
+	-rm $(DESTDIR)$(sharedir)/*.cidmap
+	-rm -rf $(DESTDIR)$(docdir)/*
 
-$(sharedir):
-	mkdir -p $(sharedir)
+$(DESTDIR)$(sharedir):
+	mkdir -p $(DESTDIR)$(sharedir)
