]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
improved detecting sphinx and pdflatex in configure.ac, improved building docs in...
authorMichal Nowikowski <godfryd@isc.org>
Fri, 26 Jul 2019 07:51:32 +0000 (09:51 +0200)
committerMichal Nowikowski <godfryd@isc.org>
Tue, 30 Jul 2019 08:45:13 +0000 (10:45 +0200)
configure.ac
doc/sphinx/Makefile.am
hammer.py

index 4e6b89eddb64e8463934405a9ac363599a14b844..af407573eb3549f737e22104a94f675ab0f56658 100644 (file)
@@ -435,45 +435,6 @@ fi
 AM_CONDITIONAL(PERFDHCP, test x$enable_perfdhcp != xno)
 AC_SUBST(DISTCHECK_PERFDHCP_CONFIGURE_FLAG)
 
-# Kea-shell is written in python. It can work with python 2.7 or any 3.x.
-# It may likely work with earlier versions, but 2.7 was the oldest one we tested
-# it with. We require python only if kea-shell was enabled. It is disabled
-# by default to not introduce hard dependency on python.
-AC_ARG_ENABLE(shell, [AC_HELP_STRING([--enable-shell],
-  [enable kea-shell, a text management client for Control Agent [default=no]])],
-  enable_shell=$enableval, enable_shell=no)
-
-DISTCHECK_KEA_SHELL_CONFIGURE_FLAG=
-PKGPYTHONDIR=
-m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
- [python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 dnl
-  python3.3 python3.2 python3.1 python3.0 python python2 python2.7])
-if test "x$enable_shell" != xno ; then
-# If kea-shell is enabled, we really need python. 2.7 or anything newer will do.
-# We try to find 3.x first. If not found, we can do with 2.7.
-  AM_PATH_PYTHON([2.7])
-  # pkgpythondir needs to be expanded
-  saved_prefix="$prefix"
-  if test "$prefix" = "NONE"; then
-    prefix=$ac_default_prefix
-  fi
-  PKGPYTHONDIR="$pkgpythondir"
-  OLD=
-  while test "x$OLD" != "x$PKGPYTHONDIR"; do
-    OLD="$PKGPYTHONDIR"
-    eval PKGPYTHONDIR="\"$OLD\""
-  done
-  prefix="$saved_prefix"
-  DISTCHECK_KEA_SHELL_CONFIGURE_FLAG="--enable-shell"
-else
-  PYTHON=no
-fi
-
-# Export to makefiles the info whether we have shell enabled or not
-AM_CONDITIONAL(KEA_SHELL, test x$enable_shell != xno)
-AC_SUBST(DISTCHECK_KEA_SHELL_CONFIGURE_FLAG)
-AC_SUBST(PKGPYTHONDIR)
-
 # produce PIC unless we disable shared libraries. need this for python bindings.
 if test $enable_shared != "no" -a "X$GXX" = "Xyes"; then
    KEA_CXXFLAGS="$KEA_CXXFLAGS -fPIC"
@@ -1434,10 +1395,51 @@ fi
 
 AM_CONDITIONAL([GENERATE_PARSER], [test x$enable_generate_parser != xno])
 
+# Kea-shell is written in python. It can work with python 2.7 or any 3.x.
+# It may likely work with earlier versions, but 2.7 was the oldest one we tested
+# it with. We require python only if kea-shell was enabled. It is disabled
+# by default to not introduce hard dependency on python.
+AC_ARG_ENABLE(shell, [AC_HELP_STRING([--enable-shell],
+  [enable kea-shell, a text management client for Control Agent [default=no]])],
+  enable_shell=$enableval, enable_shell=no)
+
+
 AC_ARG_ENABLE(generate_docs, [AC_HELP_STRING([--enable-generate-docs],
   [regenerate documentation using Sphinx [default=no]])],
   enable_generate_docs=$enableval, enable_generate_docs=no)
 
