[cheese/wip/kill-gnome-common: 4/13] Update gtkdoc_jh_path_xml_catalog.m4 from gtk-doc



commit a30838ae488b4041eaabf0260f108d423548eea5
Author: David King <amigadave amigadave com>
Date:   Thu Jan 29 09:52:37 2015 +0000

    Update gtkdoc_jh_path_xml_catalog.m4 from gtk-doc

 m4/gtkdoc_jh_path_xml_catalog.m4 |   41 +++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 7 deletions(-)
---
diff --git a/m4/gtkdoc_jh_path_xml_catalog.m4 b/m4/gtkdoc_jh_path_xml_catalog.m4
index 1618906..cca2267 100644
--- a/m4/gtkdoc_jh_path_xml_catalog.m4
+++ b/m4/gtkdoc_jh_path_xml_catalog.m4
@@ -8,17 +8,44 @@ AC_DEFUN([JH_PATH_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])
+               [with_xml_catalog=''])
+       AC_MSG_CHECKING([for XML catalog])
+       if test -n "$with_xml_catalog"; then
+               dnl path was explicitly given.  check that it exists.
+               if test -f "$with_xml_catalog"; then
+                       jh_found_xmlcatalog=true
+               else
+                       jh_found_xmlcatalog=false
+               fi
        else
+               dnl if one was not explicitly specified, try some guesses
+               dnl we look first in /etc/xml/catalog, then XDG_DATA_DIRS/xml/catalog
+               if test -z "$XDG_DATA_DIRS"; then
+                       dnl if we have no XDG_DATA_DIRS, use the default
+                       jh_xml_catalog_searchdirs="/etc:/usr/local/share:/usr/share"
+               else
+                       jh_xml_catalog_searchdirs="/etc:$XDG_DATA_DIRS"
+               fi
                jh_found_xmlcatalog=false
+               dnl take care to iterate based on ':', allowing whitespace to appear in paths
+               jh_xml_catalog_saved_ifs="$IFS"
+               IFS=':'
+               for d in $jh_xml_catalog_searchdirs; do
+                       if test -f "$d/xml/catalog"; then
+                               with_xml_catalog="$d/xml/catalog"
+                               jh_found_xmlcatalog=true
+                               break
+                       fi
+               done
+               IFS="$jh_xml_catalog_saved_ifs"
+       fi
+       if $jh_found_xmlcatalog; then
+               AC_MSG_RESULT([$with_xml_catalog])
+       else
                AC_MSG_RESULT([not found])
        fi
+       XML_CATALOG_FILE="$with_xml_catalog"
+       AC_SUBST([XML_CATALOG_FILE])
 
        dnl check for the xmlcatalog program
        AC_PATH_PROG(XMLCATALOG, xmlcatalog, no)


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