1dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)] 2dnl if the cache file is inconsistent with the current host, 3dnl target and build system types, execute CMD or print a default 4dnl error message. 5AC_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]) 15 ifelse($#, 1, [$1], 16 [AC_MSG_ERROR(["you must remove config.cache and restart configure"])]) 17 else 18 AC_MSG_RESULT([same]) 19 fi 20 ac_cv_host_system_type="$host" 21 ac_cv_build_system_type="$build" 22 ac_cv_target_system_type="$target" 23]) 24 25 26dnl test whether dirent has a d_off member 27AC_DEFUN(AC_DIRENT_D_OFF, 28[AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off, 29[AC_TRY_COMPILE([ 30#include <unistd.h> 31#include <sys/types.h> 32#include <dirent.h>], [struct dirent d; d.d_off;], 33ac_cv_dirent_d_off=yes, ac_cv_dirent_d_off=no)]) 34if test $ac_cv_dirent_d_off = yes; then 35 AC_DEFINE(HAVE_DIRENT_D_OFF,1,[Whether dirent has a d_off member]) 36fi 37]) 38 39dnl Mark specified module as shared 40dnl SMB_MODULE(name,static_files,shared_files,subsystem,whatif-static,whatif-shared) 41AC_DEFUN(SMB_MODULE, 42[ 43 AC_MSG_CHECKING([how to build $1]) 44 if test "$[MODULE_][$1]"; then 45 DEST=$[MODULE_][$1] 46 elif test "$[MODULE_]translit([$4], [A-Z], [a-z])" -a "$[MODULE_DEFAULT_][$1]"; then 47 DEST=$[MODULE_]translit([$4], [A-Z], [a-z]) 48 else 49 DEST=$[MODULE_DEFAULT_][$1] 50 fi 51 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]) 56 [$6] 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" 62 AC_SUBST($4_STATIC) 63 [$5] 64 AC_MSG_RESULT([static]) 65 else 66 string_ignored_modules="$string_ignored_modules $1" 67 AC_MSG_RESULT([not]) 68 fi 69]) 70 71AC_DEFUN(SMB_SUBSYSTEM, 72[ 73 AC_SUBST($1_STATIC) 74 AC_SUBST($1_MODULES) 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]) 77]) 78 79dnl AC_PROG_CC_FLAG(flag) 80AC_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 83if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then 84 ac_cv_prog_cc_$1=yes 85else 86 ac_cv_prog_cc_$1=no 87fi 88rm -f conftest* 89])]) 90 91dnl see if a declaration exists for a function or variable 92dnl defines HAVE_function_DECL if it exists 93dnl AC_HAVE_DECL(var, includes) 94AC_DEFUN(AC_HAVE_DECL, 95[ 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]) 101 fi 102]) 103 104 105dnl check for a function in a library, but don't 106dnl keep adding the same library to the LIBS variable. 107dnl AC_LIBTESTFUNC(lib,func) 108AC_DEFUN(AC_LIBTESTFUNC, 109[case "$LIBS" in 110 *-l$1*) AC_CHECK_FUNCS($2) ;; 111 *) AC_CHECK_LIB($1, $2) 112 AC_CHECK_FUNCS($2) 113 ;; 114 esac 115]) 116 117# AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION], 118# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], 119# [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES]) 120# ------------------------------------------------------ 121# 122# Use a cache variable name containing both the library and function name, 123# because the test really is for library $1 defining function $3, not 124# just for library $1. Separate tests with the same $1 and different $3s 125# may have different results. 126# 127# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3]) 128# is asking for trouble, since AC_CHECK_LIB($lib, fun) would give 129# ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence 130# the AS_LITERAL_IF indirection. 131# 132# FIXME: This macro is extremely suspicious. It DEFINEs unconditionally, 133# whatever the FUNCTION, in addition to not being a *S macro. Note 134# that the cache does depend upon the function we are looking for. 135# 136# It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just 137# `ac_save_LIBS': there are many macros which don't want to see `LIBS' 138# changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'. 139# And ``ac_save_LIBS' is too tempting a name, so let's leave them some 140# freedom. 141AC_DEFUN([AC_CHECK_LIB_EXT], 142[ 143AH_CHECK_LIB_EXT([$1]) 144ac_check_lib_ext_save_LIBS=$LIBS 145LIBS="-l$1 $$2 $7 $LIBS" 146AS_LITERAL_IF([$1], 147 [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])], 148 [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl 149 150m4_ifval([$3], 151 [ 152 AH_CHECK_FUNC_EXT([$3]) 153 AS_LITERAL_IF([$1], 154 [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])], 155 [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl 156 AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func, 157 [AC_TRY_LINK_FUNC($3, 158 [AS_VAR_SET(ac_Lib_func, yes); 159 AS_VAR_SET(ac_Lib_ext, yes)], 160 [AS_VAR_SET(ac_Lib_func, no); 161 AS_VAR_SET(ac_Lib_ext, no)]) 162 ]) 163 AS_IF([test AS_VAR_GET(ac_Lib_func) = yes], 164 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl 165 AS_VAR_POPDEF([ac_Lib_func])dnl 166 ],[ 167 AC_CACHE_CHECK([for -l$1], ac_Lib_ext, 168 [AC_TRY_LINK_FUNC([main], 169 [AS_VAR_SET(ac_Lib_ext, yes)], 170 [AS_VAR_SET(ac_Lib_ext, no)]) 171 ]) 172 ]) 173LIBS=$ac_check_lib_ext_save_LIBS 174 175AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes], 176 [m4_default([$4], 177 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1)) 178 case "$$2" in 179 *-l$1*) 180 ;; 181 *) 182 $2="-l$1 $$2" 183 ;; 184 esac]) 185 [$6] 186 ], 187 [$5])dnl 188AS_VAR_POPDEF([ac_Lib_ext])dnl 189])# AC_CHECK_LIB_EXT 190 191# AH_CHECK_LIB_EXT(LIBNAME) 192# --------------------- 193m4_define([AH_CHECK_LIB_EXT], 194[AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1), 195 [Define to 1 if you have the `]$1[' library (-l]$1[).])]) 196 197# AC_CHECK_FUNCS_EXT(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 198# ----------------------------------------------------------------- 199dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable. 200dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE) 201AC_DEFUN([AC_CHECK_FUNC_EXT], 202[ 203 AH_CHECK_FUNC_EXT($1) 204 ac_check_func_ext_save_LIBS=$LIBS 205 LIBS="$2 $LIBS" 206 AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl 207 AC_CACHE_CHECK([for $1], ac_var, 208 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])], 209 [AS_VAR_SET(ac_var, yes)], 210 [AS_VAR_SET(ac_var, no)])]) 211 LIBS=$ac_check_func_ext_save_LIBS 212 AS_IF([test AS_VAR_GET(ac_var) = yes], 213 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], 214 [$4])dnl 215AS_VAR_POPDEF([ac_var])dnl 216])# AC_CHECK_FUNC 217 218# AH_CHECK_FUNC_EXT(FUNCNAME) 219# --------------------- 220m4_define([AH_CHECK_FUNC_EXT], 221[AH_TEMPLATE(AS_TR_CPP(HAVE_$1), 222 [Define to 1 if you have the `]$1[' function.])]) 223 224dnl Define an AC_DEFINE with ifndef guard. 225dnl AC_N_DEFINE(VARIABLE [, VALUE]) 226define(AC_N_DEFINE, 227[cat >> confdefs.h <<\EOF 228[#ifndef] $1 229[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1) 230[#endif] 231EOF 232]) 233 234dnl Add an #include 235dnl AC_ADD_INCLUDE(VARIABLE) 236define(AC_ADD_INCLUDE, 237[cat >> confdefs.h <<\EOF 238[#include] $1 239EOF 240]) 241 242dnl Copied from libtool.m4 243AC_DEFUN(AC_PROG_LD_GNU, 244[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, 245[# I'd rather use --version here, but apparently some GNU ld's only accept -v. 246if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then 247 ac_cv_prog_gnu_ld=yes 248else 249 ac_cv_prog_gnu_ld=no 250fi]) 251]) 252 253# Configure paths for LIBXML2 254# Toshio Kuratomi 2001-04-21 255# Adapted from: 256# Configure paths for GLIB 257# Owen Taylor 97-11-3 258 259dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 260dnl Test for XML, and define XML_CFLAGS and XML_LIBS 261dnl 262AC_DEFUN(AM_PATH_XML2,[ 263AC_ARG_WITH(xml-prefix, 264 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)], 265 xml_config_prefix="$withval", xml_config_prefix="") 266AC_ARG_WITH(xml-exec-prefix, 267 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)], 268 xml_config_exec_prefix="$withval", xml_config_exec_prefix="") 269AC_ARG_ENABLE(xmltest, 270 [ --disable-xmltest Do not try to compile and run a test LIBXML program],, 271 enable_xmltest=yes) 272 273 if test x$xml_config_exec_prefix != x ; then 274 xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix" 275 if test x${XML2_CONFIG+set} != xset ; then 276 XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config 277 fi 278 fi 279 if test x$xml_config_prefix != x ; then 280 xml_config_args="$xml_config_args --prefix=$xml_config_prefix" 281 if test x${XML2_CONFIG+set} != xset ; then 282 XML2_CONFIG=$xml_config_prefix/bin/xml2-config 283 fi 284 fi 285 286 AC_PATH_PROG(XML2_CONFIG, xml2-config, no) 287 min_xml_version=ifelse([$1], ,2.0.0,[$1]) 288 AC_MSG_CHECKING(for libxml - version >= $min_xml_version) 289 no_xml="" 290 if test "$XML2_CONFIG" = "no" ; then 291 no_xml=yes 292 else 293 XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags` 294 XML_LIBS=`$XML2_CONFIG $xml_config_args --libs` 295 xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \ 296 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 297 xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \ 298 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 299 xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \ 300 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 301 if test "x$enable_xmltest" = "xyes" ; then 302 ac_save_CFLAGS="$CFLAGS" 303 ac_save_LIBS="$LIBS" 304 CFLAGS="$CFLAGS $XML_CFLAGS" 305 LIBS="$XML_LIBS $LIBS" 306dnl 307dnl Now check if the installed libxml is sufficiently new. 308dnl (Also sanity checks the results of xml2-config to some extent) 309dnl 310 rm -f conf.xmltest 311 AC_TRY_RUN([ 312#include <stdlib.h> 313#include <stdio.h> 314#include <string.h> 315#include <libxml/xmlversion.h> 316 317int 318main() 319{ 320 int xml_major_version, xml_minor_version, xml_micro_version; 321 int major, minor, micro; 322 char *tmp_version; 323 324 system("touch conf.xmltest"); 325 326 /* Capture xml2-config output via autoconf/configure variables */ 327 /* HP/UX 9 (%@#!) writes to sscanf strings */ 328 tmp_version = (char *)strdup("$min_xml_version"); 329 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 330 printf("%s, bad version string from xml2-config\n", "$min_xml_version"); 331 exit(1); 332 } 333 free(tmp_version); 334 335 /* Capture the version information from the header files */ 336 tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION); 337 if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) { 338 printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION"); 339 exit(1); 340 } 341 free(tmp_version); 342 343 /* Compare xml2-config output to the libxml headers */ 344 if ((xml_major_version != $xml_config_major_version) || 345 (xml_minor_version != $xml_config_minor_version) || 346 (xml_micro_version != $xml_config_micro_version)) 347 { 348 printf("*** libxml header files (version %d.%d.%d) do not match\n", 349 xml_major_version, xml_minor_version, xml_micro_version); 350 printf("*** xml2-config (version %d.%d.%d)\n", 351 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version); 352 return 1; 353 } 354/* Compare the headers to the library to make sure we match */ 355 /* Less than ideal -- doesn't provide us with return value feedback, 356 * only exits if there's a serious mismatch between header and library. 357 */ 358 LIBXML_TEST_VERSION; 359 360 /* Test that the library is greater than our minimum version */ 361 if ((xml_major_version > major) || 362 ((xml_major_version == major) && (xml_minor_version > minor)) || 363 ((xml_major_version == major) && (xml_minor_version == minor) && 364 (xml_micro_version >= micro))) 365 { 366 return 0; 367 } 368 else 369 { 370 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n", 371 xml_major_version, xml_minor_version, xml_micro_version); 372 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n", 373 major, minor, micro); 374 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n"); 375 printf("***\n"); 376 printf("*** If you have already installed a sufficiently new version, this error\n"); 377 printf("*** probably means that the wrong copy of the xml2-config shell script is\n"); 378 printf("*** being found. The easiest way to fix this is to remove the old version\n"); 379 printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n"); 380 printf("*** correct copy of xml2-config. (In this case, you will have to\n"); 381 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); 382 printf("*** so that the correct libraries are found at run-time))\n"); 383 } 384 return 1; 385} 386],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 387 CFLAGS="$ac_save_CFLAGS" 388 LIBS="$ac_save_LIBS" 389 fi 390 fi 391 392 if test "x$no_xml" = x ; then 393 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version)) 394 ifelse([$2], , :, [$2]) 395 else 396 AC_MSG_RESULT(no) 397 if test "$XML2_CONFIG" = "no" ; then 398 echo "*** The xml2-config script installed by LIBXML could not be found" 399 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in" 400 echo "*** your path, or set the XML2_CONFIG environment variable to the" 401 echo "*** full path to xml2-config." 402 else 403 if test -f conf.xmltest ; then 404 : 405 else 406 echo "*** Could not run libxml test program, checking why..." 407 CFLAGS="$CFLAGS $XML_CFLAGS" 408 LIBS="$LIBS $XML_LIBS" 409 AC_TRY_LINK([ 410#include <libxml/xmlversion.h> 411#include <stdio.h> 412], [ LIBXML_TEST_VERSION; return 0;], 413 [ echo "*** The test program compiled, but did not run. This usually means" 414 echo "*** that the run-time linker is not finding LIBXML or finding the wrong" 415 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your" 416 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 417 echo "*** to the installed location Also, make sure you have run ldconfig if that" 418 echo "*** is required on your system" 419 echo "***" 420 echo "*** If you have an old version installed, it is best to remove it, although" 421 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], 422 [ echo "*** The test program failed to compile or link. See the file config.log for the" 423 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed" 424 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you" 425 echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ]) 426 CFLAGS="$ac_save_CFLAGS" 427 LIBS="$ac_save_LIBS" 428 fi 429 fi 430 431 XML_CFLAGS="" 432 XML_LIBS="" 433 ifelse([$3], , :, [$3]) 434 fi 435 AC_SUBST(XML_CFLAGS) 436 AC_SUBST(XML_LIBS) 437 rm -f conf.xmltest 438]) 439 440# ========================================================================= 441# AM_PATH_MYSQL : MySQL library 442 443dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 444dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS 445dnl 446AC_DEFUN(AM_PATH_MYSQL, 447[dnl 448dnl Get the cflags and libraries from the mysql_config script 449dnl 450AC_ARG_WITH(mysql-prefix,[ --with-mysql-prefix=PFX Prefix where MYSQL is installed (optional)], 451 mysql_prefix="$withval", mysql_prefix="") 452AC_ARG_WITH(mysql-exec-prefix,[ --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)], 453 mysql_exec_prefix="$withval", mysql_exec_prefix="") 454 455 if test x$mysql_exec_prefix != x ; then 456 mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix" 457 if test x${MYSQL_CONFIG+set} != xset ; then 458 MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config 459 fi 460 fi 461 if test x$mysql_prefix != x ; then 462 mysql_args="$mysql_args --prefix=$mysql_prefix" 463 if test x${MYSQL_CONFIG+set} != xset ; then 464 MYSQL_CONFIG=$mysql_prefix/bin/mysql_config 465 fi 466 fi 467 468 AC_REQUIRE([AC_CANONICAL_TARGET]) 469 AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no) 470 AC_MSG_CHECKING(for MYSQL) 471 no_mysql="" 472 if test "$MYSQL_CONFIG" = "no" ; then 473 MYSQL_CFLAGS="" 474 MYSQL_LIBS="" 475 AC_MSG_RESULT(no) 476 ifelse([$2], , :, [$2]) 477 else 478 MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"` 479 MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"` 480 AC_MSG_RESULT(yes) 481 ifelse([$1], , :, [$1]) 482 fi 483 AC_SUBST(MYSQL_CFLAGS) 484 AC_SUBST(MYSQL_LIBS) 485]) 486 487# ========================================================================= 488# AM_PATH_PGSQL : pgSQL library 489 490dnl AM_PATH_PGSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 491dnl Test for PGSQL, and define PGSQL_CFLAGS and PGSQL_LIBS 492dnl 493AC_DEFUN(AM_PATH_PGSQL, 494[dnl 495dnl Get the cflags and libraries from the pg_config script 496dnl 497AC_ARG_WITH(pgsql-prefix,[ --with-pgsql-prefix=PFX Prefix where PostgreSQL is installed (optional)], 498 pgsql_prefix="$withval", pgsql_prefix="") 499AC_ARG_WITH(pgsql-exec-prefix,[ --with-pgsql-exec-prefix=PFX Exec prefix where PostgreSQL is installed (optional)], 500 pgsql_exec_prefix="$withval", pgsql_exec_prefix="") 501 502 if test x$pgsql_exec_prefix != x ; then 503 if test x${PGSQL_CONFIG+set} != xset ; then 504 PGSQL_CONFIG=$pgsql_exec_prefix/bin/pg_config 505 fi 506 fi 507 if test x$pgsql_prefix != x ; then 508 if test x${PGSQL_CONFIG+set} != xset ; then 509 PGSQL_CONFIG=$pgsql_prefix/bin/pg_config 510 fi 511 fi 512 513 AC_REQUIRE([AC_CANONICAL_TARGET]) 514 AC_PATH_PROG(PGSQL_CONFIG, pg_config, no, [$PATH:/usr/lib/postgresql/bin]) 515 AC_MSG_CHECKING(for PGSQL) 516 no_pgsql="" 517 if test "$PGSQL_CONFIG" = "no" ; then 518 PGSQL_CFLAGS="" 519 PGSQL_LIBS="" 520 AC_MSG_RESULT(no) 521 ifelse([$2], , :, [$2]) 522 else 523 PGSQL_CFLAGS=-I`$PGSQL_CONFIG --includedir` 524 PGSQL_LIBS="-lpq -L`$PGSQL_CONFIG --libdir`" 525 AC_MSG_RESULT(yes) 526 ifelse([$1], , :, [$1]) 527 fi 528 AC_SUBST(PGSQL_CFLAGS) 529 AC_SUBST(PGSQL_LIBS) 530]) 531 532dnl Removes -I/usr/include/? from given variable 533AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[ 534 ac_new_flags="" 535 for i in [$]$1; do 536 case [$]i in 537 -I/usr/include|-I/usr/include/) ;; 538 *) ac_new_flags="[$]ac_new_flags [$]i" ;; 539 esac 540 done 541 $1=[$]ac_new_flags 542]) 543 544dnl Removes -L/usr/lib/? from given variable 545AC_DEFUN(LIB_REMOVE_USR_LIB,[ 546 ac_new_flags="" 547 for i in [$]$1; do 548 case [$]i in 549 -L/usr/lib|-L/usr/lib/) ;; 550 *) ac_new_flags="[$]ac_new_flags [$]i" ;; 551 esac 552 done 553 $1=[$]ac_new_flags 554]) 555 556dnl From Bruno Haible. 557 558AC_DEFUN(jm_ICONV, 559[ 560 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and 561 dnl those with the standalone portable libiconv installed). 562 AC_MSG_CHECKING(for iconv in $1) 563 jm_cv_func_iconv="no" 564 jm_cv_lib_iconv="" 565 jm_cv_giconv=no 566 jm_save_LIBS="$LIBS" 567 LIBS="$LIBS -lbiconv" 568 AC_TRY_LINK([#include <stdlib.h> 569#include <biconv.h>], 570 [iconv_t cd = iconv_open("",""); 571 iconv(cd,NULL,NULL,NULL,NULL); 572 iconv_close(cd);], 573 jm_cv_func_iconv=yes 574 jm_cv_biconv=yes 575 jm_cv_include="biconv.h" 576 jm_cv_lib_iconv="biconv") 577 LIBS="$jm_save_LIBS" 578 579 dnl Check for include in funny place but no lib needed 580 if test "$jm_cv_func_iconv" != yes; then 581 AC_TRY_LINK([#include <stdlib.h> 582#include <giconv.h>], 583 [iconv_t cd = iconv_open("",""); 584 iconv(cd,NULL,NULL,NULL,NULL); 585 iconv_close(cd);], 586 jm_cv_func_iconv=yes 587 jm_cv_include="giconv.h" 588 jm_cv_giconv="yes" 589 jm_cv_lib_iconv="") 590 591 dnl Standard iconv.h include, lib in glibc or libc ... 592 if test "$jm_cv_func_iconv" != yes; then 593 AC_TRY_LINK([#include <stdlib.h> 594#include <iconv.h>], 595 [iconv_t cd = iconv_open("",""); 596 iconv(cd,NULL,NULL,NULL,NULL); 597 iconv_close(cd);], 598 jm_cv_include="iconv.h" 599 jm_cv_func_iconv=yes 600 jm_cv_lib_iconv="") 601 602 if test "$jm_cv_lib_iconv" != yes; then 603 jm_save_LIBS="$LIBS" 604 LIBS="$LIBS -lgiconv" 605 AC_TRY_LINK([#include <stdlib.h> 606#include <giconv.h>], 607 [iconv_t cd = iconv_open("",""); 608 iconv(cd,NULL,NULL,NULL,NULL); 609 iconv_close(cd);], 610 jm_cv_lib_iconv=yes 611 jm_cv_func_iconv=yes 612 jm_cv_include="giconv.h" 613 jm_cv_giconv=yes 614 jm_cv_lib_iconv="giconv") 615 616 LIBS="$jm_save_LIBS" 617 618 if test "$jm_cv_func_iconv" != yes; then 619 jm_save_LIBS="$LIBS" 620 LIBS="$LIBS -liconv" 621 AC_TRY_LINK([#include <stdlib.h> 622#include <iconv.h>], 623 [iconv_t cd = iconv_open("",""); 624 iconv(cd,NULL,NULL,NULL,NULL); 625 iconv_close(cd);], 626 jm_cv_include="iconv.h" 627 jm_cv_func_iconv=yes 628 jm_cv_lib_iconv="iconv") 629 LIBS="$jm_save_LIBS" 630 fi 631 fi 632 fi 633 fi 634 if test "$jm_cv_func_iconv" = yes; then 635 if test "$jm_cv_giconv" = yes; then 636 AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h]) 637 AC_MSG_RESULT(yes) 638 ICONV_FOUND=yes 639 else 640 if test "$jm_cv_biconv" = yes; then 641 AC_DEFINE(HAVE_BICONV, 1, [What header to include for iconv() function: biconv.h]) 642 AC_MSG_RESULT(yes) 643 ICONV_FOUND=yes 644 else 645 AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h]) 646 AC_MSG_RESULT(yes) 647 ICONV_FOUND=yes 648 fi 649 fi 650 else 651 AC_MSG_RESULT(no) 652 fi 653]) 654 655AC_DEFUN(rjs_CHARSET,[ 656 dnl Find out if we can convert from $1 to UCS2-LE 657 AC_MSG_CHECKING([can we convert from $1 to UCS2-LE?]) 658 AC_TRY_RUN([ 659#include <$jm_cv_include> 660main(){ 661 iconv_t cd = iconv_open("$1", "UCS-2LE"); 662 if (cd == 0 || cd == (iconv_t)-1) { 663 return -1; 664 } 665 return 0; 666} 667 ],ICONV_CHARSET=$1,ICONV_CHARSET=no,ICONV_CHARSET=cross) 668 AC_MSG_RESULT($ICONV_CHARSET) 669]) 670 671dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR) 672dnl This function doesn't add -I/usr/include into CFLAGS 673AC_DEFUN(CFLAGS_ADD_DIR,[ 674if test "$2" != "/usr/include" ; then 675 $1="$$1 -I$2" 676fi 677]) 678 679dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR) 680dnl This function doesn't add -L/usr/lib into LDFLAGS 681AC_DEFUN(LIB_ADD_DIR,[ 682if test "$2" != "/usr/lib" ; then 683 $1="$$1 -L$2" 684fi 685]) 686 687dnl AC_ENABLE_SHARED - implement the --enable-shared flag 688dnl Usage: AC_ENABLE_SHARED[(DEFAULT)] 689dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to 690dnl `yes'. 691AC_DEFUN([AC_ENABLE_SHARED], 692[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl 693AC_ARG_ENABLE(shared, 694changequote(<<, >>)dnl 695<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], 696changequote([, ])dnl 697[p=${PACKAGE-default} 698case $enableval in 699yes) enable_shared=yes ;; 700no) enable_shared=no ;; 701*) 702 enable_shared=no 703 # Look at the argument we got. We use all the common list separators. 704 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," 705 for pkg in $enableval; do 706 if test "X$pkg" = "X$p"; then 707 enable_shared=yes 708 fi 709 710 done 711 IFS="$ac_save_ifs" 712 ;; 713esac], 714enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl 715]) 716 717dnl AC_ENABLE_STATIC - implement the --enable-static flag 718dnl Usage: AC_ENABLE_STATIC[(DEFAULT)] 719dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to 720dnl `yes'. 721AC_DEFUN([AC_ENABLE_STATIC], 722[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl 723AC_ARG_ENABLE(static, 724changequote(<<, >>)dnl 725<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], 726changequote([, ])dnl 727[p=${PACKAGE-default} 728case $enableval in 729yes) enable_static=yes ;; 730no) enable_static=no ;; 731*) 732 enable_static=no 733 # Look at the argument we got. We use all the common list separators. 734 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," 735 for pkg in $enableval; do 736 if test "X$pkg" = "X$p"; then 737 enable_static=yes 738 fi 739 done 740 IFS="$ac_save_ifs" 741 ;; 742esac], 743enable_static=AC_ENABLE_STATIC_DEFAULT)dnl 744]) 745 746dnl AC_DISABLE_STATIC - set the default static flag to --disable-static 747AC_DEFUN([AC_DISABLE_STATIC], 748[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl 749AC_ENABLE_STATIC(no)]) 750 751dnl AC_TRY_RUN_STRICT(PROGRAM,CFLAGS,CPPFLAGS,LDFLAGS, 752dnl [ACTION-IF-TRUE],[ACTION-IF-FALSE], 753dnl [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR]) 754AC_DEFUN( [AC_TRY_RUN_STRICT], 755[ 756 old_CFLAGS="$CFLAGS"; 757 CFLAGS="$2"; 758 export CFLAGS; 759 old_CPPFLAGS="$CPPFLAGS"; 760 CPPFLAGS="$3"; 761 export CPPFLAGS; 762 old_LDFLAGS="$LDFLAGS"; 763 LDFLAGS="$4"; 764 export LDFLAGS; 765 AC_TRY_RUN([$1],[$5],[$6],[$7]); 766 CFLAGS="$old_CFLAGS"; 767 old_CFLAGS=""; 768 export CFLAGS; 769 CPPFLAGS="$old_CPPFLAGS"; 770 old_CPPFLAGS=""; 771 export CPPFLAGS; 772 LDFLAGS="$old_LDFLAGS"; 773 old_LDFLAGS=""; 774 export LDFLAGS; 775]) 776