################################################
# General purpose Makefile for LaTeX-Documents #
#                                              #
# originally by:			       #
# (c) Daniel Ciaglia 2003                      #
# contact: daniel@sigterm.de                   #
#                                              #
# modified a fair bit by:
# John Rieffel
# contact: john -at- rieffel.com
# You (may) need:                              #
#    latex2html  http://www.latex2html.org/    #
#    dvipdf     			       # 
################################################


##### Variables #############
#############################

# Basename for result
#insert your own here - jr
TARGET=thesis

# insert your own sources here
# Sources
SRC=thesis.tex


# ATTENTION!
# File-extensions to delete recursive from here
EXTENSION=aux toc idx ind ilg log out lof lot lol bbl blg

#############################
#############################

##### Targets ###############
#############################


# PortableDocumentFormat
${TARGET}.pdf: ${SRC}
	echo "Running latex..."
	pdflatex ${TARGET}
	echo "Running bibtex..."
	bibtex -min-crossrefs=200 ${TARGET} 
	echo "Rerunning latex...."
	pdflatex ${TARGET}
	pdflatex ${TARGET}

#	pdflatex_count=5 ; \
#	while egrep -s 'Rerun (LaTeX|to get cross-references right)' $*.log && [ $$pdflatex_count -gt 0 ] ;\
#	    do \
#	      echo "Rerunning latex...." ;\
#	      pdflatex ${TARGET}
#	      pdflatex_count=`expr $$pdflatex_count - 1` ;\
#	    done

# Clean
clean:
	for EXT in ${EXTENSION}; \
	do \
	find `pwd` -name \*\.$${EXT} -exec rm -v \{\} \; ;\
	done
	rm -f ${TARGET}.dvi
	rm -f ${TARGET}.pdf
	rm -f www/*\.*
	rm -f *~
	rm -f *.dvi

thesis: ${TARGET} 


