Magellan Linux

Contents of /trunk/xmms/gentoo-m4/xmms_local.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download)
Tue May 8 20:52:56 2007 UTC (17 years ago) by niro
File size: 6697 byte(s)
-import

1 # Test for libxml by Haavard Kvaalen <havardk@xmms.org>
2 # Based on GLIB test by Owen Taylor
3
4 dnl AM_PATH_LIBXML([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
5 dnl Test for libxml, and define XML_CFLAGS and XML_LIBS
6 dnl
7 AC_DEFUN(AM_PATH_LIBXML,
8 [dnl
9 dnl Get the cflags and libraries from the xml-config script
10 dnl
11 AC_ARG_WITH(libxml-prefix, [ --with-libxml-prefix=PFX Prefix where libxml is installed (optional)],
12 libxml_prefix="$withval", libxml_prefix="")
13 AC_ARG_ENABLE(libxmltest, [ --disable-libxmltest Do not try to compile and run a test libxml program],
14 , enable_libxmltest=yes)
15
16 if test x$libxml_config_prefix != x ; then
17 libxml_config_args="$libxml_config_args --prefix=$libxml_config_prefix"
18 if test x${XML_CONFIG+set} != xset ; then
19 XML_CONFIG=$libxml_config_prefix/bin/xml-config
20 fi
21 fi
22
23 AC_PATH_PROG(XML_CONFIG, xml-config, no)
24 min_libxml_version=ifelse([$1], ,1.0.0, $1)
25 AC_MSG_CHECKING(for libxml - version >= $min_libxml_version)
26 no_libxml=""
27 if test "$XML_CONFIG" = "no" ; then
28 no_libxml=yes
29 else
30 XML_CFLAGS=`$XML_CONFIG $libxml_config_args --cflags`
31 XML_LIBS=`$XML_CONFIG $libxml_config_args --libs`
32 libxml_major_version=`$XML_CONFIG $libxml_config_args --version | \
33 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)[[^0-9]]*/\1/'`
34 libxml_minor_version=`$XML_CONFIG $libxml_config_args --version | \
35 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)[[^0-9]]*/\2/'`
36 libxml_micro_version=`$XML_CONFIG $libxml_config_args --version | \
37 sed 's/[[^0-9]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)[[^0-9]]*/\3/'`
38 if test "x$enable_libxmltest" = "xyes" ; then
39 ac_save_CFLAGS="$CFLAGS"
40 ac_save_LIBS="$LIBS"
41 CFLAGS="$CFLAGS $XML_CFLAGS"
42 LIBS="$XML_LIBS $LIBS"
43 dnl
44 dnl Now check if the installed libxml is sufficiently new. (Also sanity
45 dnl checks the results of xml-config to some extent
46 dnl
47 rm -f conf.libxmltest
48 AC_TRY_RUN([
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <parser.h>
52
53 char*
54 my_strdup (char *str)
55 {
56 char *new_str;
57
58 if (str)
59 {
60 new_str = malloc((strlen (str) + 1) * sizeof(char));
61 strcpy(new_str, str);
62 }
63 else
64 new_str = NULL;
65
66 return new_str;
67 }
68
69 int
70 main ()
71 {
72 int major, minor, micro;
73 char *tmp_version;
74
75 system ("touch conf.libxmltest");
76
77 /* HP/UX 9 (%@#!) writes to sscanf strings */
78 tmp_version = my_strdup("$min_libxml_version");
79 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
80 printf("%s, bad version string\n", "$min_libxml_version");
81 exit(1);
82 }
83
84 if (($libxml_major_version > major) ||
85 (($libxml_major_version == major) && ($libxml_minor_version > minor)) ||
86 (($libxml_major_version == major) && ($libxml_minor_version == minor) && ($libxml_micro_version >= micro)))
87 {
88 return 0;
89 }
90 else
91 {
92 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
93 $libxml_major_version, $libxml_minor_version, $libxml_micro_version);
94 printf("*** You need a version of libxml newer than %d.%d.%d.\n",
95 major, minor, micro);
96 printf("***\n");
97 printf("*** If you have already installed a sufficiently new version, this error\n");
98 printf("*** probably means that the wrong copy of the xml-config shell script is\n");
99 printf("*** being found. The easiest way to fix this is to remove the old version\n");
100 printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
101 printf("*** correct copy of xml-config. (In this case, you will have to\n");
102 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
103 printf("*** so that the correct libraries are found at run-time))\n");
104 }
105 return 1;
106 }
107 ],, no_libxml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
108 CFLAGS="$ac_save_CFLAGS"
109 LIBS="$ac_save_LIBS"
110 fi
111 fi
112 if test "x$no_libxml" = x ; then
113 AC_MSG_RESULT(yes)
114 ifelse([$2], , :, [$2])
115 else
116 AC_MSG_RESULT(no)
117 if test "$XML_CONFIG" = "no" ; then
118 :
119 else
120 if test -f conf.libxmltest ; then
121 :
122 else
123 echo "*** Could not run LIBXML test program, checking why..."
124 CFLAGS="$CFLAGS $XML_CFLAGS"
125 LIBS="$LIBS $XML_LIBS"
126 AC_TRY_LINK([
127 #include <parser.h>
128 #include <stdio.h>
129 ], [ return 0; ],
130 [ echo "*** The test program compiled, but did not run. This usually means"
131 echo "*** that the run-time linker is not finding libxml or finding the"
132 echo "*** wrong version of libxml. If it is not finding libxml, you will"
133 echo "*** need to set your LD_LIBRARY_PATH environment variable, or"
134 echo "*** edit /etc/ld.so.conf to point to the installed location Also,"
135 echo "*** make sure you have run ldconfig if that is required on your system"],
136 [ echo "*** The test program failed to compile or link. See the file config.log"
137 echo "*** for the exact error that occured. This usually means libxml was"
138 echo "*** incorrectly installed or that you have moved libxml since it was"
139 echo "*** installed."])
140 CFLAGS="$ac_save_CFLAGS"
141 LIBS="$ac_save_LIBS"
142 fi
143 fi
144 XML_CFLAGS=""
145 XML_LIBS=""
146 ifelse([$3], , :, [$3])
147 fi
148 AC_SUBST(XML_CFLAGS)
149 AC_SUBST(XML_LIBS)
150 rm -f conf.libxmltest
151 ])
152
153 ##--## local
154
155 dnl XMMS_FUNC_POSIX(FUNCTION... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
156 dnl Test for functions in posix libraries, and define POSIX_LIBS
157 AC_DEFUN(XMMS_FUNC_POSIX,
158 [dnl
159 xmms_posix4=no
160 xmms_rt=no
161 for xmms_func in $1
162 do
163 xmms_have_func=no
164 AC_CHECK_FUNC($xmms_func,xmms_have_func=yes,[
165 dnl try in libposix4 if not found in current LIBS
166 AC_CHECK_LIB(posix4,$xmms_func,[xmms_have_func=yes xmms_posix4=yes],[
167 dnl try in librt, if not found so far
168 AC_CHECK_LIB(rt,$xmms_func,[xmms_have_func=yes xmms_rt=yes])
169 ])
170 ])
171 if test $xmms_have_func = yes; then
172 changequote(, )dnl
173 xmms_tr_func=HAVE_`echo $xmms_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
174 changequote([, ])dnl
175 AC_DEFINE_UNQUOTED($xmms_tr_func)
176 ifelse([$2], , :, [$2])
177 else
178 ifelse([$3], , :, [$3])
179 fi
180 done
181 POSIX_LIBS=
182 if test $xmms_posix4 = yes; then
183 POSIX_LIBS=-lposix4
184 fi
185 if test $xmms_rt = yes; then
186 POSIX_LIBS="$POSIX_LIBS -lrt"
187 fi
188 AC_SUBST(POSIX_LIBS)
189 ])