forked from cirosantilli/linux-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·50 lines (36 loc) · 1.16 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
#compiles all .md files in current directory into pdf and html.
#can mkdir and output that dir.
CC_LATEX ?= rst2latex.py
CC_HTML ?= rst2html.py --math-output=MathML
ID ?=
IN_EXT ?= .rst
OUT_DIR ?= _out/
RUN_NOEXT ?= a #basename without extension of file to view (with firefox, okular, etc.)
SRCS := $(wildcard *$(IN_EXT))
OUTEXT := .html
OUT_HTML := $(patsubst %$(IN_EXT),$(OUT_DIR)%$(OUTEXT),$(SRCS))
OUTEXT := .pdf
OUT_PDF := $(patsubst %$(IN_EXT),$(OUT_DIR)%$(OUTEXT),$(SRCS))
.PHONY: all mkdir html pdf firefox okular clean
all: html pdf
mkdir:
mkdir -p $(OUT_DIR)
html: mkdir $(OUT_HTML)
pdf: mkdir $(OUT_PDF)
firefox:
firefox "$(OUT_DIR)$(RUN_NOEXT).html$(ID)"
okular:
nohup okular --unique "$(OUT_DIR)$(RUN_NOEXT).pdf" >/dev/null &
$(OUT_DIR)%.html: %$(IN_EXT)
$(CC_HTML) $< $@
$(OUT_DIR)%.pdf: %$(IN_EXT)
$(CC_LATEX) $< $(OUT_DIR)$*.tex
( \
cd $(OUT_DIR) ;\
pdflatex -interaction=nonstopmode "$*".tex ;\
-bibtex "$*" ;\
pdflatex -interaction=nonstopmode "$*".tex ;\
pdflatex -interaction=nonstopmode -synctex=1 "$*".tex ;\
)
clean:
rm -r "$(OUT_DIR)"