forked from gjulianm/mtheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (62 loc) · 2.46 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
MAKEFLAGS := -j 1
INS = source/beamerthememetropolis.ins
PACKAGE_SRC = $(wildcard source/*.dtx)
PACKAGE_STY = $(notdir $(PACKAGE_SRC:%.dtx=%.sty))
DEMO_SRC = demo/demo.tex demo/demo.bib
DEMO_PDF = demo/demo.pdf
DOC_SRC = doc/metropolistheme.dtx
DOC_PDF = doc/metropolistheme.pdf
IMG = $(wildcard img/*.png)
IMG += $(wildcard img/*.eps)
CTAN_CONTENT = README.md $(INS) $(PACKAGE_SRC) $(DOC_SRC) $(DOC_PDF) $(DEMO_SRC) $(DEMO_PDF)
DESTDIR ?= $(shell kpsewhich -var-value=TEXMFHOME)
INSTALL_DIR = $(DESTDIR)/tex/latex/metropolis
DOC_DIR = $(DESTDIR)/doc/latex/metropolis
CACHE_DIR := $(shell pwd)/.latex-cache
COMPILE_TEX := latexmk -xelatex -output-directory=$(CACHE_DIR)
export TEXINPUTS:=$(shell pwd):$(shell pwd)/source:${TEXINPUTS}
DOCKER_IMAGE = latex-image
DOCKER_CONTAINER = latex-container
.PHONY: all sty doc demo clean install uninstall ctan clean-cache clean-sty ctan-version docker-run docker-build docker-rm
all: sty doc
sty: $(PACKAGE_STY)
doc: $(DOC_PDF)
demo: $(DEMO_PDF)
clean: clean-cache clean-sty
install: $(PACKAGE_STY) $(DOC_PDF) $(IMG)
@mkdir -p $(INSTALL_DIR)
@cp $(PACKAGE_STY) $(INSTALL_DIR)
@mkdir -p $(DOC_DIR)
@cp $(DOC_PDF) $(DOC_DIR)
@cp $(IMG) $(INSTALL_DIR)
@texhash
uninstall:
@rm -f "$(addprefix $(INSTALL_DIR)/, $(PACKAGE_STY))"
@rmdir "$(INSTALL_DIR)"
@rm -f "$(DOC_DIR)/$(notdir $(DOC_PDF))"
@rmdir "$(DOC_DIR)"
clean-cache:
@rm -rf "$(CACHE_DIR)"
clean-sty:
@rm -f $(PACKAGE_STY)
ctan: $(CTAN_CONTENT) ctan-version
@tar --transform "s@\(.*\)@metropolis/\1@" -cf metropolis-$(shell date "+%Y-%m-%d").tar.gz $(CTAN_CONTENT)
ctan-version:
@sed -i 's@20[0-9][0-9]/[0-9]*/[0-9]*@$(shell date "+%Y/%m/%d")@' $(PACKAGE_SRC)
$(CACHE_DIR):
@mkdir -p $(CACHE_DIR)
$(PACKAGE_STY): $(PACKAGE_SRC) $(INS) | clean-cache $(CACHE_DIR)
@cd $(dir $(INS)) && latex -output-directory=$(CACHE_DIR) $(notdir $(INS))
@cp $(addprefix $(CACHE_DIR)/,$(PACKAGE_STY)) .
$(DOC_PDF): $(DOC_SRC) $(PACKAGE_STY) | clean-cache $(CACHE_DIR)
@cd $(dir $(DOC_SRC)) && $(COMPILE_TEX) $(notdir $(DOC_SRC))
@cp $(CACHE_DIR)/$(notdir $(DOC_PDF)) $(DOC_PDF)
$(DEMO_PDF): $(DEMO_SRC) $(PACKAGE_STY) | clean-cache $(CACHE_DIR)
@cd demo && $(COMPILE_TEX) $(notdir $(DEMO_SRC))
@cp $(CACHE_DIR)/$(notdir $(DEMO_PDF)) $(DEMO_PDF)
docker-run: docker-build
docker run --rm=true --name $(DOCKER_CONTAINER) -i -t -v `pwd`:/data $(DOCKER_IMAGE) make
docker-build:
docker build -t $(DOCKER_IMAGE) docker
docker-rm:
docker rm $(DOCKER_CONTAINER)