summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Graf <tgraf@redhat.com>2012-05-09 10:06:24 +0200
committerThomas Graf <tgraf@redhat.com>2012-05-09 10:06:24 +0200
commit183e86913aab58acf7b5b9cd160518e527bb0348 (patch)
tree055a65b00554aafbe242ce373869e619b83fe489
parent7b503a12a039aeb129fb75804824f6b365adb54b (diff)
downloadlibnl-183e86913aab58acf7b5b9cd160518e527bb0348.tar.gz
doc: Check documentation generation requirements with autoconf
Adds --enable-doc/--disable-doc, if omitted doc will only be build if requirements are met. If explicitely enabled, configure script will fail if requirements are not met.
-rw-r--r--configure.in62
-rw-r--r--doc/Makefile.am25
-rw-r--r--doc/README6
-rw-r--r--m4/ax_python.m497
4 files changed, 188 insertions, 2 deletions
diff --git a/configure.in b/configure.in
index f676371..ed059c3 100644
--- a/configure.in
+++ b/configure.in
@@ -73,6 +73,68 @@ AC_PROG_YACC
AC_C_CONST
AC_C_INLINE
+#
+# Generating the documentation
+#
+AC_ARG_ENABLE([doc],
+ AS_HELP_STRING([--disable-doc], [Do not generate documentation]),
+ [generate_doc="$enableval"], [generate_doc=auto])
+
+if test "x$generate_doc" != "xno"; then
+ AC_PROG_SED
+ AC_PROG_EGREP
+
+ AX_PYTHON
+
+ AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], yes, no)
+ if test "x$HAVE_DOXYGEN" = "xno" -a "x$generate_doc" = "xyes"; then
+ AC_MSG_ERROR([*** doxygen package required to generate documentation])
+ fi
+
+ link_doc=yes
+ AC_CHECK_PROG(HAVE_XMLSTARLET, [xmlstarlet], yes, no)
+ if test "x$HAVE_XMLSTARLET" = "xno"; then
+ if test "x$generate_doc" = "xyes"; then
+ AC_MSG_ERROR([*** xmlstarlet package required to generate documentation])
+ else
+ AC_MSG_WARN([*** xmlstarlet not found, linking to APi reference disabled])
+ link_doc=no
+ fi
+ fi
+
+ AC_CHECK_PROG(HAVE_ASCIIDOC, [asciidoc], yes, no)
+ if test "x$HAVE_ASCIIDOC" = "xno"; then
+ if test "x$generate_doc" = "xyes"; then
+ AC_MSG_ERROR([*** asciidoc package required to generate documentation])
+ else
+ AC_MSG_WARN([*** asciidoc not found, disabling building of guides])
+ fi
+ fi
+
+ AC_CHECK_PROG(HAVE_MSCGEN, [mscgen], yes, no)
+ if test "x$HAVE_MSCGEN" = "xno"; then
+ AC_MSG_WARN([*** mscgen not found, get it at http://www.mcternan.me.uk/mscgen/])
+ if test "x$generate_doc" = "xyes"; then
+ AC_MSG_ERROR([*** mscgen package required to generate documentation])
+ else
+ AC_MSG_WARN([*** Disabling building of guides])
+ HAVE_ASCIIDOC=no
+ HAVE_DOXYGEN=no
+ fi
+ fi
+
+ if test "x$HAVE_DOXYGEN" = "xno"; then
+ AC_MSG_WARN([*** Disabling API linking due to missing doxygen package])
+ link_doc=no
+ fi
+
+ AM_CONDITIONAL([LINK_DOC], [test "x$link_doc" = "xyes"])
+ AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$HAVE_DOXYGEN" = "xyes"])
+ AM_CONDITIONAL([HAVE_ASCIIDOC], [test "x$HAVE_ASCIIDOC" = "xyes"])
+fi
+
+AM_CONDITIONAL([GENERATE_DOC], [test "x$generate_doc" != "xno"])
+
AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
[Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]),
[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 6f574dd..142dc31 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -79,20 +79,43 @@ EXTRA_DIST = \
images/icons/callouts/15.png
%.html: %.txt
+if LINK_DOC
./resolve-asciidoc-refs.py $< > asciidoc.tmp
asciidoc $(ASCIIDOCOPTS) -o $@ asciidoc.tmp
./doxygen-link.py libnl.dict $@ > asciidoc.tmp
mv asciidoc.tmp $@
+else
+ asciidoc $(ASCIIDOCOPTS) -o $@ $<
+endif
asciidoc: core.html route.html index.html
+link_doc:
+if LINK_DOC
+ ./gen-tags.sh | ./tags2dict.sh > libnl.dict
+else
+ @echo "Warning: Linking to API reference is disabled, check configure output"
+endif
+
api_ref:
doxygen Doxyfile;
- ./gen-tags.sh | ./tags2dict.sh > libnl.dict
+ $(MAKE) link_doc
gendoc:
+if GENERATE_DOC
+if HAVE_DOXYGEN
$(MAKE) api_ref
+else
+ @echo "Warning: Building of API reference (doxygen) is disabled, check autoconf logs"
+endif
+if HAVE_ASCIIDOC
$(MAKE) asciidoc
+else
+ @echo "Warning: Building of asciidoc files is disabled, check autoconf logs"
+endif
+else
+ @echo "Warning: Building of documentation disabled by user or autoconf"
+endif
clean-local:
rm -f api/* libnl.dict *.html;
diff --git a/doc/README b/doc/README
index f4d1211..0c230a2 100644
--- a/doc/README
+++ b/doc/README
@@ -1,6 +1,10 @@
Requirements to build documentation
mscgen
-asciidoc 8.6.5
+ http://www.mcternan.me.uk/mscgen/
+
mscgen-filter-1.2
+ http://code.google.com/p/asciidoc-mscgen-filter/
+
+asciidoc 8.6.x
doxygen
diff --git a/m4/ax_python.m4 b/m4/ax_python.m4
new file mode 100644
index 0000000..1bc9d8a
--- /dev/null
+++ b/m4/ax_python.m4
@@ -0,0 +1,97 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_python.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PYTHON
+#
+# DESCRIPTION
+#
+# This macro does a complete Python development environment check.
+#
+# It recurses through several python versions (from 2.1 to 2.6 in this
+# version), looking for an executable. When it finds an executable, it
+# looks to find the header files and library.
+#
+# It sets PYTHON_BIN to the name of the python executable,
+# PYTHON_INCLUDE_DIR to the directory holding the header files, and
+# PYTHON_LIB to the name of the Python library.
+#
+# This macro calls AC_SUBST on PYTHON_BIN (via AC_CHECK_PROG),
+# PYTHON_INCLUDE_DIR and PYTHON_LIB.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Michael Tindal
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 9
+
+AC_DEFUN([AX_PYTHON],
+[AC_MSG_CHECKING(for python build information)
+AC_MSG_RESULT([])
+for python in python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do
+AC_CHECK_PROGS(PYTHON_BIN, [$python])
+ax_python_bin=$PYTHON_BIN
+if test x$ax_python_bin != x; then
+ AC_CHECK_LIB($ax_python_bin, main, ax_python_lib=$ax_python_bin, ax_python_lib=no)
+ AC_CHECK_HEADER([$ax_python_bin/Python.h],
+ [[ax_python_header=`locate $ax_python_bin/Python.h | sed -e s,/Python.h,,`]],
+ ax_python_header=no)
+ if test $ax_python_lib != no; then
+ if test $ax_python_header != no; then
+ break;
+ fi
+ fi
+fi
+done
+if test x$ax_python_bin = x; then
+ ax_python_bin=no
+fi
+if test x$ax_python_header = x; then
+ ax_python_header=no
+fi
+if test x$ax_python_lib = x; then
+ ax_python_lib=no
+fi
+
+AC_MSG_RESULT([ results of the Python check:])
+AC_MSG_RESULT([ Binary: $ax_python_bin])
+AC_MSG_RESULT([ Library: $ax_python_lib])
+AC_MSG_RESULT([ Include Dir: $ax_python_header])
+
+if test x$ax_python_header != xno; then
+ PYTHON_INCLUDE_DIR=$ax_python_header
+ AC_SUBST(PYTHON_INCLUDE_DIR)
+fi
+if test x$ax_python_lib != xno; then
+ PYTHON_LIB=$ax_python_lib
+ AC_SUBST(PYTHON_LIB)
+fi
+])dnl