forked from Zyranix/ADM2-Lecture-Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
148 lines (116 loc) · 4.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
TEXINPUTS=LatexPackagesBuild//:
### Compilation of the document
# Compiles the full document, assuming gnuplots already exist
full: full.gnuplots
@TEXINPUTS=${TEXINPUTS} latexmk -pdf -dvi- -latexoption=-interaction=nonstopmode full.tex
# Compiles the master document, assuming gnuplots already exist
master: master.gnuplots
@TEXINPUTS=${TEXINPUTS} latexmk -pdf -dvi- -latexoption=-interaction=nonstopmode master.tex
# Runs pdflatex on the full document
full-pdflatex: full.gnuplots
@TEXINPUTS=${TEXINPUTS} pdflatex -interaction=nonstopmode full.tex
# Runs pdflatex on the master document
master-pdflatex: master.gnuplots
@TEXINPUTS=${TEXINPUTS} pdflatex -interaction=nonstopmode master.tex
# Compiles the full document, as well as re-computing the gnuplots.
full-with-gnuplots: gnuplots-full
@make full-pdflatex # This ensures re-compilation for the gnuplots
@make full # Latexmk now takes care of biber etc (possibly no further runs are required)
# Compiles the master document, as well as re-computing the gnuplots.
master-with-gnuplots: gnuplots-master
@make master-pdflatex
@make master
#### Clean targets
clean: clean-master clean-full
clean-master:
@ls | sed -n 's/^\(master\..*\)$$/\1/p' | sed -e '/master.tex/d' | sed -e '/master.gnuplots/d' | xargs --no-run-if-empty rm
clean-full:
@ls | sed -n 's/^\(full\..*\)$$/\1/p' | sed -e '/full.tex/d' | sed -e '/full.gnuplots/d' | sed -e '/full.cnt/d' | xargs --no-run-if-empty rm
#### Gnuplot-related targets
# Creates the folder for gnuplots of full document
full.gnuplots:
@mkdir full.gnuplots
# Creates the folder for gnuplots of master document
master.gnuplots:
@mkdir master.gnuplots
# Runs gnuplot on the gnuplot files of full document
compile-gnuplots-full: full.gnuplots
@echo "[Make] Running gnuplot in full.gnuplots directory..."
@for f in full.gnuplots/*.gnuplot ; do [ -f "$$f" ] || continue; gnuplot "$$f"; done
# Runs gnuplot on the gnuplot files of master document
compile-gnuplots-master: master.gnuplots
@echo "[Make] Running gnuplot in master.gnuplots directory..."
@for f in master.gnuplots/*.gnuplot ; do [ -f "$$f" ] || continue; gnuplot "$$f"; done
# Runs gnuplot on all gnuplot files
compile-gnuplots: compile-gnuplots-full compile-gnuplots-master
# (Re)computes gnuplot files for full document
gnuplots-full: full.gnuplots
@rm -r full.gnuplots
@make full-pdflatex
@make compile-gnuplots-full
# (Re)computes gnuplot files for master document
gnuplots-master: master.gnuplots
@rm -r master.gnuplots
@make master-pdflatex
@make compile-gnuplots-master
# (Re)computes all gnuplot files
gnuplots: gnuplots-full gnuplots-master
# Gets the current gnuplot directories from origin
get-gnuplots:
git checkout origin/gnuplots full.gnuplots
git restore --staged full.gnuplots/
git checkout origin/gnuplots master.gnuplots
git restore --staged master.gnuplots/
#### Initialization and configuration of git repository
# Initializes the submodule, i.e. clones it correctly
init-submodule:
@echo "[Make] Initialising submodules..."
@git submodule update --init --rebase
# Sets up git hooks for gitinfo2 package
init-git-hooks:
@echo "[Make] Setting up git hooks for package gitinfo2"
@cp .travis/git-info-2.sh .git/hooks/post-merge
@cp .travis/git-info-2.sh .git/hooks/post-checkout
@cp .travis/git-info-2.sh .git/hooks/post-commit
@.travis/git-info-2.sh
# Initializes submodule and git hooks for this repository
init: init-submodule init-git-hooks get-gnuplots
# Sets appropriate git configuration for this repository
config:
@echo "[Make config] Setting git configs to prevent wrong pushes"
@git config push.recurseSubmodules check
@git config status.submodulesummary 1
@echo "[Push annotated tags by default]"
@git config push.followTags true
#### CI stuff
before-install:
@wget 'https://packages.oth-regensburg.de/ctan/macros/latex/contrib/IEEEtran/tools/IEEEtrantools.sty'
@sudo chmod +x .ci/git-info-2.sh
@sudo ".ci/git-info-2.sh"
install-packages:
# @sudo apt install -y make
@sudo apt install -y wget
@sudo apt install -y tree
# @sudo apt install -y texlive-latex-recommended
# @sudo apt install -y texlive-latex-extra
# @sudo apt install -y texlive-fonts-extra
# # @sudo apt install -y texlive-lang-german
# @sudo apt install -y texlive-science
# @sudo apt install -y texlive-bibtex-extra
# @sudo apt install -y lmodern
# @sudo apt install -y latexmk
# @sudo apt install -y biber
# @sudo apt install -y gnuplot
generate-deploy:
@mkdir dist
@mv full.pdf dist/2022_ADM2.pdf
@mv full.log dist/2022_ADM2.log
@cd dist/
@tree -H '.' -I "index.html" -D --charset utf-8 -T "Discrete Optimization" > index.html
# See
# https://stackoverflow.com/a/26339924/16371376
# for explanation
# Lists all targets in this makefile
.PHONY: list
list:
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'