-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
113 lines (83 loc) · 2.88 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
108
109
110
111
112
113
TEX := uplatex
DVIPDFMX := dvipdfmx
BIB := upbibtex
MAIN := main
ABST := ISEE_abstract
AUTHOR_INFO := AuthorInfo
PRE := preamble
TEXS := $(wildcard *.tex)
TEXS := $(filter-out $(ABST).tex, $(TEXS))
DIFF := latexdiff-vc -e utf-8 --git --flatten -t CFONT --force
DIFFREV := HEAD
DIFFMAIN := $(MAIN)-diff$(DIFFREV)
BUILD_DIR := build
BST := jecon6.5.1_by_name.bst jecon6.5.1_by_number.bst
STYS := $(wildcard *.sty)
FIGS := $(wildcard fig/*)
PDFS := $(wildcard fig/*pdf)
PNGS := $(wildcard fig/*png)
FIGS := $(filter-out fig/*~, $(FIGS))
BIBS := $(wildcard *bib)
BBL := $(BUILD_DIR)/$(MAIN).bbl
DIFFBBL := $(BUILD_DIR)/$(DIFFMAIN).bbl
CWD := $(shell pwd)
.PHONY: all clean diff
all: $(MAIN).pdf $(ABST).pdf
# Avoid automatic deletion of intermidate files
.PRECIOUS: $(BUILD_DIR)/%.dvi
$(BUILD_DIR):
mkdir -p $@
$(BUILD_DIR)/%.aux: %.tex $(BUILD_DIR)
$(TEX) -output-directory=$(BUILD_DIR) $(MAIN)
$(BBL): $(BUILD_DIR)/$(MAIN).aux $(BIBS) $(BST)
# pbibtex in Tex Live 2019 (macOS) uses the current working directory for search path,
# but that in TeX Live 2018 (Linux) doesn't. So cd and BIBINPUTS/BSTINPUTS are needed.
cd $(BUILD_DIR);\
BIBINPUTS='$(CWD):${BIBINPUTS}' BSTINPUTS='$(CWD):${BSTINPUTS}' $(BIB) -terse $(MAIN);\
cd -
$(BUILD_DIR)/%.dvi: %.tex $(AUTHOR_INFO).tex $(PRE).tex $(STYS)
$(TEX) -output-directory=$(BUILD_DIR) $<
$(BUILD_DIR)/$(MAIN).dvi: $(TEXS) $(STYS) $(FIGS) $(BBL)
$(TEX) -output-directory=$(BUILD_DIR) $(MAIN)
if egrep 'No file $(BUILD_DIR)/$(MAIN).toc.' $(BUILD_DIR)/$(MAIN).log;\
then\
$(TEX) -output-directory=$(BUILD_DIR) $(MAIN);\
fi
if egrep 'LaTeX Warning: There were undefined references.' $(BUILD_DIR)/$(MAIN).log;\
then\
$(TEX) -output-directory=$(BUILD_DIR) $(MAIN);\
fi
if egrep 'There were undefined citations.' $(BUILD_DIR)/$(MAIN).log;\
then\
$(TEX) -output-directory=$(BUILD_DIR) $(MAIN);\
fi
%.pdf: $(BUILD_DIR)/%.dvi
$(DVIPDFMX) -o $@ $<
clean:
rm -rf $(BUILD_DIR)
rm -f $(DIFFMAIN).pdf $(DIFFMAIN).tex
rm -f *.pdf
# For latexdiff
diff: $(BUILD_DIR) $(DIFFMAIN).pdf
$(DIFFBBL): $(BUILD_DIR)/$(DIFFMAIN).aux $(BIBS) $(BST)
cd $(BUILD_DIR);\
BIBINPUTS='$(CWD):${BIBINPUTS}' BSTINPUTS='$(CWD):${BSTINPUTS}' $(BIB) -terse $(DIFFMAIN);\
cd -
$(DIFFMAIN).tex: $(TEXS)
$(DIFF) -r $(DIFFREV) $(MAIN).tex
$(BUILD_DIR)/$(DIFFMAIN).aux:
$(TEX) -output-directory=$(BUILD_DIR) $(DIFFMAIN)
$(BUILD_DIR)/$(DIFFMAIN).dvi: $(DIFFMAIN).tex $(STYS) $(FIGS) $(DIFFBBL)
$(TEX) -output-directory=$(BUILD_DIR) $(DIFFMAIN)
if egrep 'No file $(BUILD_DIR)/$(DIFFMAIN).toc.' $(BUILD_DIR)/$(DIFFMAIN).log;\
then\
$(TEX) -output-directory=$(BUILD_DIR) $(DIFFMAIN);\
fi
if egrep 'LaTeX Warning: There were undefined references.' $(BUILD_DIR)/$(DIFFMAIN).log;\
then\
$(TEX) -output-directory=$(BUILD_DIR) $(DIFFMAIN);\
fi
if egrep 'There were undefined citations.' $(BUILD_DIR)/$(DIFFMAIN).log;\
then\
$(TEX) -output-directory=$(BUILD_DIR) $(DIFFMAIN);\
fi