-
Notifications
You must be signed in to change notification settings - Fork 51
/
Makefile
84 lines (61 loc) · 2 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
# Makefile for SUSTechThesis
PACKAGE = sustechthesis
THESIS = sustechthesis-example
REPORT = sustechthesis-example-report
SOURCES = $(PACKAGE).ins $(PACKAGE).dtx
CLSFILE = dtx-style.sty $(PACKAGE).cls
LATEXMK = latexmk
SHELL := /bin/bash
WORDCOUNTLOG = wordcount.txt
# make deletion work on Windows
ifdef SystemRoot
RM = del /Q
else
RM = rm -f
endif
.PHONY: all all-dev clean cleanall thesis viewthesis report viewreport dist dist-github doc viewdoc cls test wordcount FORCE_MAKE
thesis: $(THESIS).pdf
report: $(REPORT).pdf
all: thesis
all-dev: doc all
cls: $(CLSFILE)
$(CLSFILE): $(SOURCES)
xetex $(PACKAGE).ins
doc: $(PACKAGE).pdf
dist-github: doc thesis test clean
dist: dist-github
rm -rf dist/
mkdir -p dist/
zip -r dist/sustech-thesis-dev-build.zip . -x *.git* /*node_modules/* .editorconfig *dist/*
$(PACKAGE).pdf: cls FORCE_MAKE
$(LATEXMK) $(PACKAGE).dtx
$(THESIS).pdf: cls FORCE_MAKE
$(LATEXMK) $(THESIS)
$(REPORT).pdf: cls FORCE_MAKE
$(LATEXMK) $(REPORT)
viewdoc: doc
$(LATEXMK) -pv $(PACKAGE).dtx
viewthesis: thesis
$(LATEXMK) -pv $(THESIS)
viewreport: report
$(LATEXMK) -pv $(REPORT)
test: cls FORCE_MAKE
bash test/test.sh
clean:
$(LATEXMK) -c $(PACKAGE).dtx $(THESIS) $(REPORT)
-@$(RM) -rf *.aux *.bbl *.blg
-@$(RM) -rf _minted-*
-@$(RM) -rf *~ *_markdown_* *.markdown.*
cleanall: clean
-@$(RM) $(CLSFILE)
-@$(RM) -rf public-test dist
-@$(RM) $(PACKAGE).pdf $(THESIS).pdf $(REPORT).pdf
wordcount : $(THESIS).tex
@echo '************ Word count ************' | tee -a $(WORDCOUNTLOG)
@date +"%Y-%m-%d %H:%M:%S" | tee -a $(WORDCOUNTLOG)
@if grep -v ^% $< | grep -q '\\documentclass\[[^\[]*english'; then \
texcount $< -inc -char-only | awk '/total/ {getline; print "英文字符数\t\t\t:",$$4}' | tee -a $(WORDCOUNTLOG); \
else \
texcount $< -inc -ch-only | awk '/total/ {getline; print "纯中文字数\t\t\t:",$$4}' | tee -a $(WORDCOUNTLOG); \
fi
@texcount $< -inc -chinese | awk '/total/ {getline; print "总字数(英文单词 + 中文字)\t:",$$4}' | tee -a $(WORDCOUNTLOG)