summaryrefslogtreecommitdiff
path: root/old/architecture/Makefile
blob: 1423d3f13ab6d1f1c9d45422fb88e53ecf08b12e (plain)
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
SRCDIR := ../src
PYGMENTDIR := pygments
#SOURCES := $(shell ls $(SRCDIR)/*.cpp $(SRCDIR)/*.h $(SRCDIR)/*.pro|grep -v /moc_|grep -v Java|grep -v /qrc_)
PYGMENTIZE := pygmentize -f latex -l cpp -O verboptions='formatcom=\scriptsize',linenos=True
LINTER := clang-format -style="{BasedOnStyle: llvm, ColumnLimit: 48}"
TARGET := architecture

all: $(TARGET).pdf


.PHONY: stats
stats:
	@echo -e "\e[1mPages:\e[91m" $(shell cat $(TARGET).toc|grep References|egrep -o '[0-9]+') "\e[0m"
	@echo -e "\e[1mFile size:\e[92m" $(shell ls -sh $(TARGET).pdf|cut -d' ' -f1) "\e[0m"
	@echo -e "\e[1mAbstract:\e[92m" $(shell grep -A1000 '\\paragraph{English}' $(TARGET).tex|sed '/\\newpage/Q'|tail -n+2|grep -v '^%'|wc -w) "\e[0mwords"
	@echo -e "\e[1mFixmes:\e[93m" $(shell grep FIXME $(TARGET).tex|wc -l) "\e[0m"
	@grep -no '%FIXME.*' $(TARGET).tex|sed 's/%FIXME//;s/^/\x1b[93m/;s/: /\x1b[0m: /1'

$(TARGET).pdf: $(TARGET).tex bibliography.bib
	pdflatex $< 
	biber $(TARGET)
	pdflatex $< 

pygments/excerpt%.cpp: $(SOURCES)
	python extract_excerpts.py $(*F) $^ | $(LINTER) > $@

$(PYGMENTDIR)/%.cpp: $(SRCDIR)/%.cpp
	$(LINTER) $< > $@

$(PYGMENTDIR)/%.h: $(SRCDIR)/%.h
	$(LINTER) $< > $@

$(PYGMENTDIR)/%.pro: $(SRCDIR)/%.pro
	cp $< $@

$(PYGMENTDIR)/%.tex: $(PYGMENTDIR)/%
	$(PYGMENTIZE) -o $@ $<

sources.zip: $(SOURCES)
	zip -j $@ $^

.PHONY: sources
sources: $(PYGMENTDIR)/sourcelist.tex $(PYGMENTDIR)/pygmentdefs.tex sources.zip


$(PYGMENTDIR)/sourcelist.tex: $(addprefix $(PYGMENTDIR)/,$(notdir $(patsubst %.cpp,%.cpp.tex,$(patsubst %.h,%.h.tex,$(patsubst %.pro,%.pro.tex,$(SOURCES))))))
	@echo $^ | tr ' ' '\n'> sources_output.txt
	@echo $(notdir $(patsubst %.tex,%,$^)) | tr ' ' '\n'> sources_input.txt
	paste -d! sources_input.txt sources_output.txt | sed 's/^\(.*\)!\(.*\)$$/\\includesource{\1}{\2}/g' > $(PYGMENTDIR)/sourcelist.tex

$(PYGMENTDIR)/pygmentdefs.tex:
	pygmentize -S default -f latex > $(PYGMENTDIR)/pygmentdefs.tex

.PHONY: clean
clean:
	rm -f *.aux *.log *.out *.toc *.bbl *.blg
	rm -f pygments/*