-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (43 loc) · 1.25 KB
/
Makefile
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
VERSION := 1.0
GIT_COMMIT := $(shell git rev-parse HEAD)
DOC_NAME := example-john-doe
OUT_DIR := out
SKIP_DOCKER := false
ifneq ($(SKIP_DOCKER),true)
DOCKER_IMAGE := local/pdflatex
DOCKER_ARGS ?= -v "$(PWD)":/opt/latex -w /opt/latex
PDFLATEX = docker run --rm --user $(shell id -u):$(shell id -g) \
$(DOCKER_ARGS) $(DOCKER_IMAGE) pdflatex
else
PDFLATEX := pdflatex
endif
.PHONY: help
help:
@echo
@echo 'Usage:'
@echo ' make pdf Build the pdf.'
@echo ' make package Build docker image with LaTex packages inside.'
@echo ' make clean Clean the directory tree.'
@echo
.PHONY: package
package:
@echo "building image $(VERSION) $(GIT_COMMIT)"
@docker build --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) \
-t $(DOCKER_IMAGE) .
define pdflatex
@mkdir -p ${OUT_DIR}
${PDFLATEX} $2 -synctex=1 -shell-escape -interaction=nonstopmode \
-file-line-error -output-directory=${OUT_DIR} "$1" >/dev/null
endef
.PRECIOUS: ${OUT_DIR}/%.aux
${OUT_DIR}/%.aux: %.tex
@echo "building $@"
$(call pdflatex,$<,-draftmode)
${OUT_DIR}/%.pdf: %.tex ${OUT_DIR}/%.aux
@echo "building $@"
$(call pdflatex,$<)
.PHONY: pdf
pdf: ${OUT_DIR}/${DOC_NAME}.pdf
.PHONY: clean
clean:
@test ! -e $(OUT_DIR) || rm -rf $(OUT_DIR)