#
# Makefile to latex document, uncompress .ps files etc...
# original version : Mark Ito
# modified:
#
#     use for hadron05 paper - Elton Smith 9/30/03
#     html output de-activated for now
#     halld_safety - Elton Smith 10/16/06
#     cc_geometry - Elton Smith 10/16/06
#     bcal_specs - Elton Smith 04/02/07
#     halld_specs - Elton Smith 08/27/07
#     feldman_cousins - Elton Smith 09/17/07
#     feldman_cousins systematics  - Elton Smith 08/05/08
#     cdc_segments  - Elton Smith 09/31/08
#     gen_pulse  - Elton Smith 09/31/08
#     gen_pulse  - Elton Smith 04/24/09
#
#
TEX_FILES_0 = gen_pulse

TEX_FILES = $(addsuffix .tex,$(TEX_FILES_0)) # add .tex suffix

PS_FILES_0 = 
PS_FILES = $(addsuffix .ps,$(PS_FILES_0)) # add .ps suffix

EPS_FILES_0 = gen_pulse_1000MeV_lin gen_pulse_1000MeV_log \
              sensl_pulse_1000MeV_save hamamatsu_pulse_1000MeV_save apd_pulse_1000MeV_save \
              small_pulse_c1_556_3 small_pulse_c2_556_3  small_pulse_c3_556_3 small_pulse_c4_556_3 \
              small_pulse_c1_835_3 small_pulse_c2_835_3 small_pulse_c3_835_3 small_pulse_c4_835_3 \
              small_pulse_c1_835_8 small_pulse_c2_835_8 small_pulse_c3_835_8 small_pulse_c4_835_8 

EPS_FILES = $(addsuffix .eps,$(EPS_FILES_0)) # add .eps suffix

all : gen_pulse.ps

gen_pulse.dvi : $(TEX_FILES) Makefile gen_pulse.bbl $(PS_FILES) \
               $(EPS_FILES)                      # make the dvi file
	latex gen_pulse
	latex gen_pulse

gen_pulse.bbl : gen_pulse.bib $(TEX_FILES) $(PS_FILES) $(EPS_FILES)
	latex gen_pulse
	bibtex gen_pulse

tar : $(TEX_FILES) $(PS_FILES) $(EPS_FILES) # tar files; will remove old tar files
	rm -f gen_pulse.tar
	rm -f gen_pulse.tar.gz
	rm -rf gen_pulse
	mkdir gen_pulse
	cp gen_pulse.ps gen_pulse
	cp gen_pulse.bib gen_pulse
	cp $(TEX_FILES) gen_pulse
	cp $(EPS_FILES) gen_pulse
#	cp $(PS_FILES) gen_pulse
	cp gen_pulse.C gen_pulse
	cp sensl_pulse.C gen_pulse
	cp hamamatsu_pulse.C gen_pulse
	cp apd_pulse.C gen_pulse
	cp gen_pulse.pdf gen_pulse
	cp Makefile gen_pulse
	tar cvf gen_pulse.tar gen_pulse
	gzip gen_pulse.tar
#	rm -rf gen_pulse

%.ps : %.dvi
	dvips -t letter -o $*.ps $* 
	dvipdf $*.dvi $*.pdf


%.dvi : %.tex
	latex $*
	latex $*

%.ps : %.ps.gz
	gunzip -l $*.ps.gz
	rm -f $*.ps
	gunzip -c $*.ps.gz > $*.ps

%.eps : %.eps.gz
	gunzip -l $*.eps.gz
	rm -f $*.eps
	gunzip -c $*.eps.gz > $*.eps

#
#
% : %.dvi
#	'rm' -rf $*
#	latex2html $*      # produce html pages

clean:
	rm -f gen_pulse.dvi gen_pulse.ps