+
+DISTCHECK_KEA_SHELL_CONFIGURE_FLAG=
+PKGPYTHONDIR=
+m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
+ [python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 dnl
+  python3.3 python3.2 python3.1 python3.0 python python2 python2.7])
+if test "x$enable_shell" != xno -o "x$enable_generate_docs" != xno; then
+# If kea-shell is enabled, we really need python. 2.7 or anything newer will do.
+# We try to find 3.x first. If not found, we can do with 2.7.
+  AM_PATH_PYTHON([2.7])
+  # pkgpythondir needs to be expanded
+  saved_prefix="$prefix"
+  if test "$prefix" = "NONE"; then
+    prefix=$ac_default_prefix
+  fi
+  PKGPYTHONDIR="$pkgpythondir"
+  OLD=
+  while test "x$OLD" != "x$PKGPYTHONDIR"; do
+    OLD="$PKGPYTHONDIR"
+    eval PKGPYTHONDIR="\"$OLD\""
+  done
+  prefix="$saved_prefix"
+  DISTCHECK_KEA_SHELL_CONFIGURE_FLAG="--enable-shell"
+else
+  PYTHON=no
+fi
+
+# Export to makefiles the info whether we have shell enabled or not
+AM_CONDITIONAL(KEA_SHELL, test x$enable_shell != xno)
+AC_SUBST(DISTCHECK_KEA_SHELL_CONFIGURE_FLAG)
+AC_SUBST(PKGPYTHONDIR)
+
 AC_ARG_WITH([sphinx],
   AC_HELP_STRING([--with-sphinx=PATH], [path to sphinx-build tool]),
   [sphinx_path="$withval"])
