dnl
m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
-AC_INIT([PostgreSQL], [9.2devel], [pgsql-bugs@postgresql.org])
+AC_INIT([PostgreSQL], [9.6devel], [pgsql-bugs@postgresql.org])
-m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.63], [], [m4_fatal([Autoconf version 2.63 is required.
+m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
Untested combinations of 'autoconf' and PostgreSQL versions are not
recommended. You can remove the check from 'configure.in' but it is then
your responsibility whether the result works or not.])])
-AC_COPYRIGHT([Copyright (c) 1996-2012, PostgreSQL Global Development Group])
+AC_COPYRIGHT([Copyright (c) 1996-2015, PostgreSQL Global Development Group])
AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
AC_CONFIG_AUX_DIR(config)
AC_PREFIX_DEFAULT(/usr/local/pgsql)
AC_SUBST(configure_args, [$ac_configure_args])
-AC_DEFINE_UNQUOTED(PG_VERSION, "$PACKAGE_VERSION", [PostgreSQL version as a string])
[PG_MAJORVERSION=`expr "$PACKAGE_VERSION" : '\([0-9][0-9]*\.[0-9][0-9]*\)'`]
AC_SUBST(PG_MAJORVERSION)
AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major version as a string])
+PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
+ [PG_VERSION="$PACKAGE_VERSION$withval"],
+ [PG_VERSION="$PACKAGE_VERSION"])
+AC_DEFINE_UNQUOTED(PG_VERSION, "$PG_VERSION", [PostgreSQL version as a string])
+
AC_CANONICAL_HOST
template=
case $host_os in
aix*) template=aix ;;
- bsdi*) template=bsdi ;;
cygwin*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
- dgux*) template=dgux ;;
freebsd*) template=freebsd ;;
hpux*) template=hpux ;;
- irix*) template=irix ;;
linux*|gnu*|k*bsd*-gnu)
template=linux ;;
mingw*) template=win32 ;;
netbsd*) template=netbsd ;;
-nextstep*) template=nextstep ;;
openbsd*) template=openbsd ;;
- osf*) template=osf ;;
sco*) template=sco ;;
solaris*) template=solaris ;;
- sunos*) template=sunos4 ;;
- sysv4.2*)
- case $host_vendor in
- univel) template=univel ;;
- esac ;;
- sysv4*) template=svr4 ;;
sysv5*) template=unixware ;;
- ultrix*) template=ultrix4 ;;
esac
if test x"$template" = x"" ; then
[Define to the default TCP port number as a string constant.])
AC_SUBST(default_port)
-#
-# Option to disable shared libraries
-#
-PGAC_ARG_BOOL(enable, shared, yes,
- [do not build shared libraries])
-AC_SUBST(enable_shared)
-
#
# '-rpath'-like feature can be disabled
#
PGAC_ARG_BOOL(enable, spinlocks, yes,
[do not use spinlocks])
+#
+# Atomic operations
+#
+PGAC_ARG_BOOL(enable, atomics, yes,
+ [do not use atomic operations])
+
#
# --enable-debug adds -g to compiler flags
#
#
PGAC_ARG_BOOL(enable, profiling, no,
[build with profiling enabled ])
-AC_SUBST(enable_profiling)
#
# --enable-coverage enables generation of code coverage metrics with gcov
#
PGAC_ARG_BOOL(enable, dtrace, no,
[build with DTrace support],
-[AC_DEFINE([ENABLE_DTRACE], 1,
- [Define to 1 to enable DTrace support. (--enable-dtrace)])
-AC_CHECK_PROGS(DTRACE, dtrace)
+[AC_CHECK_PROGS(DTRACE, dtrace)
if test -z "$DTRACE"; then
AC_MSG_ERROR([dtrace not found])
fi
AC_SUBST(DTRACEFLAGS)])
AC_SUBST(enable_dtrace)
+#
+# TAP tests
+#
+PGAC_ARG_BOOL(enable, tap-tests, no,
+ [enable TAP tests (requires Perl and IPC::Run)])
+AC_SUBST(enable_tap_tests)
+
#
# Block size
#
case $template in
aix) pgac_cc_list="gcc xlc";;
- irix) pgac_cc_list="cc";; # no gcc
*) pgac_cc_list="gcc cc";;
esac
# Check if it's Intel's compiler, which (usually) pretends to be gcc,
# but has idiosyncrasies of its own. We assume icc will define
# __INTEL_COMPILER regardless of CFLAGS.
-AC_TRY_COMPILE([], [@%:@ifndef __INTEL_COMPILER
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifndef __INTEL_COMPILER
choke me
-@%:@endif], [ICC=[yes]], [ICC=[no]])
+@%:@endif])], [ICC=yes], [ICC=no])
# Check if it's Sun Studio compiler. We assume that
# __SUNPRO_C will be defined for Sun Studio compilers
-AC_TRY_COMPILE([], [@%:@ifndef __SUNPRO_C
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifndef __SUNPRO_C
choke me
-@%:@endif], [SUN_STUDIO_CC=yes], [SUN_STUDIO_CC=no])
+@%:@endif])], [SUN_STUDIO_CC=yes], [SUN_STUDIO_CC=no])
AC_SUBST(SUN_STUDIO_CC)
fi
fi
+# CFLAGS we determined above will be added back at the end
+user_CFLAGS=$CFLAGS
+CFLAGS=""
+
+# set CFLAGS_VECTOR from the environment, if available
+if test "$ac_env_CFLAGS_VECTOR_set" = set; then
+ CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
+fi
+
# Some versions of GCC support some additional useful warning flags.
# Check whether they are supported, and add them to CFLAGS if so.
# ICC pretends to be GCC but it's lying; it doesn't support these flags,
# but has its own. Also check other compiler-specific flags here.
if test "$GCC" = yes -a "$ICC" = no; then
- CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
+ CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
# These work in some but not all gcc versions
PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
# Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
+ # Optimization flags for specific files that benefit from vectorization
+ PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
+ PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
+ # We want to suppress clang's unhelpful unused-command-line-argument warnings
+ # but gcc won't complain about unrecognized -Wno-foo switches, so we have to
+ # test for the positive form and if that works, add the negative form
+ PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
+ if test -n "$NOT_THE_CFLAGS"; then
+ CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
+ fi
elif test "$ICC" = yes; then
# Intel's compiler has a bug/misoptimization in checking for
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
elif test "$PORTNAME" = "aix"; then
# AIX's xlc has to have strict aliasing turned off too
PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias])
+ PGAC_PROG_CC_CFLAGS_OPT([-qlonglong])
elif test "$PORTNAME" = "hpux"; then
# On some versions of HP-UX, libm functions do not set errno by default.
# Fix that by using +Olibmerrno if the compiler recognizes it.
PGAC_PROG_CC_CFLAGS_OPT([+Olibmerrno])
fi
+AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
+
# supply -g if --enable-debug
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
CFLAGS="$CFLAGS -g"
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
fi
-# Check if the compiler still works with the template settings
+# Now that we're done automatically adding stuff to CFLAGS, put back the
+# user-specified flags (if any) at the end. This lets users override
+# the automatic additions.
+CFLAGS="$CFLAGS $user_CFLAGS"
+
+# Check if the compiler still works with the final flag settings
AC_MSG_CHECKING([whether the C compiler still works])
-AC_TRY_LINK([], [return 0;],
+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([cannot proceed])])
# Defend against gcc -ffast-math
if test "$GCC" = yes; then
-AC_TRY_COMPILE([], [@%:@ifdef __FAST_MATH__
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifdef __FAST_MATH__
choke me
-@%:@endif], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
+@%:@endif])], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
fi
AC_PROG_CPP
krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
])
AC_MSG_RESULT([$with_gssapi])
-AC_SUBST(with_gssapi)
-
-#
-# Kerberos 5
-#
-AC_MSG_CHECKING([whether to build with Kerberos 5 support])
-PGAC_ARG_BOOL(with, krb5, no, [build with Kerberos 5 support],
-[
- AC_DEFINE(KRB5, 1, [Define to build with Kerberos 5 support. (--with-krb5)])
- krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
-])
-AC_MSG_RESULT([$with_krb5])
-AC_SUBST(with_krb5)
AC_SUBST(krb_srvtab)
# Kerberos configuration parameters
#
PGAC_ARG_REQ(with, krb-srvnam,
- [NAME], [default service principal name in Kerberos [postgres]],
+ [NAME], [default service principal name in Kerberos (GSSAPI) [postgres]],
[],
[with_krb_srvnam="postgres"])
AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
- [Define to the name of the default PostgreSQL service principal in Kerberos. (--with-krb-srvnam=NAME)])
+ [Define to the name of the default PostgreSQL service principal in Kerberos (GSSAPI). (--with-krb-srvnam=NAME)])
#
[build with PAM support],
[AC_DEFINE([USE_PAM], 1, [Define to 1 to build with PAM support. (--with-pam)])])
AC_MSG_RESULT([$with_pam])
-AC_SUBST(with_pam)
#
[build with LDAP support],
[AC_DEFINE([USE_LDAP], 1, [Define to 1 to build with LDAP support. (--with-ldap)])])
AC_MSG_RESULT([$with_ldap])
-AC_SUBST(with_ldap)
#
[build with Bonjour support],
[AC_DEFINE([USE_BONJOUR], 1, [Define to 1 to build with Bonjour support. (--with-bonjour)])])
AC_MSG_RESULT([$with_bonjour])
-AC_SUBST(with_bonjour)
#
#
AC_MSG_CHECKING([whether to build with OpenSSL support])
PGAC_ARG_BOOL(with, openssl, no, [build with OpenSSL support],
- [AC_DEFINE([USE_SSL], 1, [Define to build with (Open)SSL support. (--with-openssl)])])
+ [AC_DEFINE([USE_OPENSSL], 1, [Define to build with OpenSSL support. (--with-openssl)])])
AC_MSG_RESULT([$with_openssl])
AC_SUBST(with_openssl)
#
-# OSSP UUID library
+# UUID library
+#
+# There are at least three UUID libraries in common use: the FreeBSD/NetBSD
+# library, the e2fsprogs libuuid (now part of util-linux-ng), and the OSSP
+# UUID library. More than one of these might be present on a given platform,
+# so we make the user say which one she wants.
#
-PGAC_ARG_BOOL(with, ossp-uuid, no, [build contrib/uuid-ossp, requires OSSP UUID library])
-AC_SUBST(with_ossp_uuid)
+PGAC_ARG_REQ(with, uuid, [LIB], [build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)])
+if test x"$with_uuid" = x"" ; then
+ with_uuid=no
+fi
+PGAC_ARG_BOOL(with, ossp-uuid, no, [obsolete spelling of --with-uuid=ossp])
+if test "$with_ossp_uuid" = yes ; then
+ with_uuid=ossp
+fi
+
+if test "$with_uuid" = bsd ; then
+ AC_DEFINE([HAVE_UUID_BSD], 1, [Define to 1 if you have BSD UUID support.])
+ UUID_EXTRA_OBJS="md5.o sha1.o"
+elif test "$with_uuid" = e2fs ; then
+ AC_DEFINE([HAVE_UUID_E2FS], 1, [Define to 1 if you have E2FS UUID support.])
+ UUID_EXTRA_OBJS="md5.o sha1.o"
+elif test "$with_uuid" = ossp ; then
+ AC_DEFINE([HAVE_UUID_OSSP], 1, [Define to 1 if you have OSSP UUID support.])
+ UUID_EXTRA_OBJS=""
+elif test "$with_uuid" = no ; then
+ UUID_EXTRA_OBJS=""
+else
+ AC_MSG_ERROR([--with-uuid must specify one of bsd, e2fs, or ossp])
+fi
+AC_SUBST(with_uuid)
+AC_SUBST(UUID_EXTRA_OBJS)
#
AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R],
[
pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,-R/usr/lib"
- AC_TRY_LINK([], [], [pgac_cv_prog_ld_R=yes], [pgac_cv_prog_ld_R=no])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+ [pgac_cv_prog_ld_R=yes],
+ [pgac_cv_prog_ld_R=no])
LDFLAGS=$pgac_save_LDFLAGS
])
ld_R_works=$pgac_cv_prog_ld_R
AC_CHECK_TOOL(WINDRES, windres, windres)
fi
+AC_PROG_INSTALL
+# When Autoconf chooses install-sh as install program it tries to generate
+# a relative path to it in each makefile where it subsitutes it. This clashes
+# with our Makefile.global concept. This workaround helps.
+case $INSTALL in
+ *install-sh*) install_bin='';;
+ *) install_bin=$INSTALL;;
+esac
+AC_SUBST(install_bin)
+
AC_PATH_PROG(TAR, tar)
AC_PROG_LN_S
AC_PROG_AWK
AC_MSG_ERROR([Perl not found])
fi
PGAC_CHECK_PERL_CONFIGS([archlibexp,privlibexp,useshrplib])
+ if test "$perl_useshrplib" != yes && test "$perl_useshrplib" != true; then
+ AC_MSG_ERROR([cannot build PL/Perl because libperl is not a shared library
+You might have to rebuild your Perl installation. Refer to the
+documentation for details. Use --without-perl to disable building
+PL/Perl.])
+ fi
PGAC_CHECK_PERL_EMBED_LDFLAGS
fi
if test "$with_python" = yes; then
PGAC_PATH_PYTHON
PGAC_CHECK_PYTHON_EMBED_SETUP
+
+ # We need libpython as a shared library. With Python >=2.5, we
+ # check the Py_ENABLE_SHARED setting. On Debian, the setting is not
+ # correct before the jessie release (http://bugs.debian.org/695979).
+ # We also want to support older Python versions. So as a fallback
+ # we see if there is a file that is named like a shared library.
+
+ if test "$python_enable_shared" != 1; then
+ if test "$PORTNAME" = darwin; then
+ # OS X does supply a .dylib even though Py_ENABLE_SHARED does
+ # not get set. The file detection logic below doesn't succeed
+ # on older OS X versions, so make it explicit.
+ python_enable_shared=1
+ elif test "$PORTNAME" = win32; then
+ # Windows also needs an explicit override.
+ python_enable_shared=1
+ else
+ # We don't know the platform shared library extension here yet,
+ # so we try some candidates.
+ for dlsuffix in .so .sl; do
+ if ls "$python_libdir"/libpython*${dlsuffix}* >/dev/null 2>&1; then
+ python_enable_shared=1
+ break
+ fi
+ done
+ fi
+ fi
+
+ if test "$python_enable_shared" != 1; then
+ AC_MSG_ERROR([cannot build PL/Python because libpython is not a shared library
+You might have to rebuild your Python installation. Refer to the
+documentation for details. Use --without-python to disable building
+PL/Python.])
+ fi
fi
if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
fi
fi
+#
+# Pthreads
+#
+# For each platform, we need to know about any special compile and link
+# libraries, and whether the normal C function names are thread-safe.
+# See the comment at the top of src/port/thread.c for more information.
+# WIN32 doesn't need the pthread tests; it always uses threads
+#
+# These tests are run before the library-tests, because linking with the
+# other libraries can pull in the pthread functions as a side-effect. We
+# want to use the -pthread or similar flags directly, and not rely on
+# the side-effects of linking with some other library.
+#
+# note: We have to use AS_IF here rather than plain if. The AC_CHECK_HEADER
+# invocation below is the first one in the script, and autoconf generates
+# additional code for that, which must not be inside the if-block. AS_IF
+# knows how to do that.
+AS_IF([test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"],
+[ # then
+AX_PTHREAD # set thread flags
+
+# Some platforms use these, so just define them. They can't hurt if they
+# are not supported. For example, on Solaris -D_POSIX_PTHREAD_SEMANTICS
+# enables 5-arg getpwuid_r, among other things.
+PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
+
+# Check for *_r functions
+_CFLAGS="$CFLAGS"
+_LIBS="$LIBS"
+CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+LIBS="$LIBS $PTHREAD_LIBS"
+
+AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
+pthread.h not found; use --disable-thread-safety to disable thread safety])])
+
+AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
+
+# Do test here with the proper thread flags
+PGAC_FUNC_STRERROR_R_INT
+
+CFLAGS="$_CFLAGS"
+LIBS="$_LIBS"
+
+], [ # else
+# do not use values from template file
+PTHREAD_CFLAGS=
+PTHREAD_LIBS=
+]) # fi
+
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_LIBS)
+
##
## Libraries
AC_CHECK_LIB(m, main)
AC_SEARCH_LIBS(setproctitle, util)
AC_SEARCH_LIBS(dlopen, dl)
-AC_SEARCH_LIBS(socket, [socket wsock32])
+AC_SEARCH_LIBS(socket, [socket ws2_32])
AC_SEARCH_LIBS(shl_load, dld)
# We only use libld in port/dynloader/aix.c
case $host_os in
esac
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
AC_SEARCH_LIBS(crypt, crypt)
+AC_SEARCH_LIBS(shm_open, rt)
+AC_SEARCH_LIBS(shm_unlink, rt)
# Solaris:
AC_SEARCH_LIBS(fdatasync, [rt posix4])
+# Required for thread_test.c on Solaris
+AC_SEARCH_LIBS(sched_yield, rt)
# Required for thread_test.c on Solaris 2.5:
# Other ports use it too (HP-UX) so test unconditionally
AC_SEARCH_LIBS(gethostbyname_r, nsl)
*** Not using spinlocks will cause poor performance.])
fi
+if test "$enable_atomics" = yes; then
+ AC_DEFINE(HAVE_ATOMICS, 1, [Define to 1 if you want to use atomics if available.])
+else
+ AC_MSG_WARN([
+*** Not using atomic operations will cause poor performance.])
+fi
+
if test "$with_gssapi" = yes ; then
if test "$PORTNAME" != "win32"; then
AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
- [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
+ [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
else
LIBS="$LIBS -lgssapi32"
fi
fi
-if test "$with_krb5" = yes ; then
- if test "$PORTNAME" != "win32"; then
- AC_SEARCH_LIBS(com_err, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken' com_err 'com_err -lssl -lcrypto'], [],
- [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
- AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
- [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
- else
- AC_SEARCH_LIBS(com_err, 'comerr32 -lkrb5_32', [],
- [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
- fi
-fi
-
if test "$with_openssl" = yes ; then
dnl Order matters!
if test "$PORTNAME" != "win32"; then
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
AC_CHECK_LIB(ssl, SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
else
- AC_CHECK_LIB(eay32, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'eay32' is required for OpenSSL])])
- AC_CHECK_LIB(ssleay32, SSL_library_init, [], [AC_MSG_ERROR([library 'ssleay32' is required for OpenSSL])])
+ AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
+ AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
fi
+ AC_CHECK_FUNCS([SSL_get_current_compression])
fi
if test "$with_pam" = yes ; then
AC_CHECK_LIB(xslt, xsltCleanupGlobals, [], [AC_MSG_ERROR([library 'xslt' is required for XSLT support])])
fi
+# Note: We can test for libldap_r only after we know PTHREAD_LIBS
+if test "$with_ldap" = yes ; then
+ _LIBS="$LIBS"
+ if test "$PORTNAME" != "win32"; then
+ AC_CHECK_LIB(ldap, ldap_bind, [],
+ [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
+ [$EXTRA_LDAP_LIBS])
+ LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
+ if test "$enable_thread_safety" = yes; then
+ # on some platforms ldap_r fails to link without PTHREAD_LIBS
+ AC_CHECK_LIB(ldap_r, ldap_simple_bind, [],
+ [AC_MSG_ERROR([library 'ldap_r' is required for LDAP])],
+ [$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
+ LDAP_LIBS_FE="-lldap_r $EXTRA_LDAP_LIBS"
+ else
+ LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
+ fi
+ else
+ AC_CHECK_LIB(wldap32, ldap_bind, [], [AC_MSG_ERROR([library 'wldap32' is required for LDAP])])
+ LDAP_LIBS_FE="-lwldap32"
+ LDAP_LIBS_BE="-lwldap32"
+ fi
+ LIBS="$_LIBS"
+fi
+AC_SUBST(LDAP_LIBS_FE)
+AC_SUBST(LDAP_LIBS_BE)
+
# for contrib/sepgsql
if test "$with_selinux" = yes; then
- AC_CHECK_LIB(selinux, selinux_status_open, [],
- [AC_MSG_ERROR([library 'libselinux', version 2.0.99 or newer, is required for SELinux support])])
+ AC_CHECK_LIB(selinux, security_compute_create_name, [],
+ [AC_MSG_ERROR([library 'libselinux', version 2.1.10 or newer, is required for SELinux support])])
fi
# for contrib/uuid-ossp
-if test "$with_ossp_uuid" = yes ; then
+if test "$with_uuid" = bsd ; then
+ # On BSD, the UUID functions are in libc
+ AC_CHECK_FUNC(uuid_to_string,
+ [UUID_LIBS=""],
+ [AC_MSG_ERROR([BSD UUID functions are not present])])
+elif test "$with_uuid" = e2fs ; then
+ # On OS X, the UUID functions are in libc
+ AC_CHECK_FUNC(uuid_generate,
+ [UUID_LIBS=""],
+ [AC_CHECK_LIB(uuid, uuid_generate,
+ [UUID_LIBS="-luuid"],
+ [AC_MSG_ERROR([library 'uuid' is required for E2FS UUID])])])
+elif test "$with_uuid" = ossp ; then
AC_CHECK_LIB(ossp-uuid, uuid_export,
- [OSSP_UUID_LIBS="-lossp-uuid"],
+ [UUID_LIBS="-lossp-uuid"],
[AC_CHECK_LIB(uuid, uuid_export,
- [OSSP_UUID_LIBS="-luuid"],
- [AC_MSG_ERROR([library 'ossp-uuid' or 'uuid' is required for OSSP-UUID])])])
+ [UUID_LIBS="-luuid"],
+ [AC_MSG_ERROR([library 'ossp-uuid' or 'uuid' is required for OSSP UUID])])])
fi
-AC_SUBST(OSSP_UUID_LIBS)
+AC_SUBST(UUID_LIBS)
##
##
dnl sys/socket.h is required by AC_FUNC_ACCEPT_ARGTYPES
-AC_CHECK_HEADERS([crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h poll.h pwd.h sys/ioctl.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/socket.h sys/sockio.h sys/tas.h sys/time.h sys/ucred.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h kernel/OS.h kernel/image.h SupportDefs.h])
+AC_CHECK_HEADERS([atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h pwd.h sys/ioctl.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/socket.h sys/sockio.h sys/tas.h sys/time.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h])
-# On BSD, cpp test for net/if.h will fail unless sys/socket.h
+# On BSD, test for net/if.h will fail unless sys/socket.h
# is included first.
AC_CHECK_HEADERS(net/if.h, [], [],
[AC_INCLUDES_DEFAULT
#endif
])
-# At least on IRIX, cpp test for netinet/tcp.h will fail unless
+# On OpenBSD, test for sys/ucred.h will fail unless sys/param.h
+# is included first.
+AC_CHECK_HEADERS(sys/ucred.h, [], [],
+[AC_INCLUDES_DEFAULT
+#include <sys/param.h>
+])
+
+# At least on IRIX, test for netinet/tcp.h will fail unless
# netinet/in.h is included first.
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(netinet/tcp.h, [], [],
[AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
fi
-if test "$with_krb5" = yes ; then
- AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
-fi
-
if test "$with_openssl" = yes ; then
AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
- AC_CHECK_FUNCS([ERR_set_mark])
fi
if test "$with_pam" = yes ; then
if test "$PORTNAME" != "win32"; then
AC_CHECK_HEADERS(ldap.h, [],
[AC_MSG_ERROR([header file <ldap.h> is required for LDAP])])
+ PGAC_LDAP_SAFE
else
AC_CHECK_HEADERS(winldap.h, [],
[AC_MSG_ERROR([header file <winldap.h> is required for LDAP])],
fi
# for contrib/uuid-ossp
-if test "$with_ossp_uuid" = yes ; then
- AC_CHECK_HEADERS(ossp/uuid.h, [], [
- AC_CHECK_HEADERS(uuid.h, [],
- [AC_MSG_ERROR([header file <ossp/uuid.h> or <uuid.h> is required for OSSP-UUID])])])
+if test "$with_uuid" = bsd ; then
+ AC_CHECK_HEADERS(uuid.h,
+ [AC_EGREP_HEADER([uuid_to_string], uuid.h, [],
+ [AC_MSG_ERROR([header file <uuid.h> does not match BSD UUID library])])],
+ [AC_MSG_ERROR([header file <uuid.h> is required for BSD UUID])])
+elif test "$with_uuid" = e2fs ; then
+ AC_CHECK_HEADERS(uuid/uuid.h,
+ [AC_EGREP_HEADER([uuid_generate], uuid/uuid.h, [],
+ [AC_MSG_ERROR([header file <uuid/uuid.h> does not match E2FS UUID library])])],
+ [AC_CHECK_HEADERS(uuid.h,
+ [AC_EGREP_HEADER([uuid_generate], uuid.h, [],
+ [AC_MSG_ERROR([header file <uuid.h> does not match E2FS UUID library])])],
+ [AC_MSG_ERROR([header file <uuid/uuid.h> or <uuid.h> is required for E2FS UUID])])])
+elif test "$with_uuid" = ossp ; then
+ AC_CHECK_HEADERS(ossp/uuid.h,
+ [AC_EGREP_HEADER([uuid_export], ossp/uuid.h, [],
+ [AC_MSG_ERROR([header file <ossp/uuid.h> does not match OSSP UUID library])])],
+ [AC_CHECK_HEADERS(uuid.h,
+ [AC_EGREP_HEADER([uuid_export], uuid.h, [],
+ [AC_MSG_ERROR([header file <uuid.h> does not match OSSP UUID library])])],
+ [AC_MSG_ERROR([header file <ossp/uuid.h> or <uuid.h> is required for OSSP UUID])])])
fi
if test "$PORTNAME" = "win32" ; then
m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
AC_C_BIGENDIAN
-AC_C_CONST
-PGAC_C_INLINE
-AC_C_STRINGIZE
+AC_C_INLINE
+PGAC_PRINTF_ARCHETYPE
AC_C_FLEXIBLE_ARRAY_MEMBER
PGAC_C_SIGNED
-AC_C_VOLATILE
PGAC_C_FUNCNAME_SUPPORT
+PGAC_C_STATIC_ASSERT
+PGAC_C_TYPES_COMPATIBLE
+PGAC_C_BUILTIN_BSWAP32
+PGAC_C_BUILTIN_CONSTANT_P
+PGAC_C_BUILTIN_UNREACHABLE
+PGAC_C_VA_ARGS
PGAC_STRUCT_TIMEZONE
PGAC_UNION_SEMUN
PGAC_STRUCT_SOCKADDR_UN
AC_CHECK_TYPES([struct cmsgcred], [], [],
[#include <sys/socket.h>
+#include <sys/param.h>
#ifdef HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif])
[#include <zlib.h>])
fi
-if test "$with_krb5" = yes; then
-# Check for differences between MIT and Heimdal (KTH) releases
- AC_CHECK_MEMBERS(krb5_ticket.enc_part2, [],
- [AC_CHECK_MEMBERS(krb5_ticket.client, [],
- [AC_MSG_ERROR([could not determine how to get client name from Kerberos 5 ticket])],
- [#include <krb5.h>])],
- [#include <krb5.h>])
- AC_CHECK_MEMBERS(krb5_error.text.data, [],
- [AC_CHECK_MEMBERS(krb5_error.e_data, [],
- [AC_MSG_ERROR([could not determine how to extract Kerberos 5 error messages])],
- [#include <krb5.h>])],
- [#include <krb5.h>])
-
-# Win32 requires headers to be loaded for __stdcall, so can't use
-# AC_CHECK_FUNCS here.
- AC_MSG_CHECKING(for krb5_free_unparsed_name)
- AC_TRY_LINK([#include <krb5.h>],
- [krb5_free_unparsed_name(NULL,NULL);],
- [AC_DEFINE(HAVE_KRB5_FREE_UNPARSED_NAME, 1, [Define to 1 if you have krb5_free_unparsed_name.])
-AC_MSG_RESULT(yes)],
- [AC_MSG_RESULT(no)])
-fi
-
# On PPC, check if assembler supports LWARX instruction's mutex hint bit
case $host_cpu in
ppc*|powerpc*)
AC_MSG_CHECKING([whether assembler supports lwarx hint bit])
- AC_TRY_COMPILE([],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[int a = 0; int *p = &a; int r;
- __asm__ __volatile__ (" lwarx %0,0,%1,1\n" : "=&r"(r) : "r"(p));],
+ __asm__ __volatile__ (" lwarx %0,0,%1,1\n" : "=&r"(r) : "r"(p));])],
[pgac_cv_have_ppc_mutex_hint=yes],
[pgac_cv_have_ppc_mutex_hint=no])
AC_MSG_RESULT([$pgac_cv_have_ppc_mutex_hint])
# defines can affect what is generated for that.
if test "$PORTNAME" != "win32"; then
AC_SYS_LARGEFILE
+ dnl Autoconf 2.69's AC_SYS_LARGEFILE believes it's a good idea to #define
+ dnl _DARWIN_USE_64_BIT_INODE, but it isn't: on OS X 10.5 that activates a
+ dnl bug that causes readdir() to sometimes return EINVAL. On later OS X
+ dnl versions where the feature actually works, it's on by default anyway.
+ AH_VERBATIM([_DARWIN_USE_64_BIT_INODE],[])
fi
# Check for largefile support (must be after AC_SYS_LARGEFILE)
AC_FUNC_ACCEPT_ARGTYPES
PGAC_FUNC_GETTIMEOFDAY_1ARG
-AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs wcstombs_l])
+# Some versions of libedit contain strlcpy(), setproctitle(), and other
+# symbols that that library has no business exposing to the world. Pending
+# acquisition of a clue by those developers, ignore libedit (including its
+# possible alias of libreadline) while checking for everything else.
+LIBS_including_readline="$LIBS"
+LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
+
+AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
AC_REPLACE_FUNCS(fseeko)
case $host_os in
- # BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
+ # NetBSD uses a custom fseeko/ftello built on fsetpos/fgetpos
# Mingw uses macros to access Win32 API calls
- bsdi*|netbsd*|mingw*)
+ netbsd*|mingw*)
AC_DEFINE(HAVE_FSEEKO, 1, [Define to 1 because replacement version used.])
ac_cv_func_fseeko=yes;;
*)
AC_SUBST(HAVE_IPV6)
AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
-[AC_TRY_LINK(
+[AC_LINK_IFELSE([AC_LANG_PROGRAM(
[#include <machine/vmparam.h>
#include <sys/exec.h>
],
[PS_STRINGS->ps_nargvstr = 1;
-PS_STRINGS->ps_argvstr = "foo";],
+PS_STRINGS->ps_argvstr = "foo";])],
[pgac_cv_var_PS_STRINGS=yes],
[pgac_cv_var_PS_STRINGS=no])])
if test "$pgac_cv_var_PS_STRINGS" = yes ; then
- AC_DEFINE([HAVE_PS_STRINGS], [], [Define to 1 if the PS_STRINGS thing exists.])
+ AC_DEFINE([HAVE_PS_STRINGS], 1, [Define to 1 if the PS_STRINGS thing exists.])
fi
dnl Cannot use AC_CHECK_FUNC because isinf may be a macro
AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
-[AC_TRY_LINK([
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <math.h>
double glob_double;
],
-[return isinf(glob_double) ? 0 : 1;],
+[return isinf(glob_double) ? 0 : 1;])],
[ac_cv_func_isinf=yes],
[ac_cv_func_isinf=no])])
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi
-# Some versions of libedit contain strlcpy(); so disregard that library while
-# checking for these standard libc functions.
-pgac_save_LIBS="$LIBS"
-LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-
-AC_REPLACE_FUNCS([crypt fls getopt getrusage inet_aton random rint srandom strdup strerror strlcat strlcpy strtol strtoul])
+AC_REPLACE_FUNCS([crypt fls getopt getrusage inet_aton mkdtemp random rint srandom strerror strlcat strlcpy])
case $host_os in
;;
esac
-
-LIBS="$pgac_save_LIBS"
-
# System's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
-# (Note: the AC_REPLACE_FUNCS probe fails on Windows, where the available
-# versions of getaddrinfo don't follow normal C call protocol. This is OK
-# because we want to use our own getaddrinfo.c on Windows anyway.)
-if test x"$ac_cv_type_struct_addrinfo" = xyes ; then
+# We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
+if test x"$ac_cv_type_struct_addrinfo" = xyes && \
+ test "$PORTNAME" != "win32"; then
AC_REPLACE_FUNCS([getaddrinfo])
else
AC_LIBOBJ(getaddrinfo)
AC_LIBOBJ(getopt_long)
fi
-# Win32 support
+# Win32 (really MinGW) support
if test "$PORTNAME" = "win32"; then
AC_REPLACE_FUNCS(gettimeofday)
+ AC_LIBOBJ(dirmod)
AC_LIBOBJ(kill)
AC_LIBOBJ(open)
+ AC_LIBOBJ(system)
AC_LIBOBJ(win32env)
AC_LIBOBJ(win32error)
AC_LIBOBJ(win32setlocale)
AC_SUBST(have_win32_dbghelp,no)
fi
-if test "$with_readline" = yes; then
- PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
- AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function])
- AC_CHECK_FUNCS([append_history history_truncate_file])
-fi
-
-
-dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
-dnl (especially on GNU libc)
-dnl See also comments in c.h.
-AC_CACHE_CHECK([for sigsetjmp], pgac_cv_func_sigsetjmp,
-[AC_TRY_LINK([#include <setjmp.h>],
- [sigjmp_buf x; sigsetjmp(x, 1);],
- [pgac_cv_func_sigsetjmp=yes],
- [pgac_cv_func_sigsetjmp=no])])
-if test x"$pgac_cv_func_sigsetjmp" = x"yes"; then
- AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have sigsetjmp().])
+# Cygwin needs only a bit of that
+if test "$PORTNAME" = "cygwin"; then
+ AC_LIBOBJ(dirmod)
fi
-AC_DECL_SYS_SIGLIST
+AC_CHECK_DECLS([sys_siglist], [], [],
+[#include <signal.h>
+/* NetBSD declares sys_siglist in unistd.h. */
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+])
AC_CHECK_FUNC(syslog,
[AC_CHECK_HEADER(syslog.h,
[AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])
AC_CACHE_CHECK([for opterr], pgac_cv_var_int_opterr,
-[AC_TRY_LINK([#include <unistd.h>],
- [extern int opterr; opterr = 1;],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>],
+ [extern int opterr; opterr = 1;])],
[pgac_cv_var_int_opterr=yes],
[pgac_cv_var_int_opterr=no])])
if test x"$pgac_cv_var_int_opterr" = x"yes"; then
fi
AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
-[AC_TRY_LINK([#include <unistd.h>],
- [extern int optreset; optreset = 1;],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>],
+ [extern int optreset; optreset = 1;])],
[pgac_cv_var_int_optreset=yes],
[pgac_cv_var_int_optreset=no])])
if test x"$pgac_cv_var_int_optreset" = x"yes"; then
AC_CHECK_FUNCS([strtoll strtoq], [break])
AC_CHECK_FUNCS([strtoull strtouq], [break])
-AC_CACHE_CHECK([for builtin locking functions], pgac_cv_gcc_int_atomics,
-[AC_TRY_LINK([],
- [int lock = 0;
- __sync_lock_test_and_set(&lock, 1);
- __sync_lock_release(&lock);],
- [pgac_cv_gcc_int_atomics="yes"],
- [pgac_cv_gcc_int_atomics="no"])])
-if test x"$pgac_cv_gcc_int_atomics" = x"yes"; then
- AC_DEFINE(HAVE_GCC_INT_ATOMICS, 1, [Define to 1 if you have __sync_lock_test_and_set(int *) and friends.])
-fi
-
-
-#
-# Pthreads
-#
-# For each platform, we need to know about any special compile and link
-# libraries, and whether the normal C function names are thread-safe.
-# See the comment at the top of src/port/thread.c for more information.
-# WIN32 doesn't need the pthread tests; it always uses threads
-if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then
-ACX_PTHREAD # set thread flags
-
-# Some platforms use these, so just define them. They can't hurt if they
-# are not supported. For example, on Solaris -D_POSIX_PTHREAD_SEMANTICS
-# enables 5-arg getpwuid_r, among other things.
-PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
-
-
-# At this point, we don't want to muck with the compiler name for threading.
-# Let's see who fails, perhaps AIX. 2004-04-23
-if test "$PTHREAD_CC" != "$CC"; then
-AC_MSG_ERROR([
-PostgreSQL does not support platforms that require a special compiler
-for thread safety; use --disable-thread-safety to disable thread safety.])
-fi
-
-# Check for *_r functions
-_CFLAGS="$CFLAGS"
-_LIBS="$LIBS"
-CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-LIBS="$LIBS $PTHREAD_LIBS"
-
-if test "$PORTNAME" != "win32"; then
-AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
-pthread.h not found; use --disable-thread-safety to disable thread safety])])
-fi
-
-AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
-
-# Do test here with the proper thread flags
-PGAC_FUNC_GETPWUID_R_5ARG
-PGAC_FUNC_STRERROR_R_INT
-
-CFLAGS="$_CFLAGS"
-LIBS="$_LIBS"
-
-else
-# do not use values from template file
-PTHREAD_CFLAGS=
-PTHREAD_LIBS=
-fi
-
-AC_SUBST(PTHREAD_CFLAGS)
-AC_SUBST(PTHREAD_LIBS)
-
-
-# We can test for libldap_r only after we know PTHREAD_LIBS
-if test "$with_ldap" = yes ; then
- _LIBS="$LIBS"
- if test "$PORTNAME" != "win32"; then
- AC_CHECK_LIB(ldap, ldap_bind, [],
- [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
- [$EXTRA_LDAP_LIBS])
- LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
- if test "$enable_thread_safety" = yes; then
- # on some platforms ldap_r fails to link without PTHREAD_LIBS
- AC_CHECK_LIB(ldap_r, ldap_simple_bind, [],
- [AC_MSG_ERROR([library 'ldap_r' is required for LDAP])],
- [$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
- LDAP_LIBS_FE="-lldap_r $EXTRA_LDAP_LIBS"
- else
- LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
- fi
- else
- AC_CHECK_LIB(wldap32, ldap_bind, [], [AC_MSG_ERROR([library 'wldap32' is required for LDAP])])
- LDAP_LIBS_FE="-lwldap32"
- LDAP_LIBS_BE="-lwldap32"
- fi
- LIBS="$_LIBS"
-fi
-AC_SUBST(LDAP_LIBS_FE)
-AC_SUBST(LDAP_LIBS_BE)
-
+# Lastly, restore full LIBS list and check for readline/libedit symbols
+LIBS="$LIBS_including_readline"
-# Older versions of libxml2 lack the xmlStructuredErrorContext variable
-# (which could be a macro referring to a function, if threading is enabled)
-if test "$with_libxml" = yes ; then
- AC_CACHE_CHECK([for xmlStructuredErrorContext], pgac_cv_libxml_structerrctx,
- [AC_TRY_LINK([#include <libxml/globals.h>
- void *globptr;],
- [globptr = xmlStructuredErrorContext],
- [pgac_cv_libxml_structerrctx=yes],
- [pgac_cv_libxml_structerrctx=no])])
- if test x"$pgac_cv_libxml_structerrctx" = x"yes"; then
- AC_DEFINE(HAVE_XMLSTRUCTUREDERRORCONTEXT,
- 1,
- [Define to 1 if your libxml has xmlStructuredErrorContext.])
- fi
+if test "$with_readline" = yes; then
+ PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
+ AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function])
+ AC_CHECK_FUNCS([append_history history_truncate_file])
fi
# This check should come after all modifications of compiler or linker
# variables, and before any other run tests.
AC_MSG_CHECKING([test program])
-AC_TRY_RUN([int main() { return 0; }],
+AC_RUN_IFELSE([AC_LANG_SOURCE([int main() { return 0; }])],
[AC_MSG_RESULT(ok)],
[AC_MSG_RESULT(failed)
AC_MSG_ERROR([[
# Force use of our snprintf if system's doesn't do arg control
# See comment above at snprintf test for details.
if test "$enable_nls" = yes -a "$pgac_need_repl_snprintf" = no; then
- PGAC_FUNC_PRINTF_ARG_CONTROL
- if test $pgac_cv_printf_arg_control != yes ; then
+ PGAC_FUNC_SNPRINTF_ARG_CONTROL
+ if test $pgac_cv_snprintf_arg_control != yes ; then
pgac_need_repl_snprintf=yes
fi
fi
PGAC_TYPE_64BIT_INT([long int])
-if test x"$HAVE_LONG_INT_64" = x"no" ; then
+if test x"$HAVE_LONG_INT_64" = x"yes" ; then
+ pg_int64_type="long int"
+else
PGAC_TYPE_64BIT_INT([long long int])
- if test x"$HAVE_LONG_LONG_INT_64" = x"no" ; then
+ if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
+ pg_int64_type="long long int"
+ else
AC_MSG_ERROR([Cannot find a working 64-bit integer type.])
fi
fi
+AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
+ [Define to the name of a signed 64-bit integer type.])
dnl If we need to use "long long int", figure out whether nnnLL notation works.
if test x"$HAVE_LONG_LONG_INT_64" = xyes ; then
- AC_TRY_COMPILE([
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#define INT64CONST(x) x##LL
long long int foo = INT64CONST(0x1234567890123456);
-],
- [],
+])],
[AC_DEFINE(HAVE_LL_CONSTANTS, 1, [Define to 1 if constants of type 'long long int' should have the suffix LL.])],
[])
fi
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
if test $pgac_need_repl_snprintf = no; then
- PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
- if test "$LONG_LONG_INT_FORMAT" = ""; then
+ PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
+ if test "$LONG_LONG_INT_MODIFIER" = ""; then
# Force usage of our own snprintf, since system snprintf is broken
pgac_need_repl_snprintf=yes
- LONG_LONG_INT_FORMAT='%lld'
+ LONG_LONG_INT_MODIFIER='ll'
fi
else
# Here if we previously decided we needed to use our own snprintf
- LONG_LONG_INT_FORMAT='%lld'
+ LONG_LONG_INT_MODIFIER='ll'
fi
- LONG_LONG_UINT_FORMAT=`echo "$LONG_LONG_INT_FORMAT" | sed 's/d$/u/'`
- INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
- UINT64_FORMAT="\"$LONG_LONG_UINT_FORMAT\""
else
# Here if we are not using 'long long int' at all
- INT64_FORMAT='"%ld"'
- UINT64_FORMAT='"%lu"'
+ LONG_LONG_INT_MODIFIER='l'
fi
-AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT,
- [Define to the appropriate snprintf format for 64-bit ints.])
+INT64_MODIFIER="\"$LONG_LONG_INT_MODIFIER\""
+
+AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
+ [Define to the appropriate snprintf length modifier for 64-bit ints.])
-AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT,
- [Define to the appropriate snprintf format for unsigned 64-bit ints.])
+# Also force use of our snprintf if the system's doesn't support the %z flag.
+if test "$pgac_need_repl_snprintf" = no; then
+ PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
+ if test "$pgac_cv_snprintf_size_t_support" != yes; then
+ pgac_need_repl_snprintf=yes
+ fi
+fi
# Now we have checked all the reasons to replace snprintf
if test $pgac_need_repl_snprintf = yes; then
# Some platforms predefine the types int8, int16, etc. Only check
# a (hopefully) representative subset.
AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
-[#include <stdio.h>
-#ifdef HAVE_SUPPORTDEFS_H
-#include <SupportDefs.h>
-#endif])
-
-# We also check for sig_atomic_t, which *should* be defined per ANSI
-# C, but is missing on some old platforms.
-AC_CHECK_TYPES(sig_atomic_t, [], [], [#include <signal.h>])
-
-
-if test "$PORTNAME" != "win32"
-then
-PGAC_FUNC_POSIX_SIGNALS
-if test "$pgac_cv_func_posix_signals" != yes -a "$enable_thread_safety" = yes; then
- AC_MSG_ERROR([
-Thread-safety requires POSIX signals, which are not supported by this
-operating system; use --disable-thread-safety to disable thread safety.])
-fi
+[#include <stdio.h>])
+
+# Check for extensions offering the integer scalar type __int128.
+PGAC_TYPE_128BIT_INT
+
+# Check for various atomic operations now that we have checked how to declare
+# 64bit integers.
+PGAC_HAVE_GCC__SYNC_CHAR_TAS
+PGAC_HAVE_GCC__SYNC_INT32_TAS
+PGAC_HAVE_GCC__SYNC_INT32_CAS
+PGAC_HAVE_GCC__SYNC_INT64_CAS
+PGAC_HAVE_GCC__ATOMIC_INT32_CAS
+PGAC_HAVE_GCC__ATOMIC_INT64_CAS
+
+
+# Check for x86 cpuid instruction
+AC_CACHE_CHECK([for __get_cpuid], [pgac_cv__get_cpuid],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <cpuid.h>],
+ [[unsigned int exx[4] = {0, 0, 0, 0};
+ __get_cpuid(1, &exx[0], &exx[1], &exx[2], &exx[3]);
+ ]])],
+ [pgac_cv__get_cpuid="yes"],
+ [pgac_cv__get_cpuid="no"])])
+if test x"$pgac_cv__get_cpuid" = x"yes"; then
+ AC_DEFINE(HAVE__GET_CPUID, 1, [Define to 1 if you have __get_cpuid.])
+fi
+
+AC_CACHE_CHECK([for __cpuid], [pgac_cv__cpuid],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <intrin.h>],
+ [[unsigned int exx[4] = {0, 0, 0, 0};
+ __get_cpuid(exx[0], 1);
+ ]])],
+ [pgac_cv__cpuid="yes"],
+ [pgac_cv__cpuid="no"])])
+if test x"$pgac_cv__cpuid" = x"yes"; then
+ AC_DEFINE(HAVE__CPUID, 1, [Define to 1 if you have __cpuid.])
+fi
+
+# Check for Intel SSE 4.2 intrinsics to do CRC calculations.
+#
+# First check if the _mm_crc32_u8 and _mm_crc32_u64 intrinsics can be used
+# with the default compiler flags. If not, check if adding the -msse4.2
+# flag helps. CFLAGS_SSE42 is set to -msse4.2 if that's required.
+PGAC_SSE42_CRC32_INTRINSICS([])
+if test x"$pgac_sse42_crc32_intrinsics" != x"yes"; then
+ PGAC_SSE42_CRC32_INTRINSICS([-msse4.2])
+fi
+AC_SUBST(CFLAGS_SSE42)
+
+# Are we targeting a processor that supports SSE 4.2? gcc, clang and icc all
+# define __SSE4_2__ in that case.
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
+#ifndef __SSE4_2__
+#error __SSE4_2__ not defined
+#endif
+])], [SSE4_2_TARGETED=1])
+
+# Select CRC-32C implementation.
+#
+# If we are targeting a processor that has SSE 4.2 instructions, we can use the
+# special CRC instructions for calculating CRC-32C. If we're not targeting such
+# a processor, but we can nevertheless produce code that uses the SSE
+# intrinsics, perhaps with some extra CFLAGS, compile both implementations and
+# select which one to use at runtime, depending on whether SSE 4.2 is supported
+# by the processor we're running on.
+#
+# You can override this logic by setting the appropriate USE_*_CRC32 flag to 1
+# in the template or configure command line.
+if test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_SLICING_BY_8_CRC32C" = x""; then
+ if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && test x"$SSE4_2_TARGETED" = x"1" ; then
+ USE_SSE42_CRC32C=1
+ else
+ # the CPUID instruction is needed for the runtime check.
+ if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && (test x"$pgac_cv__get_cpuid" = x"yes" || test x"$pgac_cv__cpuid" = x"yes"); then
+ USE_SSE42_CRC32C_WITH_RUNTIME_CHECK=1
+ else
+ # fall back to slicing-by-8 algorithm which doesn't require any special
+ # CPU support.
+ USE_SLICING_BY_8_CRC32C=1
+ fi
+ fi
fi
-# SunOS doesn't handle negative byte comparisons properly with +/- return
-AC_FUNC_MEMCMP
+# Set PG_CRC32C_OBJS appropriately depending on the selected implementation.
+AC_MSG_CHECKING([which CRC-32C implementation to use])
+if test x"$USE_SSE42_CRC32C" = x"1"; then
+ AC_DEFINE(USE_SSE42_CRC32C, 1, [Define to 1 use Intel SSE 4.2 CRC instructions.])
+ PG_CRC32C_OBJS="pg_crc32c_sse42.o"
+ AC_MSG_RESULT(SSE 4.2)
+else
+ if test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"1"; then
+ AC_DEFINE(USE_SSE42_CRC32C_WITH_RUNTIME_CHECK, 1, [Define to 1 to use Intel SSSE 4.2 CRC instructions with a runtime check.])
+ PG_CRC32C_OBJS="pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_choose.o"
+ AC_MSG_RESULT(SSE 4.2 with runtime check)
+ else
+ AC_DEFINE(USE_SLICING_BY_8_CRC32C, 1, [Define to 1 to use Intel SSE 4.2 CRC instructions with a runtime check.])
+ PG_CRC32C_OBJS="pg_crc32c_sb8.o"
+ AC_MSG_RESULT(slicing-by-8)
+ fi
+fi
+AC_SUBST(PG_CRC32C_OBJS)
# Select semaphore implementation type.
if test "$with_tcl" = yes; then
PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH],
- [TCL_INCLUDE_SPEC,TCL_LIB_FILE,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
+ [TCL_INCLUDE_SPEC,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one
+ if test "$TCL_SHARED_BUILD" != 1; then
+ AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library
+Use --without-tcl to disable building PL/Tcl.])
+ fi
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
CPPFLAGS=$ac_save_CPPFLAGS
fi
+# check for <perl.h>
+if test "$with_perl" = yes; then
+ ac_save_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS -I$perl_archlibexp/CORE"
+ AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])],
+ [#include <EXTERN.h>])
+ # While we're at it, check that we can link to libperl.
+ # On most platforms, if perl.h is there then libperl.so will be too, but at
+ # this writing Debian packages them separately. There is no known reason to
+ # waste cycles on separate probes for the Tcl or Python libraries, though.
+ pgac_save_LIBS=$LIBS
+ LIBS="$perl_embed_ldflags"
+ AC_MSG_CHECKING([for libperl])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#include <EXTERN.h>
+#include <perl.h>
+], [perl_alloc();])],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ AC_MSG_ERROR([libperl library is required for Perl])])
+ LIBS=$pgac_save_LIBS
+ CPPFLAGS=$ac_save_CPPFLAGS
+fi
+
# check for <Python.h>
if test "$with_python" = yes; then
ac_save_CPPFLAGS=$CPPFLAGS
PGAC_CHECK_DOCBOOK(4.2)
PGAC_PATH_DOCBOOK_STYLESHEETS
PGAC_PATH_COLLATEINDEX
+AC_CHECK_PROGS(DBTOEPUB, dbtoepub)
+AC_CHECK_PROGS(XMLLINT, xmllint)
AC_CHECK_PROGS(XSLTPROC, xsltproc)
AC_CHECK_PROGS(OSX, [osx sgml2xml sx])
+#
+# Check for test tools
+#
+if test "$enable_tap_tests" = yes; then
+ AC_CHECK_PROGS(PROVE, prove)
+ if test -z "$PROVE"; then
+ AC_MSG_ERROR([prove not found])
+ fi
+ if test -z "$PERL"; then
+ AC_MSG_ERROR([Perl not found])
+ fi
+fi
+
# Thread testing
# We have to run the thread test near the end so we have all our symbols
_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
LIBS="$LIBS $PTHREAD_LIBS"
-AC_TRY_RUN([#include "$srcdir/src/test/thread/thread_test.c"],
+AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[#include "$srcdir/src/test/thread/thread_test.c"]])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([thread test program failed
fi
AC_DEFINE_UNQUOTED(PG_VERSION_STR,
- ["PostgreSQL $PACKAGE_VERSION on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"],
+ ["PostgreSQL $PG_VERSION on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"],
[A string containing the version number, platform, and C compiler])
# Supply a numeric version string for use by 3rd party add-ons
tr '.' ' ' |
$AWK '{printf "%d%02d%02d", $1, $2, (NF >= 3) ? $3 : 0}'`"]
AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])
+AC_SUBST(PG_VERSION_NUM)
# Begin output steps
echo >src/include/stamp-h
])
+AC_CONFIG_HEADERS([src/include/pg_config_ext.h],
+[
+# Update timestamp for pg_config_ext.h (see Makefile.global)
+echo >src/include/stamp-ext-h
+])
+
AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h],
[echo >src/interfaces/ecpg/include/stamp-h])