LATEX::Makefile

From DiLab
Jump to: navigation, search
<nowiki>
  1. ------------------------------------------------------------------
  2. Makefile for latex papers (by Leo Selavo)
  3. Set BASE_NAME to the main file name (make, make final)
  4. Set FINAL_NAME to the checkpoint (final version) file name (make cp)
  5. Targets:
  6. make <dirname> - where <dirname> is the directory name where the source
  7. files are. Unless it is the current directory
  8. In addition, you must specify one real target goal:
  9. make final [dirname] - make the whole document (3+bib passes)
  10. make [dirname] - single pass make (no references guarranteed),
  11. for the quick sanity check
  12. make bib [dirname] - parse the bibliography list
  13. make a [dirname] - open the pdf doc in acroread
  14. make cp [dirname] - copy BASE_NAME.pdf to FINAL_NAME.pdf (checkpoint)
  15. make clean [dirname] - clean out old stuff, including the BASE_NAME.pdf
  16. make tidy [dirname] - clean out old stuff, keep the BASE_NAME.pdf
  17. make stat [dirname] - check file status (svn stat)
  18. make up [dirname] - update from svn (svn up)
  19. make ci [dirname] - check in to svn (svn ci)
  20. ------------------------------------------------------------------
  1. Main tex file name, also used as base name for the target pdf,
  2. and final name for the checkpoints

BASE_NAME = main FINAL_NAME = $(CURDIR)/final

  1. Script file name for viewing the pdf.
  2. This is useful to set as the run target in IDE. Run=>view.

VIEWPDF=viewpdf.sh

  1. Choose the latex tools (use xelatex for LV support)

PDFLATEX ?= pdflatex

  1. PDFLATEX ?= xelatex

BIBTEX ?= find ./ -maxdepth 2 -name '*.aux' -exec bibtex '{}' \;

  1. BIBTEX ?= bibtex $(BASE_NAME).aux


  1. Support tools
  2. ------------------------------------------------------------------

ECHO=@echo

  1. 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)

  1. ===== 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)

  1. ------------------------------------------------------------------

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)

  1. ------------------------------------------------------
  2. keep a checkpoint version of the pdf

cp: checkpoint

checkpoint: $(CDBASE); mv $(BASE_NAME).pdf $(FINAL_NAME).pdf

  1. svn update and checkin

up: $(CDBASE); $(SVN) up

ci: $(CDBASE); $(SVN) ci

stat: $(CDBASE); $(SVN) stat


  1. ------------------------------------------------------


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!"