1# SYNOPSIS
2#
3#   AX_PROG_SPHINX_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])
4#
5# DESCRIPTION
6#
7#   Makes sure that sphinx-build supports the version indicated. If true
8#   the shell commands in ACTION-IF-TRUE are executed. If not the shell
9#   commands in ACTION-IF-FALSE are run. Note if $SPHINX_BUILD is not set
10#   (for example by running AX_WITH_PROG) the macro will fail.
11#
12#   Example:
13#
14#     AX_WITH_PROG(SPHINX_BUILD,sphinx-build)
15#     AX_PROG_SPHINX([1.1.1],[ ... ],[ ... ])
16#
17# LICENSE
18#
19#   ax_prog_python_version.m4
20#
21#   Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net>
22#
23#   Copying and distribution of this file, with or without modification, are
24#   permitted in any medium without royalty provided the copyright notice
25#   and this notice are preserved. This file is offered as-is, without any
26#   warranty.
27#
28#   ax_prog_sphinx_version.m4
29#
30#   Copyright (c) 2013 Vivek Thampi <vivekthampi@users.sourceforge.net>
31
32
33AC_DEFUN([AX_PROG_SPHINX],[
34    AC_REQUIRE([AC_PROG_SED])
35    AC_REQUIRE([AC_PROG_GREP])
36
37
38    AS_IF([test -n "$SPHINX_BUILD"],[
39        ax_sphinx_version="$1"
40
41        AC_MSG_CHECKING([for sphinx version])
42        changequote(<<,>>)
43        sphinx_version=`$SPHINX_BUILD -h 2>&1 | $GREP "^Sphinx v" | $SED -e 's/^.* v\([0-9]*\.[0-9]*\.[0-9]*\)/\1/'`
44        changequote([,])
45        AC_MSG_RESULT($sphinx_version)
46
47        AC_SUBST([SPHINX_VERSION],[$sphinx_version])
48
49        AX_COMPARE_VERSION([$ax_sphinx_version],[le],[$sphinx_version],[
50        :
51            $2
52        ],[
53        :
54            $3
55        ])
56    ],[
57        AC_MSG_WARN([could not find the sphinx documentation tool])
58        $3
59    ])
60])
61