forked from imz/latex-g7-32
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
104 lines (81 loc) · 2.42 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
# Tools
LATEX=xelatex -interaction=nonstopmode -shell-escape
# LATEX=pdflatex
TD=./utils/texdepend
GSCONV=./utils/gsconv.sh
D2T=dot2tex -f pgf --crop --docpreamble "\usepackage[T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english, russian]{babel}"
PDFTRIMWHITE=pdfcrop
# Output file
PDF=rpz.pdf
# Input paths
DIA=graphics/dia
DOT=graphics/dot
SVG=graphics/svg
IMG=graphics/img
TEX=tex
DEPS=.deps
SRC=src
INC=$(TEX)/inc
# Input files
# no .tex allowed in MAINTEX!
MAINTEX=rpz
BIBFILE=$(TEX)/rpz.bib
PREAMBLE=preamble-std.tex
STYLES=$(TEX)/GostBase.clo $(TEX)/G7-32.sty $(TEX)/G7-32.cls $(TEX)/G2-105.sty
PARTS_TEX = $(wildcard $(TEX)/[0-9][0-9]-*.tex)
ifeq ($(firstword $(LATEX)), pdflatex)
CODE_CONVERTION=iconv -f UTF-8 -t KOI8-R
else
CODE_CONVERTION=cat
endif
all: $(PDF)
.PHONY: all tarball clean
PARTS_DEPS=$(PARTS_TEX:tex/%=$(DEPS)/%-deps.mk)
-include $(PARTS_DEPS)
MAIN_DEP=$(DEPS)/$(MAINTEX).tex-deps.mk
-include $(MAIN_DEP)
$(DEPS)/%-deps.mk: $(TEX)/% Makefile
mkdir -p $(DEPS)
(/bin/echo -n "$(PDF): " ; $(TD) -print=fi -format=1 $< | grep -v '^#' | xargs /bin/echo) > $@
$(PDF): $(TEX)/$(MAINTEX).tex $(STYLES) $(BIBFILE)
cd tex && $(LATEX) $(MAINTEX)
cd tex && bibtex $(MAINTEX)
cd tex && makeindex $(MAINTEX).nlo -s nomencl.ist -o $(MAINTEX).nls
cd tex && $(LATEX) $(MAINTEX)
cd tex && $(LATEX) $(MAINTEX)
cp tex/$(PDF) .
$(INC)/dia/%.pdf: $(DIA)/%.dia
mkdir -p $(INC)/dia
dia -e $@-tmp.svg -t svg $<
inkscape -A $@-tmp.pdf $@-tmp.svg
$(PDFTRIMWHITE) $@-tmp.pdf $@
$(INC)/svg/%.pdf : $(SVG)/%.svg
mkdir -p $(INC)/svg/
# inkscape -A $@ $<
# Обрезаем поля в svg автоматом:
inkscape -A $(INC)/svg/$*-tmp.pdf $<
cd $(INC)/svg && \
$(PDFTRIMWHITE) $*-tmp.pdf $*.pdf && \
rm $*-tmp.pdf
$(INC)/img/%.pdf: $(IMG)/%.*
mkdir -p $(INC)/img
convert $< -quality 100 $@
$(INC)/dot/%.pdf: $(DOT)/%.dot
mkdir -p $(INC)/dot
dot -o$@-tmp.svg -Tsvg $<
inkscape -A $@-tmp.pdf $@-tmp.svg
$(PDFTRIMWHITE) $@-tmp.pdf $@
$(INC)/src/%: $(SRC)/%
mkdir -p $(INC)/src
$(CODE_CONVERTION) $< > $@
clean:
find $(TEX)/ -regextype posix-egrep -type f ! -regex ".*\.(sty|tex|clo|cls|bib|bst|gitignore)" -exec $(RM) {} \; ;
# $(RM) $(DIA)/*.pdf $(DIA)/*.eps
$(RM) -r $(DEPS)
$(RM) -r $(INC)
printpdfs: $(PDF)
$(GSCONV) $(PDF)
distclean: clean
PACK = $(addprefix latex-g7-32/, Makefile tex/* src/* utils/* graphics/*)
tarball: $(PDF) clean
cd ..; rm latex-G7-32.tar.gz; tar -czf latex-G7-32.tar.gz $(PACK)