aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 20462c23219f1b59bdbd1be5a0110fa71a192ff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
OUTDIR=out
OBJDIR=obj
SRCDIR=src

TARGETS:=$(patsubst %.org,%.pdf,$(wildcard ${SRCDIR}/*.org))
TARGETS:=$(subst ${SRCDIR},${OUTDIR},${TARGETS})

TEXFLAGS=-halt-on-error --output-directory=${OBJDIR}

.phony: all dir clean

all: ${TARGETS}

${OUTDIR}/%.pdf: ${OBJDIR}/%.tex
	TEXINPUTS=./${SRCDIR}:${TEXINPUTS} pdflatex ${TEXFLAGS} $<
	mv $(<:.tex=.pdf) $@

${OBJDIR}/%.tex: ${SRCDIR}/%.org dir
	emacs $< --batch --load=export.el -f org-latex-export-to-latex --kill
	mv $(<:.org=.tex) $@

dir:
	mkdir -p ${OUTDIR}
	mkdir -p ${OBJDIR}
	rm -f img
	ln -sfv ${SRCDIR}/img img

clean:
	rm -rf ${OBJDIR}
	rm -rf ${OUTDIR}
	rm -f img