1 dnl AM_PATH_EXPAT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2 dnl Test for EXPAT, and define EXPAT_CFLAGS and EXPAT_LIBS
4 AC_DEFUN([AM_PATH_EXPAT],
6 dnl Get the cflags and libraries from the expat-config script
8 AC_ARG_WITH(expat-prefix,[ --with-expat=PFX Prefix where EXPAT is installed (optional)])
9 AC_ARG_ENABLE(expattest, [ --disable-expattest Do not try to compile and run a test EXPAT program],
10 , enable_expattest=yes)
12 if test x$with_expat != x ; then
13 EXPAT_CFLAGS="-I$with_expat/include"
14 EXPAT_LIBS="-L$with_expat/lib"
17 min_expat_version=ifelse([$1], ,1.95.1, $1)
18 AC_MSG_CHECKING(for EXPAT - version >= $min_expat_version)
20 EXPAT_CFLAGS="$EXPAT_CFLAGS"
21 EXPAT_LIBS="$EXPAT_LIBS -lexpat"
23 if test "x$enable_expattest" = "xyes" ; then
24 ac_save_CFLAGS="$CFLAGS"
26 CFLAGS="$CFLAGS $EXPAT_CFLAGS"
27 LIBS="$EXPAT_LIBS $LIBS"
29 dnl Now check if the installed EXPAT is sufficiently new. (Also sanity
30 dnl checks the results of expat-config to some extent
42 int expat_major, expat_minor, expat_micro;
43 int major, minor, micro;
44 char *tmp_expat_version;
47 system ("touch conf.expattest");
49 /* HP/UX 9 (%@#!) writes to sscanf strings */
50 tmp_expat_version = strdup(XML_ExpatVersion());
51 if (sscanf(tmp_expat_version, "expat_%d.%d.%d", &expat_major, &expat_minor, &expat_micro) != 3) {
52 printf("%s, bad expat version string\n", XML_ExpatVersion());
56 /* HP/UX 9 (%@#!) writes to sscanf strings */
57 tmp_version = strdup("$min_expat_version");
58 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
59 printf("%s, bad version string\n", "$min_expat_version");
63 if ((expat_major > major) ||
64 ((expat_major == major) && (expat_minor > minor)) ||
65 ((expat_major == major) && (expat_minor == minor) && (expat_micro >= micro)))
71 printf("\n*** An old version of EXPAT (%d.%d.%d) was found.\n",
72 expat_major, expat_minor, expat_micro);
73 printf("*** You need a version of EXPAT newer than %d.%d.%d. The latest version of\n",
76 printf("*** If you have already installed a sufficiently new version, this error\n");
77 printf("*** probably means that the wrong copy of the expat-config shell script is\n");
78 printf("*** being found. The easiest way to fix this is to remove the old version\n");
79 printf("*** of EXPAT, but you can also set the EXPAT_CONFIG environment to point to the\n");
80 printf("*** correct copy of expat-config. (In this case, you will have to\n");
81 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
82 printf("*** so that the correct libraries are found at run-time))\n");
86 ],, no_expat=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
87 CFLAGS="$ac_save_CFLAGS"
91 if test "x$no_expat" = x ; then
93 ifelse([$2], , :, [$2])
96 if test -f conf.expattest ; then
99 echo "*** Could not run EXPAT test program, checking why..."
100 CFLAGS="$CFLAGS $EXPAT_CFLAGS"
101 LIBS="$LIBS $EXPAT_LIBS"
105 ], [ return (XML_ExpatVersion()); ],
106 [ echo "*** The test program compiled, but did not run. This usually means"
107 echo "*** that the run-time linker is not finding EXPAT or finding the wrong"
108 echo "*** version of EXPAT. If it is not finding EXPAT, you'll need to set your"
109 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
110 echo "*** to the installed location Also, make sure you have run ldconfig if that"
111 echo "*** is required on your system"
113 echo "*** If you have an old version installed, it is best to remove it, although"
114 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
116 [ echo "*** The test program failed to compile or link. See the file config.log for the"
117 echo "*** exact error that occured. This usually means EXPAT was incorrectly installed"
118 echo "*** or that you have moved EXPAT since it was installed. In the latter case, you"
119 echo "*** may want to edit the expat-config script: $EXPAT_CONFIG" ])
120 CFLAGS="$ac_save_CFLAGS"
125 ifelse([$3], , :, [$3])
127 AC_SUBST(EXPAT_CFLAGS)