forked from fsi-tue/anfiheft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (96 loc) · 4.01 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
# Makefile für die Anfihefte
# Fix für Ubuntu-User, bei denen anstatt Bash Dash verwendet wird:
SHELL := /usr/bin/env bash
# Diese Variablen sollten für die aktuelle Version stimmen, müssen aber ggf.
# angepasst werden (am besten über Shell-Variablen, z. B. "export YEAR=2017"
# und "unset YEAR" zum Zurücksetzen):
YEAR ?= $(shell date '+%Y')
# Das Semester ist um 2 Monate nach vorne verschoben, da wir die Briefe ja vor
# dem entsprechenden Semester aktualisieren wollen.
SEMESTER ?= $(shell if [[ $$(date +%m) > 02 && $$(date +%m) < 07 ]]; \
then echo sommersemestertrue; \
else echo wintersemestertrue; fi)
# Variablen für die Build-Ordner
BUILDDIR = out
# Configuration file generated by the Makefile (current year, edition, etc.):
CONFIG = makeconfig.tex
# set the base year for calculating the edition
BASEYEAR = 2018
BASEEDITION_INFO = 29 # SS 19: 31. Auflage
BASEEDITION_KOGNI = 3 # WS 18/19: 3. Auflage
# automatically set the build parameters like year, semester, edition and if the kogni or info build should be done
BASE_CONF = '\\jahr=$(YEAR) \\$(SEMESTER)'
INFO_AUFLAGE = $(shell if [ $(SEMESTER) = "sommersemestertrue" ]; \
then echo $$((($(YEAR)-$(BASEYEAR))*2 + $(BASEEDITION_INFO))); \
else echo $$((($(YEAR)-$(BASEYEAR))*2 + $(BASEEDITION_INFO) + 1)); fi)
INFO_CONF = '$(BASE_CONF) \auflage=$(INFO_AUFLAGE) \infotrue'
KOGNI_AUFLAGE = $(shell echo $$(($(YEAR)-$(BASEYEAR) + $(BASEEDITION_KOGNI))))
KOGNI_CONF = '$(BASE_CONF) \auflage=$(KOGNI_AUFLAGE)'
# Aliases
.PHONY: default
default: all
.PHONY: all
all: info kogni
.PHONY: info
info: anfiheft-info.pdf
.PHONY: kogni
kogni: anfiheft-kogni.pdf
.PHONY: anfiheft-info.pdf # Let latexmk handle the dependencies
anfiheft-info.pdf: anfiheft.tex
if [ ! -d $(BUILDDIR)-info ]; then mkdir $(BUILDDIR)-info; fi
echo $(INFO_CONF) > $(CONFIG)
latexmk -f -output-directory=$(BUILDDIR)-info -pdf -pdflatex="pdflatex" anfiheft.tex $<
cp $(BUILDDIR)-info/anfiheft.pdf anfiheft-info.pdf
mv $(CONFIG) info-$(CONFIG)
.PHONY: anfiheft-kogni.pdf # Let latexmk handle the dependencies
anfiheft-kogni.pdf: anfiheft.tex
if [ ! -d $(BUILDDIR)-kogni ]; then mkdir $(BUILDDIR)-kogni; fi
echo $(KOGNI_CONF) > $(CONFIG)
latexmk -f -output-directory=$(BUILDDIR)-kogni -pdf -pdflatex="pdflatex" anfiheft.tex $<
cp $(BUILDDIR)-kogni/anfiheft.pdf anfiheft-kogni.pdf
mv $(CONFIG) kogni-$(CONFIG)
# DB-Dump der für das KKI geladen werden muss:
.PHONY: kki/dump.csv # Could always change since we fetch it from the web
kki/dump.csv:
curl -o kki/dump.csv https://kki.fsi.uni-tuebingen.de/dump.php
.PHONY: check
check:
# Note: This target requires the pdfinfo binary from Xpdf.
set -eu; \
FAILURE=0; \
for file in anfiheft-info.pdf anfiheft-kogni.pdf; do \
PAGE_COUNT=$$(pdfinfo $$file | grep Pages | grep -oE '[0-9]+$$'); \
REMAINDER=$$((PAGE_COUNT % 4)); \
if [[ $$REMAINDER -ne 0 ]]; then \
echo "Failure: The number of pages in the PDF file $$file" \
"is not divisible by 4 ($$PAGE_COUNT % 4 = $$REMAINDER)." 1>&2; \
FAILURE=1; \
fi \
done; \
if [[ $$FAILURE -eq 0 ]]; then \
echo "Success, all checks passed."; \
else \
exit 1; \
fi
.PHONY: clean
clean:
if [ -d $(BUILDDIR)-info ]; then rm --recursive ./$(BUILDDIR)-info; fi
if [ -d $(BUILDDIR)-kogni ]; then rm --recursive ./$(BUILDDIR)-kogni; fi
rm -f info-$(CONFIG)
rm -f kogni-$(CONFIG)
.PHONY: distclean
distclean: clean
if [ -f anfiheft-info.pdf ]; then rm anfiheft-info.pdf; fi
if [ -f anfiheft-kogni.pdf ]; then rm anfiheft-kogni.pdf; fi
.PHONY: help
help:
@echo 'Building targets:'
@echo ' all - Build the info- and kogni-anfiheft (default)'
@echo ' info - Build only the info-anfiheft'
@echo ' kogni - Build only the kogni-anfiheft'
@echo ' kki/dump.csv - Update the DB dump from the KKI'
@echo 'Auxiliary targets:'
@echo ' help - Show this help'
@echo 'Cleaning targets:'
@echo ' clean - Remove both $(BUILDDIR)-Directories'
@echo ' distclean - Remove both $(BUILDDIR)-Directories and anfiheft-*.pdf (i.e. everything)'