--- Imakefile.orig	2012-08-09 10:14:15.000000000 -0700
+++ Imakefile	2013-09-02 16:51:37.000000000 -0700
@@ -30,9 +30,9 @@
 XCOMM Also, you may have to uncomment and redefine MKDIRHIER because "make" looks
 XCOMM for it relative to the BINDIR variable.
 XCOMM
-XCOMM BINDIR = /usr/bin
+BINDIR = $(PREFIX)/bin
 XCOMM MKDIRHIER = /bin/sh /usr/bin/X11/mkdirhier -p
-MKDIRHIER = mkdirhier 
+MKDIRHIER = ${LOCALBASE}/bin/mkdirhier
 
 XCOMM Uncomment and change XAPPLOADDIR to the directory where you want the
 XCOMM app-defaults resource files to go.  You will have to use the environment
@@ -45,7 +45,7 @@
 XCOMM different tree than the "correct" tree that your X system expects. The usual
 XCOMM purpose of DESTDIR is to test an install process by installing in a benign area.
 
-XCOMM XAPPLOADDIR = /home/user/xfig
+XAPPLOADDIR = ${LOCALBASE}/lib/X11/app-defaults
 
 XCOMM Comment out the following definition for XAW3D if you don't to want to use
 XCOMM the 3d Athena Widget Set
@@ -75,8 +75,8 @@
 XCOMM Redefine the following if your PNG library, zlib library and/or include file
 XCOMM are in different places
 
-PNGLIBDIR = $(USRLIBDIR)
-PNGINC = -I/usr/include
+PNGLIBDIR = ${LOCALBASE}/lib
+PNGINC = -I${LOCALBASE}/include/libpng
 ZLIBDIR = $(USRLIBDIR)
 
 XCOMM If don't want JPEG support, comment out the #define USEJPEG line
@@ -95,13 +95,13 @@
 #define USEINSTALLEDJPEG
 
 #ifdef USEJPEG
-#    ifdef USEINSTALLEDJPEG
-	JPEGLIBDIR = /usr/local/lib
-	JPEGINC = -I/usr/include/X11
-#    else
-	JPEGLIBDIR = ../jpeg
-	JPEGINC = -I$(JPEGLIBDIR)
-#    endif /* USEINSTALLEDJPEG */
+#ifdef USEINSTALLEDJPEG
+JPEGLIBDIR = ${LOCALBASE}/lib
+JPEGINC = -I${LOCALBASE}/include
+#else
+JPEGLIBDIR = ../jpeg
+JPEGINC = -I$(JPEGLIBDIR)
+#endif /* USEINSTALLEDJPEG */
 #endif /* USEJPEG */
 
 XCOMM Uncomment the #define for USEXPM if you want to use the XPM
@@ -119,8 +119,8 @@
 #define USEXPM_ICON
 
 #ifdef USEXPM
-XPMLIBDIR = /usr/local/lib
-XPMINC = -I/usr/include/X11
+XPMLIBDIR = ${LOCALBASE}/lib
+XPMINC = -I${LOCALBASE}/X11
 #endif
 
 XCOMM Uncomment the following definiton if you want to use the small icons
@@ -162,7 +162,7 @@
 XCOMM inline functions. With the "INLINE" keyword, you should notice that
 XCOMM the display will be a bit faster in complex figures
 
-XCOMM USEINLINE = -DUSE_INLINE
+USEINLINE = -DUSE_INLINE
 
 XCOMM use (and change) the following if you want the multi-key data base file
 XCOMM somewhere other than the standard X11 library directory
@@ -174,11 +174,11 @@
 
 XCOMM XFIGDOCDIR tells where the html and pdf documentation should go
 XCOMM XFIGDOCDIR = $(DOCDIR)/xfig
