Skip to content

Instantly share code, notes, and snippets.

@tachi-hi
Created August 20, 2012 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tachi-hi/3402572 to your computer and use it in GitHub Desktop.
Save tachi-hi/3402572 to your computer and use it in GitHub Desktop.
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