TEX=xelatex SOURCE=. SRC =$(wildcard *.rst) SVG =$(wildcard content/*.svg) DOT =$(wildcard *.dot) PDFS = $(SRC:.rst=.pdf) INCLUDED_TEX = $(DOT:.dot=.tex) all: $(PDFS) BIBS =$(wildcard *.bib) DIR = $(sort $(shell find $(SOURCE) -name '*.rst' -print)) SOURCES = $(sort $(wildcard resources/*.tex)) null := space := $(null) # comma := , TEX_STYLE := $(subst $(space),$(comma),$(strip $(SOURCES))) TEX_BIBS := $(subst $(space),$(comma),$(strip $(BIBS))) PACK = $(shell sed -e 's/\#.*$$//' -e '/^$$/d' resources/modules) PACKAGES := $(subst $(space),$(comma),$(strip $(PACK))) tmp: mkdir tmp # Image generation content/%.pdf: content/%.svg inkscape -D -z --export-pdf=$@ $< %.tex: %.dot dot2tex --autosize --figonly -o $@ $< # Generate the latex file from rst tmp/%.tex: %.rst $(INCLUDED_TEX) $(SOURCES)| tmp $$(command -v rst2latex rst2latex.py | head -n 1) --no-section-subtitles --no-section-numbering --table-style=borderless --use-latex-citations --use-latex-docinfo --documentclass=article --documentoption=12pt,A4,table --syntax-highlight=short --stylesheet=$(PACKAGES),$(TEX_STYLE) $< $@ sed -i -e 's/{c}{\\hfill ... continued on next page/{r}{... suite sur la page suivante/;s|^%$$||' $@ sed -i -e 's/\endfirsthead/\endfirsthead\\tableHeaderStyle/g' $@ sed -i -e 's/longtable\*/mytable/g' $@ sed -i -e 's/p{[0-9]\.[0-9]*\\DUtablewidth}/X/g' $@ # Generate each pdf with latex tmp/%.pdf: tmp/%.tex $(BIBS) | tmp $(TEX) -output-directory tmp $< #bibtex tmp/$*.aux && $(TEX) -output-directory tmp $< || echo "no bib" 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