1 dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
2 dnl if the cache file is inconsistent with the current host,
3 dnl target and build system types, execute CMD or print a default
5 AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
6 AC_REQUIRE([AC_CANONICAL_SYSTEM])
7 AC_MSG_CHECKING([config.cache system type])
8 if { test x"${ac_cv_host_system_type+set}" = x"set" &&
9 test x"$ac_cv_host_system_type" != x"$host"; } ||
10 { test x"${ac_cv_build_system_type+set}" = x"set" &&
11 test x"$ac_cv_build_system_type" != x"$build"; } ||
12 { test x"${ac_cv_target_system_type+set}" = x"set" &&
13 test x"$ac_cv_target_system_type" != x"$target"; }; then
14 AC_MSG_RESULT([different])
16 [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
20 ac_cv_host_system_type="$host"
21 ac_cv_build_system_type="$build"
22 ac_cv_target_system_type="$target"
26 dnl test whether dirent has a d_off member
27 AC_DEFUN(AC_DIRENT_D_OFF,
28 [AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off,
31 #include <sys/types.h>
32 #include <dirent.h>], [struct dirent d; d.d_off;],
33 ac_cv_dirent_d_off=yes, ac_cv_dirent_d_off=no)])
34 if test $ac_cv_dirent_d_off = yes; then
35 AC_DEFINE(HAVE_DIRENT_D_OFF,1,[Whether dirent has a d_off member])
40 dnl AC_PROG_CC_FLAG(flag)
41 AC_DEFUN(AC_PROG_CC_FLAG,
42 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
43 [echo 'void f(){}' > conftest.c
44 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
52 dnl see if a declaration exists for a function or variable
53 dnl defines HAVE_function_DECL if it exists
54 dnl AC_HAVE_DECL(var, includes)
55 AC_DEFUN(AC_HAVE_DECL,
57 AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
58 AC_TRY_COMPILE([$2],[int i = (int)$1],
59 ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
60 if test x"$ac_cv_have_$1_decl" = x"yes"; then
61 AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
66 dnl check for a function in a library, but don't
67 dnl keep adding the same library to the LIBS variable.
68 dnl AC_LIBTESTFUNC(lib,func)
69 AC_DEFUN(AC_LIBTESTFUNC,
71 *-l$1*) AC_CHECK_FUNCS($2) ;;
72 *) AC_CHECK_LIB($1, $2)
78 dnl Define an AC_DEFINE with ifndef guard.
79 dnl AC_N_DEFINE(VARIABLE [, VALUE])
81 [cat >> confdefs.h <<\EOF
83 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
89 dnl AC_ADD_INCLUDE(VARIABLE)
90 define(AC_ADD_INCLUDE,
91 [cat >> confdefs.h <<\EOF
96 dnl Copied from libtool.m4
97 AC_DEFUN(AC_PROG_LD_GNU,
98 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
99 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
100 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
101 ac_cv_prog_gnu_ld=yes
107 # Configure paths for LIBXML2
108 # Toshio Kuratomi 2001-04-21
110 # Configure paths for GLIB
111 # Owen Taylor 97-11-3
113 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
114 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
116 AC_DEFUN(AM_PATH_XML2,[
117 AC_ARG_WITH(xml-prefix,
118 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
119 xml_config_prefix="$withval", xml_config_prefix="")
120 AC_ARG_WITH(xml-exec-prefix,
121 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
122 xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
123 AC_ARG_ENABLE(xmltest,
124 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
127 if test x$xml_config_exec_prefix != x ; then
128 xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
129 if test x${XML2_CONFIG+set} != xset ; then
130 XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
133 if test x$xml_config_prefix != x ; then
134 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
135 if test x${XML2_CONFIG+set} != xset ; then
136 XML2_CONFIG=$xml_config_prefix/bin/xml2-config
140 AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
141 min_xml_version=ifelse([$1], ,2.0.0,[$1])
142 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
144 if test "$XML2_CONFIG" = "no" ; then
147 XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
148 XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
149 xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
150 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
151 xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
152 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
153 xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
154 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
155 if test "x$enable_xmltest" = "xyes" ; then
156 ac_save_CFLAGS="$CFLAGS"
158 CFLAGS="$CFLAGS $XML_CFLAGS"
159 LIBS="$XML_LIBS $LIBS"
161 dnl Now check if the installed libxml is sufficiently new.
162 dnl (Also sanity checks the results of xml2-config to some extent)
169 #include <libxml/xmlversion.h>
174 int xml_major_version, xml_minor_version, xml_micro_version;
175 int major, minor, micro;
178 system("touch conf.xmltest");
180 /* Capture xml2-config output via autoconf/configure variables */
181 /* HP/UX 9 (%@#!) writes to sscanf strings */
182 tmp_version = (char *)strdup("$min_xml_version");
183 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
184 printf("%s, bad version string from xml2-config\n", "$min_xml_version");
189 /* Capture the version information from the header files */
190 tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
191 if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
192 printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
197 /* Compare xml2-config output to the libxml headers */
198 if ((xml_major_version != $xml_config_major_version) ||
199 (xml_minor_version != $xml_config_minor_version) ||
200 (xml_micro_version != $xml_config_micro_version))
202 printf("*** libxml header files (version %d.%d.%d) do not match\n",
203 xml_major_version, xml_minor_version, xml_micro_version);
204 printf("*** xml2-config (version %d.%d.%d)\n",
205 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
208 /* Compare the headers to the library to make sure we match */
209 /* Less than ideal -- doesn't provide us with return value feedback,
210 * only exits if there's a serious mismatch between header and library.
214 /* Test that the library is greater than our minimum version */
215 if ((xml_major_version > major) ||
216 ((xml_major_version == major) && (xml_minor_version > minor)) ||
217 ((xml_major_version == major) && (xml_minor_version == minor) &&
218 (xml_micro_version >= micro)))
224 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
225 xml_major_version, xml_minor_version, xml_micro_version);
226 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
227 major, minor, micro);
228 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
230 printf("*** If you have already installed a sufficiently new version, this error\n");
231 printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
232 printf("*** being found. The easiest way to fix this is to remove the old version\n");
233 printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
234 printf("*** correct copy of xml2-config. (In this case, you will have to\n");
235 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
236 printf("*** so that the correct libraries are found at run-time))\n");
240 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
241 CFLAGS="$ac_save_CFLAGS"
246 if test "x$no_xml" = x ; then
247 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
248 ifelse([$2], , :, [$2])
251 if test "$XML2_CONFIG" = "no" ; then
252 echo "*** The xml2-config script installed by LIBXML could not be found"
253 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
254 echo "*** your path, or set the XML2_CONFIG environment variable to the"
255 echo "*** full path to xml2-config."
257 if test -f conf.xmltest ; then
260 echo "*** Could not run libxml test program, checking why..."
261 CFLAGS="$CFLAGS $XML_CFLAGS"
262 LIBS="$LIBS $XML_LIBS"
264 #include <libxml/xmlversion.h>
266 ], [ LIBXML_TEST_VERSION; return 0;],
267 [ echo "*** The test program compiled, but did not run. This usually means"
268 echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
269 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
270 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
271 echo "*** to the installed location Also, make sure you have run ldconfig if that"
272 echo "*** is required on your system"
274 echo "*** If you have an old version installed, it is best to remove it, although"
275 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
276 [ echo "*** The test program failed to compile or link. See the file config.log for the"
277 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
278 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
279 echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
280 CFLAGS="$ac_save_CFLAGS"
287 ifelse([$3], , :, [$3])
294 # =========================================================================
295 # AM_PATH_MYSQL : MySQL library
297 dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
298 dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS
300 AC_DEFUN(AM_PATH_MYSQL,
302 dnl Get the cflags and libraries from the mysql_config script
304 AC_ARG_WITH(mysql-prefix,[ --with-mysql-prefix=PFX Prefix where MYSQL is installed (optional)],
305 mysql_prefix="$withval", mysql_prefix="")
306 AC_ARG_WITH(mysql-exec-prefix,[ --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)],
307 mysql_exec_prefix="$withval", mysql_exec_prefix="")
308 AC_ARG_ENABLE(mysqltest, [ --disable-mysqltest Do not try to compile and run a test MYSQL program],
309 , enable_mysqltest=yes)
311 if test x$mysql_exec_prefix != x ; then
312 mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix"
313 if test x${MYSQL_CONFIG+set} != xset ; then
314 MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config
317 if test x$mysql_prefix != x ; then
318 mysql_args="$mysql_args --prefix=$mysql_prefix"
319 if test x${MYSQL_CONFIG+set} != xset ; then
320 MYSQL_CONFIG=$mysql_prefix/bin/mysql_config
324 AC_REQUIRE([AC_CANONICAL_TARGET])
325 AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
326 min_mysql_version=ifelse([$1], ,0.11.0,$1)
327 AC_MSG_CHECKING(for MYSQL - version >= $min_mysql_version)
329 if test "$MYSQL_CONFIG" = "no" ; then
332 MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"`
333 MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"`
335 mysql_major_version=`$MYSQL_CONFIG $mysql_args --version | \
336 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
337 mysql_minor_version=`$MYSQL_CONFIG $mysql_args --version | \
338 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
339 mysql_micro_version=`$MYSQL_CONFIG $mysql_config_args --version | \
340 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
341 if test "x$enable_mysqltest" = "xyes" ; then
342 ac_save_CFLAGS="$CFLAGS"
344 CFLAGS="$CFLAGS $MYSQL_CFLAGS"
345 LIBS="$LIBS $MYSQL_LIBS"
347 dnl Now check if the installed MYSQL is sufficiently new. (Also sanity
348 dnl checks the results of mysql_config to some extent
358 my_strdup (char *str)
364 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
365 strcpy (new_str, str);
373 int main (int argc, char *argv[])
375 int major, minor, micro;
378 /* This hangs on some systems (?)
379 system ("touch conf.mysqltest");
381 { FILE *fp = fopen("conf.mysqltest", "a"); if ( fp ) fclose(fp); }
383 /* HP/UX 9 (%@#!) writes to sscanf strings */
384 tmp_version = my_strdup("$min_mysql_version");
385 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
386 printf("%s, bad version string\n", "$min_mysql_version");
390 if (($mysql_major_version > major) ||
391 (($mysql_major_version == major) && ($mysql_minor_version > minor)) ||
392 (($mysql_major_version == major) && ($mysql_minor_version == minor) && ($mysql_micro_version >= micro)))
398 printf("\n*** 'mysql_config --version' returned %d.%d.%d, but the minimum version\n", $mysql_major_version, $mysql_minor_version, $mysql_micro_version);
399 printf("*** of MYSQL required is %d.%d.%d. If mysql_config is correct, then it is\n", major, minor, micro);
400 printf("*** best to upgrade to the required version.\n");
401 printf("*** If mysql_config was wrong, set the environment variable MYSQL_CONFIG\n");
402 printf("*** to point to the correct copy of mysql_config, and remove the file\n");
403 printf("*** config.cache before re-running configure\n");
408 ],, no_mysql=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
409 CFLAGS="$ac_save_CFLAGS"
413 if test "x$no_mysql" = x ; then
415 ifelse([$2], , :, [$2])
418 if test "$MYSQL_CONFIG" = "no" ; then
419 echo "*** The mysql_config script installed by MYSQL could not be found"
420 echo "*** If MYSQL was installed in PREFIX, make sure PREFIX/bin is in"
421 echo "*** your path, or set the MYSQL_CONFIG environment variable to the"
422 echo "*** full path to mysql_config."
424 if test -f conf.mysqltest ; then
427 echo "*** Could not run MYSQL test program, checking why..."
428 CFLAGS="$CFLAGS $MYSQL_CFLAGS"
429 LIBS="$LIBS $MYSQL_LIBS"
434 int main(int argc, char *argv[])
437 #define main K_and_R_C_main
439 [ echo "*** The test program compiled, but did not run. This usually means"
440 echo "*** that the run-time linker is not finding MYSQL or finding the wrong"
441 echo "*** version of MYSQL. If it is not finding MYSQL, you'll need to set your"
442 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
443 echo "*** to the installed location Also, make sure you have run ldconfig if that"
444 echo "*** is required on your system"
446 echo "*** If you have an old version installed, it is best to remove it, although"
447 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
448 [ echo "*** The test program failed to compile or link. See the file config.log for the"
449 echo "*** exact error that occured. This usually means MYSQL was incorrectly installed"
450 echo "*** or that you have moved MYSQL since it was installed. In the latter case, you"
451 echo "*** may want to edit the mysql_config script: $MYSQL_CONFIG" ])
452 CFLAGS="$ac_save_CFLAGS"
458 ifelse([$3], , :, [$3])
460 AC_SUBST(MYSQL_CFLAGS)
465 dnl Removes -I/usr/include/? from given variable
466 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
470 -I/usr/include|-I/usr/include/) ;;
471 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
477 dnl Removes -L/usr/lib/? from given variable
478 AC_DEFUN(LIB_REMOVE_USR_LIB,[
482 -L/usr/lib|-L/usr/lib/) ;;
483 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
489 dnl From Bruno Haible.
493 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
494 dnl those with the standalone portable libiconv installed).
495 AC_MSG_CHECKING(for iconv in $1)
496 jm_cv_func_iconv="no"
499 AC_TRY_LINK([#include <stdlib.h>
500 #include <giconv.h>],
501 [iconv_t cd = iconv_open("","");
502 iconv(cd,NULL,NULL,NULL,NULL);
507 if test "$jm_cv_func_iconv" != yes; then
508 AC_TRY_LINK([#include <stdlib.h>
510 [iconv_t cd = iconv_open("","");
511 iconv(cd,NULL,NULL,NULL,NULL);
513 jm_cv_func_iconv=yes)
515 if test "$jm_cv_lib_iconv" != yes; then
517 LIBS="$LIBS -lgiconv"
518 AC_TRY_LINK([#include <stdlib.h>
519 #include <giconv.h>],
520 [iconv_t cd = iconv_open("","");
521 iconv(cd,NULL,NULL,NULL,NULL);
528 if test "$jm_cv_func_iconv" != yes; then
531 AC_TRY_LINK([#include <stdlib.h>
533 [iconv_t cd = iconv_open("","");
534 iconv(cd,NULL,NULL,NULL,NULL);
537 jm_cv_func_iconv=yes)
543 if test "$jm_cv_func_iconv" = yes; then
544 if test "$jm_cv_giconv" = yes; then
545 AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
549 AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
556 if test "$jm_cv_lib_iconv" = yes; then
557 if test "$jm_cv_giconv" = yes; then
558 LIBS="$LIBS -lgiconv"
565 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
566 dnl This function doesn't add -I/usr/include into CFLAGS
567 AC_DEFUN(CFLAGS_ADD_DIR,[
568 if test "$2" != "/usr/include" ; then
573 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
574 dnl This function doesn't add -L/usr/lib into LDFLAGS
575 AC_DEFUN(LIB_ADD_DIR,[
576 if test "$2" != "/usr/lib" ; then
581 dnl AC_ENABLE_SHARED - implement the --enable-shared flag
582 dnl Usage: AC_ENABLE_SHARED[(DEFAULT)]
583 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
585 AC_DEFUN([AC_ENABLE_SHARED],
586 [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
587 AC_ARG_ENABLE(shared,
588 changequote(<<, >>)dnl
589 << --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
591 [p=${PACKAGE-default}
593 yes) enable_shared=yes ;;
594 no) enable_shared=no ;;
597 # Look at the argument we got. We use all the common list separators.
598 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
599 for pkg in $enableval; do
600 if test "X$pkg" = "X$p"; then
608 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
611 dnl AC_ENABLE_STATIC - implement the --enable-static flag
612 dnl Usage: AC_ENABLE_STATIC[(DEFAULT)]
613 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
615 AC_DEFUN([AC_ENABLE_STATIC],
616 [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
617 AC_ARG_ENABLE(static,
618 changequote(<<, >>)dnl
619 << --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
621 [p=${PACKAGE-default}
623 yes) enable_static=yes ;;
624 no) enable_static=no ;;
627 # Look at the argument we got. We use all the common list separators.
628 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
629 for pkg in $enableval; do
630 if test "X$pkg" = "X$p"; then
637 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
640 dnl AC_DISABLE_STATIC - set the default static flag to --disable-static
641 AC_DEFUN([AC_DISABLE_STATIC],
642 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
643 AC_ENABLE_STATIC(no)])