From 96b2830733376f7e9e752b5ff936e48fea0a0123 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Mon, 14 Jan 2013 16:16:10 +0100
Subject: [PATCH] Add version check for Sphinx
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Sphinx 1.0 and above can check version by setting β€œneeds_sphinx” in the
configuration.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 configure.ac | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/configure.ac b/configure.ac
index b09be70e4..14ebe8176 100644
--- a/configure.ac
+++ b/configure.ac
@@ -373,6 +373,18 @@ if test -z "$SPHINX"
 then
   AC_MSG_WARN(m4_normalize([sphinx-build not found, documentation rebuild will
                             not be possible]))
+else
+  # Sphinx exits with code 1 when it prints its usage
+  sphinxver=`{ $SPHINX --version 2>&1 || :; } | head -n 3`
+
+  if ! echo "$sphinxver" | grep -q -w -e '^Sphinx' -e '^Usage:'; then
+    AC_MSG_ERROR([Unable to determine Sphinx version])
+
+  # Note: Character classes ([...]) need to be double quoted due to autoconf
+  # using m4
+  elif ! echo "$sphinxver" | grep -q -E '^Sphinx[[[:space:]]]+v[[1-9]]\>'; then
+    AC_MSG_ERROR([Sphinx 1.0 or higher is required])
+  fi
 fi
 
 AC_ARG_ENABLE([manpages-in-doc],
-- 
GitLab