]> git.pld-linux.org Git - packages/crossmingw32-expat.git/blame - expat.m4
- destdir no longer needed; update ac_fixes
[packages/crossmingw32-expat.git] / expat.m4
CommitLineData
c4edeee5 1dnl AM_PATH_EXPAT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2dnl Test for EXPAT, and define EXPAT_CFLAGS and EXPAT_LIBS
3dnl
5ea5c01e 4AC_DEFUN([AM_PATH_EXPAT],
c4edeee5 5[dnl
6dnl Get the cflags and libraries from the expat-config script
7dnl
8AC_ARG_WITH(expat-prefix,[ --with-expat=PFX Prefix where EXPAT is installed (optional)])
9AC_ARG_ENABLE(expattest, [ --disable-expattest Do not try to compile and run a test EXPAT program],
10 , enable_expattest=yes)
11
12 if test x$with_expat != x ; then
13 EXPAT_CFLAGS="-I$with_expat/include"
14 EXPAT_LIBS="-L$with_expat/lib"
15 fi
16
17 min_expat_version=ifelse([$1], ,1.95.1, $1)
18 AC_MSG_CHECKING(for EXPAT - version >= $min_expat_version)
19
20 EXPAT_CFLAGS="$EXPAT_CFLAGS"
21 EXPAT_LIBS="$EXPAT_LIBS -lexpat"
22
23 if test "x$enable_expattest" = "xyes" ; then
24 ac_save_CFLAGS="$CFLAGS"
25 ac_save_LIBS="$LIBS"
26 CFLAGS="$CFLAGS $EXPAT_CFLAGS"
27 LIBS="$EXPAT_LIBS $LIBS"
28dnl
29dnl Now check if the installed EXPAT is sufficiently new. (Also sanity
30dnl checks the results of expat-config to some extent
31dnl
32 rm -f conf.expattest
33 AC_TRY_RUN([
34#include <expat.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38
39int
40main ()
41{
42 int expat_major, expat_minor, expat_micro;
43 int major, minor, micro;
44 char *tmp_expat_version;
45 char *tmp_version;
46
47 system ("touch conf.expattest");
48
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());
53 exit(1);
54 }
55
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, &micro) != 3) {
59 printf("%s, bad version string\n", "$min_expat_version");
60 exit(1);
61 }
62
63 if ((expat_major > major) ||
64 ((expat_major == major) && (expat_minor > minor)) ||
65 ((expat_major == major) && (expat_minor == minor) && (expat_micro >= micro)))
66 {
67 return 0;
68 }
69 else
70 {
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",
74 major, minor, micro);
75 printf("***\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");
83 }
84 return 1;
85}
86],, no_expat=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
87 CFLAGS="$ac_save_CFLAGS"
88 LIBS="$ac_save_LIBS"
89 fi
90
91 if test "x$no_expat" = x ; then
92 AC_MSG_RESULT(yes)
93 ifelse([$2], , :, [$2])
94 else
95 AC_MSG_RESULT(no)
96 if test -f conf.expattest ; then
97 :
98 else
99 echo "*** Could not run EXPAT test program, checking why..."
100 CFLAGS="$CFLAGS $EXPAT_CFLAGS"
101 LIBS="$LIBS $EXPAT_LIBS"
102 AC_TRY_LINK([
103#include <expat.h>
104#include <stdio.h>
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"
112 echo "***"
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"
115 echo "***" ],
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"
121 LIBS="$ac_save_LIBS"
122 fi
123 EXPAT_CFLAGS=""
124 EXPAT_LIBS=""
125 ifelse([$3], , :, [$3])
126 fi
127 AC_SUBST(EXPAT_CFLAGS)
128 AC_SUBST(EXPAT_LIBS)
129 rm -f conf.expattest
130])
This page took 0.11415 seconds and 4 git commands to generate.