@@ -1445,9 +1447,11 @@ AC_ARG_WITH([sphinx],
 AC_ARG_WITH([pdflatex],
   AC_HELP_STRING([--with-pdflatex=PATH], [path to pdflatex tool]),
   [pdflatex_path="$withval"])
+PDFLATEX=no
 
 if test "x$enable_generate_docs" != xno ; then
   # Check for sphinx-build
+  AC_MSG_CHECKING([for sphinx-build])
   if test -z "$sphinx_path"; then
      AC_PATH_PROGS([SPHINXBUILD], [sphinx-build sphinx-build-3])
   else
@@ -1457,12 +1461,15 @@ if test "x$enable_generate_docs" != xno ; then
   if test -z "$SPHINXBUILD"; then
     AC_MSG_ERROR([sphinx-build not found; it is required for --enable-generate-docs, please see http://www.sphinx-doc.org/en/master/usage/installation.html for details])
   else
-    AC_MSG_CHECKING([whether $SPHINXBUILD works])
-    $SPHINXBUILD --version
+    AC_MSG_RESULT([$SPHINXBUILD])
+
+    AC_MSG_CHECKING([whether $SPHINXBUILD is runnable])
+    $SPHINXBUILD --version > conftest.err 2>&1
     if test $? -ne 0 ; then
-      AC_MSG_ERROR("Error with $SPHINXBUILD --version")
+      AC_MSG_ERROR([error with $SPHINXBUILD --version, check conftest.err for details])
     fi
-    AC_MSG_RESULT(yes (found in $SPHINXBUILD))
+    rm -f conftest.err
+    AC_MSG_RESULT([yes])
   fi
 
   # Check for pdflatex
@@ -1473,20 +1480,43 @@ if test "x$enable_generate_docs" != xno ; then
   fi
 
   if test -z "$PDFLATEX"; then
-    AC_MSG_ERROR([pdflatex not found; it is expected for --enable-generate-docs if not explicitly disabled by ???])
+    PDFLATEX=no
   elif test "x$PDFLATEX" == "xno"; then
-    :
+    AC_MSG_CHECKING([for pdflatex])
+    AC_MSG_RESULT([no (disabled)])
   else
-    AC_MSG_CHECKING([whether $PDFLATEX works])
-    $PDFLATEX --version
+    AC_MSG_CHECKING([whether $PDFLATEX is runnable])
+    $PDFLATEX --version > /dev/null 2>&1
     if test $? -ne 0 ; then
-      AC_MSG_ERROR("Error with $PDFLATEX --version")
+      AC_MSG_RESULT([no - disabled building docs in PDF])
+      PDFLATEX=no
+    else
+      AC_MSG_RESULT([yes])
     fi
-    AC_MSG_RESULT(yes (found in $PDFLATEX))
   fi
-  AM_CONDITIONAL(HAVE_PDFLATEX, test "x$PDFLATEX" != "xno")
+
+  if test -n "$SPHINXBUILD" -a "x$PDFLATEX" != "xno"; then
+    AC_MSG_CHECKING([whether $SPHINXBUILD and $PDFLATEX work])
+    ti=`mktemp -d`
+    to=`mktemp -d`
+    echo 'hello' > $ti/contents.rst
+    sphinx-build -b latex -C $ti $to > /dev/null 2>&1
+    pushd $to > /dev/null 2>&1
+    $PDFLATEX -interaction nonstopmode Python.tex > /dev/null 2>&1
+    popd > /dev/null 2>&1
+    file $to/Python.pdf | grep PDF > /dev/null 2>&1
+    if test $? -ne 0 ; then
+      AC_MSG_RESULT([no - disabled building docs in PDF])
+      PDFLATEX=no
+    else
+      AC_MSG_RESULT([ok])
+    fi
+    rm -rf $ti $to
+  fi
+
 fi
 
+AM_CONDITIONAL(HAVE_PDFLATEX, test "x$PDFLATEX" != "xno")
 AM_CONDITIONAL(GENERATE_DOCS, test x$enable_generate_docs != xno)
 
 AC_ARG_ENABLE(install-configurations,
index 050d9814e2e914f747a5b6b5bb1f8f45fd484803..d26f10788cbb7e77e225e1b47e2f3b3db3c4630e 100644 (file)
@@ -231,17 +231,18 @@ api_files+=$(srcdir)/api/version-get.json
 EXTRA_DIST += $(api_files)
 
 
-all: html mans
 if HAVE_PDFLATEX
-all: pdf
+all: html mans pdf
+else
+all: html mans
 endif
 
 $(srcdir)/kea-messages.rst: $(mes_files) mes2doc.py
-       $(srcdir)/mes2doc.py -o $@ $(mes_files)
+       $(PYTHON) $(srcdir)/mes2doc.py -o $@ $(mes_files)
 
 
 $(srcdir)/api.rst: $(api_files) api2doc.py
-       $(srcdir)/api2doc.py -o $@ $(api_files)
+       $(PYTHON) $(srcdir)/api2doc.py -o $@ $(api_files)
 
 
 PDFLATEX_AND_OPTS=$(PDFLATEX) -interaction nonstopmode
@@ -272,8 +273,10 @@ mans: $(man_sources)
 install-data-local:
        mkdir -p $(DESTDIR)$(docdir)
        cp -r $(sphinxbuilddir)/html $(DESTDIR)$(docdir)
+if HAVE_PDFLATEX
        ${INSTALL_DATA} $(sphinxbuilddir)/latex/kea-arm.pdf $(DESTDIR)$(docdir)
        ${INSTALL_DATA} $(sphinxbuilddir)/latex/kea-messages.pdf $(DESTDIR)$(docdir)
+endif
        ${MKDIR_P} ${DESTDIR}${mandir}/man8
        ${INSTALL_DATA} $(man8s) ${DESTDIR}${mandir}/man8/
 
index adaf9778f58119652ba87040891e56f395aef965..68bad0cc2ac6a8cee2d668e01a53052a7537ce2d 100755 (executable)
--- a/hammer.py
+++ b/hammer.py
@@ -1068,7 +1068,7 @@ def prepare_system_local(features, check_times):
             packages.extend(['rpm-build', 'python2-devel'])
 
         if 'docs' in features:
-            packages.extend(['python36-virtualenv'])
+            packages.extend(['python-virtualenv'])
 
         if 'mysql' in features:
             packages.extend(['mariadb', 'mariadb-server', 'mariadb-devel'])
@@ -1085,7 +1085,7 @@ def prepare_system_local(features, check_times):
         install_pkgs(packages, env=env, check_times=check_times)
 
         if 'docs' in features:
-            execute('virtualenv-3 ~/venv',
+            execute('virtualenv ~/venv',
                     env=env, timeout=60, check_times=check_times)
             execute('~/venv/bin/pip install sphinx sphinx-rtd-theme',
                     env=env, timeout=120, check_times=check_times)
@@ -1224,7 +1224,11 @@ def prepare_system_local(features, check_times):
                 packages.append('mariadb-server')
 
         if 'pgsql' in features:
-            packages.extend(['postgresql-client', 'libpq-dev', 'postgresql-all'])
+            packages.extend(['postgresql-client', 'libpq-dev'])
+            if revision == '8':
+                packages.extend(['postgresql', 'postgresql-client'])
+            else:
+                packages.append('postgresql-all')
 
         if 'radius' in features:
             packages.extend(['git'])
@@ -1360,7 +1364,6 @@ def _build_binaries_and_run_ut(system, revision, features, tarball_path, env, ch
             cmd += ' --with-sphinx=$HOME/venv/bin/sphinx-build'
         elif system == 'centos' and revision == '7':
             cmd += ' --with-sphinx=$HOME/venv/bin/sphinx-build'
-            cmd += ' --with-pdflatex=no'
     if 'radius' in features:
         cmd += ' --with-freeradius=/usr/local'
     if 'shell' in features: