#
# using convert from ImageMagick instead of my own jconv version v0.2.8
#   to crop the example images
#
# Version: @(#)ImageMagick 4.1.6 99/01/01 cristy@mystic.es.dupont.com
# Copyright: Copyright 1999 E. I. du Pont de Nemours and Company
# ... hmm, convert seems to use a lot of memory, pnmcrop works better
CROPPG = convert -crop 0x0+1+1

.PHONY: all examples fonts install

all: examples

help:
	echo " make examples       # Fig-examples (very fast)"
	echo " make examples_tex   # TeX-examples (takes lot of time)"
	echo " make [proper|clean] # remove non source stuff"

examples: font21.pcx font22.pcx font23.pcx font24.pcx
	ls -l font2*.pcx

examples_tex: text.pbm font0.pbm font1.pbm font2.pbm polish.pbm man.pbm
# what about small.pbm? anyone remember?

.SUFFIXES: .ps .tex .dvi
.tex.dvi:
	latex $*.tex

.dvi.ps:
	dvips -E -o $*.ps $*.dvi    # -PAPERSIZE=a4

font21.pcx: font2.fig
	fig2dev -L pcx -m 2 font2.fig font21.pcx

font22.pcx: font2.fig
	fig2dev -L pcx -m 3 font2.fig font22.pcx

font23.pcx: font2.fig
	fig2dev -L pcx -m 4 font2.fig font23.pcx

font24.pcx: font2.fig
	fig2dev -L pcx -m 5 font2.fig font24.pcx

font.tex: font1.tex
	cp font1.tex font.tex

# unfortunatly gs always creates a4 from boxed-ps, therefore we must crop it
# gs options: pgmraw, pcxmono, laserjet
font0.pbm: font.ps Makefile
	gs -dNOPAUSE -q -r600 -sDEVICE=pbmraw \
	 -sOutputFile=font0.pbm - < font.ps
#	$(CROPPG) font0.pbm font0.pbm
	pnmcrop font0.pbm >a.pbm; mv a.pbm font0.pbm

font1.pbm: font.ps Makefile
	gs -dNOPAUSE -q -r300 -sDEVICE=pbmraw \
	 -sOutputFile=font1.pbm - < font.ps
#	$(CROPPG) font1.pbm font1.pbm
	pnmcrop font1.pbm >a.pbm; mv a.pbm font1.pbm

font2.pbm: font.ps Makefile 
	gs -dNOPAUSE -q -r150 -sDEVICE=pbmraw \
	 -sOutputFile=font2.pbm - < font.ps
#	$(CROPPG) font2.pbm font2.pbm
	pnmcrop font2.pbm >a.pbm; mv a.pbm font2.pbm

polish.pbm: polish.ps Makefile 
	gs -dNOPAUSE -q -r200 -sDEVICE=pbmraw \
	 -sOutputFile=polish.pbm - < polish.ps
#	$(CROPPG) polish.pbm polish.pbm
	pnmcrop polish.pbm >a.pbm; mv a.pbm polish.pbm

text.pbm: text.ps Makefile
	gs -dNOPAUSE -q -r150 -sDEVICE=pbmraw \
	 -sOutputFile=text.pbm - < text.ps
#	 $(CROPPG) text.pbm text.pbm
	pnmcrop text.pbm >a.pbm; mv a.pbm text.pbm
	
small.pbm: small.ps Makefile
	gs -dNOPAUSE -q -r150 -sDEVICE=pbmraw \
	 -sOutputFile=small.pbm - < small.ps
#	 $(CROPPG) text.pbm text.pbm
	pnmcrop small.pbm >a.pbm; mv a.pbm small.pbm

# change this to make a man page to a test.pbm file
man.pbm: Makefile
	man -Tdvi man >man.dvi
	dvips -o man.ps man.dvi
	gs -dNOPAUSE -q -r300 -sDEVICE=pbmraw \
	 -sOutputFile=man.pbm - < man.ps
#	$(CROPPG) man.pbm man.pbm
	pnmcrop man.pbm >a.pbm; mv a.pbm man.pbm
	rm -f man.ps man.dvi

fonts: font0.pbm font1.pbm font2.pbm

clean:
	-rm -f *.aux *.log *.dvi man.ps font.ps polish.ps *~

proper: clean
	-rm -f *.pbm *.pcx *.bak
 
install:

