
# deactivate rules pertaining to the Pascal compiler (.p is for tptp)
%.o : %.p

% : %.p

.PHONY: all clean

all : h1.pdf h1index.html

clean :
	-rm h1.dvi h1.pdf *.html *.gif *~ *_err *_exec *.p *.pl *.log.gz
	-rm *.aux *.log *.bbl *.haux *.htoc *.bak *.toc *.image.tex

h1.pdf : h1.dvi
	dvipdf $<

h1.dvi : h1.tex h1.bib test1.p h1_test1_err zcat_test1_err \
  butler1_err butler2_exec butler3_err butler4_exec butler5_err butler6_exec \
  listeven.p tree3plus2.p tree3plus2.model.pl tree3plus2_model.tex \
  listeven_model.tex list_even_inter_tree3plus2.p list_even_inter_tree3plus2.model.pl \
  list_even_inter_tree3plus2_model.tex h1_inter2_err h1_inter3_err h1_inter4_err \
  list_even_inter_tree3plus2.trace \
  h1_inter5_err h1_inter6_err h1_inter7_err rinter_model.tex rinter_nd_model.tex \
  rinter_nd.purged.pl rinter_nd_purged.tex rinter_d.xml rinter_d.pl rinterd.tex \
  list_even_union_tree3plus2.p list_even_union_tree3plus2.model.pl \
  list_even_union_tree3plus2_model.tex list_even_union_tree3plus2_d.pl \
  list_even_union_tree3plus2_model_d.tex rinter_d_plus.model.pl \
  agatha.model.pl agatha_model.tex agathad.tex \
  nspriv_model.tex nspriv_twopi.tex
	latex h1
	bibtex h1
	makeindex -s cours.ist indexC.idx
	makeindex -s cours.ist indexN.idx
	latex h1
	latex h1

test1.p : ../test1.p
	grep -v "^%" $< >$@

h1_test1_err : test1.p h1_test1
	sh h1_test1 2>h1_test1_err
	sleep 1 # because generating test1.log.gz takes some time after h1_test1 has completed... [infamous h1 bug]

zcat_test1_err : h1_test1_err zcat_test1
	sh zcat_test1 >/dev/null
	touch $@

butler-puzzle.p :
	ln ../butler-puzzle.p .

butler1_err : butler-puzzle.p butler1
	sh butler1 2>$@
	sleep 1 # because generating h1out.log.gz takes some time after h1_test1 has completed... [infamous h1 bug]

butler2_exec dummy : butler1_err butler2
	sh butler2
	touch $@

butler3_err : butler-puzzle.p butler3
	sh butler3 2>$@

butler4_exec : butler-puzzle.p butler4
	sh butler4
	touch $@

butler5_err : butler-puzzle.p butler5
	sh butler5 >$@

butler6_exec : butler-puzzle.p butler6
	sh butler6
	touch $@

listeven.p : ../listeven.p
	grep -v "^%" $< >$@

tree3plus2.p : ../tree3plus2.p
	grep -v "^%" $< >$@

tree3plus2.model.pl : tree3plus2.p tree3plus2
	sh tree3plus2

tree3plus2_model.tex : tree3plus2.model.pl
	pl2gastex $< >$@

listeven.model.pl : listeven.p
	h1 -no-trim $<

listeven_model.tex : listeven.model.pl
	pl2gastex $< >$@

list_even_inter_tree3plus2.p : listeven.p tree3plus2.p h1_inter
	sh h1_inter

list_even_inter_tree3plus2.model.pl : list_even_inter_tree3plus2.p
	h1 -no-trim $<

list_even_inter_tree3plus2_model.tex : list_even_inter_tree3plus2.model.pl
	pl2gastex $< >$@

h1_inter2_err list_even_inter_tree3plus2.log: list_even_inter_tree3plus2.p h1_inter2
	sh h1_inter2 2>h1_inter2_err >list_even_inter_tree3plus2.log

list_even_inter_tree3plus2.trace : list_even_inter_tree3plus2.log
	h1trace -type tree $< >$@

h1_inter3_err : list_even_inter_tree3plus2.p h1_inter3
	sh h1_inter3 2>$@

h1_inter4_err : list_even_inter_tree3plus2.p h1_inter4
	sh h1_inter4 2>$@

h1_inter5_err : list_even_inter_tree3plus2.p h1_inter5
	sh h1_inter5 2>$@

h1_inter6_err : list_even_inter_tree3plus2.p h1_inter6
	sh h1_inter6 2>$@

h1_inter7_err rinter.model.pl : list_even_inter_tree3plus2.p h1_inter7
	sh h1_inter7 2>$h1_inter7_err

rinter_model.tex : rinter.model.pl
	pl2gastex -v -epsilon 0.5 $< >$@

rinter_nd.model.pl : rinter.model.pl
	sh h1_inter8

rinter_nd_model.tex : rinter_nd.model.pl
	pl2gastex -v $< >$@

rinter_nd.purged.pl : rinter_nd.model.pl
	sh h1_inter9

rinter_nd_purged.tex : rinter_nd.purged.pl
	pl2gastex -v $< >$@

rinter.model.xml : rinter.model.pl
	pldet -v1 $< >$@

rinter_d.xml : rinter_nd.purged.pl
	sh h1det

rinter_d.pl : rinter_d.xml
	sh h1detpl

rinterd.tex : rinter_d.pl
	sh h1detg

list_even_union_tree3plus2.p : listeven.p tree3plus2.p h1_union
	sh h1_union

list_even_union_tree3plus2.model.pl : list_even_union_tree3plus2.p
	sh h1_union2

list_even_union_tree3plus2_model.tex : list_even_union_tree3plus2.model.pl
	pl2gastex $< >$@

list_even_union_tree3plus2_d.pl : list_even_union_tree3plus2.model.pl
	sh h1detu

list_even_union_tree3plus2_model_d.tex : list_even_union_tree3plus2_d.pl
	sh pl2gdetu

rinter_d_plus.p : rinter_d.pl
	sh h1_tc

rinter_d_plus.model.pl : rinter_d_plus.p
	sh h1_tc2

agatha.model.pl : butler-puzzle.p
	sh butler_model

agatha_model.tex : agatha.model.pl
	pl2gastex -v $< >$@

agathad.tex : agatha.model.pl
	sh butler_model_det

agatha_c.pl : agatha.model.pl
	sh butler_model_c

nspriv.p : ../nspriv.p
	grep -v "^%" $< >$@

nspriv.model.pl : nspriv.p
	h1 -all $<

nspriv_model.tex : nspriv.model.pl
	pl2gastex -v -epsilon 0.3 $< >$@

nspriv_twopi.tex : nspriv.model.pl
	pl2gastex -v -layout twopi -overlap false $< >$@

h1index.html : h1.html
	hacha -o h1index.html -tocbis h1.html

h1.html : h1.dvi
	hevea -O h1.hva urlhref.hva h1.tex
	./imagen h1
