aboutsummaryrefslogtreecommitdiff
path: root/model_6/Makefile
blob: 170dd324a1a5fea35b0b049f3fa60deb3081d1c3 (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
TEX=xelatex
SOURCE=.

SRC  =$(wildcard *.rst)

PDFS = $(SRC:.rst=.pdf)

all: $(PDFS)

DIR = $(sort $(shell find $(SOURCE) -name '*.rst' -print))
SOURCES = $(sort $(wildcard resources/*.tex) )

null  :=
space := $(null) #
comma := ,
TEX_STYLE := $(subst $(space),$(comma),$(strip $(SOURCES)))

PACK = $(shell sed -e 's/\#.*$$//' -e '/^$$/d' resources/modules)
PACKAGES := $(subst $(space),$(comma),$(strip $(PACK)))

tmp:
	mkdir tmp

# Generate the latex file from rst
tmp/%.tex: %.rst $(SOURCES)| tmp
	$$(command -v rst2latex rst2latex.py | head -n 1)  --no-section-subtitles --table-style=borderless --use-latex-citations --use-latex-docinfo --documentclass=extarticle --documentoption=12pt,A4,table --syntax-highlight=short --stylesheet=$(PACKAGES),$(TEX_STYLE) $< $@
	sed -i -e 's/continued on next page/suite sur la page suivante/;s|^%$$||' $@
	sed -i -e 's/admonition-/admonition/g' $@

# Generate each pdf with latex
tmp/%.pdf: tmp/%.tex | tmp
	$(TEX) -output-directory tmp $<
	while grep 'Rerun to get ' tmp/$*.log ; do $(TEX) -output-directory tmp $< ; done

# Put the pdf in the right place
%.pdf: tmp/%.pdf | tmp
	cp $< $@

clean:
	rm -r tmp