#OPTIONEN:

#LaTeX befehl
LATEX = latex
BIBTEX = bibtex
INDEX = makeindex
INDEX_OPT = -o $(MAIN_FILE).ind $(MAIN_FILE).idx
#dvi viewer befehl
DVI_VIEWER = xdvi
#spellchecker befehl
SPELL = aspell
#spelchecker optionen
SPELL_OPT = --dont-backup --lang=de --mode=tex -c
#Gnuplot
GPLOT = gnuplot

#HILFS VARIABLEN
MAIN_FILE = theo_kurz
ALL_FILES = $(wildcard *.tex)
AUX = *.aux *.dvi *.log *.toc *.bak *.ind *.ilg  *.idx *.lof *.lot *.out *.bbl *.blg *~ *.thm

all:   tex 

build: spell tex view

tex:
	$(LATEX)  $(MAIN_FILE).tex
	@$(LATEX) $(MAIN_FILE).tex 2>&1 >> /dev/null 
	@$(LATEX) $(MAIN_FILE).tex 2>&1 >> /dev/null 
clean:
	@echo Cleaning up...
	-rm -f $(AUX)
view:
	$(DVI_VIEWER) theo_kurz

spell:
	@$(foreach file, $(ALL_FILES), $(SPELL) $(SPELL_OPT) $(file);) 

ps: tex
	dvips -GO -Ppdf -sPAPERSIZE=a4 theo_kurz.dvi

pdf: tex ps
	ps2pdf -dSubsetFonts=true -sPAPERSIZE=a4 theo_kurz.ps

help: 
	@echo "SYNOPSIS"
	@echo "	  make [target]"
	@echo ""
	@echo "TARGETS"
	@echo "   all*     compile the *.tex files to DVI and view the result"
	@echo "   build    spellcheck, compile to DVI and view"
	@echo "   dvi      compile to DVI"
	@echo "   view     view the DVI"
	@echo "   spell    spellcheck *.tex"
	@echo "   clear    remove all generated files"
	@echo ""
	@echo "*: default"
