LATEX::Makefile
<nowiki>
- ------------------------------------------------------------------
- Makefile for latex papers (by Leo Selavo)
- Set BASE_NAME to the main file name (make, make final)
- Set FINAL_NAME to the checkpoint (final version) file name (make cp)
- Targets:
- make <dirname> - where <dirname> is the directory name where the source
- files are. Unless it is the current directory
- In addition, you must specify one real target goal:
- make final [dirname] - make the whole document (3+bib passes)
- make [dirname] - single pass make (no references guarranteed),
- for the quick sanity check
- make bib [dirname] - parse the bibliography list
- make a [dirname] - open the pdf doc in acroread
- make cp [dirname] - copy BASE_NAME.pdf to FINAL_NAME.pdf (checkpoint)
- make clean [dirname] - clean out old stuff, including the BASE_NAME.pdf
- make tidy [dirname] - clean out old stuff, keep the BASE_NAME.pdf
- make stat [dirname] - check file status (svn stat)
- make up [dirname] - update from svn (svn up)
- make ci [dirname] - check in to svn (svn ci)
- ------------------------------------------------------------------
- Main tex file name, also used as base name for the target pdf,
- and final name for the checkpoints
BASE_NAME = main FINAL_NAME = $(CURDIR)/final
- Script file name for viewing the pdf.
- This is useful to set as the run target in IDE. Run=>view.
VIEWPDF=viewpdf.sh
- Choose the latex tools (use xelatex for LV support)
PDFLATEX ?= pdflatex
- PDFLATEX ?= xelatex
BIBTEX ?= find ./ -maxdepth 2 -name '*.aux' -exec bibtex '{}' \;
- BIBTEX ?= bibtex $(BASE_NAME).aux
- Support tools
- ------------------------------------------------------------------
ECHO=@echo
- SVN=svn
SVN=mysvn.sh
ROOT_DIR=. DIRLIST := ${shell find -L . -maxdepth 1 -mindepth 1 -type d -print} DIRS=$(DIRLIST:./%=%)
GOALS += $(MAKECMDGOALS) TARGETS = $(filter $(GOALS), $(DIRS)) TARGET = $(firstword $(TARGETS)) ifneq ("", "$(TARGET)")
BASE_DIR=./$(TARGET)
else
BASE_DIR=.
endif CDBASE=cd $(BASE_DIR)
- ===== Targets =====
all: pdf x: xpdf a: acroread
.PHONY: test $(DIRS)
test: $(ECHO) "DIRLIST:"$(DIRLIST) $(ECHO) "DIRS:"$(DIRS) $(ECHO) "TARGETS:"$(TARGETS) $(ECHO) "TARGET:"$(TARGET) $(ECHO) "BASE_DIR:"$(BASE_DIR) $(ECHO) "CDBASE:"$(CDBASE)
- ------------------------------------------------------------------
final: clean viewpdf $(ECHO) "========================================== First pass..." $(CDBASE); $(PDFLATEX) $(BASE_NAME).tex $(ECHO) "========================================== Second pass (bib)..." $(CDBASE); $(BIBTEX) $(ECHO) "========================================== Third pass..." $(CDBASE); $(PDFLATEX) $(BASE_NAME).tex $(ECHO) "========================================== Fourth pass..." $(CDBASE); $(PDFLATEX) $(BASE_NAME).tex
pdf: viewpdf $(CDBASE); $(PDFLATEX) $(BASE_NAME).tex
xpdf: $(CDBASE); evince $(BASE_NAME).pdf
acroread: $(CDBASE); acroread $(BASE_NAME).pdf
bib: $(CDBASE); $(BIBTEX)
index: $(CDBASE); makeindex $(BASE_NAME)
viewpdf: echo /usr/bin/acroread $(BASE_DIR)/$(BASE_NAME).pdf >$(VIEWPDF) chmod a+x $(VIEWPDF)
- ------------------------------------------------------
- keep a checkpoint version of the pdf
cp: checkpoint
checkpoint: $(CDBASE); mv $(BASE_NAME).pdf $(FINAL_NAME).pdf
- svn update and checkin
up: $(CDBASE); $(SVN) up
ci: $(CDBASE); $(SVN) ci
stat: $(CDBASE); $(SVN) stat
- ------------------------------------------------------
tidy:
$(CDBASE); rm -f *% *.aux *~ *.blg *.toc *.log $(BASE_NAME).idx
find $(BASE_DIR)/ -name *.synctex.gz | xargs /bin/rm -f
find $(BASE_DIR)/ -name *.aux | xargs /bin/rm -f
find $(BASE_DIR)/ -name *.out | xargs /bin/rm -f
find $(BASE_DIR)/ -name *.blg | xargs /bin/rm -f
find $(BASE_DIR)/ -name *~ | xargs /bin/rm -f
find $(BASE_DIR)/ -name '*.bbl' | xargs /bin/rm -f
clean: tidy $(CDBASE); rm -f $(BASE_NAME).pdf
cleanfinal: clean
cleanall: clean $(ECHO) "I feel so clean now... Thanks!"