• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Based on:
2# Configure paths for LIBXML2
3# Toshio Kuratomi 2001-04-21
4# Adapted from:
5# Configure paths for GLIB
6# Owen Taylor     97-11-3
7#
8# Modified to work with libxslt by Thomas Schraitle 2002/10/25
9# Fixed by Edward Rudd 2004/05/12
10
11dnl AM_PATH_XSLT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
12dnl Test for XML, and define XML_CFLAGS and XML_LIBS
13dnl
14AC_DEFUN([AM_PATH_XSLT],[
15AC_ARG_WITH(xslt-prefix,
16            [  --with-xslt-prefix=PFX   Prefix where libxslt is installed (optional)],
17            xslt_config_prefix="$withval", xslt_config_prefix="")
18AC_ARG_WITH(xslt-exec-prefix,
19            [  --with-xslt-exec-prefix=PFX Exec prefix where libxslt is installed (optional)],
20            xslt_config_exec_prefix="$withval", xslt_config_exec_prefix="")
21AC_ARG_ENABLE(xslttest,
22              [  --disable-xslttest       Do not try to compile and run a test LIBXSLT program],,
23              enable_xslttest=yes)
24
25  if test x$xslt_config_exec_prefix != x ; then
26     xslt_config_args="$xslt_config_args --exec-prefix=$xslt_config_exec_prefix"
27     if test x${XSLT_CONFIG+set} != xset ; then
28        XSLT_CONFIG=$xslt_config_exec_prefix/bin/xslt-config
29     fi
30  fi
31  if test x$xslt_config_prefix != x ; then
32     xslt_config_args="$xslt_config_args --prefix=$xslt_config_prefix"
33     if test x${XSLT_CONFIG+set} != xset ; then
34        XSLT_CONFIG=$xslt_config_prefix/bin/xslt-config
35     fi
36  fi
37
38  AC_PATH_PROG(XSLT_CONFIG, xslt-config, no)
39  min_xslt_version=ifelse([$1], ,1.0.0,[$1])
40  AC_MSG_CHECKING(for libxslt - version >= $min_xslt_version)
41  no_xslt=""
42  if test "$XSLT_CONFIG" = "no" ; then
43    no_xslt=yes
44  else
45    XSLT_CFLAGS=`$XSLT_CONFIG $xslt_config_args --cflags`
46    XSLT_LIBS=`$XSLT_CONFIG $xslt_config_args --libs`
47    xslt_config_major_version=`$XSLT_CONFIG $xslt_config_args --version | \
48           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
49    xslt_config_minor_version=`$XSLT_CONFIG $xslt_config_args --version | \
50           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
51    xslt_config_micro_version=`$XSLT_CONFIG $xslt_config_args --version | \
52           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
53    if test "x$enable_xslttest" = "xyes" ; then
54      ac_save_CFLAGS="$CFLAGS"
55      ac_save_LIBS="$LIBS"
56      CFLAGS="$CFLAGS $XSLT_CFLAGS"
57      LIBS="$XSLT_LIBS $LIBS"
58dnl
59dnl Now check if the installed libxslt is sufficiently new.
60dnl (Also sanity checks the results of xslt-config to some extent)
61dnl
62      rm -f conf.xslttest
63      AC_TRY_RUN([
64#include <stdlib.h>
65#include <stdio.h>
66#include <string.h>
67#include <libxslt/xsltconfig.h>
68#include <libxslt/xslt.h>
69int
70main()
71{
72  int xslt_major_version, xslt_minor_version, xslt_micro_version;
73  int major, minor, micro;
74  char *tmp_version;
75
76  system("touch conf.xslttest");
77
78  /* Capture xslt-config output via autoconf/configure variables */
79  /* HP/UX 9 (%@#!) writes to sscanf strings */
80  tmp_version = (char *)strdup("$min_xslt_version");
81  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
82     printf("%s, bad version string from xslt-config\n", "$min_xslt_version");
83     exit(1);
84   }
85   free(tmp_version);
86
87   /* Capture the version information from the header files */
88   tmp_version = (char *)strdup(LIBXSLT_DOTTED_VERSION);
89   if (sscanf(tmp_version, "%d.%d.%d", &xslt_major_version, &xslt_minor_version, &xslt_micro_version) != 3) {
90     printf("%s, bad version string from libxslt includes\n", "LIBXSLT_DOTTED_VERSION");
91     exit(1);
92   }
93   free(tmp_version);
94
95 /* Compare xslt-config output to the libxslt headers */
96  if ((xslt_major_version != $xslt_config_major_version) ||
97      (xslt_minor_version != $xslt_config_minor_version) ||
98      (xslt_micro_version != $xslt_config_micro_version))
99    {
100      printf("*** libxslt header files (version %d.%d.%d) do not match\n",
101         xslt_major_version, xslt_minor_version, xslt_micro_version);
102      printf("*** xslt-config (version %d.%d.%d)\n",
103         $xslt_config_major_version, $xslt_config_minor_version, $xslt_config_micro_version);
104      return 1;
105    }
106/* Compare the headers to the library to make sure we match */
107  /* Less than ideal -- doesn't provide us with return value feedback,
108   * only exits if there's a serious mismatch between header and library.
109   */
110    /* copied from LIBXML_TEST_VERSION; */
111    xmlCheckVersion(LIBXML_VERSION);
112
113    /* Test that the library is greater than our minimum version */
114    if ((xslt_major_version > major) ||
115        ((xslt_major_version == major) && (xslt_minor_version > minor)) ||
116        ((xslt_major_version == major) && (xslt_minor_version == minor) &&
117        (xslt_micro_version >= micro)))
118      {
119        return 0;
120       }
121     else
122      {
123        printf("\n*** An old version of libxslt (%d.%d.%d) was found.\n",
124               xslt_major_version, xslt_minor_version, xslt_micro_version);
125        printf("*** You need a version of libxslt newer than %d.%d.%d. The latest version of\n",
126           major, minor, micro);
127        printf("*** libxslt is always available from ftp://ftp.xmlsoft.org.\n");
128        printf("***\n");
129        printf("*** If you have already installed a sufficiently new version, this error\n");
130        printf("*** probably means that the wrong copy of the xslt-config shell script is\n");
131        printf("*** being found. The easiest way to fix this is to remove the old version\n");
132        printf("*** of LIBXSLT, but you can also set the XSLT_CONFIG environment to point to the\n");
133        printf("*** correct copy of xslt-config. (In this case, you will have to\n");
134        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
135        printf("*** so that the correct libraries are found at run-time))\n");
136    }
137  return 1;
138}
139],, no_xslt=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
140       CFLAGS="$ac_save_CFLAGS"
141       LIBS="$ac_save_LIBS"
142     fi
143  fi
144
145  if test "x$no_xslt" = x ; then
146     AC_MSG_RESULT(yes (version $xslt_config_major_version.$xslt_config_minor_version.$xslt_config_micro_version))
147     ifelse([$2], , :, [$2])
148  else
149     AC_MSG_RESULT(no)
150     if test "$XSLT_CONFIG" = "no" ; then
151       echo "*** The xslt-config script installed by LIBXSLT could not be found"
152       echo "*** If libxslt was installed in PREFIX, make sure PREFIX/bin is in"
153       echo "*** your path, or set the XSLT_CONFIG environment variable to the"
154       echo "*** full path to xslt-config."
155     else
156       if test -f conf.xslttest ; then
157        :
158       else
159          echo "*** Could not run libxslt test program, checking why..."
160          CFLAGS="$CFLAGS $XSLT_CFLAGS"
161          LIBS="$LIBS $XSLT_LIBS"
162          AC_TRY_LINK([
163#include <libxslt/xslt.h>
164#include <stdio.h>
165],      [ LIBXSLT_TEST_VERSION; return 0;],
166        [ echo "*** The test program compiled, but did not run. This usually means"
167          echo "*** that the run-time linker is not finding LIBXSLT or finding the wrong"
168          echo "*** version of LIBXSLT. If it is not finding LIBXSLT, you'll need to set your"
169          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
170          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
171          echo "*** is required on your system"
172          echo "***"
173          echo "*** If you have an old version installed, it is best to remove it, although"
174          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
175        [ echo "*** The test program failed to compile or link. See the file config.log for the"
176          echo "*** exact error that occured. This usually means LIBXSLT was incorrectly installed"
177          echo "*** or that you have moved LIBXSLT since it was installed. In the latter case, you"
178          echo "*** may want to edit the xslt-config script: $XSLT_CONFIG" ])
179          CFLAGS="$ac_save_CFLAGS"
180          LIBS="$ac_save_LIBS"
181       fi
182     fi
183
184     XSLT_CFLAGS=""
185     XSLT_LIBS=""
186     ifelse([$3], , :, [$3])
187  fi
188  AC_SUBST(XSLT_CFLAGS)
189  AC_SUBST(XSLT_LIBS)
190  rm -f conf.xslttest
191])
192