-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
49 lines (38 loc) · 1.19 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
TARGET = rec3d
PANDOC = pandoc
GITBOOK = gitbook
OPTS = --mathjax --template=template.html
BIB = bibtex
BIBFILE = thesis.bib
BIBSTYLE = cad.csl
BIBOPTS = --biblio $(BIBFILE) -cls $(BIBSTYLE)
SERVER = 157.88.193.20
USER = fradelg
LOCALDIR = _book
FIGUREDIR = figures
REMOTEDIR = /home/fradelg/www/phd
SRC = $(shell find . -type f -name '*.md')
HTML1 = $(filter-out ./README.md, $(SRC))
HTML2 = $(filter-out ./SUMMARY.md, $(HTML1))
HTML = $(patsubst %.md, %.html, $(HTML2))
.PHONY: all
all: book $(HTML)
book: $(SRC)
$(GITBOOK) build
$(TARGET).pdf: $(SOURCES)
$(PANDOC) $(OPTS) $(BIBOPTS) -o $(TARGET).pdf $(SOURCES)
$(TARGET).html: $(SOURCES)
$(PANDOC) $(OPTS) $(BIBOPTS) -o $(TARGET).html $(SOURCES)
$(TARGET).epub: $(SOURCES)
$(PANDOC) $(OPTS) $(BIBOPTS) -o $(TARGET).epub $(SOURCES)
%.html: %.md
@echo "Pandoc building for file $<"
@$(PANDOC) $(OPTS) $(BIBOPTS) -o tmp.html $<
@tail -n +371 tmp.html > tail.html
@sed -i -ne '/<section/ {p; r tail.html' -e ':a; n; /<\/section>/ {p; b}; ba}; p' _book/$@
@rm tail.html tmp.html
clean:
rm -f $(LOCALDIR)
upload:
rsync -rvzhe ssh $(LOCALDIR) $(USER)@$(SERVER):$(REMOTEDIR)
# rsync -rvzhe ssh $(FIGUREDIR) $(USER)@$(SERVER):$(REMOTEDIR)/figures/