1# ===========================================================================
2# https://github.com/BrianAker/ddm4
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_PROG_SPHINX_BUILD([ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
8#
9# DESCRIPTION
10#
11#   Look for sphinx-build and make sure it is a recent version of it.
12#
13# LICENSE
14#
15#   Copyright (c) 2012-2013 Brian Aker <brian@tangent.org>
16#
17#   Copying and distribution of this file, with or without modification, are
18#   permitted in any medium without royalty provided the copyright notice
19#   and this notice are preserved. This file is offered as-is, without any
20#   warranty.
21
22#serial 5
23
24AC_DEFUN([AX_PROG_SPHINX_BUILD],
25         [AX_WITH_PROG([SPHINXBUILD],[sphinx-build],[:])
26         AS_IF([test x"SPHINXBUILD" = x":"],
27               [SPHINXBUILD=],
28               [AS_IF([test -x "$SPHINXBUILD"],
29                      [AC_MSG_CHECKING([Checking to see if $SPHINXBUILD is recent])
30                      junk=`$SPHINXBUILD --version &> version_file`
31                      AS_IF([test $? -eq 0],
32                            [ax_sphinx_build_version=`head -1 version_file`],
33                            [junk=`$SPHINXBUILD &> version_file`
34                            ax_sphinx_build_version=`head -1 version_file`
35                            rm version_file
36                            AC_MSG_RESULT([$SPHINXBUILD is version "$ax_sphinx_build_version"])
37                            $SPHINXBUILD -Q -C -b man -d conftest.d . . >/dev/null 2>&1
38                            AS_IF([test $? -eq 0], ,[SPHINXBUILD=])
39                            rm -rf conftest.d ])
40                      ])
41                      rm -f version_file
42               ])
43
44         AS_IF([test -n "${SPHINXBUILD}"],
45               [AC_SUBST([SPHINXBUILD])
46               ifelse([$1], , :, [$1])],
47               [ifelse([$2], , :, [$2])])
48         ])
49