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])
39 dnl Mark specified module as shared
40 dnl SMB_MODULE(type,name,static_files,shared_files,subsystem)
43 AC_MSG_CHECKING([how to build $2])
44 if test x"$1" = xSHARED; then
45 AC_DEFINE([$2][_init], [init_module], [Whether to build $2 as shared module])
46 $5_MODULES="$$5_MODULES $4"
47 AC_MSG_RESULT([shared])
48 elif test x"$1" = xSTATIC; then
49 [init_static_modules_]translit([$5], [A-Z], [a-z])="$[init_static_modules_]translit([$5], [A-Z], [a-z]) $2_init();"
50 $5_STATIC="$$5_STATIC $3"
52 AC_MSG_RESULT([static])
58 AC_DEFUN(SMB_SUBSYSTEM,
62 AC_DEFINE_UNQUOTED([static_init_]translit([$1], [A-Z], [a-z]), ["$init_static_modules_]translit([$1], [A-Z], [a-z])["], [Static init functions])
65 dnl AC_PROG_CC_FLAG(flag)
66 AC_DEFUN(AC_PROG_CC_FLAG,
67 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
68 [echo 'void f(){}' > conftest.c
69 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
77 dnl see if a declaration exists for a function or variable
78 dnl defines HAVE_function_DECL if it exists
79 dnl AC_HAVE_DECL(var, includes)
80 AC_DEFUN(AC_HAVE_DECL,
82 AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
83 AC_TRY_COMPILE([$2],[int i = (int)$1],
84 ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
85 if test x"$ac_cv_have_$1_decl" = x"yes"; then
86 AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
91 dnl check for a function in a library, but don't
92 dnl keep adding the same library to the LIBS variable.
93 dnl AC_LIBTESTFUNC(lib,func)
94 AC_DEFUN(AC_LIBTESTFUNC,
96 *-l$1*) AC_CHECK_FUNCS($2) ;;
97 *) AC_CHECK_LIB($1, $2)
103 dnl Define an AC_DEFINE with ifndef guard.
104 dnl AC_N_DEFINE(VARIABLE [, VALUE])
106 [cat >> confdefs.h <<\EOF
108 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
114 dnl AC_ADD_INCLUDE(VARIABLE)
115 define(AC_ADD_INCLUDE,
116 [cat >> confdefs.h <<\EOF
121 dnl Copied from libtool.m4
122 AC_DEFUN(AC_PROG_LD_GNU,
123 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
124 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
125 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
126 ac_cv_prog_gnu_ld=yes
132 # Configure paths for LIBXML2
133 # Toshio Kuratomi 2001-04-21
135 # Configure paths for GLIB
136 # Owen Taylor 97-11-3
138 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
139 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
141 AC_DEFUN(AM_PATH_XML2,[
142 AC_ARG_WITH(xml-prefix,
143 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
144 xml_config_prefix="$withval", xml_config_prefix="")
145 AC_ARG_WITH(xml-exec-prefix,
146 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
147 xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
148 AC_ARG_ENABLE(xmltest,
149 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
152 if test x$xml_config_exec_prefix != x ; then
153 xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
154 if test x${XML2_CONFIG+set} != xset ; then
155 XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
158 if test x$xml_config_prefix != x ; then
159 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
160 if test x${XML2_CONFIG+set} != xset ; then
161 XML2_CONFIG=$xml_config_prefix/bin/xml2-config
165 AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
166 min_xml_version=ifelse([$1], ,2.0.0,[$1])
167 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
169 if test "$XML2_CONFIG" = "no" ; then
172 XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
173 XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
174 xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
175 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
176 xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
177 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
178 xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
179 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
180 if test "x$enable_xmltest" = "xyes" ; then
181 ac_save_CFLAGS="$CFLAGS"
183 CFLAGS="$CFLAGS $XML_CFLAGS"
184 LIBS="$XML_LIBS $LIBS"
186 dnl Now check if the installed libxml is sufficiently new.
187 dnl (Also sanity checks the results of xml2-config to some extent)
194 #include <libxml/xmlversion.h>
199 int xml_major_version, xml_minor_version, xml_micro_version;
200 int major, minor, micro;
203 system("touch conf.xmltest");
205 /* Capture xml2-config output via autoconf/configure variables */
206 /* HP/UX 9 (%@#!) writes to sscanf strings */
207 tmp_version = (char *)strdup("$min_xml_version");
208 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
209 printf("%s, bad version string from xml2-config\n", "$min_xml_version");
214 /* Capture the version information from the header files */
215 tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
216 if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
217 printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
222 /* Compare xml2-config output to the libxml headers */
223 if ((xml_major_version != $xml_config_major_version) ||
224 (xml_minor_version != $xml_config_minor_version) ||
225 (xml_micro_version != $xml_config_micro_version))
227 printf("*** libxml header files (version %d.%d.%d) do not match\n",
228 xml_major_version, xml_minor_version, xml_micro_version);
229 printf("*** xml2-config (version %d.%d.%d)\n",
230 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
233 /* Compare the headers to the library to make sure we match */
234 /* Less than ideal -- doesn't provide us with return value feedback,
235 * only exits if there's a serious mismatch between header and library.
239 /* Test that the library is greater than our minimum version */
240 if ((xml_major_version > major) ||
241 ((xml_major_version == major) && (xml_minor_version > minor)) ||
242 ((xml_major_version == major) && (xml_minor_version == minor) &&
243 (xml_micro_version >= micro)))
249 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
250 xml_major_version, xml_minor_version, xml_micro_version);
251 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
252 major, minor, micro);
253 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
255 printf("*** If you have already installed a sufficiently new version, this error\n");
256 printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
257 printf("*** being found. The easiest way to fix this is to remove the old version\n");
258 printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
259 printf("*** correct copy of xml2-config. (In this case, you will have to\n");
260 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
261 printf("*** so that the correct libraries are found at run-time))\n");
265 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
266 CFLAGS="$ac_save_CFLAGS"
271 if test "x$no_xml" = x ; then
272 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
273 ifelse([$2], , :, [$2])
276 if test "$XML2_CONFIG" = "no" ; then
277 echo "*** The xml2-config script installed by LIBXML could not be found"
278 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
279 echo "*** your path, or set the XML2_CONFIG environment variable to the"
280 echo "*** full path to xml2-config."
282 if test -f conf.xmltest ; then
285 echo "*** Could not run libxml test program, checking why..."
286 CFLAGS="$CFLAGS $XML_CFLAGS"
287 LIBS="$LIBS $XML_LIBS"
289 #include <libxml/xmlversion.h>
291 ], [ LIBXML_TEST_VERSION; return 0;],
292 [ echo "*** The test program compiled, but did not run. This usually means"
293 echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
294 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
295 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
296 echo "*** to the installed location Also, make sure you have run ldconfig if that"
297 echo "*** is required on your system"
299 echo "*** If you have an old version installed, it is best to remove it, although"
300 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
301 [ echo "*** The test program failed to compile or link. See the file config.log for the"
302 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
303 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
304 echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
305 CFLAGS="$ac_save_CFLAGS"
312 ifelse([$3], , :, [$3])
319 # =========================================================================
320 # AM_PATH_MYSQL : MySQL library
322 dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
323 dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS
325 AC_DEFUN(AM_PATH_MYSQL,
327 dnl Get the cflags and libraries from the mysql_config script
329 AC_ARG_WITH(mysql-prefix,[ --with-mysql-prefix=PFX Prefix where MYSQL is installed (optional)],
330 mysql_prefix="$withval", mysql_prefix="")
331 AC_ARG_WITH(mysql-exec-prefix,[ --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)],
332 mysql_exec_prefix="$withval", mysql_exec_prefix="")
333 AC_ARG_ENABLE(mysqltest, [ --disable-mysqltest Do not try to compile and run a test MYSQL program],
334 , enable_mysqltest=yes)
336 if test x$mysql_exec_prefix != x ; then
337 mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix"
338 if test x${MYSQL_CONFIG+set} != xset ; then
339 MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config
342 if test x$mysql_prefix != x ; then
343 mysql_args="$mysql_args --prefix=$mysql_prefix"
344 if test x${MYSQL_CONFIG+set} != xset ; then
345 MYSQL_CONFIG=$mysql_prefix/bin/mysql_config
349 AC_REQUIRE([AC_CANONICAL_TARGET])
350 AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
351 min_mysql_version=ifelse([$1], ,0.11.0,$1)
352 AC_MSG_CHECKING(for MYSQL - version >= $min_mysql_version)
354 if test "$MYSQL_CONFIG" = "no" ; then
357 MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"`
358 MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"`
360 mysql_major_version=`$MYSQL_CONFIG $mysql_args --version | \
361 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
362 mysql_minor_version=`$MYSQL_CONFIG $mysql_args --version | \
363 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
364 mysql_micro_version=`$MYSQL_CONFIG $mysql_config_args --version | \
365 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
366 if test "x$enable_mysqltest" = "xyes" ; then
367 ac_save_CFLAGS="$CFLAGS"
369 CFLAGS="$CFLAGS $MYSQL_CFLAGS"
370 LIBS="$LIBS $MYSQL_LIBS"
372 dnl Now check if the installed MYSQL is sufficiently new. (Also sanity
373 dnl checks the results of mysql_config to some extent
383 my_strdup (char *str)
389 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
390 strcpy (new_str, str);
398 int main (int argc, char *argv[])
400 int major, minor, micro;
403 /* This hangs on some systems (?)
404 system ("touch conf.mysqltest");
406 { FILE *fp = fopen("conf.mysqltest", "a"); if ( fp ) fclose(fp); }
408 /* HP/UX 9 (%@#!) writes to sscanf strings */
409 tmp_version = my_strdup("$min_mysql_version");
410 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
411 printf("%s, bad version string\n", "$min_mysql_version");
415 if (($mysql_major_version > major) ||
416 (($mysql_major_version == major) && ($mysql_minor_version > minor)) ||
417 (($mysql_major_version == major) && ($mysql_minor_version == minor) && ($mysql_micro_version >= micro)))
423 printf("\n*** 'mysql_config --version' returned %d.%d.%d, but the minimum version\n", $mysql_major_version, $mysql_minor_version, $mysql_micro_version);
424 printf("*** of MYSQL required is %d.%d.%d. If mysql_config is correct, then it is\n", major, minor, micro);
425 printf("*** best to upgrade to the required version.\n");
426 printf("*** If mysql_config was wrong, set the environment variable MYSQL_CONFIG\n");
427 printf("*** to point to the correct copy of mysql_config, and remove the file\n");
428 printf("*** config.cache before re-running configure\n");
433 ],, no_mysql=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
434 CFLAGS="$ac_save_CFLAGS"
438 if test "x$no_mysql" = x ; then
440 ifelse([$2], , :, [$2])
443 if test "$MYSQL_CONFIG" = "no" ; then
444 echo "*** The mysql_config script installed by MYSQL could not be found"
445 echo "*** If MYSQL was installed in PREFIX, make sure PREFIX/bin is in"
446 echo "*** your path, or set the MYSQL_CONFIG environment variable to the"
447 echo "*** full path to mysql_config."
449 if test -f conf.mysqltest ; then
452 echo "*** Could not run MYSQL test program, checking why..."
453 CFLAGS="$CFLAGS $MYSQL_CFLAGS"
454 LIBS="$LIBS $MYSQL_LIBS"
459 int main(int argc, char *argv[])
462 #define main K_and_R_C_main
464 [ echo "*** The test program compiled, but did not run. This usually means"
465 echo "*** that the run-time linker is not finding MYSQL or finding the wrong"
466 echo "*** version of MYSQL. If it is not finding MYSQL, you'll need to set your"
467 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
468 echo "*** to the installed location Also, make sure you have run ldconfig if that"
469 echo "*** is required on your system"
471 echo "*** If you have an old version installed, it is best to remove it, although"
472 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
473 [ echo "*** The test program failed to compile or link. See the file config.log for the"
474 echo "*** exact error that occured. This usually means MYSQL was incorrectly installed"
475 echo "*** or that you have moved MYSQL since it was installed. In the latter case, you"
476 echo "*** may want to edit the mysql_config script: $MYSQL_CONFIG" ])
477 CFLAGS="$ac_save_CFLAGS"
483 ifelse([$3], , :, [$3])
485 AC_SUBST(MYSQL_CFLAGS)
490 dnl Removes -I/usr/include/? from given variable
491 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
495 -I/usr/include|-I/usr/include/) ;;
496 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
502 dnl Removes -L/usr/lib/? from given variable
503 AC_DEFUN(LIB_REMOVE_USR_LIB,[
507 -L/usr/lib|-L/usr/lib/) ;;
508 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
514 dnl From Bruno Haible.
518 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
519 dnl those with the standalone portable libiconv installed).
520 AC_MSG_CHECKING(for iconv in $1)
521 jm_cv_func_iconv="no"
524 AC_TRY_LINK([#include <stdlib.h>
525 #include <giconv.h>],
526 [iconv_t cd = iconv_open("","");
527 iconv(cd,NULL,NULL,NULL,NULL);
532 if test "$jm_cv_func_iconv" != yes; then
533 AC_TRY_LINK([#include <stdlib.h>
535 [iconv_t cd = iconv_open("","");
536 iconv(cd,NULL,NULL,NULL,NULL);
538 jm_cv_func_iconv=yes)
540 if test "$jm_cv_lib_iconv" != yes; then
542 LIBS="$LIBS -lgiconv"
543 AC_TRY_LINK([#include <stdlib.h>
544 #include <giconv.h>],
545 [iconv_t cd = iconv_open("","");
546 iconv(cd,NULL,NULL,NULL,NULL);
553 if test "$jm_cv_func_iconv" != yes; then
556 AC_TRY_LINK([#include <stdlib.h>
558 [iconv_t cd = iconv_open("","");
559 iconv(cd,NULL,NULL,NULL,NULL);
562 jm_cv_func_iconv=yes)
568 if test "$jm_cv_func_iconv" = yes; then
569 if test "$jm_cv_giconv" = yes; then
570 AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
574 AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
581 if test "$jm_cv_lib_iconv" = yes; then
582 if test "$jm_cv_giconv" = yes; then
583 LIBS="$LIBS -lgiconv"
590 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
591 dnl This function doesn't add -I/usr/include into CFLAGS
592 AC_DEFUN(CFLAGS_ADD_DIR,[
593 if test "$2" != "/usr/include" ; then
598 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
599 dnl This function doesn't add -L/usr/lib into LDFLAGS
600 AC_DEFUN(LIB_ADD_DIR,[
601 if test "$2" != "/usr/lib" ; then
606 dnl AC_ENABLE_SHARED - implement the --enable-shared flag
607 dnl Usage: AC_ENABLE_SHARED[(DEFAULT)]
608 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
610 AC_DEFUN([AC_ENABLE_SHARED],
611 [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
612 AC_ARG_ENABLE(shared,
613 changequote(<<, >>)dnl
614 << --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
616 [p=${PACKAGE-default}
618 yes) enable_shared=yes ;;
619 no) enable_shared=no ;;
622 # Look at the argument we got. We use all the common list separators.
623 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
624 for pkg in $enableval; do
625 if test "X$pkg" = "X$p"; then
633 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
636 dnl AC_ENABLE_STATIC - implement the --enable-static flag
637 dnl Usage: AC_ENABLE_STATIC[(DEFAULT)]
638 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
640 AC_DEFUN([AC_ENABLE_STATIC],
641 [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
642 AC_ARG_ENABLE(static,
643 changequote(<<, >>)dnl
644 << --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
646 [p=${PACKAGE-default}
648 yes) enable_static=yes ;;
649 no) enable_static=no ;;
652 # Look at the argument we got. We use all the common list separators.
653 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
654 for pkg in $enableval; do
655 if test "X$pkg" = "X$p"; then
662 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
665 dnl AC_DISABLE_STATIC - set the default static flag to --disable-static
666 AC_DEFUN([AC_DISABLE_STATIC],
667 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
668 AC_ENABLE_STATIC(no)])