# Makefile for compiling LaTeX.  By Jeff Vinocur.
# Last modified 30 October 2000
#
# This works provided the .tex file has the same name as the directory
# containing it.  To use another name, set the environment variable
# TEX-MAKEFILE-FILENAME to the filename minus the .tex part.
#
# In your directory, do `ln -s /wherever/this/file/is/Makefile` to
# make ./Makefile be a symlink, or copy it in if you prefer.
#
# Valid targets are:
# - "dvi", "ps", "pdf" - file formats, pdf requires ps, ps requires dvi
# - "world"            - an alias for "pdf"
# - "done"             - does "world" and then deletes the latex
#                        temporary files (.aux, .log)
# - "clean"            - deletes everything generated (.aux, .log,
#                        .dvi, .ps, .pdf)
# - "spell"            - runs ispell on the .tex file


ifdef TEX-MAKEFILE-FILENAME
  NAME=$(TEX-MAKEFILE-FILENAME)
else
  NAME=$(basename $(notdir $(PWD)))
endif


world: pdf
dvi: $(NAME).dvi
ps: $(NAME).ps
pdf: $(NAME).pdf


$(NAME).dvi: $(NAME).tex
	latex $(NAME).tex

$(NAME).ps: $(NAME).dvi
	dvips $(NAME).dvi -o $(NAME).ps

$(NAME).pdf: $(NAME).tex
	pdflatex $(NAME).tex

.PHONY: clean done notemp spell dvi ps pdf

spell:
	ispell $(NAME).tex

clean: notemp
	rm -f $(NAME).dvi $(NAME).ps $(NAME).pdf

done: world notemp

notemp:
	rm -f $(NAME).log $(NAME).aux
