Skip to content

Instantly share code, notes, and snippets.

@Deraen
Last active January 10, 2016 16:23
Show Gist options
  • Save Deraen/22ba548acec9dfba1fd8 to your computer and use it in GitHub Desktop.
Save Deraen/22ba548acec9dfba1fd8 to your computer and use it in GitHub Desktop.
Makefile and watch script for LaTeX thesis
cc=pdflatex -halt-on-error -output-directory=temp -shell-escape
bb=biber -q
pandoc=pandoc --highlight-style pygments
MDS=$(wildcard md/*.md)
MDTEXS=$(MDS:.md=.tex)
IMGS=$(wildcard kuvat/*.svg)
IMGPDFS=$(IMGS:.svg=.pdf)
output=dippa.pdf
all: $(output)
.PHONY: clean
clean:
rm -rf dippa.pdf temp
rm $(IMGPDFS)
rm $(MDTEXS)
temp:
mkdir -p temp
kuvat: $(IMGPDFS)
mds: $(MDTEXS)
$(output): dippa.tex tex/*.tex temp kuvat mds
$(cc) dippa
$(bb) temp/dippa
$(cc) dippa
md/%.tex: md/%.md
$(pandoc) $< -f markdown -t latex -o $@
# FIXME:
kuvat/%.pdf: kuvat/%.svg
inkscape -D -z --file=$(abspath kuvat/grid.svg) --export-pdf=$(abspath kuvat/grid.pdf)
#!/bin/bash
WATCH_PATHS="./kuvat ./tex ./Lahdeluettelo.bib"
if command -v fswatch >/dev/null 2>&1 || true; then
# OS X
WAIT="fswatch -1 -r"
else
WAIT="inotifywait -q -r -e modify"
fi
make -s
while true; do
$WAIT $WATCH_PATHS
make -s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment