1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Header: /cvsroot/pgsql/configure.in,v 1.304 2003/11/24 14:52:57 petere Exp $
4 dnl Developers, please strive to achieve this order:
6 dnl 0. Initialization and options processing
12 dnl 6. Compiler characteristics
13 dnl 7. Functions, global variables
14 dnl 8. System services
16 dnl Read the Autoconf manual for details.
18 m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
20 AC_INIT([PostgreSQL], [7.5devel], [pgsql-bugs@postgresql.org])
23 AC_COPYRIGHT([Copyright 2003 PostgreSQL Global Development Group])
24 AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
25 AC_CONFIG_AUX_DIR(config)
26 AC_PREFIX_DEFAULT(/usr/local/pgsql)
27 AC_SUBST(configure_args, [$ac_configure_args])
29 AC_DEFINE_UNQUOTED(PG_VERSION, "$PACKAGE_VERSION", [PostgreSQL version])
34 AC_MSG_CHECKING([which template to use])
36 PGAC_ARG_REQ(with, template, [],
39 list) echo; ls "$srcdir/src/template"; exit;;
40 *) if test -f "$srcdir/src/template/$with_template" ; then
43 AC_MSG_ERROR(['$withval' is not a valid template name. Use 'list' for a list.])
48 # --with-template not given
52 beos*) template=beos ;;
53 bsdi*) template=bsdi ;;
54 cygwin*) template=cygwin ;;
55 darwin*) template=darwin ;;
56 dgux*) template=dgux ;;
57 freebsd*) template=freebsd ;;
58 hpux*) template=hpux ;;
59 irix*) template=irix5 ;;
60 linux*) template=linux ;;
61 mingw*) template=win32 ;;
62 netbsd*) template=netbsd ;;
63 nextstep*) template=nextstep ;;
64 openbsd*) template=openbsd ;;
66 qnx*) template=qnx4 ;;
68 solaris*) template=solaris ;;
69 sunos*) template=sunos4 ;;
72 univel) template=univel ;;
74 sysv4*) template=svr4 ;;
75 sysv5*) template=unixware ;;
76 ultrix*) template=ultrix4 ;;
79 if test x"$template" = x"" ; then
81 *******************************************************************
82 PostgreSQL has apparently not been ported to your platform yet.
83 To try a manual configuration, look into the src/template directory
84 for a similar platform and use the '--with-template=' option.
86 Please also contact <pgsql-ports@postgresql.org> to see about
87 rectifying this. Include the above 'checking host system type...'
89 *******************************************************************
95 AC_MSG_RESULT([$template])
100 # Pick right test-and-set (TAS) code. Most platforms have inline
101 # assembler code in src/include/storage/s_lock.h, so we just use
104 hppa*-*-hpux*) need_tas=yes; tas_file=hpux_hppa.s ;;
105 sparc-*-solaris*) need_tas=yes; tas_file=solaris_sparc.s ;;
106 i?86-*-solaris*) need_tas=yes; tas_file=solaris_i386.s ;;
107 *) need_tas=no; tas_file=dummy.s ;;
109 AC_CONFIG_LINKS([src/backend/port/tas.s:src/backend/port/tas/${tas_file}])
111 if test "$need_tas" = yes ; then
119 ## Command line options
123 # Installation directory for documentation
125 PGAC_ARG(with, docdir, [ --with-docdir=DIR install the documentation in DIR [[PREFIX/doc]]
126 --without-docdir do not install the documentation],
127 [AC_MSG_ERROR([option --with-docdir requires an argument])],
130 [docdir='${prefix}/doc'])
135 # Add non-standard directories to the include path
137 PGAC_ARG_REQ(with, includes, [ --with-includes=DIRS look for additional header files in DIRS])
141 # Add non-standard directories to the library search path
143 PGAC_ARG_REQ(with, libraries, [ --with-libraries=DIRS look for additional libraries in DIRS],
144 [LIBRARY_DIRS=$withval])
146 PGAC_ARG_REQ(with, libs, [ --with-libs=DIRS alternative spelling of --with-libraries],
147 [LIBRARY_DIRS=$withval])
151 # 64-bit integer date/time storage (--enable-integer-datetimes)
153 AC_MSG_CHECKING([whether to build with 64-bit integer date/time support])
154 PGAC_ARG_BOOL(enable, integer-datetimes, no, [ --enable-integer-datetimes enable 64-bit integer date/time support],
155 [AC_DEFINE([USE_INTEGER_DATETIMES], 1,
156 [Define to 1 if you want 64-bit integer timestamp and interval support. (--enable-integer-datetimes)])])
157 AC_MSG_RESULT([$enable_integer_datetimes])
163 AC_MSG_CHECKING([whether NLS is wanted])
164 PGAC_ARG_OPTARG(enable, nls,
165 [[ --enable-nls[=LANGUAGES] enable Native Language Support]],
167 [WANTED_LANGUAGES=$enableval],
168 [AC_DEFINE(ENABLE_NLS, 1,
169 [Define to 1 if you want National Language Support. (--enable-nls)])])
170 AC_MSG_RESULT([$enable_nls])
172 AC_SUBST(WANTED_LANGUAGES)
175 # Default port number (--with-pgport), default 5432
177 AC_MSG_CHECKING([for default port number])
178 PGAC_ARG_REQ(with, pgport, [ --with-pgport=PORTNUM change default port number [5432]],
179 [default_port=$withval],
181 AC_MSG_RESULT([$default_port])
182 # Need both of these because some places want an integer and some a string
183 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port},
184 [Define to the default TCP port number on which the server listens and
185 to which clients will try to connect. This can be overridden at run-time,
186 but it's convenient if your clients have the right default compiled in.
187 (--with-pgport=PORTNUM)])
188 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}",
189 [Define to the default TCP port number as a string constant.])
190 AC_SUBST(default_port)
193 # Option to disable shared libraries
195 PGAC_ARG_BOOL(enable, shared, yes,
196 [ --disable-shared do not build shared libraries])
197 AC_SUBST(enable_shared)
200 # '-rpath'-like feature can be disabled
202 PGAC_ARG_BOOL(enable, rpath, yes,
203 [ --disable-rpath do not embed shared library search path in executables])
204 AC_SUBST(enable_rpath)
209 PGAC_ARG_BOOL(enable, spinlocks, yes,
210 [ --disable-spinlocks do not use spinlocks])
213 # --enable-debug adds -g to compiler flags
215 PGAC_ARG_BOOL(enable, debug, no,
216 [ --enable-debug build with debugging symbols (-g)])
217 AC_SUBST(enable_debug)
223 # For historical reasons you can also use --with-CC to specify the C compiler
224 # to use, although the standard way to do this is to set the CC environment
226 PGAC_ARG_REQ(with, CC, [], [CC=$with_CC])
229 aix) pgac_cc_list="gcc xlc";;
230 irix) pgac_cc_list="cc";; # no gcc
231 *) pgac_cc_list="gcc cc";;
234 AC_PROG_CC([$pgac_cc_list])
241 . "$srcdir/src/template/$template" || exit
243 # CFLAGS are selected so:
244 # If the user specifies something in the environment, that is used.
245 # else: If the template file set something, that is used.
246 # else: If the compiler is GCC, then we use -O2.
247 # else: If the compiler is something else, then we use -0.
249 if test "$ac_env_CFLAGS_set" = set; then
250 CFLAGS=$ac_env_CFLAGS_value
251 elif test "${CFLAGS+set}" = set; then
252 : # (keep what template set)
253 elif test "$GCC" = yes; then
256 # if the user selected debug mode, don't use -O
257 if test "$enable_debug" != yes; then
262 # Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
263 PGAC_PROG_CC_NO_STRICT_ALIASING
265 # supply -g if --enable-debug
266 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
270 AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
272 # We already have this in Makefile.win32, but configure needs it too
273 if test "$PORTNAME" = "win32"; then
274 CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
277 # Check if the compiler still works with the template settings
278 AC_MSG_CHECKING([whether the C compiler still works])
279 AC_TRY_LINK([], [return 0;],
280 [AC_MSG_RESULT(yes)],
282 AC_MSG_ERROR([cannot proceed])])
284 # Defend against gcc -ffast-math
285 if test "$GCC" = yes; then
286 AC_TRY_COMPILE([], [@%:@ifdef __FAST_MATH__
288 @%:@endif], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
294 # Create compiler version string
295 if test x"$GCC" = x"yes" ; then
296 cc_string="GCC `${CC} --version | sed q`"
300 AC_DEFINE_UNQUOTED(PG_VERSION_STR,
301 ["PostgreSQL $PACKAGE_VERSION on $host, compiled by $cc_string"],
302 [A string containing the version number, platform, and C compiler])
306 # Automatic dependency tracking
308 PGAC_ARG_BOOL(enable, depend, no, [ --enable-depend turn on automatic dependency tracking],
314 # Enable assert checks
316 PGAC_ARG_BOOL(enable, cassert, no, [ --enable-cassert enable assertion checks (for debugging)],
317 [AC_DEFINE([USE_ASSERT_CHECKING], 1,
318 [Define to 1 to build with assertion checks. (--enable-cassert)])])
322 # Include directories
326 # SRCH_INC comes from the template file
327 for dir in $with_includes $SRCH_INC; do
328 if test -d "$dir"; then
329 INCLUDES="$INCLUDES -I$dir"
331 AC_MSG_WARN([*** Include directory $dir does not exist.])
339 # Library directories
343 # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
344 for dir in $LIBRARY_DIRS $SRCH_LIB; do
345 if test -d "$dir"; then
346 LIBDIRS="$LIBDIRS -L$dir"
348 AC_MSG_WARN([*** Library directory $dir does not exist.])
354 # Enable thread-safe client libraries
356 AC_MSG_CHECKING([allow thread-safe client libraries])
357 PGAC_ARG_BOOL(enable, thread-safety, no, [ --enable-thread-safety make client libraries thread-safe],
358 [AC_DEFINE([ENABLE_THREAD_SAFETY], 1,
359 [Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])])
360 AC_MSG_RESULT([$enable_thread_safety])
361 AC_SUBST(enable_thread_safety)
366 AC_MSG_CHECKING([whether to build with Tcl])
367 PGAC_ARG_BOOL(with, tcl, no, [ --with-tcl build Tcl and Tk interfaces])
368 AC_MSG_RESULT([$with_tcl])
371 # If Tcl is enabled (above) then Tk is also, unless the user disables it using --without-tk
372 AC_MSG_CHECKING([whether to build with Tk])
373 if test "$with_tcl" = yes; then
374 PGAC_ARG_BOOL(with, tk, yes, [ --without-tk do not build Tk interfaces if Tcl is enabled])
378 AC_MSG_RESULT([$with_tk])
382 # We see if the path to the Tcl/Tk configuration scripts is specified.
383 # This will override the use of tclsh to find the paths to search.
385 PGAC_ARG_REQ(with, tclconfig, [ --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR])
387 # We see if the path to the Tk configuration scripts is specified.
388 # This will override the use of tclsh to find the paths to search.
390 PGAC_ARG_REQ(with, tkconfig, [ --with-tkconfig=DIR tkConfig.sh is in DIR])
393 # Optionally build Perl modules (PL/Perl)
395 AC_MSG_CHECKING([whether to build Perl modules])
396 PGAC_ARG_BOOL(with, perl, no, [ --with-perl build Perl modules (PL/Perl)])
397 AC_MSG_RESULT([$with_perl])
401 # Optionally build Python modules (PL/Python)
403 AC_MSG_CHECKING([whether to build Python modules])
404 PGAC_ARG_BOOL(with, python, no, [ --with-python build Python modules (PL/Python)])
405 AC_MSG_RESULT([$with_python])
406 AC_SUBST(with_python)
409 # Optionally build the Java/JDBC tools
411 AC_MSG_CHECKING([whether to build Java/JDBC tools])
412 PGAC_ARG_BOOL(with, java, no, [ --with-java build JDBC interface and Java tools],
415 if test -z "$ANT"; then
416 AC_MSG_ERROR([Ant is required to build Java components
417 If you have Ant already installed, see config.log for details on the failure.])
419 if "$ANT" -version | egrep -i 'ant version' | sed q | egrep -v ' 1\.[[5-9]]| [[2-9]]\.' >/dev/null ; then
420 AC_MSG_ERROR([Ant version >= 1.5 is required to build Java components])
425 dnl A note on the Kerberos and OpenSSL options:
427 dnl The user can give an argument to the option in order the specify
428 dnl the base path of the respective installation (what he specified
429 dnl perhaps as --prefix). If no argument is given ($withval is "yes")
430 dnl then we take the path where the package installs by default. This
431 dnl way the user doesn't have to use redundant --with-includes and
432 dnl --with-libraries options, but he can still use them if the layout
438 AC_MSG_CHECKING([whether to build with Kerberos 4 support])
439 PGAC_ARG_OPTARG(with, krb4, [[ --with-krb4[=DIR] build with Kerberos 4 support [/usr/athena]]],
440 [krb4_prefix=/usr/athena],
441 [krb4_prefix=$withval],
444 AC_DEFINE(KRB4, 1, [Define to build with Kerberos 4 support. (--with-krb4)])
446 if test -d "$krb4_prefix/include"; then
447 INCLUDES="$INCLUDES -I$krb4_prefix/include"
449 if test -d "$krb4_prefix/lib"; then
450 LIBDIRS="$LIBDIRS -L$krb4_prefix/lib"
453 krb_srvtab="/etc/srvtab"
463 AC_MSG_CHECKING([whether to build with Kerberos 5 support])
464 PGAC_ARG_OPTARG(with, krb5, [[ --with-krb5[=DIR] build with Kerberos 5 support [/usr/athena]]],
465 [krb5_prefix=/usr/athena],
466 [krb5_prefix=$withval],
469 AC_DEFINE(KRB5, 1, [Define to build with Kerberos 5 support. (--with-krb5)])
471 if test -d "$krb5_prefix/include"; then
472 INCLUDES="$INCLUDES -I$krb5_prefix/include"
474 if test -d "$krb5_prefix/lib"; then
475 LIBDIRS="$LIBDIRS -L$krb5_prefix/lib"
478 krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
485 # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
486 if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
487 AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
494 # Kerberos configuration parameters
496 PGAC_ARG_REQ(with, krb-srvnam,
497 [ --with-krb-srvnam=NAME name of the service principal in Kerberos [[postgres]]],
499 [with_krb_srvnam="postgres"])
500 AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
501 [Define to the name of the PostgreSQL service principal in Kerberos. (--with-krb-srvnam=NAME)])
507 AC_MSG_CHECKING([whether to build with PAM support])
508 PGAC_ARG_BOOL(with, pam, no,
509 [ --with-pam build with PAM support],
510 [AC_DEFINE([USE_PAM], 1, [Define to 1 to build with PAM support. (--with-pam)])])
511 AC_MSG_RESULT([$with_pam])
518 AC_MSG_CHECKING([whether to build with Rendezvous support])
519 PGAC_ARG_BOOL(with, rendezvous, no,
520 [ --with-rendezvous build with Rendezvous support],
521 [AC_DEFINE([USE_RENDEZVOUS], 1, [Define to 1 to build with Rendezvous support. (--with-rendezvous)])])
522 AC_MSG_RESULT([$with_rendezvous])
523 AC_SUBST(with_rendezvous)
529 PGAC_ARG_OPTARG(with, openssl,
530 [[ --with-openssl[=DIR] build with OpenSSL support [/usr/local/ssl]]],
531 [openssl_prefix=/usr/local/ssl],
532 [openssl_prefix=$withval],
534 AC_MSG_RESULT([building with OpenSSL support])
535 AC_DEFINE([USE_SSL], 1, [Define to build with (Open)SSL support. (--with-openssl)])
537 if test -d "${openssl_prefix}/include" ; then
538 INCLUDES="$INCLUDES -I${openssl_prefix}/include"
540 if test -d "${openssl_prefix}/lib" ; then
541 LIBDIRS="$LIBDIRS -L${openssl_prefix}/lib"
545 AC_SUBST(with_openssl)
551 PGAC_ARG_BOOL(with, readline, yes,
552 [ --without-readline do not use Readline])
557 PGAC_ARG_BOOL(with, zlib, yes,
558 [ --without-zlib do not use Zlib])
564 # Assume system is ELF if it predefines __ELF__ as 1,
565 # otherwise believe host_os based default.
567 freebsd1*|freebsd2*) elf=no;;
568 freebsd3*|freebsd4*) elf=yes;;
577 [if test "X$elf" = "Xyes" ; then
588 CPPFLAGS="$CPPFLAGS $INCLUDES"
589 LDFLAGS="$LDFLAGS $LIBDIRS"
591 AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
592 AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
600 AC_SUBST(with_gnu_ld)
601 case $host_os in sysv5*)
602 AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R],
604 pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,-R/usr/lib"
605 AC_TRY_LINK([], [], [pgac_cv_prog_ld_R=yes], [pgac_cv_prog_ld_R=no])
606 LDFLAGS=$pgac_save_LDFLAGS
608 ld_R_works=$pgac_cv_prog_ld_R
612 AC_CHECK_PROGS(LORDER, lorder)
613 AC_PATH_PROG(TAR, tar)
616 AC_CHECK_PROGS(YACC, ['bison -y'])
618 if test "$YACC"; then
619 if $YACC --version | sed q | $AWK '{ if ($4 < 1.875) exit 0; else exit 1;}'; then
621 *** The installed version of Bison is too old. PostgreSQL needs
622 *** Bison version 1.875 or later.])
626 if test -z "$YACC"; then
628 *** Without Bison you will not be able to build PostgreSQL from CVS or
629 *** change any of the parser definition files. You can obtain Bison from
630 *** a GNU mirror site. (If you are using the official distribution of
631 *** PostgreSQL then you do not need to worry about this because the Bison
632 *** output is pre-generated.) To use a different yacc program (possible,
633 *** but not recommended), set the environment variable YACC before running
639 if test "$with_perl" = yes; then
640 PGAC_CHECK_PERL_CONFIGS([archlibexp,privlibexp,useshrplib])
641 PGAC_CHECK_PERL_EMBED_LDFLAGS
644 if test "$with_python" = yes; then
646 PGAC_CHECK_PYTHON_EMBED_SETUP
654 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
656 AC_CHECK_LIB(bsd, main)
658 AC_CHECK_LIB(util, setproctitle)
659 AC_CHECK_LIB(m, main)
660 AC_CHECK_LIB(dl, main)
661 AC_CHECK_LIB(nsl, main)
662 AC_CHECK_LIB(socket, main)
663 AC_CHECK_LIB(ipc, main)
664 AC_CHECK_LIB(IPC, main)
665 AC_CHECK_LIB(lc, main)
666 AC_CHECK_LIB(dld, main)
667 AC_CHECK_LIB(ld, main)
668 AC_CHECK_LIB(compat, main)
669 AC_CHECK_LIB(BSD, main)
670 AC_CHECK_LIB(gen, main)
671 AC_CHECK_LIB(PW, main)
672 AC_CHECK_LIB(resolv, main)
673 AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
675 AC_CHECK_LIB(unix, main)
676 AC_SEARCH_LIBS(crypt, crypt)
678 if test "$PORTNAME" = "beos"
680 AC_CHECK_LIB(bind, __inet_ntoa)
683 AC_SEARCH_LIBS(fdatasync, [rt posix4])
685 AC_CHECK_LIB(cygipc, shmget)
687 if test "$PORTNAME" = "win32"
689 AC_CHECK_LIB(wsock32, main)
692 if test "$with_readline" = yes; then
694 if test x"$pgac_cv_check_readline" = x"no"; then
695 AC_MSG_ERROR([readline library not found
696 If you have readline already installed, see config.log for details on the
697 failure. It is possible the compiler isn't looking in the proper directory.
698 Use --without-readline to disable readline support.])
702 if test "$with_zlib" = yes; then
703 AC_CHECK_LIB(z, inflate, [],
704 [AC_MSG_ERROR([zlib library not found
705 If you have zlib already installed, see config.log for details on the
706 failure. It is possible the compiler isn't looking in the proper directory.
707 Use --without-zlib to disable zlib support.])])
710 if test "$enable_spinlocks" = yes; then
711 AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
714 *** Not using spinlocks will cause poor performance.])
717 if test "$with_krb4" = yes ; then
718 AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])])
719 AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])])
720 AC_REPLACE_FUNCS([gethostname])
723 if test "$with_krb5" = yes ; then
724 AC_SEARCH_LIBS(com_err, [krb5 'krb5 -ldes -lasn1 -lroken' com_err], [],
725 [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
726 AC_SEARCH_LIBS(krb5_encrypt, [krb5 'krb5 -ldes -lasn1 -lroken' crypto k5crypto], [],
727 [AC_MSG_ERROR([could not find function 'krb5_encrypt' required for Kerberos 5])])
728 AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -ldes -lasn1 -lroken'], [],
729 [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
732 if test "$with_openssl" = yes ; then
734 AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
735 AC_CHECK_LIB(ssl, SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
738 if test "$with_pam" = yes ; then
739 AC_CHECK_LIB(pam, pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])])
747 dnl sys/socket.h is required by AC_FUNC_ACCEPT_ARGTYPES
748 AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h poll.h pwd.h sys/ipc.h sys/poll.h sys/pstat.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/un.h termios.h utime.h kernel/OS.h kernel/image.h SupportDefs.h])
750 # At least on IRIX, cpp test for netinet/tcp.h will fail unless
751 # netinet/in.h is included first.
752 AC_CHECK_HEADERS(netinet/in.h)
753 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
755 #ifdef HAVE_NETINET_IN_H
756 #include <netinet/in.h>
760 if test "$with_readline" = yes; then
761 AC_CHECK_HEADERS(readline/readline.h, [],
762 [AC_CHECK_HEADERS(editline/readline.h, [],
763 [AC_CHECK_HEADERS(readline.h, [],
764 [AC_MSG_ERROR([readline header not found
765 If you have readline already installed, see config.log for details on the
766 failure. It is possible the compiler isn't looking in the proper directory.
767 Use --without-readline to disable readline support.])])])])
768 AC_CHECK_HEADERS(readline/history.h, [],
769 [AC_CHECK_HEADERS(editline/history.h, [],
770 [AC_CHECK_HEADERS(history.h, [],
771 [AC_MSG_ERROR([history header not found
772 If you have readline already installed, see config.log for details on the
773 failure. It is possible the compiler isn't looking in the proper directory.
774 Use --without-readline to disable readline support.])])])])
777 if test "$with_zlib" = yes; then
778 AC_CHECK_HEADER(zlib.h, [], [AC_MSG_ERROR([zlib header not found
779 If you have zlib already installed, see config.log for details on the
780 failure. It is possible the compiler isn't looking in the proper directory.
781 Use --without-zlib to disable zlib support.])])
784 if test "$with_krb4" = yes ; then
785 AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
788 if test "$with_krb5" = yes ; then
789 AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
790 AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
793 if test "$with_openssl" = yes ; then
794 AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
795 AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
798 if test "$with_pam" = yes ; then
799 AC_CHECK_HEADERS(security/pam_appl.h, [],
800 [AC_CHECK_HEADERS(pam/pam_appl.h, [],
801 [AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required for PAM.])])])
804 if test "$with_rendezvous" = yes ; then
805 AC_CHECK_HEADER(DNSServiceDiscovery/DNSServiceDiscovery.h, [], [AC_MSG_ERROR([header file <DNSServiceDiscovery/DNSServiceDiscovery.h> is required for Rendezvous])])
810 ## Types, structures, compiler characteristics
813 m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
819 PGAC_C_FUNCNAME_SUPPORT
822 PGAC_STRUCT_SOCKADDR_UN
823 PGAC_STRUCT_SOCKADDR_STORAGE
824 PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
827 AC_CHECK_TYPES([struct cmsgcred, struct fcred, struct sockcred], [], [],
828 [#include <sys/param.h>
829 #include <sys/types.h>
830 #include <sys/socket.h>
831 #include <sys/ucred.h>])
833 AC_CHECK_TYPES([struct option], [], [],
834 [#ifdef HAVE_GETOPT_H
838 if test "$with_zlib" = yes; then
839 # Check that <zlib.h> defines z_streamp (versions before about 1.0.4
840 # did not). While we could work around the lack of z_streamp, it
841 # seems unwise to encourage people to use such old zlib versions...
842 AC_CHECK_TYPE(z_streamp, [], [AC_MSG_ERROR([zlib version is too old
843 Use --without-zlib to disable zlib support.])],
847 if test "$with_krb5" = yes; then
848 # Check for differences between MIT and Heimdal (KTH) releases
849 AC_CHECK_MEMBERS(krb5_ticket.enc_part2, [],
850 [AC_CHECK_MEMBERS(krb5_ticket.client, [],
851 [AC_MSG_ERROR([could not determine how to get client name from Kerberos 5 ticket])],
852 [#include <krb5.h>])],
854 AC_CHECK_MEMBERS(krb5_error.text.data, [],
855 [AC_CHECK_MEMBERS(krb5_error.e_data, [],
856 [AC_MSG_ERROR([could not determine how to extract Kerberos 5 error messages])],
857 [#include <krb5.h>])],
863 ## Functions, global variables
866 PGAC_VAR_INT_TIMEZONE
867 AC_FUNC_ACCEPT_ARGTYPES
868 PGAC_FUNC_GETTIMEOFDAY_1ARG
870 # SunOS doesn't handle negative byte comparisons properly with +/- return
873 AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getpeereid memmove poll pstat setproctitle setsid sigprocmask symlink sysconf utime utimes waitpid])
875 AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
878 AC_CHECK_TYPE([struct sockaddr_in6],
879 [AC_CHECK_FUNC(inet_ntop,
880 [AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])
883 [$ac_includes_default
884 #include <netinet/in.h>])
887 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
889 [#include <machine/vmparam.h>
890 #include <sys/exec.h>
892 [PS_STRINGS->ps_nargvstr = 1;
893 PS_STRINGS->ps_argvstr = "foo";],
894 [pgac_cv_var_PS_STRINGS=yes],
895 [pgac_cv_var_PS_STRINGS=no])])
896 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
897 AC_DEFINE([HAVE_PS_STRINGS], [], [Define to 1 if the PS_STRINGS thing exists.])
901 # We use our snprintf.c emulation if either snprintf() or vsnprintf()
902 # is missing. Yes, there are machines that have only one. We may
903 # also decide to use snprintf.c if snprintf() is present but does not
904 # have working "long long int" support -- see below.
906 pgac_need_repl_snprintf=no
907 AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
908 AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
911 # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
912 # include/c.h will provide declarations. Note this is a separate test
913 # from whether the functions exist in the C library --- there are
914 # systems that have the functions but don't bother to declare them :-(
916 AC_CHECK_DECLS([snprintf, vsnprintf])
919 # do this one the hard way in case isinf() is a macro
920 AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
924 [double x = 0.0; int res = isinf(x);],
925 [ac_cv_func_isinf=yes],
926 [ac_cv_func_isinf=no])])
928 if test $ac_cv_func_isinf = yes ; then
929 AC_DEFINE(HAVE_ISINF, 1, [Define to 1 if you have isinf().])
932 # Look for a way to implement a substitute for isinf()
933 AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
936 AC_REPLACE_FUNCS([crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
938 # system's version of getaddrinfo(), if any, may be used only if we found
939 # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
940 if test x"$ac_cv_type_struct_addrinfo" = xyes ; then
941 AC_REPLACE_FUNCS([getaddrinfo])
943 AC_LIBOBJ(getaddrinfo)
946 # similarly, use system's getopt_long() only if system provides struct option.
947 if test x"$ac_cv_type_struct_option" = xyes ; then
948 AC_REPLACE_FUNCS([getopt_long])
950 AC_LIBOBJ(getopt_long)
953 # BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
954 # We override the previous test that said fseeko/ftello didn't exist
955 # OS tests are also done in include/c.h and port/fseeko.c
956 case $host_os in bsdi*|netbsd*)
957 ac_cv_func_fseeko=yes
960 # Solaris has a very slow qsort in certain cases, so we replace it.
961 case $host_os in solaris*)
965 # Win32 can't to rename or unlink on an open file
966 case $host_os in mingw*)
969 AC_LIBOBJ(gettimeofday) ;;
972 if test "$with_readline" = yes; then
973 PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
974 AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function])
975 AC_CHECK_FUNCS([replace_history_entry])
979 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
980 AC_MSG_CHECKING(for finite)
981 AC_TRY_LINK([#include <math.h>],
982 [int dummy=finite(1.0);],
983 [AC_DEFINE(HAVE_FINITE, 1, [Define to 1 if you have finite().])
987 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
988 dnl (especially on GNU libc)
989 dnl See also comments in c.h.
990 AC_MSG_CHECKING(for sigsetjmp)
991 AC_TRY_LINK([#include <setjmp.h>],
992 [sigjmp_buf x; sigsetjmp(x, 1);],
993 [AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have sigsetjmp().])
997 AC_CHECK_FUNC(syslog,
998 [AC_CHECK_HEADER(syslog.h,
999 [AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])
1001 AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
1002 [AC_TRY_LINK([#include <unistd.h>],
1003 [extern int optreset; optreset = 1;],
1004 [pgac_cv_var_int_optreset=yes],
1005 [pgac_cv_var_int_optreset=no])])
1006 if test x"$pgac_cv_var_int_optreset" = x"yes"; then
1007 AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
1010 AC_CHECK_FUNCS([strtoll strtoq], [break])
1011 AC_CHECK_FUNCS([strtoull strtouq], [break])
1013 # Check for one of atexit() or on_exit()
1014 AC_CHECK_FUNCS(atexit, [],
1015 [AC_CHECK_FUNCS(on_exit, [],
1016 [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
1023 # For each platform, we need to know about any special compile and link
1024 # libraries, and whether the normal C function names are thread-safe.
1025 # See the comment at the top of src/port/thread.c for more information.
1027 if test "$enable_thread_safety" = yes; then
1028 AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safetys])])
1030 if test "$THREAD_SUPPORT" != yes; then
1032 Cannot enable threads on your platform.
1033 Please report your platform threading info to the PostgreSQL mailing lists
1034 so it can be added to the next release. Report all compile flags, link flags,
1035 functions, or libraries required for threading support.
1036 See the comment at the top of src/port/thread.c for more information.
1040 # do not use values from template file
1044 AC_SUBST(THREAD_SUPPORT)
1045 AC_SUBST(THREAD_CPPFLAGS)
1046 AC_SUBST(THREAD_LIBS)
1050 # Check for re-entrant versions of certain functions
1052 # Include special flags if threads are enabled _and_ if required for
1053 # threading on this platform. Some platforms have *_r functions but
1054 # their natively named funcs are threadsafe, and should be used instead.
1056 # One trick here is that if we don't call AC_CHECK_FUNCS, the
1057 # functions are marked "not found", which is perfect.
1059 if test "$enable_thread_safety" = yes -a "$NEED_REENTRANT_FUNCS" = yes ; then
1062 CFLAGS="$CFLAGS $THREAD_CPPFLAGS"
1063 LIBS="$LIBS $THREAD_LIBS"
1064 AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
1070 # This test makes sure that run tests work at all. Sometimes a shared
1071 # library is found by the linker, but the runtime linker can't find it.
1072 # This check should come after all modifications of compiler or linker
1073 # variables, and before any other run tests.
1074 AC_MSG_CHECKING([test program])
1075 AC_TRY_RUN([int main() { return 0; }],
1076 [AC_MSG_RESULT(ok)],
1077 [AC_MSG_RESULT(failed)
1079 *** Could not execute a simple test program. This may be a problem
1080 *** related to locating shared libraries. Check the file 'config.log'
1081 *** for the exact reason.]])],
1082 [AC_MSG_RESULT([cross-compiling])])
1085 dnl Check to see if we have a working 64-bit integer type.
1086 dnl This breaks down into two steps:
1087 dnl (1) figure out if the compiler has a 64-bit int type with working
1088 dnl arithmetic, and if so
1089 dnl (2) see whether snprintf() can format the type correctly. (Currently,
1090 dnl snprintf is the only library routine we really need for int8 support.)
1091 dnl It's entirely possible to have a compiler that handles a 64-bit type
1092 dnl when the C library doesn't; this is fairly likely when using gcc on
1093 dnl an older platform, for example.
1094 dnl If there is no native snprintf() or it does not handle the 64-bit type,
1095 dnl we force our own version of snprintf() to be used instead.
1096 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
1098 PGAC_TYPE_64BIT_INT([long int])
1100 if test x"$HAVE_LONG_INT_64" = x"no" ; then
1101 PGAC_TYPE_64BIT_INT([long long int])
1105 dnl If we need to use "long long int", figure out whether nnnLL notation works.
1107 if test x"$HAVE_LONG_LONG_INT_64" = xyes ; then
1109 #define INT64CONST(x) x##LL
1110 long long int foo = INT64CONST(0x1234567890123456);
1113 [AC_DEFINE(HAVE_LL_CONSTANTS, 1, [Define to 1 if constants of type 'long long int' should have the suffix LL.])],
1118 # If we found "long int" is 64 bits, assume snprintf handles it. If
1119 # we found we need to use "long long int", better check. We cope with
1120 # snprintfs that use either %lld, %qd, or %I64d as the format. If
1121 # neither works, fall back to our own snprintf emulation (which we
1124 if test "$HAVE_LONG_LONG_INT_64" = yes ; then
1125 if test $pgac_need_repl_snprintf = no; then
1126 PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
1127 if test "$LONG_LONG_INT_FORMAT" = ""; then
1128 # Force usage of our own snprintf, since system snprintf is broken
1129 pgac_need_repl_snprintf=yes
1130 LONG_LONG_INT_FORMAT='%lld'
1133 # Here if we previously decided we needed to use our own snprintf
1134 LONG_LONG_INT_FORMAT='%lld'
1136 INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
1138 # Here if we are not using 'long long int' at all
1139 INT64_FORMAT='"%ld"'
1142 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT,
1143 [Define to the appropriate snprintf format for 64-bit ints, if any.])
1145 if test $pgac_need_repl_snprintf = yes; then
1149 # Need a #define for the size of Datum (unsigned long)
1150 AC_CHECK_SIZEOF([unsigned long])
1152 # Determine memory alignment requirements for the basic C data types.
1154 PGAC_CHECK_ALIGNOF(short)
1155 PGAC_CHECK_ALIGNOF(int)
1156 PGAC_CHECK_ALIGNOF(long)
1157 if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
1158 PGAC_CHECK_ALIGNOF(long long int)
1160 PGAC_CHECK_ALIGNOF(double)
1162 # Compute maximum alignment of any basic type.
1163 # We assume long's alignment is at least as strong as char, short, or int;
1164 # but we must check long long (if it exists) and double.
1166 MAX_ALIGNOF=$pgac_cv_alignof_long
1167 if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1168 MAX_ALIGNOF=$pgac_cv_alignof_double
1170 if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1171 MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1173 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
1176 # Some platforms predefine the types int8, int16, etc. Only check
1177 # a (hopefully) representative subset.
1178 AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
1180 #ifdef HAVE_SUPPORTDEFS_H
1181 #include <SupportDefs.h>
1184 # We also check for sig_atomic_t, which *should* be defined per ANSI
1185 # C, but is missing on some old platforms.
1186 AC_CHECK_TYPES(sig_atomic_t, [], [], [#include <signal.h>])
1189 PGAC_FUNC_POSIX_SIGNALS
1190 if test $ac_cv_func_fseeko = yes; then
1195 # Select semaphore implementation type.
1196 if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
1197 AC_DEFINE(USE_NAMED_POSIX_SEMAPHORES, 1, [Define to select named POSIX semaphores.])
1198 SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
1200 if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
1201 AC_DEFINE(USE_UNNAMED_POSIX_SEMAPHORES, 1, [Define to select unnamed POSIX semaphores.])
1202 SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
1204 AC_DEFINE(USE_SYSV_SEMAPHORES, 1, [Define to select SysV-style semaphores.])
1205 SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
1210 # Select shared-memory implementation type.
1211 AC_DEFINE(USE_SYSV_SHARED_MEMORY, 1, [Define to select SysV-style shared memory.])
1212 SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
1215 if test "$enable_nls" = yes ; then
1219 # Check for Tcl configuration script tclConfig.sh
1220 if test "$with_tcl" = yes; then
1221 PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
1222 PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH],
1223 [TCL_INCLUDE_SPEC,TCL_LIB_FILE,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
1224 AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one
1227 # Check for Tk configuration script tkConfig.sh
1228 if test "$with_tk" = yes; then
1229 PGAC_PATH_TKCONFIGSH([$with_tkconfig $with_tclconfig])
1230 PGAC_EVAL_TCLCONFIGSH([$TK_CONFIG_SH], [TK_LIBS,TK_LIB_SPEC,TK_XINCLUDES])
1235 # Check for DocBook and tools
1239 PGAC_CHECK_DOCBOOK(3.1)
1240 PGAC_PATH_DOCBOOK_STYLESHEETS
1241 PGAC_PATH_COLLATEINDEX
1242 AC_CHECK_PROGS(SGMLSPL, sgmlspl)
1245 # prepare build tree if outside source tree
1246 # Note 1: test -ef might not exist, but it's more reliable than `pwd`.
1247 # Note 2: /bin/pwd might be better than shell's built-in at getting
1248 # a symlink-free name.
1249 if test "$no_create" != yes; then
1250 if ( test "$srcdir" -ef . ) >/dev/null 2>&1 || test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
1253 AC_SUBST(vpath_build, yes)
1254 _AS_ECHO_N([preparing build tree... ])
1255 pgac_abs_top_srcdir=`cd "$srcdir" && pwd`
1256 $SHELL "$ac_aux_dir/prep_buildtree" "$pgac_abs_top_srcdir" "." \
1257 || AC_MSG_ERROR(failed)
1263 AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
1266 src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c
1267 src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}
1268 src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}
1269 src/include/dynloader.h:src/backend/port/dynloader/${template}.h
1270 src/include/pg_config_os.h:src/include/port/${template}.h
1271 src/Makefile.port:src/makefiles/Makefile.${template}
1274 AC_CONFIG_HEADERS([src/include/pg_config.h],
1276 # Update timestamp for pg_config.h (see Makefile.global)
1277 echo >src/include/stamp-h