aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile.common23
1 files changed, 18 insertions, 5 deletions
diff --git a/common/Makefile.common b/common/Makefile.common
index 460bdc7..311db70 100644
--- a/common/Makefile.common
+++ b/common/Makefile.common
@@ -13,7 +13,11 @@ all: $(PDFS)
BIBS =$(wildcard *.bib)
DIR = $(sort $(shell find $(SOURCE) -name '*.rst' -print))
-SOURCES := $(sort $(wildcard $(MODEL)/resources/*.tex) )
+SOURCES = $(sort $(filter-out $(FILTERS), $(wildcard $(MODEL)/resources/*.tex) ))
+
+# Sources comming from extra styles.
+# Used in the target regeneration.
+EXT_SOURCES = $(filter %.tex, $(EXTRA_STYLES) )
null :=
space := $(null) #
@@ -35,8 +39,12 @@ PACKAGES = $(subst $(space),$(comma),$(strip $(PACK)))
tmp:
mkdir tmp
+# Hack used to identify the path to the shared configuration in latex.
+tmp/model.tex: | tmp
+ $(file >$@,\def\commonPath{$(MODEL)/../common/})
+
# Generate the latex file from rst
-tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES)| tmp
+tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES) $(EXT_SOURCES) | tmp
$$(command -v rst2latex rst2latex.py | head -n 1) \
--no-section-subtitles \
--table-style=borderless \
@@ -46,15 +54,18 @@ tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES)| tmp
--documentoption=12pt,A4,table \
--syntax-highlight=short \
$(EXTRA_RST_OPTIONS) \
- --stylesheet=$(PACKAGES),$(EXTRA_STYLES),$(TEX_STYLE) $< $@
+ --stylesheet=tmp/model.tex,$(PACKAGES),$(subst $(space),$(comma),\$(EXTRA_STYLES)),$(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 $(BIBS) | tmp
+tmp/%.pdf: tmp/%.tex tmp/model.tex $(BIBS) | tmp
+ set TEXINPUTS=.:$(MODEL):$$(TEXINPUTS)
$(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
+ while grep 'Rerun to get ' tmp/$*.log ; do \
+ $(TEX) --halt-on-error -output-directory tmp $< ;\
+ done
# Put the pdf in the right place
%.pdf: tmp/%.pdf | tmp
@@ -62,6 +73,7 @@ tmp/%.pdf: tmp/%.tex $(BIBS) | tmp
# Update mupdf if the process exist, or do nothing.
pkill -HUP mupdf || true
+.PHONY: clean
clean:
rm -r tmp
@@ -73,6 +85,7 @@ clean:
# Watch mode, which regenerate the documents as soon there is a change in a
# file.,
# requires inotifywait (package inotify-tools)
+.PHONY: watch
watch:
while true; do \
$(MAKE) all; \