Blame libxml.m4

Packit Service a31ea6
# Configure paths for LIBXML2
Packit Service a31ea6
# Mike Hommey 2004-06-19
Packit Service a31ea6
# use CPPFLAGS instead of CFLAGS
Packit Service a31ea6
# Toshio Kuratomi 2001-04-21
Packit Service a31ea6
# Adapted from:
Packit Service a31ea6
# Configure paths for GLIB
Packit Service a31ea6
# Owen Taylor     97-11-3
Packit Service a31ea6
Packit Service a31ea6
dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
Packit Service a31ea6
dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
Packit Service a31ea6
dnl
Packit Service a31ea6
AC_DEFUN([AM_PATH_XML2],[ 
Packit Service a31ea6
AC_ARG_WITH(xml-prefix,
Packit Service a31ea6
            [  --with-xml-prefix=PFX   Prefix where libxml is installed (optional)],
Packit Service a31ea6
            xml_config_prefix="$withval", xml_config_prefix="")
Packit Service a31ea6
AC_ARG_WITH(xml-exec-prefix,
Packit Service a31ea6
            [  --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
Packit Service a31ea6
            xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
Packit Service a31ea6
AC_ARG_ENABLE(xmltest,
Packit Service a31ea6
              [  --disable-xmltest       Do not try to compile and run a test LIBXML program],,
Packit Service a31ea6
              enable_xmltest=yes)
Packit Service a31ea6
Packit Service a31ea6
  if test x$xml_config_exec_prefix != x ; then
Packit Service a31ea6
     xml_config_args="$xml_config_args"
Packit Service a31ea6
     if test x${XML2_CONFIG+set} != xset ; then
Packit Service a31ea6
        XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
Packit Service a31ea6
     fi
Packit Service a31ea6
  fi
Packit Service a31ea6
  if test x$xml_config_prefix != x ; then
Packit Service a31ea6
     xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
Packit Service a31ea6
     if test x${XML2_CONFIG+set} != xset ; then
Packit Service a31ea6
        XML2_CONFIG=$xml_config_prefix/bin/xml2-config
Packit Service a31ea6
     fi
Packit Service a31ea6
  fi
Packit Service a31ea6
Packit Service a31ea6
  AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
Packit Service a31ea6
  min_xml_version=ifelse([$1], ,2.0.0,[$1])
Packit Service a31ea6
  AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
Packit Service a31ea6
  no_xml=""
Packit Service a31ea6
  if test "$XML2_CONFIG" = "no" ; then
Packit Service a31ea6
    no_xml=yes
Packit Service a31ea6
  else
Packit Service a31ea6
    XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
Packit Service a31ea6
    XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
Packit Service a31ea6
    xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
Packit Service a31ea6
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
Packit Service a31ea6
    xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
Packit Service a31ea6
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
Packit Service a31ea6
    xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
Packit Service a31ea6
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
Packit Service a31ea6
    if test "x$enable_xmltest" = "xyes" ; then
Packit Service a31ea6
      ac_save_CPPFLAGS="$CPPFLAGS"
Packit Service a31ea6
      ac_save_LIBS="$LIBS"
Packit Service a31ea6
      CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
Packit Service a31ea6
      LIBS="$XML_LIBS $LIBS"
Packit Service a31ea6
dnl
Packit Service a31ea6
dnl Now check if the installed libxml is sufficiently new.
Packit Service a31ea6
dnl (Also sanity checks the results of xml2-config to some extent)
Packit Service a31ea6
dnl
Packit Service a31ea6
      rm -f conf.xmltest
Packit Service a31ea6
      AC_TRY_RUN([
Packit Service a31ea6
#include <stdlib.h>
Packit Service a31ea6
#include <stdio.h>
Packit Service a31ea6
#include <string.h>
Packit Service a31ea6
#include <libxml/xmlversion.h>
Packit Service a31ea6
Packit Service a31ea6
int 
Packit Service a31ea6
main()
Packit Service a31ea6
{
Packit Service a31ea6
  int xml_major_version, xml_minor_version, xml_micro_version;
Packit Service a31ea6
  int major, minor, micro;
Packit Service a31ea6
  char *tmp_version;
Packit Service a31ea6
Packit Service a31ea6
  system("touch conf.xmltest");
Packit Service a31ea6
Packit Service a31ea6
  /* Capture xml2-config output via autoconf/configure variables */
Packit Service a31ea6
  /* HP/UX 9 (%@#!) writes to sscanf strings */
Packit Service a31ea6
  tmp_version = (char *)strdup("$min_xml_version");
Packit Service a31ea6
  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
Packit Service a31ea6
     printf("%s, bad version string from xml2-config\n", "$min_xml_version");
Packit Service a31ea6
     exit(1);
Packit Service a31ea6
   }
Packit Service a31ea6
   free(tmp_version);
Packit Service a31ea6
Packit Service a31ea6
   /* Capture the version information from the header files */
Packit Service a31ea6
   tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
Packit Service a31ea6
   if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
Packit Service a31ea6
     printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
Packit Service a31ea6
     exit(1);
Packit Service a31ea6
   }
Packit Service a31ea6
   free(tmp_version);
Packit Service a31ea6
Packit Service a31ea6
 /* Compare xml2-config output to the libxml headers */
Packit Service a31ea6
  if ((xml_major_version != $xml_config_major_version) ||
Packit Service a31ea6
      (xml_minor_version != $xml_config_minor_version) ||
Packit Service a31ea6
      (xml_micro_version != $xml_config_micro_version))
Packit Service a31ea6
    {
Packit Service a31ea6
      printf("*** libxml header files (version %d.%d.%d) do not match\n",
Packit Service a31ea6
         xml_major_version, xml_minor_version, xml_micro_version);
Packit Service a31ea6
      printf("*** xml2-config (version %d.%d.%d)\n",
Packit Service a31ea6
         $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
Packit Service a31ea6
      return 1;
Packit Service a31ea6
    } 
Packit Service a31ea6
/* Compare the headers to the library to make sure we match */
Packit Service a31ea6
  /* Less than ideal -- doesn't provide us with return value feedback, 
Packit Service a31ea6
   * only exits if there's a serious mismatch between header and library.
Packit Service a31ea6
   */
Packit Service a31ea6
    LIBXML_TEST_VERSION;
Packit Service a31ea6
Packit Service a31ea6
    /* Test that the library is greater than our minimum version */
Packit Service a31ea6
    if ((xml_major_version > major) ||
Packit Service a31ea6
        ((xml_major_version == major) && (xml_minor_version > minor)) ||
Packit Service a31ea6
        ((xml_major_version == major) && (xml_minor_version == minor) &&
Packit Service a31ea6
        (xml_micro_version >= micro)))
Packit Service a31ea6
      {
Packit Service a31ea6
        return 0;
Packit Service a31ea6
       }
Packit Service a31ea6
     else
Packit Service a31ea6
      {
Packit Service a31ea6
        printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
Packit Service a31ea6
               xml_major_version, xml_minor_version, xml_micro_version);
Packit Service a31ea6
        printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
Packit Service a31ea6
           major, minor, micro);
Packit Service a31ea6
        printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
Packit Service a31ea6
        printf("***\n");
Packit Service a31ea6
        printf("*** If you have already installed a sufficiently new version, this error\n");
Packit Service a31ea6
        printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
Packit Service a31ea6
        printf("*** being found. The easiest way to fix this is to remove the old version\n");
Packit Service a31ea6
        printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
Packit Service a31ea6
        printf("*** correct copy of xml2-config. (In this case, you will have to\n");
Packit Service a31ea6
        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
Packit Service a31ea6
        printf("*** so that the correct libraries are found at run-time))\n");
Packit Service a31ea6
    }
Packit Service a31ea6
  return 1;
Packit Service a31ea6
}
Packit Service a31ea6
],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
Packit Service a31ea6
       CPPFLAGS="$ac_save_CPPFLAGS"
Packit Service a31ea6
       LIBS="$ac_save_LIBS"
Packit Service a31ea6
     fi
Packit Service a31ea6
  fi
Packit Service a31ea6
Packit Service a31ea6
  if test "x$no_xml" = x ; then
Packit Service a31ea6
     AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
Packit Service a31ea6
     ifelse([$2], , :, [$2])     
Packit Service a31ea6
  else
Packit Service a31ea6
     AC_MSG_RESULT(no)
Packit Service a31ea6
     if test "$XML2_CONFIG" = "no" ; then
Packit Service a31ea6
       echo "*** The xml2-config script installed by LIBXML could not be found"
Packit Service a31ea6
       echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
Packit Service a31ea6
       echo "*** your path, or set the XML2_CONFIG environment variable to the"
Packit Service a31ea6
       echo "*** full path to xml2-config."
Packit Service a31ea6
     else
Packit Service a31ea6
       if test -f conf.xmltest ; then
Packit Service a31ea6
        :
Packit Service a31ea6
       else
Packit Service a31ea6
          echo "*** Could not run libxml test program, checking why..."
Packit Service a31ea6
          CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
Packit Service a31ea6
          LIBS="$LIBS $XML_LIBS"
Packit Service a31ea6
          AC_TRY_LINK([
Packit Service a31ea6
#include <libxml/xmlversion.h>
Packit Service a31ea6
#include <stdio.h>
Packit Service a31ea6
],      [ LIBXML_TEST_VERSION; return 0;],
Packit Service a31ea6
        [ echo "*** The test program compiled, but did not run. This usually means"
Packit Service a31ea6
          echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
Packit Service a31ea6
          echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
Packit Service a31ea6
          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
Packit Service a31ea6
          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
Packit Service a31ea6
          echo "*** is required on your system"
Packit Service a31ea6
          echo "***"
Packit Service a31ea6
          echo "*** If you have an old version installed, it is best to remove it, although"
Packit Service a31ea6
          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
Packit Service a31ea6
        [ echo "*** The test program failed to compile or link. See the file config.log for the"
Packit Service a31ea6
          echo "*** exact error that occurred. This usually means LIBXML was incorrectly installed"
Packit Service a31ea6
          echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
Packit Service a31ea6
          echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
Packit Service a31ea6
          CPPFLAGS="$ac_save_CPPFLAGS"
Packit Service a31ea6
          LIBS="$ac_save_LIBS"
Packit Service a31ea6
       fi
Packit Service a31ea6
     fi
Packit Service a31ea6
Packit Service a31ea6
     XML_CPPFLAGS=""
Packit Service a31ea6
     XML_LIBS=""
Packit Service a31ea6
     ifelse([$3], , :, [$3])
Packit Service a31ea6
  fi
Packit Service a31ea6
  AC_SUBST(XML_CPPFLAGS)
Packit Service a31ea6
  AC_SUBST(XML_LIBS)
Packit Service a31ea6
  rm -f conf.xmltest
Packit Service a31ea6
])