Adding gst-python package
[platform/upstream/gst-python.git] / common / m4 / as-docbook.m4
1 dnl AS_DOCBOOK([, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
2 dnl checks if xsltproc can build docbook documentation
3 dnl (which is possible if the catalog is set up properly
4 dnl I also tried checking for a specific version and type of docbook
5 dnl but xsltproc seemed to happily run anyway, so we can't check for that
6 dnl and version
7 dnl this macro takes inspiration from
8 dnl http://www.movement.uklinux.net/docs/docbook-autotools/configure.html
9 AC_DEFUN([AS_DOCBOOK],
10 [
11   XSLTPROC_FLAGS=--nonet
12   DOCBOOK_ROOT=
13   TYPE_LC=xml
14   TYPE_UC=XML
15   DOCBOOK_VERSION=4.1.2
16
17   if test -n "$XML_CATALOG_FILES"; then
18     oldIFS=$IFS
19     IFS=' '
20     for xml_catalog_file in $XML_CATALOG_FILES; do
21       if test -f $xml_catalog_file; then
22         XML_CATALOG=$xml_catalog_file
23         CAT_ENTRY_START='<!--'
24         CAT_ENTRY_END='-->'
25         break
26       fi
27     done
28     IFS=$oldIFS
29   elif test ! -f /etc/xml/catalog; then
30     for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/ /usr/local/share/xsl/docbook ;
31     do
32       if test -d "$i"; then
33         DOCBOOK_ROOT=$i
34       fi
35     done
36   else
37     XML_CATALOG=/etc/xml/catalog
38     CAT_ENTRY_START='<!--'
39     CAT_ENTRY_END='-->'
40   fi
41
42   dnl We need xsltproc to process the test
43   AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,)
44   XSLTPROC_WORKS=no
45   if test -n "$XSLTPROC"; then
46     AC_MSG_CHECKING([whether xsltproc docbook processing works])
47
48     if test -n "$XML_CATALOG"; then
49       DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
50     else
51       DB_FILE="$DOCBOOK_ROOT/xhtml/docbook.xsl"
52     fi
53     $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END
54 <?xml version="1.0" encoding='ISO-8859-1'?>
55 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook $TYPE_UC V$DOCBOOK_VERSION//EN" "http://www.oasis-open.org/docbook/$TYPE_LC/$DOCBOOK_VERSION/docbookx.dtd">
56 <book id="test">
57 </book>
58 END
59     if test "$?" = 0; then
60       XSLTPROC_WORKS=yes
61     fi
62     AC_MSG_RESULT($XSLTPROC_WORKS)
63   fi
64
65   if test "x$XSLTPROC_WORKS" = "xyes"; then
66     dnl execute ACTION-IF-FOUND
67     ifelse([$1], , :, [$1])
68   else
69     dnl execute ACTION-IF-NOT-FOUND
70     ifelse([$2], , :, [$2])
71   fi
72
73   AC_SUBST(XML_CATALOG)
74   AC_SUBST(XSLTPROC_FLAGS)
75   AC_SUBST(DOCBOOK_ROOT)
76   AC_SUBST(CAT_ENTRY_START)
77   AC_SUBST(CAT_ENTRY_END)
78 ])