forked from BITNP/BIThesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (83 loc) · 3.09 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 以下命令仅保证能在 Linux 或 MacOS 环境下执行。
# 如果你是 Windows 用户,可以使用 Git Bash 或者 Cygwin 来执行;
# 或者可以考虑将此脚本移植为 PowerShell。
PACKAGE = bithesis
LATEX = xelatex
SOURCES = $(PACKAGE).ins $(PACKAGE).dtx
CLSFILE = dtx-style.sty bitreport.cls bithesis.cls bitbeamer.cls
LATEXMK = latexmk
SCAFFOLDDIR = ./templates
TESTDIR = ./tests
EXAMPLEDIR = ./examples
ifeq ($(OS), Windows_NT)
REGRESSION_TEST_COMMAND=pwsh ./scripts/regression-testing.ps1
else
REGRESSION_TEST_COMMAND=zsh ./scripts/regression-testing.zsh
endif
.PHONY: all cls doc clean FORCE_MAKE copy
$(PACKAGE).pdf: cls FORCE_MAKE
@$(LATEXMK) -xelatex $(PACKAGE).dtx
$(CLSFILE): $(SOURCES)
yes y | xetex $(PACKAGE).ins
cls: $(CLSFILE)
doc: $(PACKAGE).pdf
viewdoc: doc
$(LATEXMK) -pv $(PACKAGE).dtx
clean:
$(LATEXMK) -c $(PACKAGE).dtx
-rm -rf *.glo $(CLSFILE)
clean-dist:
-rm -rf $(PACKAGE).pdf
clean-all: clean clean-dist FORCE_MAKE
test: doc copy FORCE_MAKE
cd $(SCAFFOLDDIR)/undergraduate-thesis && latexmk && cd ..
cd $(SCAFFOLDDIR)/paper-translation && latexmk && cd ..
cd $(SCAFFOLDDIR)/undergraduate-thesis-en && latexmk && cd ..
cd $(SCAFFOLDDIR)/graduate-thesis && latexmk && cd ..
cd $(SCAFFOLDDIR)/lab-report && latexmk && cd ..
cd $(SCAFFOLDDIR)/presentation-slide && latexmk && cd ..
cd $(TESTDIR)/doctor-thesis && latexmk && cd ..
cd $(TESTDIR)/autorefs && latexmk && cd ..
regression-test: cls
$(REGRESSION_TEST_COMMAND)
copy: cls
cp bithesis.cls $(SCAFFOLDDIR)/undergraduate-thesis
cp bithesis.cls $(SCAFFOLDDIR)/undergraduate-thesis-en
cp bithesis.cls $(SCAFFOLDDIR)/paper-translation
cp bithesis.cls $(SCAFFOLDDIR)/graduate-thesis
cp bithesis.cls $(TESTDIR)/doctor-thesis
cp bithesis.cls $(TESTDIR)/autorefs
cp bitreport.cls $(SCAFFOLDDIR)/lab-report
cp bitbeamer.cls $(SCAFFOLDDIR)/presentation-slide
# Generate scaffolds for overleaf
overleaf: doc FORCE_MAKE
# if $version is not specified, alert the user.
@if [ -z "$$version" ]; then \
echo -e "\e[32mPlease specify the version of the template you want to generate.\e[0m"; \
echo -e "\e[32mFor example: make overleaf version=1.0.0\e[0m"; \
exit 1; \
fi
git clean -fdx ./templates/
rm -rf overleaf
make copy
mkdir overleaf
ls templates | \
xargs -I {} bash -c \
"cp -r ./templates/{} overleaf && cp $(PACKAGE).pdf ./overleaf/{} && zip -r ./overleaf/BIThesis-{}-v$(version).zip ./overleaf/{}"
dev:
ls bithesis.dtx | entr -s 'yes y | make doc && make copy'
dev-doc:
ls bithesis.dtx | entr -s 'make clean-all && yes y | make doc && open bithesis.pdf'
pkg: doc
rm -rf ./bithesis ./bithesis.zip
mkdir bithesis
cp bithesis.{ins,dtx,pdf} ./README*.md ./contributing*.md ./bithesis
mv ./bithesis/README-bithesis.md ./bithesis/README.md
zip -r bithesis.zip bithesis
examples: cls
cp bithesis.cls $(EXAMPLEDIR)/cover/
cp bithesis.cls $(EXAMPLEDIR)/publications/
cd $(EXAMPLEDIR)/cover && latexmk && cd -
cd $(EXAMPLEDIR)/publications && latexmk && cd -
check-cls: copy
git status --porcelain | (! grep -q .) || (echo "Please execute \`make copy\` to update the *.cls in each templates."; exit 1)