<./latex.mk
<./spell.mk
<./bbl.$USER.mk
<./bitly.$USER.mk


LASTPAGE=13  # final draft has extra page

TGT=dfopt

all:V: $TGT.pdf $TGT.ps hoopl10-supplement.bitly hoopl10.bitly
old:V: popl-index.bitly
bib:V: $TGT.bbl
bibfile:V: $TGT.bib
dvi:V: $TGT.dvi
pdf:V: $TGT.pdf
ps:V: $TGT.ps
bbl:V: bib
xdvi:V: $TGT.dvi
	sht=`xwininfo -root | awk '$1 == "Height:" { print $2 }'`
	swd=`xwininfo -root | awk '$1 == "Width:"  { print $2 }'`
    swd=`expr $swd - 120` # more room
	xdvi -s 5 -geometry =$(expr $swd / 2)x$(expr $sht - 20)+78+2 $prereq


tag:VQ: $TGT.tex
	tag=`$HOME/bin/md5words -trim $prereq | tr -d "'" | tr -cs a-zA-Z0-9 - | sed s/-*$//`
	echo git tag $tag
	git tag $tag

dfopt.dvi: dfopt.bbl code.sty timestamp.tex dfoptdu.tex cprop.tex comb1.tex iterf.tex pairf.tex dg.tex cat.tex

dfoptdu.tex: cprop.tex comb1.tex iterf.tex pairf.tex dg.tex node.tex

$TGT.pdf: $TGT.dvi
	dvips -Ppdf -o"|ps2pdf - $target" -pp 1-$LASTPAGE $prereq

$TGT.ps: $TGT.dvi
	dvips -Ppdf -o "$target" -pp 1-$LASTPAGE $prereq

$HOME/www/pubs/hoopl10-supplement.pdf: $TGT.dvi
	dvips -Ppdf -o"|ps2pdf - $target" -pp `expr $LASTPAGE + 1`- $prereq

$HOME/www/pubs/hoopl10.pdf: $TGT.dvi
	dvips -Ppdf -o"|ps2pdf - $target" $prereq

timestamp.tex: $TGT.tex
	date=`stat -c "%y" $prereq`
	signature=""
	if [ -x $HOME/bin/md5words ]; then
	  words="`md5words -trim $prereq`"
      signature=" [MD5: \\mbox{$words}]"
    else
      words="(could not compute signature words)"
	fi
	date -d "$date" "+\def\mdfivestamp{\\rlap{\\textbf{%a %e %b %Y, %l:%M %p$signature}}}\def\mdfivewords{$words}" > $target



%du.tex:D: defuse %.tex hsprelude
	[ -r "$target" ] && chmod +w $target
	./defuse '\^' < $stem.tex > $target
	chmod -w $target


CLIENT=../testing
CPROPS=ConstProp Simplify Test

cprop.tex:D: ./xsource ${CPROPS:%=$CLIENT/%.hs}
	lua $prereq > $target

HOOPL=../src/Compiler/Hoopl

comb1.tex iterf.tex pairf.tex:D: ./xsource $HOOPL/Combinators.hs
	lua $prereq

dfoptdu.tex: fptype.tex bodyfun.tex block.tex

dfoptdu.tex: bodyfun.tex fptype.tex update.tex fpimp.tex txfb.tex

txfb.tex block.tex cat.tex bodyfun.tex update.tex fptype.tex fpimp.tex dg.tex node.tex:D: ./xsource $HOOPL/Dataflow.hs
	lua ./xsource -4 $HOOPL/Dataflow.hs
