aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2024-05-11 17:56:58 +0200
committerSébastien Dailly <sebastien@dailly.me>2024-05-11 17:56:58 +0200
commit3b1107a34f2f2db787157f11ab68d7b468f603ec (patch)
tree8f6c58585be0ae3fe55daac6d13bea4c2690cc4c /common
parentd97654d95b269eb9f6de8105e2eb01ca5566ae14 (diff)
Override model styles with local styles automaticaly
Diffstat (limited to 'common')
-rw-r--r--common/Makefile.common31
1 files changed, 25 insertions, 6 deletions
diff --git a/common/Makefile.common b/common/Makefile.common
index 311db70..730a994 100644
--- a/common/Makefile.common
+++ b/common/Makefile.common
@@ -13,11 +13,31 @@ all: $(PDFS)
BIBS =$(wildcard *.bib)
DIR = $(sort $(shell find $(SOURCE) -name '*.rst' -print))
-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) )
+# Pick the first file for the given name, either in the path from the model, or
+# in the local path from the source.
+select_file = \
+ $(firstword $(wildcard ./resources/$(1)) $(wildcard $(MODEL)/resources/$1))
+
+
+# Select the files to use in the styles.
+ifeq ($(MODEL),.)
+ $(info Modèle de base)
+
+ SOURCES = $(sort $(filter-out $(FILTERS), $(wildcard $(MODEL)/resources/*.tex) ))
+
+else
+ $(info Modèle surchargé)
+
+ # Remove from the list the elements given in the variable FILTERS
+ NEW_STYLES = $(wildcard resources/*.tex)
+ MODEL_STYLES = $(wildcard $(MODEL)/resources/*.tex)
+ # For each file, extract the name, and sort the list by order.
+ STYLE_NAME = $(sort $(foreach fic,$(NEW_STYLES) $(filter-out $(FILTERS),$(MODEL_STYLES)),$(notdir $(fic))))
+ # Pick the file either in the current directory, or in the model path
+ SOURCES = $(foreach fic,$(STYLE_NAME),$(call select_file,$(fic)))
+
+endif
null :=
space := $(null) #
@@ -31,7 +51,6 @@ EXTRA_RST_OPTIONS ?=
EXTRA_STYLES ?=
-
# Remove the comments and the empty lines from the module list file
PACK = $(shell sed -e 's/\#.*$$//' -e '/^\s$$/d' $(MODEL)/resources/modules)
PACKAGES = $(subst $(space),$(comma),$(strip $(PACK)))
@@ -44,7 +63,7 @@ tmp/model.tex: | tmp
$(file >$@,\def\commonPath{$(MODEL)/../common/})
# Generate the latex file from rst
-tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES) $(EXT_SOURCES) | tmp
+tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES) | tmp
$$(command -v rst2latex rst2latex.py | head -n 1) \
--no-section-subtitles \
--table-style=borderless \