From 7072776a60f1e1f3522406cd88f7481c69bbb967 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 15 Sep 2023 18:05:29 +0200
Subject: [PATCH] Build system / Manual: use variables for specifying the
 version number

Rather than using a generated file. This will ease the transition to Meson.
---
 configure.ac                   | 1 -
 doc/manual/Makefile.am         | 7 +++++--
 doc/manual/source/conf.py      | 4 ----
 doc/manual/utils/version.py.in | 2 --
 4 files changed, 5 insertions(+), 9 deletions(-)
 delete mode 100644 doc/manual/utils/version.py.in

diff --git a/configure.ac b/configure.ac
index 2cc60101c8..8d489c7de9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,7 +112,6 @@ AC_CONFIG_FILES([Makefile
                  VERSION
                  doc/Makefile
                  doc/manual/Makefile
-                 doc/manual/utils/version.py
                  doc/parallel/Makefile
                  doc/internals/Makefile
                  doc/gsa/Makefile
diff --git a/doc/manual/Makefile.am b/doc/manual/Makefile.am
index ae0a572144..23439869c5 100644
--- a/doc/manual/Makefile.am
+++ b/doc/manual/Makefile.am
@@ -7,12 +7,15 @@ SRC = $(wildcard source/*.rst)
 html-local: build/html/index.html
 
 build/html/index.html: $(SRC) source/conf.py
-	$(SPHINXBUILD) -M html source build
+	$(SPHINXBUILD) -b html -D version=$(PACKAGE_VERSION) -D release=$(PACKAGE_VERSION) -d build/doctrees source build/html
 
 pdf-local: build/latex/dynare-manual.pdf
 
+# NB: we cannot use -M latexpdf because of this bug:
+#  https://bugs.debian.org/933347
 build/latex/dynare-manual.pdf: $(SRC) source/conf.py
-	$(SPHINXBUILD) -M latexpdf source build
+	$(SPHINXBUILD) -b latex -D version=$(PACKAGE_VERSION) -D release=$(PACKAGE_VERSION) -d build/doctrees source build/latex
+	make -C build/latex all-pdf
 
 clean-local:
 	rm -rf build
diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py
index 57d79d92ff..dcb5f4da09 100644
--- a/doc/manual/source/conf.py
+++ b/doc/manual/source/conf.py
@@ -41,10 +41,6 @@ author = u'Dynare Team'
 
 add_function_parentheses = False
 
-# See ../utils/version.py, which is generated by autoconf
-from version import version
-from version import release
-
 language = 'en'
 
 exclude_patterns = []
diff --git a/doc/manual/utils/version.py.in b/doc/manual/utils/version.py.in
deleted file mode 100644
index 2add40f511..0000000000
--- a/doc/manual/utils/version.py.in
+++ /dev/null
@@ -1,2 +0,0 @@
-version = u'@PACKAGE_VERSION@'
-release = u'@PACKAGE_VERSION@'
-- 
GitLab