-XFIGDOCDIR = /usr/local/xfig/doc
+XFIGDOCDIR = $(DOCSDIR)
 
 XCOMM MANDIR tells where the standard man pages should go (no need to change it
 XCOMM if you want the man pages installed in the standard place on your system
-MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
+XCOMM MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
 XCOMM MANDIR = /usr/local/xfig/man
 
 XCOMM If your system doesn't have strstr undefine the following definition
@@ -391,8 +391,8 @@
 install::
 	@if [ -d $(DESTDIR)$(XFIGLIBDIR) ]; then set +x; \
 		else (set -x; $(MKDIRHIER) $(DESTDIR)$(XFIGLIBDIR) ; set +x; ); fi
-	chmod a+x,u+w $(DESTDIR)$(XFIGLIBDIR)
-	$(INSTALL) -m 644 -c CompKeyDB $(DESTDIR)$(XFIGLIBDIR)
+	${CHMOD} a+x,u+w $(DESTDIR)$(XFIGLIBDIR)
+	$(INSTALL) $(INSTALLFLAGS) $(INSTDATFLAGS) CompKeyDB $(DESTDIR)$(XFIGLIBDIR)
 
 XCOMM Install program, libraries and documentation with "make install.all"
 install.all::
@@ -407,11 +407,14 @@
 XCOMM Install the documentation here with "make install.doc"
 install.doc::
 	@echo Installing man pages to $(MANDIR)
-	@if [ -d $(DESTDIR)$(XFIGDOCDIR) ]; then set +x; \
-		else (set -x; $(MKDIRHIER) $(DESTDIR)$(XFIGDOCDIR) ; set +x; ); fi
+	@$(MAKE) install.docdir
 	@$(MAKE) install.man
 	@$(MAKE) install.html
 
+install.docdir::
+	@if [ -d $(DESTDIR)$(XFIGDOCDIR) ]; then set +x; \
+	else (set -x; $(MKDIRHIER) $(DESTDIR)$(XFIGDOCDIR) ; set +x; ); fi
+
 XCOMM Install the HTML documentation here with "make install.html"
 
 #ifdef I18N
@@ -424,24 +427,25 @@
 #endif
 
 install.rhtml::
+	@$(MAKE) install.docdir
 	@(cd Doc ; \
 	echo Copying pdf and html files to $(DESTDIR)$(XFIGDOCDIR) ; \
 	if [ -d $(DESTDIR)$(XFIGDOCDIR)/html ]; then set +x; \
 	   else (set -x; $(MKDIRHIER) $(DESTDIR)$(XFIGDOCDIR)/html ); fi ; \
-	$(INSTALL) -m 644 -c xfig_man.html $(DESTDIR)$(XFIGDOCDIR) ; \
-	$(INSTALL) -m 644 -c xfig_ref_en.pdf $(DESTDIR)$(XFIGDOCDIR) ; \
-	$(INSTALL) -m 644 -c xfig-howto.pdf $(DESTDIR)$(XFIGDOCDIR) ; \
+	$(INSTALL) $(INSTALLFLAGS) $(INSTDATFLAGS) xfig_ref_en.pdf $(DESTDIR)$(XFIGDOCDIR) ; \
+	$(INSTALL) $(INSTALLFLAGS) $(INSTDATFLAGS) xfig-howto.pdf $(DESTDIR)$(XFIGDOCDIR) ; \
 	if [ -d html ]; then \
-	( cd html ; tar cf - *.* images ) | ( cd $(DESTDIR)$(XFIGDOCDIR)/html ; tar xf - ) ; fi ; \
+	( cd html ; ${TAR} -cf - *.* images ) | ( cd $(DESTDIR)$(XFIGDOCDIR)/html ; exec ${TAR} -xpof - ) ; fi ; \
 	) ;
 
 #ifdef I18N
 install.jhtml::
 	@echo "Copying japanese html files to $(DESTDIR)$(XFIGDOCDIR)"
+	@$(MAKE) install.docdir
 	@(cd Doc/html/japanese ; \
 	if [ -d $(DESTDIR)$(XFIGDOCDIR)/html/japanese ]; then set +x; \
 	   else (set -x; $(MKDIRHIER) $(DESTDIR)$(XFIGDOCDIR)/html/japanese ); fi ; \
-	tar cf - * | ( cd $(DESTDIR)$(XFIGDOCDIR)/html/japanese ; tar xf - ) ; \
+	${TAR} -cf - * | ( cd $(DESTDIR)$(XFIGDOCDIR)/html/japanese ; exec ${TAR} -xpof - ) ; \
 	) ;
 #endif
 
@@ -451,7 +455,7 @@
 	@if [ -d $(DESTDIR)$(OBJLIBDIR) ]; then set +x; \
 		else (set -x; $(MKDIRHIER) $(DESTDIR)$(OBJLIBDIR) ; set +x; ); fi
 	@if [ -d Libraries ]; then \
-		(cd Libraries ; tar cf - */. ) | ( cd $(DESTDIR)$(OBJLIBDIR) ; tar xf - ) ; \
+		(cd Libraries ; ${TAR} -cf - */. ) | ( cd $(DESTDIR)$(OBJLIBDIR) ; exec ${TAR} -xpof - ) ; \
 	else echo No Object Libraries to install ; \
 	fi;
 
