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 Specify the default build method of this module
40 dnl SMB_MODULE_DEFAULT(name,default_build)
41 AC_DEFUN(SMB_MODULE_DEFAULT,
43 dnl Fall back to static if dlopen() is not available
44 eval MODULE_DEFAULT_$1=$2
46 if test x"MODULE_DEFAULT_$1" = xSHARED -a x"$ac_cv_func_dlopen" != xyes; then
47 eval MODULE_DEFAULT_$1=STATIC
51 dnl Mark specified module as shared
52 dnl SMB_MODULE(name,default_build,static_files,shared_files,subsystem,whatif-static,whatif-shared,whatif-not)
55 AC_MSG_CHECKING([how to build $1])
56 if test -z "$[MODULE_DEFAULT_][$1]"; then
57 eval MODULE_DEFAULT_$1=$2
59 if test x"MODULE_DEFAULT_$1" = xSHARED -a x"$ac_cv_func_dlopen" != xyes; then
60 eval MODULE_DEFAULT_$1=STATIC
64 if test "$[MODULE_][$1]"; then
66 elif test "$[MODULE_]translit([$5], [A-Z], [a-z])" -a "$[MODULE_DEFAULT_][$1]"; then
67 DEST=$[MODULE_]translit([$5], [A-Z], [a-z])
69 DEST=$[MODULE_DEFAULT_][$1]
72 if test x"$DEST" = xSHARED; then
73 AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module])
74 $5_MODULES="$$5_MODULES $4"
75 AC_MSG_RESULT([shared])
77 string_shared_modules="$string_shared_modules $1"
78 elif test x"$DEST" = xSTATIC; then
79 [init_static_modules_]translit([$5], [A-Z], [a-z])="$[init_static_modules_]translit([$5], [A-Z], [a-z]) $1_init();"
80 string_static_modules="$string_static_modules $1"
81 $5_STATIC="$$5_STATIC $3"
84 AC_MSG_RESULT([static])
86 string_ignored_modules="$string_ignored_modules $1"
92 AC_DEFUN(SMB_SUBSYSTEM,
96 AC_DEFINE_UNQUOTED([static_init_]translit([$1], [A-Z], [a-z]), [{$init_static_modules_]translit([$1], [A-Z], [a-z])[}], [Static init functions])
97 ifelse([$2], , :, [rm -f $2])
100 dnl AC_PROG_CC_FLAG(flag)
101 AC_DEFUN(AC_PROG_CC_FLAG,
102 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
103 [echo 'void f(){}' > conftest.c
104 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
112 dnl see if a declaration exists for a function or variable
113 dnl defines HAVE_function_DECL if it exists
114 dnl AC_HAVE_DECL(var, includes)
115 AC_DEFUN(AC_HAVE_DECL,
117 AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
118 AC_TRY_COMPILE([$2],[int i = (int)$1],
119 ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
120 if test x"$ac_cv_have_$1_decl" = x"yes"; then
121 AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
126 dnl check for a function in a library, but don't
127 dnl keep adding the same library to the LIBS variable.
128 dnl AC_LIBTESTFUNC(lib,func)
129 AC_DEFUN(AC_LIBTESTFUNC,
131 *-l$1*) AC_CHECK_FUNCS($2) ;;
132 *) AC_CHECK_LIB($1, $2)
138 dnl Define an AC_DEFINE with ifndef guard.
139 dnl AC_N_DEFINE(VARIABLE [, VALUE])
141 [cat >> confdefs.h <<\EOF
143 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
149 dnl AC_ADD_INCLUDE(VARIABLE)
150 define(AC_ADD_INCLUDE,
151 [cat >> confdefs.h <<\EOF
156 dnl Copied from libtool.m4
157 AC_DEFUN(AC_PROG_LD_GNU,
158 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
159 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
160 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
161 ac_cv_prog_gnu_ld=yes
167 # Configure paths for LIBXML2
168 # Toshio Kuratomi 2001-04-21
170 # Configure paths for GLIB
171 # Owen Taylor 97-11-3
173 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
174 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
176 AC_DEFUN(AM_PATH_XML2,[
177 AC_ARG_WITH(xml-prefix,
178 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
179 xml_config_prefix="$withval", xml_config_prefix="")
180 AC_ARG_WITH(xml-exec-prefix,
181 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
182 xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
183 AC_ARG_ENABLE(xmltest,
184 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
187 if test x$xml_config_exec_prefix != x ; then
188 xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
189 if test x${XML2_CONFIG+set} != xset ; then
190 XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
193 if test x$xml_config_prefix != x ; then
194 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
195 if test x${XML2_CONFIG+set} != xset ; then
196 XML2_CONFIG=$xml_config_prefix/bin/xml2-config
200 AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
201 min_xml_version=ifelse([$1], ,2.0.0,[$1])
202 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
204 if test "$XML2_CONFIG" = "no" ; then
207 XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
208 XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
209 xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
210 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
211 xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
212 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
213 xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
214 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
215 if test "x$enable_xmltest" = "xyes" ; then
216 ac_save_CFLAGS="$CFLAGS"
218 CFLAGS="$CFLAGS $XML_CFLAGS"
219 LIBS="$XML_LIBS $LIBS"
221 dnl Now check if the installed libxml is sufficiently new.
222 dnl (Also sanity checks the results of xml2-config to some extent)
229 #include <libxml/xmlversion.h>
234 int xml_major_version, xml_minor_version, xml_micro_version;
235 int major, minor, micro;
238 system("touch conf.xmltest");
240 /* Capture xml2-config output via autoconf/configure variables */
241 /* HP/UX 9 (%@#!) writes to sscanf strings */
242 tmp_version = (char *)strdup("$min_xml_version");
243 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
244 printf("%s, bad version string from xml2-config\n", "$min_xml_version");
249 /* Capture the version information from the header files */
250 tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
251 if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
252 printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
257 /* Compare xml2-config output to the libxml headers */
258 if ((xml_major_version != $xml_config_major_version) ||
259 (xml_minor_version != $xml_config_minor_version) ||
260 (xml_micro_version != $xml_config_micro_version))
262 printf("*** libxml header files (version %d.%d.%d) do not match\n",
263 xml_major_version, xml_minor_version, xml_micro_version);
264 printf("*** xml2-config (version %d.%d.%d)\n",
265 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
268 /* Compare the headers to the library to make sure we match */
269 /* Less than ideal -- doesn't provide us with return value feedback,
270 * only exits if there's a serious mismatch between header and library.
274 /* Test that the library is greater than our minimum version */
275 if ((xml_major_version > major) ||
276 ((xml_major_version == major) && (xml_minor_version > minor)) ||
277 ((xml_major_version == major) && (xml_minor_version == minor) &&
278 (xml_micro_version >= micro)))
284 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
285 xml_major_version, xml_minor_version, xml_micro_version);
286 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
287 major, minor, micro);
288 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
290 printf("*** If you have already installed a sufficiently new version, this error\n");
291 printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
292 printf("*** being found. The easiest way to fix this is to remove the old version\n");
293 printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
294 printf("*** correct copy of xml2-config. (In this case, you will have to\n");
295 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
296 printf("*** so that the correct libraries are found at run-time))\n");
300 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
301 CFLAGS="$ac_save_CFLAGS"
306 if test "x$no_xml" = x ; then
307 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
308 ifelse([$2], , :, [$2])
311 if test "$XML2_CONFIG" = "no" ; then
312 echo "*** The xml2-config script installed by LIBXML could not be found"
313 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
314 echo "*** your path, or set the XML2_CONFIG environment variable to the"
315 echo "*** full path to xml2-config."
317 if test -f conf.xmltest ; then
320 echo "*** Could not run libxml test program, checking why..."
321 CFLAGS="$CFLAGS $XML_CFLAGS"
322 LIBS="$LIBS $XML_LIBS"
324 #include <libxml/xmlversion.h>
326 ], [ LIBXML_TEST_VERSION; return 0;],
327 [ echo "*** The test program compiled, but did not run. This usually means"
328 echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
329 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
330 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
331 echo "*** to the installed location Also, make sure you have run ldconfig if that"
332 echo "*** is required on your system"
334 echo "*** If you have an old version installed, it is best to remove it, although"
335 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
336 [ echo "*** The test program failed to compile or link. See the file config.log for the"
337 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
338 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
339 echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
340 CFLAGS="$ac_save_CFLAGS"
347 ifelse([$3], , :, [$3])
354 # =========================================================================
355 # AM_PATH_MYSQL : MySQL library
357 dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
358 dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS
360 AC_DEFUN(AM_PATH_MYSQL,
362 dnl Get the cflags and libraries from the mysql_config script
364 AC_ARG_WITH(mysql-prefix,[ --with-mysql-prefix=PFX Prefix where MYSQL is installed (optional)],
365 mysql_prefix="$withval", mysql_prefix="")
366 AC_ARG_WITH(mysql-exec-prefix,[ --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)],
367 mysql_exec_prefix="$withval", mysql_exec_prefix="")
369 if test x$mysql_exec_prefix != x ; then
370 mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix"
371 if test x${MYSQL_CONFIG+set} != xset ; then
372 MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config
375 if test x$mysql_prefix != x ; then
376 mysql_args="$mysql_args --prefix=$mysql_prefix"
377 if test x${MYSQL_CONFIG+set} != xset ; then
378 MYSQL_CONFIG=$mysql_prefix/bin/mysql_config
382 AC_REQUIRE([AC_CANONICAL_TARGET])
383 AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
384 AC_MSG_CHECKING(for MYSQL)
386 if test "$MYSQL_CONFIG" = "no" ; then
390 ifelse([$2], , :, [$2])
392 MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"`
393 MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"`
395 ifelse([$1], , :, [$1])
397 AC_SUBST(MYSQL_CFLAGS)
401 dnl Removes -I/usr/include/? from given variable
402 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
406 -I/usr/include|-I/usr/include/) ;;
407 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
413 dnl Removes -L/usr/lib/? from given variable
414 AC_DEFUN(LIB_REMOVE_USR_LIB,[
418 -L/usr/lib|-L/usr/lib/) ;;
419 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
425 dnl From Bruno Haible.
429 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
430 dnl those with the standalone portable libiconv installed).
431 AC_MSG_CHECKING(for iconv in $1)
432 jm_cv_func_iconv="no"
435 AC_TRY_LINK([#include <stdlib.h>
436 #include <giconv.h>],
437 [iconv_t cd = iconv_open("","");
438 iconv(cd,NULL,NULL,NULL,NULL);
443 if test "$jm_cv_func_iconv" != yes; then
444 AC_TRY_LINK([#include <stdlib.h>
446 [iconv_t cd = iconv_open("","");
447 iconv(cd,NULL,NULL,NULL,NULL);
449 jm_cv_func_iconv=yes)
451 if test "$jm_cv_lib_iconv" != yes; then
453 LIBS="$LIBS -lgiconv"
454 AC_TRY_LINK([#include <stdlib.h>
455 #include <giconv.h>],
456 [iconv_t cd = iconv_open("","");
457 iconv(cd,NULL,NULL,NULL,NULL);
464 if test "$jm_cv_func_iconv" != yes; then
467 AC_TRY_LINK([#include <stdlib.h>
469 [iconv_t cd = iconv_open("","");
470 iconv(cd,NULL,NULL,NULL,NULL);
473 jm_cv_func_iconv=yes)
479 if test "$jm_cv_func_iconv" = yes; then
480 if test "$jm_cv_giconv" = yes; then
481 AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
485 AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
492 if test "$jm_cv_lib_iconv" = yes; then
493 if test "$jm_cv_giconv" = yes; then
494 LIBS="$LIBS -lgiconv"
501 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
502 dnl This function doesn't add -I/usr/include into CFLAGS
503 AC_DEFUN(CFLAGS_ADD_DIR,[
504 if test "$2" != "/usr/include" ; then
509 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
510 dnl This function doesn't add -L/usr/lib into LDFLAGS
511 AC_DEFUN(LIB_ADD_DIR,[
512 if test "$2" != "/usr/lib" ; then
517 dnl AC_ENABLE_SHARED - implement the --enable-shared flag
518 dnl Usage: AC_ENABLE_SHARED[(DEFAULT)]
519 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
521 AC_DEFUN([AC_ENABLE_SHARED],
522 [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
523 AC_ARG_ENABLE(shared,
524 changequote(<<, >>)dnl
525 << --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
527 [p=${PACKAGE-default}
529 yes) enable_shared=yes ;;
530 no) enable_shared=no ;;
533 # Look at the argument we got. We use all the common list separators.
534 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
535 for pkg in $enableval; do
536 if test "X$pkg" = "X$p"; then
544 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
547 dnl AC_ENABLE_STATIC - implement the --enable-static flag
548 dnl Usage: AC_ENABLE_STATIC[(DEFAULT)]
549 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
551 AC_DEFUN([AC_ENABLE_STATIC],
552 [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
553 AC_ARG_ENABLE(static,
554 changequote(<<, >>)dnl
555 << --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
557 [p=${PACKAGE-default}
559 yes) enable_static=yes ;;
560 no) enable_static=no ;;
563 # Look at the argument we got. We use all the common list separators.
564 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
565 for pkg in $enableval; do
566 if test "X$pkg" = "X$p"; then
573 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
576 dnl AC_DISABLE_STATIC - set the default static flag to --disable-static
577 AC_DEFUN([AC_DISABLE_STATIC],
578 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
579 AC_ENABLE_STATIC(no)])