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(name,static_files,shared_files,subsystem,whatif-static,whatif-shared)
43 AC_MSG_CHECKING([how to build $1])
44 if test "$[MODULE_][$1]"; then
46 elif test "$[MODULE_]translit([$4], [A-Z], [a-z])" -a "$[MODULE_DEFAULT_][$1]"; then
47 DEST=$[MODULE_]translit([$4], [A-Z], [a-z])
49 DEST=$[MODULE_DEFAULT_][$1]
52 if test x"$DEST" = xSHARED; then
53 AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module])
54 $4_MODULES="$$4_MODULES $3"
55 AC_MSG_RESULT([shared])
57 string_shared_modules="$string_shared_modules $1"
58 elif test x"$DEST" = xSTATIC; then
59 [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z]) $1_init();"
60 string_static_modules="$string_static_modules $1"
61 $4_STATIC="$$4_STATIC $2"
64 AC_MSG_RESULT([static])
66 string_ignored_modules="$string_ignored_modules $1"
71 AC_DEFUN(SMB_SUBSYSTEM,
75 AC_DEFINE_UNQUOTED([static_init_]translit([$1], [A-Z], [a-z]), [{$init_static_modules_]translit([$1], [A-Z], [a-z])[}], [Static init functions])
76 ifelse([$2], , :, [rm -f $2])
79 dnl AC_PROG_CC_FLAG(flag)
80 AC_DEFUN(AC_PROG_CC_FLAG,
81 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
82 [echo 'void f(){}' > conftest.c
83 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
91 dnl see if a declaration exists for a function or variable
92 dnl defines HAVE_function_DECL if it exists
93 dnl AC_HAVE_DECL(var, includes)
94 AC_DEFUN(AC_HAVE_DECL,
96 AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
97 AC_TRY_COMPILE([$2],[int i = (int)$1],
98 ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
99 if test x"$ac_cv_have_$1_decl" = x"yes"; then
100 AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
105 dnl check for a function in a library, but don't
106 dnl keep adding the same library to the LIBS variable.
107 dnl AC_LIBTESTFUNC(lib,func)
108 AC_DEFUN(AC_LIBTESTFUNC,
110 *-l$1*) AC_CHECK_FUNCS($2) ;;
111 *) AC_CHECK_LIB($1, $2)
117 dnl Define an AC_DEFINE with ifndef guard.
118 dnl AC_N_DEFINE(VARIABLE [, VALUE])
120 [cat >> confdefs.h <<\EOF
122 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
128 dnl AC_ADD_INCLUDE(VARIABLE)
129 define(AC_ADD_INCLUDE,
130 [cat >> confdefs.h <<\EOF
135 dnl Copied from libtool.m4
136 AC_DEFUN(AC_PROG_LD_GNU,
137 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
138 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
139 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
140 ac_cv_prog_gnu_ld=yes
146 # Configure paths for LIBXML2
147 # Toshio Kuratomi 2001-04-21
149 # Configure paths for GLIB
150 # Owen Taylor 97-11-3
152 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
153 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
155 AC_DEFUN(AM_PATH_XML2,[
156 AC_ARG_WITH(xml-prefix,
157 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
158 xml_config_prefix="$withval", xml_config_prefix="")
159 AC_ARG_WITH(xml-exec-prefix,
160 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
161 xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
162 AC_ARG_ENABLE(xmltest,
163 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
166 if test x$xml_config_exec_prefix != x ; then
167 xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
168 if test x${XML2_CONFIG+set} != xset ; then
169 XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
172 if test x$xml_config_prefix != x ; then
173 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
174 if test x${XML2_CONFIG+set} != xset ; then
175 XML2_CONFIG=$xml_config_prefix/bin/xml2-config
179 AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
180 min_xml_version=ifelse([$1], ,2.0.0,[$1])
181 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
183 if test "$XML2_CONFIG" = "no" ; then
186 XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
187 XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
188 xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
189 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
190 xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
191 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
192 xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
193 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
194 if test "x$enable_xmltest" = "xyes" ; then
195 ac_save_CFLAGS="$CFLAGS"
197 CFLAGS="$CFLAGS $XML_CFLAGS"
198 LIBS="$XML_LIBS $LIBS"
200 dnl Now check if the installed libxml is sufficiently new.
201 dnl (Also sanity checks the results of xml2-config to some extent)
208 #include <libxml/xmlversion.h>
213 int xml_major_version, xml_minor_version, xml_micro_version;
214 int major, minor, micro;
217 system("touch conf.xmltest");
219 /* Capture xml2-config output via autoconf/configure variables */
220 /* HP/UX 9 (%@#!) writes to sscanf strings */
221 tmp_version = (char *)strdup("$min_xml_version");
222 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
223 printf("%s, bad version string from xml2-config\n", "$min_xml_version");
228 /* Capture the version information from the header files */
229 tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
230 if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
231 printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
236 /* Compare xml2-config output to the libxml headers */
237 if ((xml_major_version != $xml_config_major_version) ||
238 (xml_minor_version != $xml_config_minor_version) ||
239 (xml_micro_version != $xml_config_micro_version))
241 printf("*** libxml header files (version %d.%d.%d) do not match\n",
242 xml_major_version, xml_minor_version, xml_micro_version);
243 printf("*** xml2-config (version %d.%d.%d)\n",
244 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
247 /* Compare the headers to the library to make sure we match */
248 /* Less than ideal -- doesn't provide us with return value feedback,
249 * only exits if there's a serious mismatch between header and library.
253 /* Test that the library is greater than our minimum version */
254 if ((xml_major_version > major) ||
255 ((xml_major_version == major) && (xml_minor_version > minor)) ||
256 ((xml_major_version == major) && (xml_minor_version == minor) &&
257 (xml_micro_version >= micro)))
263 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
264 xml_major_version, xml_minor_version, xml_micro_version);
265 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
266 major, minor, micro);
267 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
269 printf("*** If you have already installed a sufficiently new version, this error\n");
270 printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
271 printf("*** being found. The easiest way to fix this is to remove the old version\n");
272 printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
273 printf("*** correct copy of xml2-config. (In this case, you will have to\n");
274 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
275 printf("*** so that the correct libraries are found at run-time))\n");
279 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
280 CFLAGS="$ac_save_CFLAGS"
285 if test "x$no_xml" = x ; then
286 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
287 ifelse([$2], , :, [$2])
290 if test "$XML2_CONFIG" = "no" ; then
291 echo "*** The xml2-config script installed by LIBXML could not be found"
292 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
293 echo "*** your path, or set the XML2_CONFIG environment variable to the"
294 echo "*** full path to xml2-config."
296 if test -f conf.xmltest ; then
299 echo "*** Could not run libxml test program, checking why..."
300 CFLAGS="$CFLAGS $XML_CFLAGS"
301 LIBS="$LIBS $XML_LIBS"
303 #include <libxml/xmlversion.h>
305 ], [ LIBXML_TEST_VERSION; return 0;],
306 [ echo "*** The test program compiled, but did not run. This usually means"
307 echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
308 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
309 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
310 echo "*** to the installed location Also, make sure you have run ldconfig if that"
311 echo "*** is required on your system"
313 echo "*** If you have an old version installed, it is best to remove it, although"
314 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
315 [ echo "*** The test program failed to compile or link. See the file config.log for the"
316 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
317 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
318 echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
319 CFLAGS="$ac_save_CFLAGS"
326 ifelse([$3], , :, [$3])
333 # =========================================================================
334 # AM_PATH_MYSQL : MySQL library
336 dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
337 dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS
339 AC_DEFUN(AM_PATH_MYSQL,
341 dnl Get the cflags and libraries from the mysql_config script
343 AC_ARG_WITH(mysql-prefix,[ --with-mysql-prefix=PFX Prefix where MYSQL is installed (optional)],
344 mysql_prefix="$withval", mysql_prefix="")
345 AC_ARG_WITH(mysql-exec-prefix,[ --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)],
346 mysql_exec_prefix="$withval", mysql_exec_prefix="")
348 if test x$mysql_exec_prefix != x ; then
349 mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix"
350 if test x${MYSQL_CONFIG+set} != xset ; then
351 MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config
354 if test x$mysql_prefix != x ; then
355 mysql_args="$mysql_args --prefix=$mysql_prefix"
356 if test x${MYSQL_CONFIG+set} != xset ; then
357 MYSQL_CONFIG=$mysql_prefix/bin/mysql_config
361 AC_REQUIRE([AC_CANONICAL_TARGET])
362 AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
363 AC_MSG_CHECKING(for MYSQL)
365 if test "$MYSQL_CONFIG" = "no" ; then
369 ifelse([$2], , :, [$2])
371 MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"`
372 MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"`
374 ifelse([$1], , :, [$1])
376 AC_SUBST(MYSQL_CFLAGS)
380 dnl Removes -I/usr/include/? from given variable
381 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
385 -I/usr/include|-I/usr/include/) ;;
386 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
392 dnl Removes -L/usr/lib/? from given variable
393 AC_DEFUN(LIB_REMOVE_USR_LIB,[
397 -L/usr/lib|-L/usr/lib/) ;;
398 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
404 dnl From Bruno Haible.
408 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
409 dnl those with the standalone portable libiconv installed).
410 AC_MSG_CHECKING(for iconv in $1)
411 jm_cv_func_iconv="no"
414 AC_TRY_LINK([#include <stdlib.h>
415 #include <giconv.h>],
416 [iconv_t cd = iconv_open("","");
417 iconv(cd,NULL,NULL,NULL,NULL);
422 if test "$jm_cv_func_iconv" != yes; then
423 AC_TRY_LINK([#include <stdlib.h>
425 [iconv_t cd = iconv_open("","");
426 iconv(cd,NULL,NULL,NULL,NULL);
428 jm_cv_func_iconv=yes)
430 if test "$jm_cv_lib_iconv" != yes; then
432 LIBS="$LIBS -lgiconv"
433 AC_TRY_LINK([#include <stdlib.h>
434 #include <giconv.h>],
435 [iconv_t cd = iconv_open("","");
436 iconv(cd,NULL,NULL,NULL,NULL);
443 if test "$jm_cv_func_iconv" != yes; then
446 AC_TRY_LINK([#include <stdlib.h>
448 [iconv_t cd = iconv_open("","");
449 iconv(cd,NULL,NULL,NULL,NULL);
452 jm_cv_func_iconv=yes)
458 if test "$jm_cv_func_iconv" = yes; then
459 if test "$jm_cv_giconv" = yes; then
460 AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
464 AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
471 if test "$jm_cv_lib_iconv" = yes; then
472 if test "$jm_cv_giconv" = yes; then
473 LIBS="$LIBS -lgiconv"
480 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
481 dnl This function doesn't add -I/usr/include into CFLAGS
482 AC_DEFUN(CFLAGS_ADD_DIR,[
483 if test "$2" != "/usr/include" ; then
488 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
489 dnl This function doesn't add -L/usr/lib into LDFLAGS
490 AC_DEFUN(LIB_ADD_DIR,[
491 if test "$2" != "/usr/lib" ; then
496 dnl AC_ENABLE_SHARED - implement the --enable-shared flag
497 dnl Usage: AC_ENABLE_SHARED[(DEFAULT)]
498 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
500 AC_DEFUN([AC_ENABLE_SHARED],
501 [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
502 AC_ARG_ENABLE(shared,
503 changequote(<<, >>)dnl
504 << --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
506 [p=${PACKAGE-default}
508 yes) enable_shared=yes ;;
509 no) enable_shared=no ;;
512 # Look at the argument we got. We use all the common list separators.
513 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
514 for pkg in $enableval; do
515 if test "X$pkg" = "X$p"; then
523 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
526 dnl AC_ENABLE_STATIC - implement the --enable-static flag
527 dnl Usage: AC_ENABLE_STATIC[(DEFAULT)]
528 dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
530 AC_DEFUN([AC_ENABLE_STATIC],
531 [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
532 AC_ARG_ENABLE(static,
533 changequote(<<, >>)dnl
534 << --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
536 [p=${PACKAGE-default}
538 yes) enable_static=yes ;;
539 no) enable_static=no ;;
542 # Look at the argument we got. We use all the common list separators.
543 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
544 for pkg in $enableval; do
545 if test "X$pkg" = "X$p"; then
552 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
555 dnl AC_DISABLE_STATIC - set the default static flag to --disable-static
556 AC_DEFUN([AC_DISABLE_STATIC],
557 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
558 AC_ENABLE_STATIC(no)])