# -*- Mode: Makefile -*-
#
# A makefile for LaTeX documents, including BibTeX bibliographies.
#
# Copyfnord (K) 3166, 3167, James A. Crippen <james@unlambda.com>

# This makefile can make LaTeX documents, including those with BibTeX
# bibliographies.  It can't do indexes yet unfortunately, nor can it do fancy
# things like different versions of a document (such as you might want for
# submission to different journals).  Perhaps such features will be added in
# the future (although they might be better handled with TeX macros).
#
# Nota Bene:
#   This depends heavily upon features of GNU Make.  If you don't have GNU
#   Make you should probably get it rather than hacking on this makefile.
#
# For any particular file FOO.tex you can use any of the following
#
#    make FOO.bbl
#    make FOO.dvi
#    make FOO.ps
#    make FOO.pdf
#
# to make that particular output file.  You can't make aux or toc files
# directly, though making a DVI will cause those files to be generated.
#
# To make PDF output you must have PDFLaTeX installed, as this makefile does
# not support conversion using, eg ps2pdf.

# You need to customize the SRCS variable below to point to the LaTeX source
# files (without extensions) for every LaTeX document to be generated.  If you
# have multifile documents you should probably be using LaTeX to manage the
# multiple files and not depend on make to get things right.
SRCS=lispref

  #
##### Commands.
  #

RM = /bin/rm -f

LATEX = /usr/bin/latex
PDFLATEX = /usr/bin/pdflatex
BIBTEX = /usr/bin/bibtex
DVIPS = /usr/bin/dvips

  #
##### Special rules.
  #

# Non-file rules.
.PHONY : texclean bibclean mostlyclean clean distclean

# Clear all suffix rules.
.SUFFIXES :

# Protect intermediate files from removal.
.PRECIOUS : %.dvi %.ps %.pdf

# The default target.
.DEFAULT : default

  #
##### Suffix rules.
  #

%.tex :

# Must run LaTeX once to get aux file.
%.bib :
	$(LATEX) $*
	$(if $(shell test -f $* && echo T),$(BIBTEX) $*)

%.dvi : %.bib
	$(LATEX) $*
	$(LATEX) $*

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

# PDFLaTeX doesn't need DVIs.
%.pdf : %.bib
	$(PDFLATEX) $*
	$(PDFLATEX) $*

  #
##### Default rule.  Like 'all'.
  #

default : $(SRCS:=.tex) $(SRCS:=.bib) $(SRCS:=.dvi)

  #
##### Cleansing rules.
  #

# Clean up TeX turds.
texclean :
	-$(RM) *.aux *.toc *.log

# Clean up BibTeX turds.
bibclean :
	-$(RM) *.bbl *.blg

mostlyclean : texclean bibclean

# Clean up generated docs.
clean : texclean bibclean
	-$(RM) *.dvi *.ps *.pdf

# Clean up other turds, like Emacs backups.
distclean : texclean bibclean clean
	-$(RM) *~

# 
# Here lie fnords.
# 
# Local Variables:
# compile-command: "make default"
# fill-column: 78
# End:
