Created
April 22, 2015 13:45
-
-
Save borntyping/05077df08ffb03aa7b96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pdflatex options: | |
# -shell-escape is used by the minted package to call pygments | |
# -interaction=nonstopmode stops pdflatex waiting for user input on errors | |
pdflatex = pdflatex -shell-escape -interaction=nonstopmode report.tex | |
pdflatex_warn = $(pdflatex) | grep Warning | grep -v 'float' | sed "s/^LaTeX / /" | |
pdflatex_error = $(pdflatex) | grep -e "^!" | sed "s/^! / Error: /" | |
pdflatex_quiet = $(pdflatex) >/dev/null | |
# Other tools | |
texcount = texcount -merge -template="{1}" report.tex | |
todos = ack TODO 1-preliminaries 2-chapters 3-appendixes extras | |
# Print a nicely formatted message | |
message = echo -e "\033[36m`date +%T` \033[0;34m$(1)\033[0m" | |
export SHELL:=/bin/bash | |
export SHELLOPTS:=pipefail | |
report: report.pdf report.txt | |
$(call message,"Report is up to date") | |
$(call message,"Wordcount: \\033[1\;35m`$(texcount)`") | |
$(texcount) > report.wc | |
$(todos) >/dev/null && $(call message,"TODO notes: \\033[1\;35m`$(todos) | wc -l`") | |
report.pdf: report.tex $(wildcard *-*/*.tex) $(wildcard examples/*) $(wildcard extras/*) extras/report.bib | |
$(call message,"Building $@") | |
$(call message,"Updated files $?") | |
$(call message,"Running pdflatex: $(pdflatex)") | |
$(pdflatex_warn) || $(pdflatex_error) || $(pdflatex) >Makefile.log 2>&1 | |
$(call message,"Running bibtex") | |
bibtex report.aux | grep Warning | sed "s/Warning--/ Warning: /" || : | |
$(call message,"Running makeglossaries") | |
makeglossaries -q report | |
$(call message,"Running pdflatex again") | |
$(pdflatex_quiet) | |
$(pdflatex_quiet) | |
$(call message,"Built $@") | |
report.txt: $(wildcard 2-chapters/*.tex) | |
$(call message,"Running pandoc") | |
pandoc -t plain $^ > $@ | |
extras/report.bib: extras/library.bib | |
sed s/abstract/annote/ $^ | tail -n +6 > $@ | |
clean: | |
rm report.{aux,bbl,blg,glg,glo,gls,lof,log,lol,lot,out,toc,xdy} texput.log | |
rm Makefile.log extras/glossary.aux extras/layout.aux | |
rm -r _minted-report | |
.PHONY: report clean | |
.SILENT: report report.pdf report.txt extras/report.bib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment