TITLE:		Xfig and Transfig

LFS VERSION:	4.1, but probably anything with gcc >= 2.95.3

AUTHOR:		Uli Fahrenberg <uli at math dot auc dot dk>

SYNOPSIS:
	Installing Xfig and Transfig in /usr

HINT:

Xfig is a powerful drawing program especially useful for schematic drawings,
and Transfig is the image format conversion tool that goes with it. Xfig
depends on Transfig, but Transfig can be used as a standalone tool, too. This
hint covers installation of them both, and we tweak the Imakefiles to make
them install in the /usr hierarchy, instead of /usr/X11R6 and /usr/local.


SOFTWARE:

xfig.3.2.4.full.tar.gz and transfig.3.2.4.tar.gz from

	http://www.xfig.org/xfigdist/


DEPENDENCIES:

Xfig needs:

	png
	zlib (?)

Xfig will utilize:

	jpeg
	xpm
	ghostscript
	netpbm

Transfig needs:

Transfig will utilize:

	png
	xpm

I install Xfig first, but the order most probably doesn't matter. The variable
XFIGLIBDIR is used in both programs' Imakefiles and should point to the same
directory, so for consistency I declare it first:

XFIGLIBDIR=/usr/share/xfig


So now for the Xfig installation. If your X is too old and does not contain
Xpm, leave out the USEXPM stuff below, or install Xpm separately before (or
upgrade your X).

mv Imakefile{,.orig}
echo MANDIR=/usr/share/man/man1 > Imakefile
cat Imakefile.orig | sed "s:XCOMM BINDIR = /usr/bin/X11:BINDIR=/usr/bin:g" \
    | sed "s:XCOMM MKDIRHIER = /bin/sh /usr/bin/X11/mkdirhier:MKDIRHIER=$(type -p mkdirhier):g" \
    | sed "s:XCOMM #define USEXPM:#define USEXPM:g" \
    | sed "s:XFIGLIBDIR = \$(LIBDIR)/xfig:XFIGLIBDIR=$XFIGLIBDIR:g" \
    | sed "s:XFIGDOCDIR = \$(LIBDIR)/xfig:XFIGDOCDIR=/usr/share/doc/xfig:g" \
    >> Imakefile
xmkmf
make
make install.all


Note: This will install some html and pdf documentation of Xfig, some of
it in Japanese. If you want to avoid the japanese stuff, replace the
`make install.all' above with

make install
make install.libs
make install.man
make install.rhtml


Leave out the last one if you're not interested in html documentation at all.

If your compilation bails out at SimpleMenu.c, you most probably do not have
Xaw3d installed. Don't worry, you don't need Xaw3d (not for Xfig, that is).
SimpleMenu.c wants to include some Xaw3d headers, but the original Xaw ones
will do fine. Do the following to your Xfig sources and you should be going
strong:

mv SimpleMenu.c{,.orig}
sed 's:#include <X11/Xaw3d/:#include <X11/Xaw/:g' SimpleMenu.c.orig \
    > SimpleMenu.c


Thanks to Ken Moffat for the info. Note that not only will Xfig do fine with
Xaw instead of Xaw3d, it even seems to look the same regardless of which
headers are used.


OK, here we go with transfig. The DDA4 = -DA4 stuff is because I use DIN A4
paper, leave it out if you don't. For Xpm see above. The DDEPSFIG and
USELATEX2E sed's are useful only if you use LaTeX and partly influenced by my
personal tastes. Read the Imakefiles for further info (hint: There's graphicx
support too (and if you copy my instructions, you'll get both graphicx and
epsfig)).

mv Imakefile{,.orig} 
echo BINDIR=/usr/bin > Imakefile 
echo MANDIR=/usr/share/man/man1 >> Imakefile 
cat Imakefile.orig >> Imakefile 
mv fig2dev/Imakefile{,.orig} 
echo BINDIR=/usr/bin > fig2dev/Imakefile 
echo MANDIR=/usr/share/man/man1 >> fig2dev/Imakefile 
cat fig2dev/Imakefile.orig | \
    sed "s:/usr/local/lib/X11/xfig:$XFIGLIBDIR:g" \
    | sed "s:XCOMM #define USEXPM:#define USEXPM:g" \
    | sed "s:XCOMM DDA4 = -DA4:DDA4 = -DA4:g" \
    | sed "s:XCOMM DDEPSFIG = -DEPSFIG:DDEPSFIG = -DEPSFIG:g" \
    | sed "s:FIG2DEV_LIBDIR = /usr/local/lib/fig2dev:FIG2DEV_LIBDIR=/usr/share/transfig:g" \
    >> fig2dev/Imakefile 
mv transfig/Imakefile{,.orig} 
echo BINDIR=/usr/bin > transfig/Imakefile 
echo MANDIR=/usr/share/man/man1 >> transfig/Imakefile 
cat transfig/Imakefile.orig | \
    sed "s:XCOMM USELATEX2E = -DLATEX2E:USELATEX2E = -DLATEX2E:g" \
    >> transfig/Imakefile 
xmkmf 
make Makefiles 
make 
make install 
make install.man 


That's it.
