[cheese] Check for DTD and stylesheets for man generation



commit c4e543723a940842ae212e85bc887bc9db48ed20
Author: David King <amigadave amigadave com>
Date:   Fri Dec 30 10:47:58 2011 +0100

    Check for DTD and stylesheets for man generation
    
    Copy M4 checks for installed XML catalogs from gtk-doc. Use the checks
    in configure.ac to only enable man generation when the required DTDs and
    stylesheets are available.

 configure.ac                      |   20 ++++++++++++++++----
 m4/gtkdoc_jh_check_xml_catalog.m4 |   16 ++++++++++++++++
 m4/gtkdoc_jh_path_xml_catalog.m4  |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 03b33af..cbe04ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,10 +194,22 @@ AC_ARG_ENABLE([man],
   [AS_HELP_STRING([--disable-man], [Disable building the man page])])
 
 AS_IF([test "x$enable_man" != "xno"],
-  [AC_CHECK_PROG([have_xsltproc], [xsltproc], [yes], [no])],
-  [have_xsltproc=no])
-
-AM_CONDITIONAL([ENABLE_MAN], [test "x$have_xsltproc" = "xyes"])
+  [AC_CHECK_PROG([have_xsltproc], [xsltproc], [yes], [no])
+   JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.3//EN],
+     [DocBook XML DTD V4.3], [have_docbookdtd=yes], [have_docbookdtd=no])
+   JH_CHECK_XML_CATALOG(
+     [http://docbook.sourceforge.net/release/xsl/current/html/refentry.xsl],
+     [DocBook XSL Stylesheets], [have_docbookxsl=yes], [have_docbookxsl=no])
+   AS_IF([test "x$have_xsltproc" = "xyes" -a "x$have_docbookdtd" = "xyes" \
+     -a "x$have_docbookxsl" = "xyes"],
+     [have_manutils=yes],
+     [AS_IF([test "x$enable_man" = "xyes"],
+       [AC_MSG_ERROR(
+         [manpage generation requested but required utilities were not found])])
+      have_manutils=no])],
+  [have_manutils=no])
+
+AM_CONDITIONAL([ENABLE_MAN], [test "x$have_manutils" = "xyes"])
 
 # Mallard help
 YELP_HELP_INIT
diff --git a/m4/gtkdoc_jh_check_xml_catalog.m4 b/m4/gtkdoc_jh_check_xml_catalog.m4
new file mode 100644
index 0000000..618c1c9
--- /dev/null
+++ b/m4/gtkdoc_jh_check_xml_catalog.m4
@@ -0,0 +1,16 @@
+dnl Checks if a particular URI appears in the XML catalog
+dnl Usage:
+dnl	JH_CHECK_XML_CATALOG(URI, [FRIENDLY-NAME], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+AC_DEFUN([JH_CHECK_XML_CATALOG],
+[
+	AC_REQUIRE([JH_PATH_XML_CATALOG],[JH_PATH_XML_CATALOG(,[:])])dnl
+	AC_MSG_CHECKING([for ifelse([$2],,[$1],[$2]) in XML catalog])
+	if $jh_found_xmlcatalog && \
+		AC_RUN_LOG([$XMLCATALOG --noout "$XML_CATALOG_FILE" "$1" >&2]); then
+		AC_MSG_RESULT([found])
+		ifelse([$3],,,[$3])
+	else
+		AC_MSG_RESULT([not found])
+		ifelse([$4],,[AC_MSG_ERROR([could not find ifelse([$2],,[$1],[$2]) in XML catalog])],[$4])
+	fi
+])
diff --git a/m4/gtkdoc_jh_path_xml_catalog.m4 b/m4/gtkdoc_jh_path_xml_catalog.m4
new file mode 100644
index 0000000..1618906
--- /dev/null
+++ b/m4/gtkdoc_jh_path_xml_catalog.m4
@@ -0,0 +1,34 @@
+dnl Checks the location of the XML Catalog
+dnl Usage:
+dnl	JH_PATH_XML_CATALOG([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl Defines XMLCATALOG and XML_CATALOG_FILE substitutions
+AC_DEFUN([JH_PATH_XML_CATALOG],
+[
+	dnl check for the presence of the XML catalog
+	AC_ARG_WITH([xml-catalog],
+		AS_HELP_STRING([--with-xml-catalog=CATALOG],
+		[path to xml catalog to use]),,
+		[with_xml_catalog=/etc/xml/catalog])
+	jh_found_xmlcatalog=true
+	XML_CATALOG_FILE="$with_xml_catalog"
+	AC_SUBST([XML_CATALOG_FILE])
+	AC_MSG_CHECKING([for XML catalog ($XML_CATALOG_FILE)])
+	if test -f "$XML_CATALOG_FILE"; then
+		AC_MSG_RESULT([found])
+	else
+		jh_found_xmlcatalog=false
+		AC_MSG_RESULT([not found])
+	fi
+
+	dnl check for the xmlcatalog program
+	AC_PATH_PROG(XMLCATALOG, xmlcatalog, no)
+	if test "x$XMLCATALOG" = xno; then
+		jh_found_xmlcatalog=false
+	fi
+
+	if $jh_found_xmlcatalog; then
+		ifelse([$1],,[:],[$1])
+	else
+		ifelse([$2],,[AC_MSG_ERROR([could not find XML catalog])],[$2])
+	fi
+])



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]