1dnl Process this file with autoconf to produce a configure script. 2AC_INIT([pgpool-II], [4.3.0], [pgpool-hackers@pgpool.net], [pgpool-II]) 3 4dnl Checks for programs. 5AC_PROG_CC 6AC_PROG_CC_C99() 7 8# Error out if the compiler does not support C99, as the codebase 9# relies on that. 10if test "$ac_cv_prog_cc_c99" = no; then 11 AC_MSG_ERROR([C compiler "$CC" does not support C99]) 12fi 13 14AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects]) 15 16dnl Disallow to rebuild configure. 17AM_MAINTAINER_MODE(disable) 18 19# AC_PROG_RANLIB 20AR_FLAGS="cr" 21AC_SUBST(AR_FLAGS) 22AC_PROG_LIBTOOL 23 24AM_PROG_LEX 25AC_PROG_YACC 26AM_PROG_CC_C_O 27 28dnl suggested by libtoolize --force 29AC_CONFIG_MACRO_DIR([m4]) 30# Check for docbook 31PGAC_PROG_NSGMLS 32PGAC_PROG_JADE 33PGAC_CHECK_DOCBOOK(4.2) 34PGAC_PATH_DOCBOOK_STYLESHEETS 35PGAC_PATH_COLLATEINDEX 36AC_CHECK_PROGS(XSLTPROC, xsltproc) 37AC_CHECK_PROGS(XMLLINT, xmllint) 38AC_CHECK_PROGS(OSX, [osx sgml2xml sx]) 39AC_CHECK_PROGS(PERL, perl) 40AC_CHECK_PROGS(LYNX, lynx) 41AC_CHECK_PROGS(SUNIFDEF, sunifdef) 42 43AC_SUBST([XSLTPROC_HTML_FLAGS]) 44AC_SUBST([STYLE]) 45AM_CONDITIONAL([STYLE_ENV_SET], [test ! -z "$STYLE"]) 46 47dnl Check compiler option 48dnl check -Wall option 49OLD_CFLAGS=$CFLAGS 50CFLAGS="$CFLAGS -Wall" 51AC_MSG_CHECKING(for -Wall option) 52AC_CACHE_VAL(ac_cv_wall, 53 AC_TRY_COMPILE([], [char a;], ac_cv_wall=yes, ac_cv_wall=no)) 54echo $ac_cv_wall 55if test $ac_cv_wall = no; then 56 CFLAGS=$OLD_CFLAGS 57fi 58 59dnl check -Wmissing-prototypes 60OLD_CFLAGS=$CFLAGS 61CFLAGS="$CFLAGS -Wmissing-prototypes" 62AC_MSG_CHECKING(for -Wmissing-prototypes option) 63AC_CACHE_VAL(ac_cv_wmissing_prototypes, 64 AC_TRY_COMPILE([], [char a;], ac_cv_wmissing_prototypes=yes, 65 ac_cv_wmissing_prototypes=no)) 66echo $ac_cv_wmissing_prototypes 67if test $ac_cv_wmissing_prototypes = no; then 68 CFLAGS=$OLD_CFLAGS 69fi 70 71 72dnl check -Wmissing-prototypes 73OLD_CFLAGS=$CFLAGS 74CFLAGS="$CFLAGS -Wmissing-declarations" 75AC_MSG_CHECKING(for -Wmissing-declarations option) 76AC_CACHE_VAL(ac_cv_wmissing_declarations, 77 AC_TRY_COMPILE([], [char a;], ac_cv_wmissing_declarations=yes, 78 ac_cv_wmissing_declarations=no)) 79echo $ac_cv_wmissing_declarations 80if test $ac_cv_wmissing_declarations = no; then 81 CFLAGS=$OLD_CFLAGS 82fi 83 84dnl Checks for libraries. 85AC_CHECK_LIB(m, main) 86AC_CHECK_LIB(nsl, main) 87AC_CHECK_LIB(socket, main) 88AC_CHECK_LIB(ipc, main) 89AC_CHECK_LIB(IPC, main) 90AC_CHECK_LIB(lc, main) 91AC_CHECK_LIB(BSD, main) 92AC_CHECK_LIB(gen, main) 93AC_CHECK_LIB(PW, main) 94AC_CHECK_LIB(resolv, main) 95AC_CHECK_LIB(crypt, main) 96 97AC_CHECK_FUNCS([strlcat, strlcpy]) 98 99dnl Checks for header files. 100AC_HEADER_STDC 101AC_HEADER_SYS_WAIT 102AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h netdb.h sys/param.h sys/types.h sys/socket.h sys/un.h sys/time.h sys/sem.h sys/shm.h sys/select.h crypt.h sys/pstat.h) 103AC_CHECK_HEADER([termios.h], [AC_DEFINE(HAVE_TERMIOS_H,1,checking termios)]) 104dnl Checks for typedefs, structures, and compiler characteristics. 105AC_C_CONST 106AC_TYPE_PID_T 107AC_HEADER_TIME 108 109 110dnl ===== Copied from PostgreSQL's configure start ===== 111dnl 112dnl Check to see if we have a working 64-bit integer type. 113dnl This breaks down into two steps: 114dnl (1) figure out if the compiler has a 64-bit int type with working 115dnl arithmetic, and if so 116dnl (2) see whether snprintf() can format the type correctly. (Currently, 117dnl snprintf is the only library routine we really need for int8 support.) 118dnl It's entirely possible to have a compiler that handles a 64-bit type 119dnl when the C library doesn't; this is fairly likely when using gcc on 120dnl an older platform, for example. 121dnl If there is no native snprintf() or it does not handle the 64-bit type, 122dnl we force our own version of snprintf() to be used instead. 123dnl Note this test must be run after our initial check for snprintf/vsnprintf. 124m4_include([c-compiler.m4]) 125m4_include([c-library.m4]) 126m4_include([general.m4]) 127 128dnl This mazic variable is set to "yes" in PostgreSQL's configure.in 129dnl if PORTNAME is "win32". 130dnl pgpool-II does not suppport Windows at the moment, so we set to "no". 131pgac_need_repl_snprintf=no 132AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes) 133AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes) 134 135PGAC_TYPE_64BIT_INT([long int]) 136 137if test x"$HAVE_LONG_INT_64" = x"no" ; then 138 PGAC_TYPE_64BIT_INT([long long int]) 139fi 140 141dnl If we need to use "long long int", figure out whether nnnLL notation works. 142 143if test x"$HAVE_LONG_LONG_INT_64" = xyes ; then 144 AC_TRY_COMPILE([ 145#define INT64CONST(x) x##LL 146long long int foo = INT64CONST(0x1234567890123456); 147], 148 [], 149 [AC_DEFINE(HAVE_LL_CONSTANTS, 1, [Define to 1 if constants of type 'long long int' should have the suffix LL.])], 150 []) 151fi 152 153# If we found "long int" is 64 bits, assume snprintf handles it. If 154# we found we need to use "long long int", better check. We cope with 155# snprintfs that use %lld, %qd, or %I64d as the format. If none of these 156# work, fall back to our own snprintf emulation (which we know uses %lld). 157 158if test "$HAVE_LONG_LONG_INT_64" = yes ; then 159 if test $pgac_need_repl_snprintf = no; then 160 PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT 161 if test "$LONG_LONG_INT_FORMAT" = ""; then 162 # Force usage of our own snprintf, since system snprintf is broken 163 pgac_need_repl_snprintf=yes 164 LONG_LONG_INT_FORMAT='%lld' 165 fi 166 else 167 # Here if we previously decided we needed to use our own snprintf 168 LONG_LONG_INT_FORMAT='%lld' 169 fi 170 LONG_LONG_UINT_FORMAT=`echo "$LONG_LONG_INT_FORMAT" | sed 's/d$/u/'` 171 INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\"" 172 UINT64_FORMAT="\"$LONG_LONG_UINT_FORMAT\"" 173else 174 # Here if we are not using 'long long int' at all 175 INT64_FORMAT='"%ld"' 176 UINT64_FORMAT='"%lu"' 177fi 178 179# disable useless truncation warnings from gcc 8+ 180NOT_THE_CFLAGS="" 181PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation]) 182if test -n "$NOT_THE_CFLAGS"; then 183 CFLAGS="$CFLAGS -Wno-format-truncation" 184fi 185PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wstringop-truncation]) 186if test -n "$NOT_THE_CFLAGS"; then 187 CFLAGS="$CFLAGS -Wno-stringop-truncation" 188fi 189AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", 190 [Name of package]) 191 192AC_DEFINE_UNQUOTED(VERSION, "$VERSION", 193 [Version number of package]) 194 195AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT, 196 [Define to the appropriate snprintf format for 64-bit ints, if any.]) 197 198AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT, 199 [Define to the appropriate snprintf format for unsigned 64-bit ints, if any.]) 200 201# Now we have checked all the reasons to replace snprintf 202if test $pgac_need_repl_snprintf = yes; then 203 AC_DEFINE(USE_REPL_SNPRINTF, 1, [Use replacement snprintf() functions.]) 204 AC_LIBOBJ(snprintf) 205fi 206AM_CONDITIONAL(use_repl_snprintf, test $pgac_need_repl_snprintf = yes) 207# Need a #define for the size of Datum (unsigned long) 208AC_CHECK_SIZEOF([unsigned long]) 209 210# And check size of void *, size_t (enables tweaks for > 32bit address space) 211AC_CHECK_SIZEOF([void *]) 212AC_CHECK_SIZEOF([size_t]) 213 214# Decide whether float4 is passed by value: user-selectable, enabled by default 215AC_MSG_CHECKING([whether to build with float4 passed by value]) 216PGAC_ARG_BOOL(enable, float4-byval, yes, [disable float4 passed by value], 217 [AC_DEFINE([USE_FLOAT4_BYVAL], 1, 218 [Define to 1 if you want float4 values to be passed by value. (--enable-float4-byval)]) 219 float4passbyval=true], 220 [float4passbyval=false]) 221AC_MSG_RESULT([$enable_float4_byval]) 222AC_DEFINE_UNQUOTED([FLOAT4PASSBYVAL], [$float4passbyval], [float4 values are passed by value if 'true', by reference if 'false']) 223 224# Decide whether float8 is passed by value. 225# Note: this setting also controls int8 and related types such as timestamp. 226# If sizeof(Datum) >= 8, this is user-selectable, enabled by default. 227# If not, trying to select it is an error. 228AC_MSG_CHECKING([whether to build with float8 passed by value]) 229if test $ac_cv_sizeof_unsigned_long -ge 8 ; then 230 PGAC_ARG_BOOL(enable, float8-byval, yes, [disable float8 passed by value]) 231else 232 PGAC_ARG_BOOL(enable, float8-byval, no, [disable float8 passed by value]) 233 if test "$enable_float8_byval" = yes ; then 234 AC_MSG_ERROR([--enable-float8-byval is not supported on 32-bit platforms.]) 235 fi 236fi 237if test "$enable_float8_byval" = yes ; then 238 AC_DEFINE([USE_FLOAT8_BYVAL], 1, 239 [Define to 1 if you want float8, int8, etc values to be passed by value. (--enable-float8-byval)]) 240 float8passbyval=true 241else 242 float8passbyval=false 243fi 244AC_MSG_RESULT([$enable_float8_byval]) 245AC_DEFINE_UNQUOTED([FLOAT8PASSBYVAL], [$float8passbyval], [float8, int8, and related values are passed by value if 'true', by reference if 'false']) 246 247dnl Rest of part cannot be executed by autocnf-2.59. 248dnl AC_CHECK_ALIGNOF is supported autoconf-2.60 or higher. 249dnl ===== Copied from PostgreSQL's configure start ===== 250 251 252 253dnl Checks for sockaddr_storage structure, members and necessary types 254m4_include([ac_func_accept_argtypes.m4]) 255AC_CHECK_TYPES([struct sockaddr_storage], [], [], 256[#include <sys/types.h> 257#ifdef HAVE_SYS_SOCKET_H 258#include <sys/socket.h> 259#endif 260]) 261AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family, 262 struct sockaddr_storage.__ss_family, 263 struct sockaddr_storage.ss_len, 264 struct sockaddr_storage.__ss_len, 265 struct sockaddr.sa_len], [], [], 266[#include <sys/types.h> 267#ifdef HAVE_SYS_SOCKET_H 268#include <sys/socket.h> 269#endif 270]) 271 272AC_CHECK_TYPES([union semun],[],[],[#include <sys/types.h> 273#include <sys/ipc.h> 274#include <sys/sem.h>]) 275 276dnl Checks for library functions. 277AC_TYPE_SIGNAL 278AC_FUNC_VPRINTF 279AC_FUNC_WAIT3 280AC_FUNC_ACCEPT_ARGTYPES 281AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf vasprintf gai_strerror hstrerror pstat setproctitle syslog) 282 283PGAC_C_TYPES_COMPATIBLE 284 285dnl Checks for pg_config command. 286AC_CHECK_PROGS(PGCONFIG, pg_config) 287 288if test -z $PGCONFIG 289then 290 PGSQL_INCLUDE_DIR=/usr/local/pgsql/include 291 PGSQL_LIB_DIR=/usr/local/pgsql/lib 292 PGSQL_BIN_DIR=/usr/local/pgsql/bin 293else 294 PGSQL_INCLUDE_DIR=`pg_config --includedir` 295 PGSQL_LIB_DIR=`pg_config --libdir` 296 PGSQL_BIN_DIR=`pg_config --bindir` 297fi 298 299AC_ARG_WITH(pgsql, 300 [ --with-pgsql=DIR site header files for PostgreSQL in DIR], 301 [ 302 case "$withval" in 303 "" | y | ye | yes | n | no) 304 AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql option.]) 305 ;; 306 esac 307 PGSQL_INCLUDE_DIR="$withval"/include 308 PGSQL_LIB_DIR="$withval"/lib 309 PGSQL_BIN_DIR="$withval"/bin 310 ]) 311 312AC_ARG_WITH(pgsql-includedir, 313 [ --with-pgsql-includedir=DIR site header files for PostgreSQL in DIR], 314 [ 315 case "$withval" in 316 "" | y | ye | yes | n | no) 317 AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql-includedir option.]) 318 ;; 319 esac 320 PGSQL_INCLUDE_DIR="$withval" 321 ]) 322 323AC_ARG_WITH(pgsql-libdir, 324 [ --with-pgsql-libdir=DIR site library files for PostgreSQL in DIR], 325 [ 326 case "$withval" in 327 "" | y | ye | yes | n | no) 328 AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql-libdir option.]) 329 ;; 330 esac 331 PGSQL_LIB_DIR="$withval" 332 ]) 333 334AC_ARG_WITH(pgsql-bindir, 335 [ --with-pgsql-bindir=DIR site executable files for PostgreSQL in DIR], 336 [ 337 case "$withval" in 338 "" | y | ye | yes | n | no) 339 AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql-bindir option.]) 340 ;; 341 esac 342 PGSQL_BIN_DIR="$withval" 343 ]) 344 345AC_ARG_WITH(sunifdef, 346 [ --with-sunifdef=DIR install path for sunifdef utility ], 347 [ 348 case "$withval" in 349 "" | y | ye | yes | n | no) 350 AC_MSG_ERROR([*** You must supply an argument to the --with-sunifdef option.]) 351 ;; 352 esac 353 SUNIFDEF="$withval"/sunifdef 354 ]) 355 356AC_ARG_WITH(openssl, 357 [ --with-openssl build with OpenSSL support], 358 [], 359 [openssl=no]) 360 361if test "$with_openssl" = yes || test "$with_openssl" = auto; then 362 AC_CHECK_HEADERS(openssl/ssl.h, 363 [AC_DEFINE([USE_SSL], 1, 364 [Define to 1 to build with SSL support. (--with-openssl)])], 365 [ 366 if test "$with_openssl" = yes; then 367 AC_MSG_ERROR([header file <openssl/ssl.h> is required for SSL]) 368 else 369 AC_MSG_WARN([header file <openssl/ssl.h> is required for SSL]) 370 fi 371 ]) 372 373 AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]) 374 AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]) 375fi 376 377AC_ARG_WITH(ldap, 378 [ --with-ldap build with LDAP support], 379 [AC_DEFINE([USE_LDAP], 1, [Define to 1 to build with LDAP support. (--with-ldap)])]) 380if test "$with_ldap" = yes ; then 381 AC_CHECK_LIB(ldap, ldap_bind, [], 382 [AC_MSG_ERROR([library 'ldap' is required for LDAP])], 383 [$EXTRA_LDAP_LIBS]) 384 AC_CHECK_HEADERS(ldap.h, [], 385 [AC_MSG_ERROR([header file <ldap.h> is required for LDAP])]) 386 AC_CHECK_FUNCS([ldap_initialize]) 387fi 388 389AC_ARG_WITH(pam, 390 [ --with-pam build with PAM support], 391 [AC_DEFINE([USE_PAM], 1, [Define to 1 to build with PAM support. (--with-pam)])]) 392if test "$with_pam" = yes ; then 393 AC_CHECK_LIB(pam, pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])]) 394 AC_CHECK_HEADERS(security/pam_appl.h, [], 395 [AC_CHECK_HEADERS(pam/pam_appl.h, [], 396 [AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required for PAM.])])]) 397fi 398 399 400AC_ARG_WITH(memcached, 401 [ --with-memcached=DIR site header files for libmemcached in DIR], 402 [ 403 case "$withval" in 404 "" | y | ye | yes | n | no) 405 AC_MSG_ERROR([*** You must supply an argument to the --with-memcached option.]) 406 ;; 407 *) 408 409 MEMCACHED_INCLUDE_DIR="$withval"/include 410 MEMCACHED_LIB_DIR="$withval"/lib 411 OLD_CFLAGS="$CFLAGS" 412 CFLAGS="$CFLAGS -I$MEMCACHED_INCLUDE_DIR" 413 AC_CHECK_HEADERS( 414 [libmemcached/memcached.h], 415 [AC_DEFINE([USE_MEMCACHED], 1, [Define to 1 to build with memcached support])], 416 [AC_MSG_ERROR([header file <libmemcached/memcached.h> is required for memcached support])]) 417 CFLAGS=$OLD_CFLAGS 418 AC_CHECK_LIB(memcached, memcached_create, [], [AC_MSG_ERROR(libmemcached is not installed)]) 419 MEMCACHED_INCLUDE_OPT="-I $MEMCACHED_INCLUDE_DIR" 420 MEMCACHED_LINK_OPT="-L$MEMCACHED_LIB_DIR" 421 MEMCACHED_RPATH_OPT="-rpath $MEMCACHED_LIB_DIR" 422 ;; 423 esac 424 ]) 425 426CFLAGS="$CFLAGS -fno-strict-aliasing" 427 428AC_SUBST(MEMCACHED_INCLUDE_OPT) 429AC_SUBST(MEMCACHED_LINK_OPT) 430AC_SUBST(MEMCACHED_RPATH_OPT) 431 432OLD_LDFLAGS="$LDFLAGS" 433LDFLAGS="-L$PGSQL_LIB_DIR $LDFLAGS" 434OLD_LIBS="$LIBS" 435AC_CHECK_LIB(pq, PQexecPrepared, [], [AC_MSG_ERROR(libpq is not installed or libpq is old)]) 436AC_CHECK_FUNCS(PQprepare) 437AC_CHECK_FUNCS(PQpingParams) 438LDFLAGS="$OLD_LDFLAGS" 439LIBS="$OLD_LIBS" 440 441AC_SUBST(PGSQL_INCLUDE_DIR) 442AC_SUBST(PGSQL_LIB_DIR) 443AC_SUBST(PGSQL_BIN_DIR) 444AC_SUBST(MEMCACHED_DIR) 445 446# --enable(disable)-rpath option 447AC_ARG_ENABLE(rpath, 448 [ --disable-rpath do not embed shared library search path in executables], 449 [case "${enableval}" in 450 yes) rpath=yes ;; 451 no) rpath=no ;; 452 esac], 453 [rpath=yes] 454) 455AM_CONDITIONAL([enable_rpath], test x$rpath = xyes) 456 457# Decide whether to use row lock against the sequence table for insert_lock. 458# This lock method is compatible with pgpool-II 3.0 series(until 3.0.4). 459AC_MSG_CHECKING([whether to use row lock against the sequence table for insert_lock]) 460PGAC_ARG_BOOL(enable, sequence-lock, no, [insert_lock compatible with pgpool-II 3.0 series (until 3.0.4)]) 461if test "$enable_sequence_lock" = yes && test "$enable_table_lock" = yes ; then 462 AC_MSG_ERROR([--enable-table-lock cannot be enabled at the same time.]) 463fi 464if test "$enable_sequence_lock" = yes ; then 465 AC_DEFINE([USE_SEQUENCE_LOCK], 1, 466 [Define to 1 if you want to use row lock against the sequence table for insert_lock. (--enable-sequence-lock)]) 467fi 468AC_MSG_RESULT([$enable_sequence_lock]) 469 470# Decide whether to use table lock against the target table for insert_lock. 471# This lock method is compatible with pgpool-II 2.2 and 2.3 series. 472AC_MSG_CHECKING([whether to use table lock against the target table for insert_lock]) 473PGAC_ARG_BOOL(enable, table-lock, no, [insert_lock compatible with pgpool-II 2.2 and 2.3 series]) 474if test "$enable_table_lock" = yes && test "$enable_sequence_lock" = yes ; then 475 AC_MSG_ERROR([--enable-sequence-lock cannot be enabled at the same time.]) 476fi 477if test "$enable_table_lock" = yes ; then 478 AC_DEFINE([USE_TABLE_LOCK], 1, 479 [Define to 1 if you want to use table lock against the target table for insert_lock. (--enable-table-lock)]) 480fi 481AC_MSG_RESULT([$enable_table_lock]) 482 483PGAC_ARG_BOOL(enable, cassert, no, [build with assertion checks]) 484if test "$enable_cassert" = yes ; then 485 AC_DEFINE([USE_ASSERT_CHECKING], 1, 486 [Define to 1 to build with assertion checks. (--enable-cassert)]) 487fi 488AC_MSG_RESULT([enable cassert = $enable_cassert]) 489 490AM_CONFIG_HEADER(src/include/config.h) 491 492AC_OUTPUT([Makefile doc/Makefile doc/src/Makefile doc/src/sgml/Makefile doc.ja/Makefile doc.ja/src/Makefile doc.ja/src/sgml/Makefile doc.zh-cn/Makefile doc.zh-cn/src/Makefile doc.zh-cn/src/sgml/Makefile src/Makefile src/include/Makefile src/parser/Makefile src/libs/Makefile src/libs/pcp/Makefile src/tools/Makefile src/tools/pgmd5/Makefile src/tools/pgenc/Makefile src/tools/pcp/Makefile src/tools/pgproto/Makefile src/tools/watchdog/Makefile src/watchdog/Makefile]) 493