LATEX=latex
BIBTEX=bibtex
PDFLATEX=pdflatex
DVIPS=dvips
GZIP=gzip
PDFTOPS=pdftops

SOURCES=$(wildcard *.tex)
DVIFILES=$(addsuffix .dvi, $(basename $(SOURCES)))
PSFILES=$(addsuffix .ps, $(basename $(SOURCES)))
GZFILES=$(addsuffix .gz, $(SOURCES) $(DVIFILES) $(PSFILES))
TARGETS=$(DVIFILES) $(PSFILES) $(GZFILES)

TEXTINPUTS =.:/asm/home/caiwei/Tex/E02_revtex31/:

.PHONY:default all path clean

default:prompt path

all:$(DVIFILES) $(PSFILES)

#%.dvi:%.tex
#	$(LATEX) $(basename $<)
#	$(BIBTEX) $(basename $<)
#	$(LATEX) $(basename $<)
#	$(LATEX) $(basename $<)
#
#%.pdf:%.tex
#	$(LATEX) $(basename $<)
#	$(BIBTEX) $(basename $<)
#	$(PDFLATEX) $(basename $<)
#	$(PDFLATEX) $(basename $<)
#
#%.ps:%.pdf
#	$(PDFTOPS) $< $@
#
%.dvi:%.tex
	$(LATEX) $(basename $<)
	$(LATEX) $(basename $<)

%.pdf:%.tex
	$(PDFLATEX) $(basename $<)
	$(PDFLATEX) $(basename $<)

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

%.gz:%
	$(GZIP) -c $< > $@ 
clean:
	@echo rm -f \(EVERYTHING\)
	@rm -rf $(TARGETS) *.toc *.aux *.dvi *.log *.bbl *.blg *.lot *.lof

path:
	@echo Have you set the following [31mpath?[0m
	@echo setenv [36mTEXINPUTS[0m $(TEXTINPUTS)
#/afs/athena/contrib/consult/lib/tex/macros

prompt:
	@echo You can make
	@echo [36mfilename.dvi[0m or [36mfilename.ps[0m or [36mall[0m or [36mclean[0m
