--- src/MkInstal.in.sav	Sat Mar  8 11:58:01 2003
+++ src/MkInstal.in	Sat Mar  8 11:59:17 2003
@@ -29,49 +29,49 @@
 install_ffi	:: install_libraries_ffi              # for hierarchical libs
 
 install_bin	:: hugs$(EXE) runhugs$(EXE) ffihugs$(EXE)
-		$(INSTALL) -d $(bindir)
-		$(INSTALL) -c hugs$(EXE) $(bindir)
-		$(INSTALL) -c runhugs$(EXE) $(bindir)
-		$(INSTALL) -c ffihugs$(EXE) $(bindir)
+		$(INSTALL) -d $(DESTDIR)$(bindir)
+		$(INSTALL) -c hugs$(EXE) $(DESTDIR)$(bindir)
+		$(INSTALL) -c runhugs$(EXE) $(DESTDIR)$(bindir)
+		$(INSTALL) -c ffihugs$(EXE) $(DESTDIR)$(bindir)
 
 install_lib	::
-		$(INSTALL) -d $(hugsdir)/lib
-		$(INSTALL_DATA) ../lib/*.* $(hugsdir)/lib
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/lib
+		$(INSTALL_DATA) ../lib/*.* $(DESTDIR)$(hugsdir)/lib
 
 install_libhugs	:: install_lib
-		$(INSTALL) -d $(hugsdir)/lib/hugs
-		$(INSTALL_DATA) ../lib/hugs/*.*    $(hugsdir)/lib/hugs
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/lib/hugs
+		$(INSTALL_DATA) ../lib/hugs/*.*    $(DESTDIR)$(hugsdir)/lib/hugs
 
 install_demos	:: install_libhugs
-		$(INSTALL) -d $(hugsdir)/demos
-		$(INSTALL) -d $(hugsdir)/demos/prolog
-		$(INSTALL_DATA) ../demos/*.*            $(hugsdir)/demos
-		$(INSTALL_DATA) ../demos/prolog/*.*     $(hugsdir)/demos/prolog
-		$(INSTALL_DATA) ../demos/prolog/readme  $(hugsdir)/demos/prolog
-		$(INSTALL_DATA) ../demos/prolog/stdlib  $(hugsdir)/demos/prolog
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/demos
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/demos/prolog
+		$(INSTALL_DATA) ../demos/*.*            $(DESTDIR)$(hugsdir)/demos
+		$(INSTALL_DATA) ../demos/prolog/*.*     $(DESTDIR)$(hugsdir)/demos/prolog
+		$(INSTALL_DATA) ../demos/prolog/readme  $(DESTDIR)$(hugsdir)/demos/prolog
+		$(INSTALL_DATA) ../demos/prolog/stdlib  $(DESTDIR)$(hugsdir)/demos/prolog
 
 install_libexts	:: $(LIBRARIES)
-		$(INSTALL) -d $(hugsdir)/lib/exts
-		$(INSTALL_DATA) ../lib/exts/*.*     $(hugsdir)/lib/exts
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/lib/exts
+		$(INSTALL_DATA) ../lib/exts/*.*     $(DESTDIR)$(hugsdir)/lib/exts
 
 install_man	::
 		$(INSTALL) -d $(mandir)/man1
 		$(INSTALL_DATA) ../docs/hugs.1 $(mandir)/man1
 
 install_include	::
-		$(INSTALL) -d $(hugsdir)/include
-		$(INSTALL_DATA) ../include/GreenCard.h  $(hugsdir)/include
-		$(INSTALL_DATA) HsFFI.h  $(hugsdir)/include
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/include
+		$(INSTALL_DATA) ../include/GreenCard.h  $(DESTDIR)$(hugsdir)/include
+		$(INSTALL_DATA) HsFFI.h  $(DESTDIR)$(hugsdir)/include
 
 install_notes	::
-		$(INSTALL) -d $(hugsdir)/docs
-		$(INSTALL_DATA) ../docs/*.txt  $(hugsdir)/docs
-		$(INSTALL_DATA) ../docs/server.*  $(hugsdir)/docs
-		$(INSTALL_DATA) ../Readme  $(hugsdir)
-		$(INSTALL_DATA) ../License $(hugsdir)
-		$(INSTALL_DATA) ../Credits $(hugsdir)
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/docs
+		$(INSTALL_DATA) ../docs/*.txt  $(DESTDIR)$(hugsdir)/docs
+		$(INSTALL_DATA) ../docs/server.*  $(DESTDIR)$(hugsdir)/docs
+		$(INSTALL_DATA) ../Readme  $(DESTDIR)$(hugsdir)
+		$(INSTALL_DATA) ../License $(DESTDIR)$(hugsdir)
+		$(INSTALL_DATA) ../Credits $(DESTDIR)$(hugsdir)
 
-BUILD_FFI_OLD = ./ffihugs -N +G -W
+BUILD_FFI_OLD = ./ffihugs -P"$(DESTDIR)$(hugsdir)/lib:$(DESTDIR)$(hugsdir)/lib/hugs:$(DESTDIR)$(hugsdir)/lib/exts" +G -W +L"-I$(DESTDIR)$(hugsdir)/include/"
 
 install_libexts_ffi :: install_libexts install_include ffihugs$(EXE)
 		$(BUILD_FFI_OLD) +L"../lib/exts/Storable_aux.c" HugsStorable 
@@ -79,14 +79,14 @@
 		$(BUILD_FFI_OLD) MarshalUtils
 
 install_libraries :: $(LIBRARIES)
-		$(INSTALL) -d $(hugsdir)
-		$(INSTALL_DATA) -R ../libraries $(hugsdir)
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)
+		$(INSTALL_DATA) -R ../libraries $(DESTDIR)$(hugsdir)
 
 install_oldlib :: $(LIBRARIES)
-		$(INSTALL) -d $(hugsdir)/oldlib
-		$(INSTALL_DATA) ../oldlib/*.* $(hugsdir)/oldlib
+		$(INSTALL) -d $(DESTDIR)$(hugsdir)/oldlib
+		$(INSTALL_DATA) ../oldlib/*.* $(DESTDIR)$(hugsdir)/oldlib
 
-BUILD_FFI_NEW = ./ffihugs +N +G -W
+BUILD_FFI_NEW = ./ffihugs +N -P"$(DESTDIR)$(hugsdir)/libraries:$(DESTDIR)$(hugsdir)/oldlib" +G -W +L"-I$(DESTDIR)$(hugsdir)/include/"
 
 install_libraries_ffi :: install_libraries install_include ffihugs$(EXE)
 		$(BUILD_FFI_NEW) +L"../libraries/Hugs/Storable_aux.c" Hugs.Storable 
@@ -94,6 +94,6 @@
 		$(BUILD_FFI_NEW) Foreign.Marshal.Utils 
 		$(BUILD_FFI_NEW) +L"../libraries/Foreign/C/errno.c" Foreign.C.Error  
 		$(BUILD_FFI_NEW) Text.Regex.Posix
-		$(RM) $(hugsdir)/libraries/Hugs/*.[ch]
-		$(RM) $(hugsdir)/libraries/Foreign/*/*.[ch]
-		$(RM) $(hugsdir)/libraries/Text/Regex/*.[ch]
+		$(RM) $(DESTDIR)$(hugsdir)/libraries/Hugs/*.[ch]
+		$(RM) $(DESTDIR)$(hugsdir)/libraries/Foreign/*/*.[ch]
+		$(RM) $(DESTDIR)$(hugsdir)/libraries/Text/Regex/*.[ch]
