# -*- makefile -*-
# Author: Petter Reinholdtsen <pere@td.org.uit.no>
# Date:	  2000-04-23
#
# Rules for LaTeX to Postscript/PDF/HTML convertion, including image
# format translation.

LATEX=latex
DVIPS=dvips
PDFLATEX=pdflatex
PS2PDF=ps2pdf
FIG2DEV=fig2dev
L2H=tth
# L2H=latex2html
L2HFLAGS=

# Document formats
.SUFFIXES: .tex .ps .dvi .pdf .html
.tex.html:
	$(L2H) $* $(L2HFLAGS)
.tex.pdf:
	$(PDFLATEX) $<
.tex.dvi:
	$(LATEX) $<
.dvi.ps:
	$(DVIPS) $< -o $@

# Image formats
.SUFFIXES: .fig .pgm .pnm .eps .png .gif .jpeg
.fig.eps:
	$(FIG2DEV) -L ps $< > $@
.fig.png:
	$(FIG2DEV) -L png -m 0.5 $< $@
.pnm.png:
	pnmscale -xscale 2 -yscale 2 < $< | pnmtopng > $@
.pgm.png:
	pnmscale -xscale 2 -yscale 2 < $< | pnmtopng > $@
.pgm.eps:
	pnmtops -noturn < $< > $@
.pnm.eps:
	pnmtops -noturn < $< > $@
.jpeg.png:
	convert $< $@
.png.eps:
	pngtopnm $< | pnmtops -noturn> $@
.gif.eps:
	giftopnm $< | pnmtops -noturn> $@


.ps.pdf:
#	ps2pdf $< $@
#	ghostscript -sDEVICE=pdfwrite -sOutputFile=$@ < $<
	epstopdf $<

.ps.eps:
	ps2epsi $<
	mv $*.epsi $@

.eps.pdf:
	epstopdf $<
