Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
makefile for TeX (manual version management)
#
# makefile for TeX document whose version number is managed manually
# e.g.
# document_v1.tex document_v2.tex ...
#
LATEX = latex
BIBTEX = bibtex
DVIPDF = dvipdf
RM = rm -f
ASPELL = aspell -t -c --lang=en
VERSION = $(shell ls *.tex | sed -e 's/.*_v\([0-9]*\).*/\1/g' | sort -n | tail -n 1)
TEXFILE = $(shell ls *_v$(VERSION).tex)
FILE = $(TEXFILE:%.tex=%)
DVIFILE = $(TEXFILE:%.tex=%.dvi)
PDFFILE = $(TEXFILE:%.tex=%.pdf)
BIBFILE = $(shell ls *.bib)
EPS = $(shell ls *.eps)
all: $(DVIFILE)
$(DVIFILE): $(TEXFILE) $(BIBFILE) $(EPS)
@$(RM) *.bbl
$(LATEX) ${TEXFILE} > /dev/null
$(BIBTEX) ${FILE}
$(LATEX) ${TEXFILE} > /dev/null
$(LATEX) ${TEXFILE}
@$(RM) *.aux *.log
pdf: $(PDFFILE)
$(PDFFILE): $(DVIFILE)
$(DVIPDF) $(FILE)
aspell:
$(ASPELL) $(TEXFILE)
.PHONY: clean
clean:
$(RM) *.aux *.toc *.lot *.log *.bbl *.blg *.pbm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment