###############################################################################
#
# Based on Makefile for a sample CDF Note by
#                                  Stefan Stonjek  <s.stonjek@physics.ox.ac.uk>
#                                  Martin Hennecke <hennecke@fnal.gov> 
#
###############################################################################

graphics_eps := $(wildcard *.eps)
graphics_pdf := $(patsubst %.eps,%.pdf,$(wildcard figs/*.eps)) $(patsubst %.eps.gz,%.pdf,$(wildcard figs/*.eps.gz))

ps: RunIIa_Si_Performance_vs_Lumi.ps
	gv RunIIa_Si_Performance_vs_Lumi.ps

pdf: RunIIa_Si_Performance_vs_Lumi.pdf
	acroread RunIIa_Si_Performance_vs_Lumi.pdf

RunIIa_Si_Performance_vs_Lumi.pdf: RunIIa_Si_Performance_vs_Lumi.tex $(graphics_pdf)
	pdflatex RunIIa_Si_Performance_vs_Lumi.tex && thumbpdf RunIIa_Si_Performance_vs_Lumi && pdflatex RunIIa_Si_Performance_vs_Lumi.tex

RunIIa_Si_Performance_vs_Lumi.ps: RunIIa_Si_Performance_vs_Lumi.tex
	latex RunIIa_Si_Performance_vs_Lumi.tex && latex RunIIa_Si_Performance_vs_Lumi.tex && dvips RunIIa_Si_Performance_vs_Lumi.dvi -o 

%.pdf: %.eps
	epstopdf --outfile=$@ $< 

%.pdf: %.eps.gz
	gunzip $<
	epstopdf --outfile=$@ $(subst .gz,,$<)
	gzip --best $(subst .gz,,$<)

.PHONY: clean
clean: nearlyclean
	rm -r -f RunIIa_Si_Performance_vs_Lumi.pdf RunIIa_Si_Performance_vs_Lumi.ps

nearlyclean:
	rm -r -f RunIIa_Si_Performance_vs_Lumi.aux derivation.aux doubletag.aux RunIIa_Si_Performance_vs_Lumi.dvi RunIIa_Si_Performance_vs_Lumi.log RunIIa_Si_Performance_vs_Lumi.out \
	RunIIa_Si_Performance_vs_Lumi.toc RunIIa_Si_Performance_vs_Lumi.tof RunIIa_Si_Performance_vs_Lumi.bbl RunIIa_Si_Performance_vs_Lumi.blg RunIIa_Si_Performance_vs_Lumi.brf RunIIa_Si_Performance_vs_Lumi.fot \
        thumb*.* *~ $(graphics_pdf)
