1 dnl Process this file with autoconf to produce a configure script.
3 dnl Developers, please strive to achieve this order:
5 dnl 0. Initialization and options processing
11 dnl 6. Compiler characteristics
12 dnl 7. Functions, global variables
13 dnl 8. System services
15 dnl Read the Autoconf manual for details.
17 dnl The GNU folks apparently haven't heard that some people don't use
18 dnl Texinfo. Use this sorcery to use "docdir" instead of "infodir".
20 define([infodir], [docdir])
21 AC_INIT(src/backend/access/common/heaptuple.c)
25 AC_PREFIX_DEFAULT(/usr/local/pgsql)
26 AC_CONFIG_HEADER(src/include/pg_config.h)
29 AC_CONFIG_AUX_DIR(config)
33 AC_DEFINE_UNQUOTED(PG_VERSION, "$VERSION")
43 AC_MSG_CHECKING([which template to use])
45 PGAC_ARG_REQ(with, template, [],
48 list) echo; ls "$srcdir/src/template"; exit;;
49 *) if test -f "$srcdir/src/template/$with_template" ; then
52 AC_MSG_ERROR(['$withval' is not a valid template name. Use 'list' for a list.])
57 # --with-template not given
61 beos*) template=beos ;;
62 bsdi*) template=bsdi ;;
63 cygwin*) template=win ;;
64 darwin*) template=darwin ;;
65 dgux*) template=dgux ;;
66 freebsd*) template=freebsd ;;
67 hpux*) template=hpux ;;
68 irix*) template=irix5 ;;
69 linux*) template=linux ;;
70 netbsd*) template=netbsd ;;
71 nextstep*) template=nextstep ;;
72 openbsd*) template=openbsd ;;
74 qnx*) template=qnx4 ;;
76 solaris*) template=solaris ;;
77 sunos*) template=sunos4 ;;
80 univel) template=univel ;;
82 sysv4*) template=svr4 ;;
83 sysv5*) template=unixware ;;
84 ultrix*) template=ultrix4 ;;
87 if test x"$template" = x"" ; then
89 *******************************************************************
90 PostgreSQL has apparently not been ported to your platform yet.
91 To try a manual configuration, look into the src/template directory
92 for a similar platform and use the '--with-template=' option.
94 Please also contact <pgsql-ports@postgresql.org> to see about
95 rectifying this. Include the above 'checking host system type...'
97 *******************************************************************
103 AC_MSG_RESULT([$template])
108 AC_LINK_FILES([src/backend/port/dynloader/${template}.c], [src/backend/port/dynloader.c])
109 AC_LINK_FILES([src/backend/port/dynloader/${template}.h], [src/include/dynloader.h])
110 AC_LINK_FILES([src/include/port/${template}.h], [src/include/pg_config_os.h])
111 AC_LINK_FILES([src/makefiles/Makefile.${template}], [src/Makefile.port])
113 # Pick right test-and-set (TAS) code. Most platforms have inline
114 # assembler code in src/include/storage/s_lock.h, so we just use
117 *-*-hpux*) need_tas=yes; tas_file=hpux.s ;;
118 sparc-*-solaris*) need_tas=yes; tas_file=solaris_sparc.s ;;
119 i?86-*-solaris*) need_tas=yes; tas_file=solaris_i386.s ;;
120 *) need_tas=no; tas_file=dummy.s ;;
122 AC_LINK_FILES([src/backend/port/tas/${tas_file}], [src/backend/port/tas.s])
124 if test "$need_tas" = yes ; then
132 ## Command line options
137 # Add non-standard directories to the include path
139 PGAC_ARG_REQ(with, includes, [ --with-includes=DIRS look for additional header files in DIRS])
143 # Add non-standard directories to the library search path
145 PGAC_ARG_REQ(with, libraries, [ --with-libraries=DIRS look for additional libraries in DIRS],
146 [LIBRARY_DIRS=$withval])
148 PGAC_ARG_REQ(with, libs, [ --with-libs=DIRS alternative spelling of --with-libraries],
149 [LIBRARY_DIRS=$withval])
153 # Locale (--enable-locale)
155 AC_MSG_CHECKING([whether to build with locale support])
156 PGAC_ARG_BOOL(enable, locale, no, [ --enable-locale enable locale support],
157 [AC_DEFINE([USE_LOCALE], 1,
158 [Set to 1 if you want LOCALE support (--enable-locale)])])
159 AC_MSG_RESULT([$enable_locale])
163 # Character set recode (--enable-recode)
165 AC_MSG_CHECKING([whether to build with recode support])
166 PGAC_ARG_BOOL(enable, recode, no, [ --enable-recode enable character set recode support],
167 [AC_DEFINE([CYR_RECODE], 1,
168 [Set to 1 if you want cyrillic recode support (--enable-recode)])])
169 AC_MSG_RESULT([$enable_recode])
176 AC_MSG_CHECKING([whether to build with multibyte character support])
178 PGAC_ARG_OPTARG(enable, multibyte, [ --enable-multibyte enable multibyte character support],
179 [MULTIBYTE=SQL_ASCII],
182 SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|JOHAB|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|LATIN6|LATIN7|LATIN8|LATIN9|LATIN10|WIN1256|TCVN|WIN874|KOI8|WIN|ALT|ISO_8859_5|ISO_8859_6|ISO_8859_7|ISO_8859_8)
183 MULTIBYTE=$enableval;;
186 [argument to --enable-multibyte must be one of:
187 SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW, JOHAB,
188 UNICODE, MULE_INTERNAL,
189 LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
190 LATIN6, LATIN7, LATIN8, LATIN9, LATIN10,
191 WIN1256, TCVN, WIN874, KOI8, WIN, ALT,
192 ISO_8859_5, ISO_8859_6, ISO_8859_7, ISO_8859_8
193 Or do not specify an argument to the option to use the default.]);;
197 AC_DEFINE(MULTIBYTE, 1, [Set to 1 if you want to use multibyte characters (--enable-multibyte)])
198 AC_MSG_RESULT([yes, default $MULTIBYTE])
207 AC_MSG_CHECKING([whether NLS is wanted])
208 PGAC_ARG_OPTARG(enable, nls,
209 [ --enable-nls[=LANGUAGES] enable Native Language Support],
211 [WANTED_LANGUAGES=$enableval],
212 [AC_DEFINE(ENABLE_NLS)])
213 AC_MSG_RESULT([$enable_nls])
215 AC_SUBST(WANTED_LANGUAGES)
218 # Default port number (--with-pgport), default 5432
220 AC_MSG_CHECKING([for default port number])
221 PGAC_ARG_REQ(with, pgport, [ --with-pgport=PORTNUM change default port number [5432]],
222 [default_port=$withval],
224 AC_MSG_RESULT([$default_port])
225 # Need both of these because some places want an integer and some a string
226 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
227 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
228 AC_SUBST(default_port)
231 # Maximum number of allowed connections (--with-maxbackends), default 32
233 AC_MSG_CHECKING([for default soft limit on number of connections])
234 PGAC_ARG_REQ(with, maxbackends, [ --with-maxbackends=N set default maximum number of connections [32]],
236 [with_maxbackends=32])
237 AC_MSG_RESULT([$with_maxbackends])
238 AC_DEFINE_UNQUOTED([DEF_MAXBACKENDS], [$with_maxbackends],
239 [The default soft limit on the number of concurrent connections, i.e., the default for the postmaster -N switch (--with-maxbackends)])
243 # Option to disable shared libraries
245 PGAC_ARG_BOOL(enable, shared, yes,
246 [ --disable-shared do not build shared libraries])
247 AC_SUBST(enable_shared)
250 # '-rpath'-like feature can be disabled
252 PGAC_ARG_BOOL(enable, rpath, yes,
253 [ --disable-rpath do not embed shared library search path in executables])
254 AC_SUBST(enable_rpath)
258 # --enable-debug adds -g to compiler flags
260 PGAC_ARG_BOOL(enable, debug, no,
261 [ --enable-debug build with debugging symbols (-g)])
262 AC_SUBST(enable_debug)
268 # For historical reasons you can also use --with-CC to specify the C compiler
269 # to use, although the standard way to do this is to set the CC environment
271 PGAC_ARG_REQ(with, CC, [], [CC=$with_CC])
273 # On AIX, default compiler to xlc.
274 if test "$template" = aix && test -z "$CC" ; then CC=xlc; fi
276 # Save CFLAGS from the environment
277 has_environ_CFLAGS="${CFLAGS+yes}"
282 . "$srcdir/src/template/$template" || exit
284 if test "$has_environ_CFLAGS" = yes; then
287 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
290 echo "using CFLAGS=$CFLAGS"
291 # Check if the compiler still works with the template settings
295 AC_PROG_GCC_TRADITIONAL
298 # Create compiler version string
299 if test x"$GCC" = x"yes" ; then
300 cc_string="GCC `${CC} --version | sed q`"
304 AC_DEFINE_UNQUOTED(PG_VERSION_STR, ["PostgreSQL $VERSION on $host, compiled by $cc_string"], [A canonical string containing the version number, platform, and C compiler])
308 # Automatic dependency tracking
310 PGAC_ARG_BOOL(enable, depend, no, [ --enable-depend turn on automatic dependency tracking],
316 # Enable assert checks
318 PGAC_ARG_BOOL(enable, cassert, no, [ --enable-cassert enable assertion checks (for debugging)],
319 [AC_DEFINE([USE_ASSERT_CHECKING], 1,
320 [Define to 1 to build with assertion checks])])
324 # Include directories
328 # SRCH_INC comes from the template file
329 for dir in $with_includes $SRCH_INC; do
330 if test -d "$dir"; then
331 INCLUDES="$INCLUDES -I$dir"
333 AC_MSG_WARN([*** Include directory $dir does not exist.])
341 # Library directories
345 # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
346 for dir in $LIBRARY_DIRS $SRCH_LIB; do
347 if test -d "$dir"; then
348 LIBDIRS="$LIBDIRS -L$dir"
350 AC_MSG_WARN([*** Library directory $dir does not exist.])
359 AC_MSG_CHECKING([whether to build with Tcl])
360 PGAC_ARG_BOOL(with, tcl, no, [ --with-tcl build Tcl and Tk interfaces])
361 AC_MSG_RESULT([$with_tcl])
364 # If Tcl is enabled (above) then Tk is also, unless the user disables it using --without-tk
365 AC_MSG_CHECKING([whether to build with Tk])
366 if test "$with_tcl" = yes; then
367 PGAC_ARG_BOOL(with, tk, yes, [ --without-tk do not build Tk interfaces if Tcl is enabled])
371 AC_MSG_RESULT([$with_tk])
375 # We see if the path to the TCL/TK configuration scripts is specified.
376 # This will override the use of tclsh to find the paths to search.
378 PGAC_ARG_REQ(with, tclconfig, [ --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR])
380 # We see if the path to the TK configuration scripts is specified.
381 # This will override the use of tclsh to find the paths to search.
383 PGAC_ARG_REQ(with, tkconfig, [ --with-tkconfig=DIR tkConfig.sh is in DIR])
386 # Optionally build Perl modules (Pg.pm and PL/Perl)
388 AC_MSG_CHECKING([whether to build Perl modules])
389 PGAC_ARG_BOOL(with, perl, no, [ --with-perl build Perl interface and PL/Perl])
390 AC_MSG_RESULT([$with_perl])
394 # Optionally build Python interface module
396 AC_MSG_CHECKING([whether to build Python modules])
397 PGAC_ARG_BOOL(with, python, no, [ --with-python build Python interface module])
398 AC_MSG_RESULT([$with_python])
399 AC_SUBST(with_python)
402 # Optionally build the Java/JDBC tools
404 AC_MSG_CHECKING([whether to build Java/JDBC tools])
405 PGAC_ARG_BOOL(with, java, no, [ --with-java build JDBC interface and Java tools],
408 if test -z "$ANT"; then
409 AC_MSG_ERROR([Ant is required to build Java components])
414 dnl A note on the Kerberos and OpenSSL options:
416 dnl The user can give an argument to the option in order the specify
417 dnl the base path of the respective installation (what he specified
418 dnl perhaps as --prefix). If no argument is given ($withval is "yes")
419 dnl then we take the path where the package installs by default. This
420 dnl way the user doesn't have to use redundant --with-includes and
421 dnl --with-libraries options, but he can still use them if the layout
427 PGAC_ARG_OPTARG(with, krb4, [ --with-krb4[=DIR] build with Kerberos 4 support [/usr/athena]],
428 [krb4_prefix=/usr/athena],
429 [krb4_prefix=$withval],
431 AC_MSG_RESULT([building with Kerberos 4 support])
432 AC_DEFINE(KRB4, 1, [Define if you are building with Kerberos 4 support.])
434 if test -d "$krb4_prefix/include"; then
435 INCLUDES="$INCLUDES -I$krb4_prefix/include"
437 if test -d "$krb4_prefix/lib"; then
438 LIBDIRS="$LIBDIRS -L$krb4_prefix/lib"
441 krb_srvtab="/etc/srvtab"
450 PGAC_ARG_OPTARG(with, krb5, [ --with-krb5[=DIR] build with Kerberos 5 support [/usr/athena]],
451 [krb5_prefix=/usr/athena],
452 [krb5_prefix=$withval],
454 AC_MSG_RESULT([building with Kerberos 5 support])
455 AC_DEFINE(KRB5, 1, [Define if you are building with Kerberos 5 support.])
457 if test -d "$krb5_prefix/include"; then
458 INCLUDES="$INCLUDES -I$krb5_prefix/include"
460 if test -d "$krb5_prefix/lib"; then
461 LIBDIRS="$LIBDIRS -L$krb5_prefix/lib"
464 krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
470 # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
471 if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
472 AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
479 # Kerberos configuration parameters
481 PGAC_ARG_REQ(with, krb-srvnam,
482 [ --with-krb-srvnam=NAME name of the service principal in Kerberos [postgres]],
484 [with_krb_srvnam="postgres"])
485 AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
486 [The name of the PostgreSQL service principal in Kerberos])
492 AC_MSG_CHECKING([whether to build with PAM support])
493 PGAC_ARG_BOOL(with, pam, no,
494 [ --with-pam build with PAM support],
495 [AC_DEFINE([USE_PAM], 1, [Define to build with PAM support])])
496 AC_MSG_RESULT([$with_pam])
503 PGAC_ARG_OPTARG(with, openssl,
504 [ --with-openssl[=DIR] build with OpenSSL support [/usr/local/ssl]],
505 [openssl_prefix=/usr/local/ssl],
506 [openssl_prefix=$withval],
508 AC_MSG_RESULT([building with OpenSSL support])
509 AC_DEFINE([USE_SSL], 1, [Define to build with (Open)SSL support])
511 if test -d "${openssl_prefix}/include" ; then
512 INCLUDES="$INCLUDES -I${openssl_prefix}/include"
514 if test -d "${openssl_prefix}/lib" ; then
515 LIBDIRS="$LIBDIRS -L${openssl_prefix}/lib"
519 AC_SUBST(with_openssl)
524 # Optionally enable the building of the ODBC driver
528 if test "${with_odbc+set}" = set && test "${enable_odbc+set}" != set; then
529 enable_odbc=$with_odbc
532 AC_MSG_CHECKING([whether to build the ODBC driver])
533 PGAC_ARG_BOOL(enable, odbc, no, [ --enable-odbc build the ODBC driver package])
534 PGAC_ARG_BOOL(with, unixodbc, no, [ --with-unixodbc build ODBC driver for unixODBC])
535 PGAC_ARG_BOOL(with, iodbc, no, [ --with-iodbc build ODBC driver for iODBC])
536 if test "$with_unixodbc" = yes && test "$with_iodbc" = yes; then
537 AC_MSG_ERROR([ODBC driver cannot be built for both unixODBC and iODBC])
539 if test "$with_unixodbc" = yes || test "$with_iodbc" = yes; then
542 case $enable_odbc:$with_unixodbc:$with_iodbc in
543 yes:no:no) AC_MSG_RESULT([yes (stand-alone)]);;
544 yes:yes:no) AC_MSG_RESULT([yes (unixODBC)]); AC_DEFINE(WITH_UNIXODBC);;
545 yes:no:yes) AC_MSG_RESULT([yes (iODBC)]); AC_DEFINE(WITH_IODBC);;
546 no:*) AC_MSG_RESULT(no);;
548 AC_SUBST([enable_odbc])
549 AC_SUBST([with_unixodbc])
550 AC_SUBST([with_iodbc])
553 # Allow for overriding the default location of the odbcinst.ini
554 # file which is normally ${sysconfdir} (i.e., ${prefix}/etc).
555 PGAC_ARG_REQ(with, odbcinst,
556 [ --with-odbcinst=DIR default directory for odbcinst.ini [sysconfdir]],
557 [odbcinst_ini_dir=$withval],
558 [odbcinst_ini_dir="\${sysconfdir}"])
559 AC_SUBST([odbcinst_ini_dir])
563 # Assume system is ELF if it predefines __ELF__ as 1,
564 # otherwise believe host_os based default.
566 freebsd1*|freebsd2*) elf=no;;
567 freebsd3*|freebsd4*) elf=yes;;
576 [if test "X$elf" = "Xyes" ; then
586 # Optionally build C++ code (i.e., libpq++)
588 AC_MSG_CHECKING([whether to build C++ modules])
589 PGAC_ARG_OPTARG(with, CXX, [ --with-CXX build C++ modules (libpq++)],
595 # If the user has specified CXXFLAGS in the environment, leave it
596 # alone, else use a default.
598 has_environ_CXXFLAGS="${CXXFLAGS+yes}"
600 if test "$has_environ_CXXFLAGS" != yes; then
601 if test "$GXX" = yes; then
605 osf) CXXFLAGS='-O4 -Olimit 2000' ;;
606 unixware) CXXFLAGS='-O' ;;
611 if test "$enable_debug" = yes && test "$ac_cv_prog_cxx_g" = yes; then
612 CXXFLAGS="$CXXFLAGS -g"
614 echo "using CXXFLAGS=$CXXFLAGS"
619 PGAC_CXX_NAMESPACE_STD
624 CPPFLAGS="$CPPFLAGS $INCLUDES"
625 LDFLAGS="$LDFLAGS $LIBDIRS"
627 echo "using CPPFLAGS=$CPPFLAGS"
628 echo "using LDFLAGS=$LDFLAGS"
636 AC_SUBST(with_gnu_ld)
637 case $host_os in sysv5*)
638 AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R],
640 pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,-R/usr/lib"
641 AC_TRY_LINK([], [], [pgac_cv_prog_ld_R=yes], [pgac_cv_prog_ld_R=no])
642 LDFLAGS=$pgac_save_LDFLAGS
644 ld_R_works=$pgac_cv_prog_ld_R
648 AC_CHECK_PROGS(LORDER, lorder)
649 AC_PATH_PROG(TAR, tar)
651 AC_CHECK_PROGS(YACC, ['bison -y'])
652 if test -z "$YACC"; then
654 *** Without Bison you will not be able to build PostgreSQL from CVS or
655 *** change any of the parser definition files. You can obtain Bison from
656 *** a GNU mirror site. (If you are using the official distribution of
657 *** PostgreSQL then you do not need to worry about this because the Bison
658 *** output is pre-generated.) To use a different yacc program (possible,
659 *** but not recommended), set the environment variable YACC before running
664 if test "$with_tk" = yes; then
665 AC_PATH_PROG(WISH, wish)
666 test -z "$WISH" && AC_MSG_ERROR(['wish' is required for Tk support])
670 if test "$with_perl" = yes; then
674 if test "$with_python" = yes; then
676 PGAC_CHECK_PYTHON_MODULE_SETUP
677 PGAC_CHECK_PYTHON_EMBED_SETUP
686 AC_SEARCH_LIBS(using_history, history, [AC_DEFINE(HAVE_HISTORY_FUNCTIONS)])
688 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
690 AC_CHECK_LIB(bsd, main)
692 AC_CHECK_LIB(util, setproctitle)
693 AC_CHECK_LIB(m, main)
694 AC_CHECK_LIB(dl, main)
695 AC_CHECK_LIB(socket, main)
696 AC_CHECK_LIB(nsl, main)
697 AC_CHECK_LIB(ipc, main)
698 AC_CHECK_LIB(IPC, main)
699 AC_CHECK_LIB(lc, main)
700 AC_CHECK_LIB(dld, main)
701 AC_CHECK_LIB(ld, main)
702 AC_CHECK_LIB(compat, main)
703 AC_CHECK_LIB(BSD, main)
704 AC_CHECK_LIB(gen, main)
705 AC_CHECK_LIB(PW, main)
706 AC_CHECK_LIB(resolv, main)
708 AC_CHECK_LIB([[unix]], main)
709 AC_SEARCH_LIBS(crypt, crypt)
711 AC_CHECK_LIB(bind, __inet_ntoa)
712 # Only consider libz to be present if we find <zlib.h> as well;
713 # furthermore, check that <zlib.h> defines z_streamp (versions before
714 # about 1.0.4 did not). While we could work around the lack of z_streamp,
715 # it seems unwise to encourage people to use such old zlib versions...
716 AC_EGREP_HEADER(z_streamp, zlib.h, [
717 AC_CHECK_LIB(z, inflate)
720 AC_SEARCH_LIBS(fdatasync, [rt posix4])
722 if test "$with_krb4" = yes ; then
723 AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])])
724 AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])])
727 if test "$with_krb5" = yes ; then
728 AC_SEARCH_LIBS(com_err, [krb5 'krb5 -ldes -lasn1 -lroken' com_err], [],
729 [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
730 AC_SEARCH_LIBS(krb5_encrypt, [krb5 'krb5 -ldes -lasn1 -lroken' crypto k5crypto], [],
731 [AC_MSG_ERROR([could not find function 'krb5_encrypt' required for Kerberos 5])])
732 AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -ldes -lasn1 -lroken'], [],
733 [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
736 if test "$with_openssl" = yes ; then
738 AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
739 AC_CHECK_LIB(ssl, [SSL_library_init], [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
742 if test "$with_pam" = yes ; then
743 AC_CHECK_LIB(pam, [pam_start], [], [AC_MSG_ERROR([library 'pam' is required for PAM])])
746 if test "$enable_nls" = yes ; then
753 dnl sys/socket.h and sys/types.h are required by AC_FUNC_ACCEPT_ARGTYPES
754 AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h pwd.h sys/ipc.h sys/pstat.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/types.h sys/un.h termios.h kernel/OS.h kernel/image.h SupportDefs.h])
756 dnl At least on IRIX, cpp test for netinet/tcp.h will fail unless netinet/in.h
757 dnl is included first. So can't just use AC_CHECK_HEADERS; do it this way:
758 AC_CHECK_HEADERS([netinet/in.h])
759 AC_MSG_CHECKING([for netinet/tcp.h])
761 #ifdef HAVE_NETINET_IN_H
762 #include <netinet/in.h>
764 #include <netinet/tcp.h>
765 ], [AC_DEFINE(HAVE_NETINET_TCP_H) AC_MSG_RESULT(yes)],
770 AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
771 AC_CHECK_HEADERS([readline/history.h history.h], [break])
773 if test "$with_krb4" = yes ; then
774 AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
777 if test "$with_krb5" = yes ; then
778 AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
779 AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
782 if test "$with_openssl" = yes ; then
783 AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
784 AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
787 if test "$with_pam" = yes ; then
788 AC_CHECK_HEADER([security/pam_appl.h], [], [AC_MSG_ERROR([header file <security/pam_appl.h> is required for PAM])])
793 ## Types, structures, compiler characteristics
805 PGAC_STRUCT_SOCKADDR_UN
807 if test "$with_krb5" = yes; then
808 # Check for differences between MIT and Heimdal (KTH) releases
809 PGAC_CHECK_MEMBER([krb5_ticket.enc_part2], [],
810 [PGAC_CHECK_MEMBER([krb5_ticket.client], [],
811 [AC_MSG_ERROR([could not determine how to get client name from Kerberos 5 ticket])],
812 [#include <krb5.h>])],
814 PGAC_CHECK_MEMBER([krb5_error.text.data], [],
815 [PGAC_CHECK_MEMBER([krb5_error.e_data], [],
816 [AC_MSG_ERROR([could not determine how to extract Kerberos 5 error messages])],
817 [#include <krb5.h>])],
823 ## Functions, global variables
825 PGAC_VAR_INT_TIMEZONE
826 AC_FUNC_ACCEPT_ARGTYPES
827 PGAC_FUNC_GETTIMEOFDAY_1ARG
829 # SunOS doesn't handle negative byte comparisons properly with +/- return
832 AC_CHECK_FUNCS([fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync])
834 dnl Check whether <unistd.h> declares fdatasync().
835 AC_EGREP_HEADER(fdatasync, unistd.h, AC_DEFINE(HAVE_FDATASYNC_DECL))
837 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
839 [#include <machine/vmparam.h>
840 #include <sys/exec.h>
842 [PS_STRINGS->ps_nargvstr = 1;
843 PS_STRINGS->ps_argvstr = "foo";],
844 [pgac_cv_var_PS_STRINGS=yes],
845 [pgac_cv_var_PS_STRINGS=no])])
846 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
847 AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
850 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
851 dnl is missing. Yes, there are machines that have only one.
852 dnl We may also decide to use snprintf.c if snprintf() is present but does
853 dnl not have working "long long int" support -- see below.
855 AC_CHECK_FUNC(snprintf,
856 AC_DEFINE(HAVE_SNPRINTF),
857 SNPRINTF='snprintf.o')
858 AC_CHECK_FUNC(vsnprintf,
859 AC_DEFINE(HAVE_VSNPRINTF),
860 SNPRINTF='snprintf.o')
862 dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
863 dnl include/c.h will provide declarations. Note this is a separate test
864 dnl from whether the functions exist in the C library --- there are systems
865 dnl that have the functions but don't bother to declare them :-(
866 dnl Note: simple-minded pattern here will do wrong thing if stdio.h
867 dnl declares vsnprintf() but not snprintf(). Hopefully there are no
868 dnl systems that are *that* brain-damaged...
869 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
870 AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
872 # do this one the hard way in case isinf() is a macro
873 AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
877 [double x = 0.0; int res = isinf(x);],
878 [ac_cv_func_isinf=yes],
879 [ac_cv_func_isinf=no])])
881 if test $ac_cv_func_isinf = yes ; then
882 AC_DEFINE(HAVE_ISINF)
886 # Look for a way to implement a substitute for isinf()
887 AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
891 AC_CHECK_FUNC(getrusage,
892 AC_DEFINE(HAVE_GETRUSAGE),
893 GETRUSAGE='getrusage.o')
895 AC_CHECK_FUNC(srandom,
896 AC_DEFINE(HAVE_SRANDOM),
899 AC_CHECK_FUNC(gethostname,
900 AC_DEFINE(HAVE_GETHOSTNAME),
901 GETHOSTNAME='gethostname.o')
902 AC_SUBST(GETHOSTNAME)
903 AC_CHECK_FUNC(random,
904 AC_DEFINE(HAVE_RANDOM),
905 MISSING_RANDOM='random.o')
906 AC_SUBST(MISSING_RANDOM)
907 AC_CHECK_FUNC(inet_aton,
908 AC_DEFINE(HAVE_INET_ATON),
909 INET_ATON='inet_aton.o')
911 AC_CHECK_FUNC(strerror,
912 AC_DEFINE(HAVE_STRERROR),
913 STRERROR='strerror.o')
915 AC_CHECK_FUNC(strdup,
916 AC_DEFINE(HAVE_STRDUP),
917 STRDUP='../../utils/strdup.o')
919 AC_CHECK_FUNC(strtol,
920 AC_DEFINE(HAVE_STRTOL),
923 AC_CHECK_FUNC(strtoul,
924 AC_DEFINE(HAVE_STRTOUL),
927 AC_CHECK_FUNC(strcasecmp,
928 AC_DEFINE(HAVE_STRCASECMP),
929 STRCASECMP='strcasecmp.o')
932 AC_DEFINE(HAVE_CBRT),
933 AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
935 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
936 # this hackery with HPUXMATHLIB allows us to cope.
940 if [[ -r /lib/pa1.1/libm.a ]] ; then
941 HPUXMATHLIB="-L /lib/pa1.1 -lm"
944 AC_SUBST(HPUXMATHLIB)
947 AC_DEFINE(HAVE_RINT),
948 AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
951 # Readline versions < 2.1 don't have rl_completion_append_character
952 AC_MSG_CHECKING([for rl_completion_append_character])
953 AC_TRY_LINK([#include <stdio.h>
954 #ifdef HAVE_READLINE_READLINE_H
955 # include <readline/readline.h>
956 #elif defined(HAVE_READLINE_H)
957 # include <readline.h>
960 [rl_completion_append_character = 'x';],
962 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER)],
965 AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function])
968 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
969 AC_MSG_CHECKING(for finite)
970 AC_TRY_LINK([#include <math.h>],
971 [int dummy=finite(1.0);],
972 [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
975 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
976 dnl (especially on GNU libc)
977 dnl See also comments in pg_config.h.
978 AC_MSG_CHECKING(for sigsetjmp)
979 AC_TRY_LINK([#include <setjmp.h>],
980 [sigjmp_buf x; sigsetjmp(x, 1);],
981 [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
985 PGAC_ARG_BOOL(enable, syslog, no, [ --enable-syslog enable logging to syslog],
986 [AC_CHECK_FUNC(syslog,
987 [AC_DEFINE([ENABLE_SYSLOG], 1,
988 [Define to 1 if to enable the syslogging code])],
989 [AC_MSG_ERROR([no syslog interface found])])])
992 AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
993 [AC_TRY_LINK([#include <unistd.h>],
994 [extern int optreset; optreset = 1;],
995 [pgac_cv_var_int_optreset=yes],
996 [pgac_cv_var_int_optreset=no])])
997 if test x"$pgac_cv_var_int_optreset" = x"yes"; then
998 AC_DEFINE(HAVE_INT_OPTRESET, 1)
1002 # This test makes sure that run tests work at all. Sometimes a shared
1003 # library is found by the linker, but the runtime linker can't find it.
1004 # This check should come after all modifications of compiler or linker
1005 # variables, and before any other run tests.
1006 AC_MSG_CHECKING([test program])
1007 AC_TRY_RUN([int main() { return 0; }],
1008 [AC_MSG_RESULT(ok)],
1009 [AC_MSG_RESULT(failed)
1011 *** Could not execute a simple test program. This may be a problem
1012 *** related to locating shared libraries. Check the file 'config.log'
1013 *** for the exact reason.]])],
1014 [AC_MSG_RESULT([cross-compiling])])
1017 dnl Check to see if we have a working 64-bit integer type.
1018 dnl This breaks down into two steps:
1019 dnl (1) figure out if the compiler has a 64-bit int type with working
1020 dnl arithmetic, and if so
1021 dnl (2) see whether snprintf() can format the type correctly. (Currently,
1022 dnl snprintf is the only library routine we really need for int8 support.)
1023 dnl It's entirely possible to have a compiler that handles a 64-bit type
1024 dnl when the C library doesn't; this is fairly likely when using gcc on
1025 dnl an older platform, for example.
1026 dnl If there is no native snprintf() or it does not handle the 64-bit type,
1027 dnl we force our own version of snprintf() to be used instead.
1028 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
1030 PGAC_TYPE_64BIT_INT([long int])
1032 if test x"$HAVE_LONG_INT_64" = x"no" ; then
1033 PGAC_TYPE_64BIT_INT([long long int])
1037 dnl If we need to use "long long int", figure out whether nnnLL notation works.
1039 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1041 #define INT64CONST(x) x##LL
1042 long long int foo = INT64CONST(0x1234567890123456);
1045 [AC_DEFINE(HAVE_LL_CONSTANTS)],
1050 dnl If we found "long int" is 64 bits, assume snprintf handles it.
1051 dnl If we found we need to use "long long int", better check.
1052 dnl We cope with snprintfs that use either %lld or %qd as the format.
1053 dnl If neither works, fall back to our own snprintf emulation (which we
1054 dnl know uses %lld).
1056 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1057 if [[ x$SNPRINTF = x ]] ; then
1058 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
1059 AC_TRY_RUN([#include <stdio.h>
1060 typedef long long int int64;
1061 #define INT64_FORMAT "%lld"
1066 int does_int64_snprintf_work()
1071 if (sizeof(int64) != 8)
1072 return 0; /* doesn't look like the right size */
1075 snprintf(buf, 100, INT64_FORMAT, c);
1076 if (strcmp(buf, "800000140000005") != 0)
1077 return 0; /* either multiply or snprintf is busted */
1081 exit(! does_int64_snprintf_work());
1083 [ AC_MSG_RESULT(yes)
1084 INT64_FORMAT='"%lld"'
1087 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
1088 AC_TRY_RUN([#include <stdio.h>
1089 typedef long long int int64;
1090 #define INT64_FORMAT "%qd"
1095 int does_int64_snprintf_work()
1100 if (sizeof(int64) != 8)
1101 return 0; /* doesn't look like the right size */
1104 snprintf(buf, 100, INT64_FORMAT, c);
1105 if (strcmp(buf, "800000140000005") != 0)
1106 return 0; /* either multiply or snprintf is busted */
1110 exit(! does_int64_snprintf_work());
1112 [ AC_MSG_RESULT(yes)
1113 INT64_FORMAT='"%qd"'
1116 # Force usage of our own snprintf, since system snprintf is broken
1117 SNPRINTF='snprintf.o'
1118 INT64_FORMAT='"%lld"'
1120 [ AC_MSG_RESULT(assuming not on target machine)
1121 # Force usage of our own snprintf, since we cannot test foreign snprintf
1122 SNPRINTF='snprintf.o'
1123 INT64_FORMAT='"%lld"'
1125 [ AC_MSG_RESULT(assuming not on target machine)
1126 # Force usage of our own snprintf, since we cannot test foreign snprintf
1127 SNPRINTF='snprintf.o'
1128 INT64_FORMAT='"%lld"'
1131 # here if we previously decided we needed to use our own snprintf
1132 INT64_FORMAT='"%lld"'
1135 # Here if we are not using 'long long int' at all
1136 INT64_FORMAT='"%ld"'
1139 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
1142 AC_CHECK_FUNCS([strtoll strtoq], [break])
1143 AC_CHECK_FUNCS([strtoull strtouq], [break])
1145 dnl psql needs atexit() or on_exit()
1146 AC_CHECK_FUNC(atexit,
1147 [AC_DEFINE(HAVE_ATEXIT)],
1148 [AC_CHECK_FUNCS(on_exit,
1149 [AC_DEFINE(HAVE_ON_EXIT)],
1150 [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
1152 dnl Need a #define for the size of Datum (unsigned long)
1154 AC_CHECK_SIZEOF(unsigned long, 4)
1155 AC_DEFINE_UNQUOTED(SIZEOF_DATUM, $ac_cv_sizeof_unsigned_long)
1157 dnl Determine memory alignment requirements for the basic C datatypes.
1159 PGAC_CHECK_ALIGNOF(short)
1160 PGAC_CHECK_ALIGNOF(int)
1161 PGAC_CHECK_ALIGNOF(long)
1162 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1163 PGAC_CHECK_ALIGNOF(long long int)
1165 PGAC_CHECK_ALIGNOF(double)
1167 dnl Compute maximum alignment of any basic type.
1168 dnl We assume long's alignment is at least as strong as char, short, or int;
1169 dnl but we must check long long (if it exists) and double.
1171 if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
1172 MAX_ALIGNOF=$pgac_cv_alignof_long
1173 if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1174 MAX_ALIGNOF=$pgac_cv_alignof_double
1176 if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1177 MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1180 dnl cross-compiling: assume that double's alignment is worst case
1181 MAX_ALIGNOF="$pgac_cv_alignof_double"
1183 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1186 # Some platforms predefine the types int8, int16, etc. Only check
1187 # a (hopefully) representative subset. We also check for sig_atomic_t,
1188 # which *should* be defined per ANSI C, but is missing on some old platforms.
1190 pgac_type_includes="\
1193 #ifdef HAVE_SUPPORTDEFS_H
1194 #include <SupportDefs.h>
1197 PGAC_CHECK_TYPE(int8, [], [], [$pgac_type_includes])
1198 PGAC_CHECK_TYPE(uint8, [], [], [$pgac_type_includes])
1199 PGAC_CHECK_TYPE(int64, [], [], [$pgac_type_includes])
1200 PGAC_CHECK_TYPE(uint64, [], [], [$pgac_type_includes])
1201 PGAC_CHECK_TYPE(sig_atomic_t, [], [], [$pgac_type_includes])
1204 PGAC_FUNC_POSIX_SIGNALS
1207 # Check for Tcl configuration script tclConfig.sh
1208 if test "$with_tcl" = yes; then
1209 PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
1212 # Check for Tk configuration script tkConfig.sh
1213 if test "$with_tk" = yes; then
1214 PGAC_PATH_TKCONFIGSH([$with_tkconfig $with_tclconfig])
1219 # Check for DocBook and tools
1222 # If you don't have nsgmls you won't get very far, so save the cycles.
1223 if test -n "$NSGMLS"; then
1225 PGAC_CHECK_DOCBOOK([3.1])
1226 PGAC_PATH_DOCBOOK_STYLESHEETS
1227 AC_CHECK_PROGS(SGMLSPL, sgmlspl)
1231 AC_SUBST(abs_top_srcdir)
1233 # prepare build tree if outside source tree
1234 # Note 1: test -ef might not exist, but it's more reliable than `pwd`.
1235 # Note 2: /bin/pwd might be better than shell's built-in at getting
1236 # a symlink-free name.
1237 if ( test "$srcdir" -ef . ) >/dev/null 2>&1 || test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
1240 abs_top_srcdir=`cd $srcdir && pwd`
1241 echo $ac_n "preparing build tree... $ac_c" 1>&6
1242 /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "." \
1243 || AC_MSG_ERROR(failed)
1253 # Update timestamp for pg_config.h (see Makefile.global)
1254 test x"$CONFIG_HEADERS" != x"" && echo >src/include/stamp-h