LATEX = latex
BIBTEX = bibtex
L2H = latex2html
PDFLATEX = ps2pdf
DVIPS = dvips

RERUN = "(There were undefined references|Rerun to get (cross-references|the bars) right)"
RERUNBIB = "No file.*\.bbl|Citation.*undefined"

GOALS = enonce.ps enonce.pdf
DVIFILES = enonce.dvi

main:		$(DVIFILES)

all:		$(GOALS)

%.dvi:		%.tex 
#		$(BIBTEX) $*
#		$(MAKE) $*.bbl
		$(LATEX) $<
		egrep -c $(RERUNBIB) $*.log && ($(BIBTEX) $*;$(LATEX) $<) ; true
		egrep $(RERUN) $*.log && $(LATEX) $< ; true
		egrep $(RERUN) $*.log && $(LATEX) $< ; true
# Display relevant warnings
		egrep -i "(Reference|Citation).*undefined" $*.log ; true


%.bbl:		%.tex *.bib
	 	$(LATEX) $*
		$(BIBTEX) $*

%.ps:		%.dvi
		dvips $< -o $@

%.pdf:		%.ps
	        $(PDFLATEX) $<

clean:		
		rm -f *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg  \
		*.inx *.ps *.dvi *.pdf *.toc *.out

