# Programmierung
# Makefile fr das Skript
# based on work by
# Marco Kuhlmann <kuhlmann@ps.uni-sb.de>

SHELL = /bin/sh

# Benutzte Programme

BIBTEX		:= bibtex
DVIPS		:= dvips -Pwww -z
LATEX		:= latex
MAKEINDEX       := makeindex

PS2PDF		:= ps2pdf14 -sPAPERSIZE=a4
FIG2EPS         := fig2dev -L eps

master		:= diplomarbeit
FIGS            := jvm.fig scheduler.fig \
			jvm-seam.fig \
			execution_model_seam.fig \
			stack-frame.fig \
			object-layout.fig \
			seam.fig \
			kaffe-abstraction.fig \
			implementierung.fig
topdir		:= .


default: all

# Bibliografie und Index

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

%.ind: %.idx
	@$(MAKEINDEX) $*


# Erzeugung der grafischen Dateien

%_fig.eps: %.fig
	$(FIG2EPS) $< $@

%.dvi: %.tex
	$(LATEX) $<

%.ps: %.dvi
	$(DVIPS) -o $@ $<

%.pdf: %.ps
	$(PS2PDF) $< $@


# Stabilisierung der Querverweise etc.

stable-latex: latex $(master).bbl #$(master).ind
	while egrep -q -s '((Citation|Reference).*undefined)|Rerun to get cross-references right.' $(master).log ; \
	do $(MAKE) latex ; \
	done

stable: stable-latex ps pdf

latex: $(FIGS:.fig=_fig.eps)
	$(LATEX) $(master).tex

# High-Level-Regeln

.PHONY : stable-latex stable all bib index ps pdf clean distclean

all: latex ps pdf

bib: $(master).bbl

index: $(master).ind

pdf: $(master).pdf

ps: $(master).ps

# Zum Schluss: Aufrumen nicht vergessen

clean:
	rm -f *~ *.*~ *.aux *.bbl *.blg *.dvi *.idx *.ilg *.ind \
	*.log *.out *.sol *.toc *.tmp

clean-images:
	rm -f $(FIGS:.fig=_fig.eps)

distclean: clean clean-images
	rm -f *.ps *.pdf
