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