default-paper/Makefile

48 lines
1.6 KiB
Makefile

.PHONY: install_docker main clean redo test_git test_version versioned latexdiff check-common-typos
DOCKER_VERSION=latest
DOCKER=docker run -i --rm --name latex -v "$$PWD":/usr/src/app -w /usr/src/app texlive/texlive
LATEXMK=$(DOCKER) latexmk
XETEX=$(DOCKER) xetex
LATEXDIFFVC=$(DOCKER) latexdiff-vc
# keep as first command to build by default
main: main.tex main.bib
$(LATEXMK) -pdf -sy main.tex # use xelatex to build pdf
main-xe: main.tex main.bib
$(LATEXMK) -pdfxe main.tex
install_docker:
docker pull texlive/texlive:$(DOCKER_VERSION)
clean:
$(LATEXMK) -c
x=`biber --cache` && if [ -d "$x" ]; then $(RM) $x; fi
redo: clean main.pdf
test_git:
if [ -z "$$(git status --untracked-files=no --porcelain)" ]; then exit 0; else echo -e "\nERROR: working directory not clean. commit changes before running versioned build."; exit 1; fi
git remote update
if [ -z "$$(git status -uno | grep -q 'Your branch is up to date')" ]; then exit 0; else echo -e "\nERROR: not synced to remote. push changes before running a versioned build."; exit 1; fi
test_version:
rm -f .version_local
$(LATEXMK) --version > .version_local
$(XETEX) --version | head -1 >> .version_local
@if ! diff -b .version_local .version_repo; then echo -e "\nWARNING! local versions and remote versions do not match! (above is local, below is repo)"; else echo "versions match!"; fi
versioned: test_git clean main.pdf test_version
cp main.pdf "main-$$(date -u +'%Y-%m-%dT%H:%M:%SZ')-$$(git rev-parse --short HEAD).pdf"
# latexdiff: # TODO
# latexdiff-vc --pdf main.tex -r 123456 -r abcdef
# common typos check. find words, but ignore latex comment and macros
check-common-typos:
./typos.sh