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/config.h)
29 AC_CONFIG_AUX_DIR(config)
33 AC_DEFINE_UNQUOTED(PG_VERSION, "$VERSION")
41 AC_MSG_CHECKING([which template to use])
43 PGAC_ARG_REQ(with, template, [],
46 list) echo; ls "$srcdir/src/template"; exit;;
47 *) if test -f "$srcdir/src/template/$with_template" ; then
50 AC_MSG_ERROR([\`$withval' is not a valid template name. Use \`list' for a list.])
55 # --with-template not given
59 bsdi*) template=bsdi ;;
60 cygwin*) template=win ;;
61 dgux*) template=dgux ;;
62 freebsd*) template=freebsd ;;
63 hpux*) template=hpux ;;
64 irix*) template=irix5 ;;
65 linux*) template=linux ;;
66 netbsd*) template=netbsd ;;
67 nextstep*) template=nextstep ;;
68 openbsd*) template=openbsd ;;
70 qnx*) template=qnx4 ;;
74 sparc) template=solaris_sparc ;;
75 i?86) template=solaris_i386 ;;
77 sunos*) template=sunos4 ;;
80 univel) template=univel ;;
82 sysv4*) template=svr4 ;;
83 sysv5uw*) 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/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 their port include file, so we just use a dummy
119 hpux) need_tas=yes; tas_file=hpux.s ;;
120 solaris_sparc) need_tas=yes; tas_file=solaris_sparc.s ;;
121 solaris_i386) need_tas=yes; tas_file=solaris_i386.s ;;
124 if test "$need_tas" = yes ; then
125 AC_LINK_FILES([src/backend/port/tas/${tas_file}], [src/backend/port/tas.s])
133 ## Command line options
138 # Add non-standard directories to the include path
140 PGAC_ARG_REQ(with, includes, [ --with-includes=DIRS look for additional header files in DIRS])
144 # Add non-standard directories to the library search path
146 PGAC_ARG_REQ(with, libraries, [ --with-libraries=DIRS look for additional libraries in DIRS],
147 [LIBRARY_DIRS=$withval])
149 PGAC_ARG_REQ(with, libs, [ --with-libs=DIRS alternative spelling of --with-libraries],
150 [LIBRARY_DIRS=$withval])
154 # Locale (--enable-locale)
156 AC_MSG_CHECKING([whether to build with locale support])
157 PGAC_ARG_BOOL(enable, locale, no, [ --enable-locale enable locale support],
158 [AC_DEFINE([USE_LOCALE], 1,
159 [Set to 1 if you want LOCALE support (--enable-locale)])])
160 AC_MSG_RESULT([$enable_locale])
164 # Character set recode (--enable-recode)
166 AC_MSG_CHECKING([whether to build with recode support])
167 PGAC_ARG_BOOL(enable, recode, no, [ --enable-recode enable character set recode support],
168 [AC_DEFINE([CYR_RECODE], 1,
169 [Set to 1 if you want cyrillic recode support (--enable-recode)])])
170 AC_MSG_RESULT([$enable_recode])
177 AC_MSG_CHECKING([whether to build with multibyte character support])
179 PGAC_ARG_OPTARG(enable, multibyte, [ --enable-multibyte enable multibyte character support],
180 [MULTIBYTE=SQL_ASCII],
183 SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
184 MULTIBYTE=$enableval;;
187 [argument to --enable-multibyte must be one of:
188 SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW,
189 UNICODE, MULE_INTERNAL,
190 LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
192 Or do not specify an argument to the option to use the default.]);;
196 AC_DEFINE(MULTIBYTE, 1, [Set to 1 if you want to use multibyte characters (--enable-multibyte)])
197 AC_MSG_RESULT([yes, default $MULTIBYTE])
205 # Default port number (--with-pgport), default 5432
207 AC_MSG_CHECKING([for default port number])
208 PGAC_ARG_REQ(with, pgport, [ --with-pgport=PORTNUM change default port number [5432]],
209 [default_port=$withval],
211 # Need both of these because backend wants an integer and frontend a string
212 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
213 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
214 AC_MSG_RESULT([$default_port])
218 # Maximum number of allowed connections (--with-maxbackends), default 32
220 AC_MSG_CHECKING([for default soft limit on number of connections])
221 PGAC_ARG_REQ(with, maxbackends, [ --with-maxbackends=N set default maximum number of connections [32]],
223 [with_maxbackends=32])
224 AC_MSG_RESULT([$with_maxbackends])
225 AC_DEFINE_UNQUOTED([DEF_MAXBACKENDS], [$with_maxbackends],
226 [The default soft limit on the number of concurrent connections, i.e., the default for the postmaster -N switch (--with-maxbackends)])
233 # For historical reasons you can also use --with-CC to specify the C compiler
234 # to use, although the standard way to do this is to set the CC environment
236 PGAC_ARG_REQ(with, CC, [], [CC=$with_CC])
238 # On AIX, default compiler to xlc.
239 if test "$template" = aix && test -z "$CC" ; then CC=xlc; fi
243 . "$srcdir/src/template/$template" || exit
244 echo "using CFLAGS=$CFLAGS"
245 # Check if the compiler still works with the template settings
249 AC_PROG_GCC_TRADITIONAL
257 # Create compiler version string
258 if test x"$GCC" = x"yes" ; then
259 cc_string="GCC `${CC} --version`"
263 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])
267 # Automatic dependency tracking
269 PGAC_ARG_BOOL(enable, depend, no, [ --enable-depend turn on automatic dependency tracking],
275 # --enable-debug adds -g to compiler flags
277 PGAC_ARG_BOOL(enable, debug, no, [ --enable-debug build with debugging symbols (-g)],
278 [CFLAGS="$CFLAGS -g"])
282 # Enable assert checks
284 PGAC_ARG_BOOL(enable, cassert, no, [ --enable-cassert enable assertion checks (for debugging)],
285 [AC_DEFINE([USE_ASSERT_CHECKING], 1,
286 [Define to 1 to build with assertion checks])])
290 # Include directories
294 # SRCH_INC comes from the template file
295 for dir in $with_includes $SRCH_INC; do
296 if test -d "$dir"; then
297 INCLUDES="$INCLUDES -I$dir"
299 AC_MSG_WARN([*** Include directory $dir does not exist.])
307 # Library directories
311 # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
312 for dir in $LIBRARY_DIRS $SRCH_LIB; do
313 if test -d "$dir"; then
314 PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
316 AC_MSG_WARN([*** Library directory $dir does not exist.])
325 AC_MSG_CHECKING([whether to build with Tcl])
326 PGAC_ARG_BOOL(with, tcl, no, [ --with-tcl build Tcl and Tk interfaces])
327 AC_MSG_RESULT([$with_tcl])
330 # If Tcl is enabled (above) then Tk is also, unless the user disables it using --without-tk
331 AC_MSG_CHECKING([whether to build with Tk])
332 if test "$with_tcl" = yes; then
333 PGAC_ARG_BOOL(with, tk, yes, [ --without-tk do not build Tk interfaces if Tcl is enabled])
337 AC_MSG_RESULT([$with_tk])
341 # We see if the path to the TCL/TK configuration scripts is specified.
342 # This will override the use of tclsh to find the paths to search.
344 PGAC_ARG_REQ(with, tclconfig, [ --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR])
346 # We see if the path to the TK configuration scripts is specified.
347 # This will override the use of tclsh to find the paths to search.
349 PGAC_ARG_REQ(with, tkconfig, [ --with-tkconfig=DIR tkConfig.sh is in DIR])
353 # Optionally build Perl modules (Pg.pm and PL/Perl)
355 AC_MSG_CHECKING([whether to build Perl modules])
356 PGAC_ARG_BOOL(with, perl, no, [ --with-perl build Perl interface and PL/Perl])
357 AC_MSG_RESULT([$with_perl])
362 # Optionally build Python interface module
364 AC_MSG_CHECKING([whether to build Python modules])
365 PGAC_ARG_BOOL(with, python, no, [ --with-python build Python interface module],
368 PGAC_PATH_PYTHONDIR],
370 AC_SUBST(with_python)
373 dnl A note on the Kerberos and OpenSSL options:
375 dnl The user can give an argument to the option in order the specify
376 dnl the base path of the respective installation (what he specified
377 dnl perhaps as --prefix). If no argument is given ($withval is "yes")
378 dnl then we take the path where the package installs by default. This
379 dnl way the user doesn't have to use redundant --with-includes and
380 dnl --with-libraries options, but he can still use them if the layout
386 PGAC_ARG_OPTARG(with, krb4, [ --with-krb4[=DIR] build with Kerberos 4 support [/usr/athena]],
387 [krb4_prefix=/usr/athena],
388 [krb4_prefix=$withval],
390 AC_MSG_RESULT([building with Kerberos 4 support])
391 AC_DEFINE(KRB4, 1, [Define if you are building with Kerberos 4 support.])
393 if test -d "$krb4_prefix"; then
394 if test -d "$krb4_prefix/include"; then
395 INCLUDES="$INCLUDES -I$krb4_prefix/include"
397 if test -d "$krb4_prefix/lib"; then
398 krb_libdir="-L$krb4_prefix/lib"
399 LIBS="$krb_libdir $LIBS"
402 # Test for these libraries is below
403 KRB_LIBS="$krb_libdir -lkrb -ldes"
405 krb_srvtab="/etc/srvtab"
414 PGAC_ARG_OPTARG(with, krb5, [ --with-krb5[=DIR] build with Kerberos 5 support [/usr/athena]],
415 [krb5_prefix=/usr/athena],
416 [krb5_prefix=$withval],
418 AC_MSG_RESULT([building with Kerberos 5 support])
419 AC_DEFINE(KRB5, 1, [Define if you are building with Kerberos 5 support.])
421 if test -d "$krb5_prefix"; then
422 if test -d "$krb5_prefix/include"; then
423 INCLUDES="$INCLUDES -I$krb5_prefix/include"
425 if test -d "$krb5_prefix/lib"; then
426 krb_libdir="-L$krb5_prefix/lib"
427 LIBS="$krb_libdir $LIBS"
431 # Test for these libraries is below
432 KRB_LIBS="$krb_libdir -lkrb5 -lcrypto -lcom_err"
434 krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
440 # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
441 if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
442 AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
446 dnl Necessary for special libpq link
451 # Kerberos configuration parameters
453 PGAC_ARG_REQ(with, krb-srvnam,
454 [ --with-krb-srvnam=NAME name of the PostgreSQL service principal in Kerberos [postgres]],
456 [with_krb_srvnam="postgres"])
457 AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
458 [The name of the PostgreSQL service principal in Kerberos])
465 PGAC_ARG_OPTARG(with, openssl,
466 [ --with-openssl[=DIR] build with OpenSSL support [/usr/local/ssl]],
467 [openssl_prefix=/usr/local/ssl],
468 [openssl_prefix=$withval],
470 AC_MSG_RESULT([building with OpenSSL support])
471 AC_DEFINE([USE_SSL], 1, [Define to build with (Open)SSL support])
473 if test -d "${openssl_prefix}/include" ; then
474 INCLUDES="$INCLUDES -I${openssl_prefix}/include"
476 if test -d "${openssl_prefix}/lib" ; then
477 openssl_libdir="${openssl_prefix}/lib"
478 LIBS="$LIBS -L${openssl_prefix}/lib"
480 openssl_libdir="${openssl_prefix}"
481 LIBS="$LIBS -L${openssl_prefix}"
485 AC_SUBST(with_openssl)
488 # OpenSSL and Kerberos 5 both have a `crypto' library, so if you want to
489 # use both of them you'll have to figure it out yourself.
490 if test "$with_openssl" = yes && test "$with_krb5" = yes ; then
491 AC_MSG_ERROR([OpenSSL and Kerberos 5 support cannot be combined])
496 # Optionally enable the building of the ODBC driver
500 if test "${with_odbc+set}" = set && test "${enable_odbc+set}" != set; then
501 enable_odbc=$with_odbc
504 AC_MSG_CHECKING([whether to build the ODBC driver])
505 PGAC_ARG_BOOL(enable, odbc, no, [ --enable-odbc build the ODBC driver package])
506 AC_MSG_RESULT([$enable_odbc])
507 AC_SUBST([enable_odbc])
510 # Allow for overriding the default location of the odbcinst.ini
511 # file which is normally ${sysconfdir} (i.e., ${prefix}/etc).
512 PGAC_ARG_REQ(with, odbcinst,
513 [ --with-odbcinst=DIR default directory for odbcinst.ini [sysconfdir]],
514 [odbcinst_ini_dir=$withval],
515 [odbcinst_ini_dir="\${sysconfdir}"])
516 AC_SUBST([odbcinst_ini_dir])
520 # Assume system is ELF if it predefines __ELF__ as 1,
521 # otherwise believe host_os based default.
523 freebsd1*|freebsd2*) elf=yes;;
532 [if test "X$elf" = "Xyes" ; then
542 # Optionally build C++ code (i.e., libpq++)
544 AC_MSG_CHECKING([whether to build C++ modules])
545 PGAC_ARG_OPTARG(with, CXX, [ --with-CXX build C++ modules (libpq++)],
553 PGAC_CXX_NAMESPACE_STD
559 CPPFLAGS="$CPPFLAGS $INCLUDES"
560 LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
562 echo "using CPPFLAGS=$CPPFLAGS"
563 echo "using LDFLAGS=$LDFLAGS"
566 # Figure out how to invoke "install" and what install options to use.
569 # When Autoconf chooses install-sh as install program it tries to generate
570 # a relative path to it in each makefile where it subsitutes it. This clashes
571 # with our Makefile.global concept. This workaround helps.
573 *install-sh*) INSTALL='\${SHELL} \${top_srcdir}/config/install-sh -c';;
576 # Fix Autoconf's brain-dead defaults for script installs.
577 INSTALL_SCRIPT="\${INSTALL} -m 755"
579 # HPUX wants shared libs to be mode 555. Add your platform's special
580 # needs here if necessary.
582 hpux*) INSTL_SHLIB_OPTS="-m 555" ;;
583 *) INSTL_SHLIB_OPTS="-m 644" ;;
586 INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
587 AC_SUBST(INSTALL_SHLIB)
590 mkinstalldirs="\$(SHELL) \$(top_srcdir)/config/mkinstalldirs"
591 AC_SUBST(mkinstalldirs)
598 AC_PATH_PROG(tar, tar)
599 AC_CHECK_PROGS(PERL, perl,)
602 if test "$with_tk" = yes; then
603 AC_PATH_PROG(WISH, wish)
604 test -z "$WISH" && AC_MSG_ERROR([\`wish' is required for Tk support])
612 AC_CHECK_LIB(sfio, main)
613 AC_CHECK_LIB(ncurses, main, [], [AC_CHECK_LIB(curses, main)])
614 AC_CHECK_LIB(termcap, main)
615 AC_CHECK_LIB(readline, main)
616 AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
617 AC_CHECK_LIB(history, main) )
619 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
621 AC_CHECK_LIB(bsd, main)
623 AC_CHECK_LIB(util, setproctitle)
624 AC_CHECK_LIB(m, main)
625 AC_CHECK_LIB(dl, main)
626 AC_CHECK_LIB(socket, main)
627 AC_CHECK_LIB(nsl, main)
628 AC_CHECK_LIB(ipc, main)
629 AC_CHECK_LIB(IPC, main)
630 AC_CHECK_LIB(lc, main)
631 AC_CHECK_LIB(dld, main)
632 AC_CHECK_LIB(ln, main)
633 AC_CHECK_LIB(ld, main)
634 AC_CHECK_LIB(compat, main)
635 AC_CHECK_LIB(BSD, main)
636 AC_CHECK_LIB(gen, main)
637 AC_CHECK_LIB(PW, main)
638 AC_SEARCH_LIBS(crypt, crypt)
639 AC_CHECK_LIB(z, inflate)
641 if test "$with_krb4" = yes ; then
642 AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library \`des' is required for Kerberos 4])])
643 AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library \`krb' is required for Kerberos 4])])
646 if test "$with_krb5" = yes ; then
647 AC_CHECK_LIB(com_err, main, [], [AC_MSG_ERROR([library \`com_err' is required for Kerberos 5])])
648 AC_CHECK_LIB(crypto, main, [], [AC_MSG_ERROR([library \`crypto' is required for Kerberos 5])])
649 AC_CHECK_LIB(krb5, main, [], [AC_MSG_ERROR([library \`krb5' is required for Kerberos 5])])
652 if test "$with_openssl" = yes ; then
654 AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
655 AC_CHECK_LIB(ssl, [SSL_library_init], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
662 dnl sys/socket.h and sys/types.h are required by AC_FUNC_ACCEPT_ARGTYPES
663 AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h netinet/tcp.h pwd.h sys/pstat.h sys/select.h sys/socket.h sys/types.h sys/un.h termios.h])
665 AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
666 AC_CHECK_HEADERS([readline/history.h history.h], [break])
668 if test "$with_krb4" = yes ; then
669 AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
672 if test "$with_krb5" = yes ; then
673 AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
674 AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
677 if test "$with_openssl" = yes ; then
678 AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
679 AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
684 ## Types, structures, compiler characteristics
693 PGAC_STRUCT_SOCKADDR_UN
696 ## Functions, global variables
698 PGAC_VAR_INT_TIMEZONE
699 AC_FUNC_ACCEPT_ARGTYPES
700 PGAC_FUNC_GETTIMEOFDAY_1ARG
702 AC_MSG_CHECKING([for fcntl(F_SETLK)])
704 linux*) AC_MSG_RESULT([broken on Linux]) ;;
711 lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
712 lck.l_type = F_WRLCK;
713 fcntl(0, F_SETLK, &lck);],
714 [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
719 AC_CHECK_FUNCS([fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen])
721 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
723 [#include <machine/vmparam.h>
724 #include <sys/exec.h>
726 [PS_STRINGS->ps_nargvstr = 1;
727 PS_STRINGS->ps_argvstr = "foo";],
728 [pgac_cv_var_PS_STRINGS=yes],
729 [pgac_cv_var_PS_STRINGS=no])])
730 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
731 AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
734 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
735 dnl is missing. Yes, there are machines that have only one.
736 dnl We may also decide to use snprintf.c if snprintf() is present but does
737 dnl not have working "long long int" support -- see below.
739 AC_CHECK_FUNC(snprintf,
740 AC_DEFINE(HAVE_SNPRINTF),
741 SNPRINTF='snprintf.o')
742 AC_CHECK_FUNC(vsnprintf,
743 AC_DEFINE(HAVE_VSNPRINTF),
744 SNPRINTF='snprintf.o')
746 dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
747 dnl include/c.h will provide declarations. Note this is a separate test
748 dnl from whether the functions exist in the C library --- there are systems
749 dnl that have the functions but don't bother to declare them :-(
750 dnl Note: simple-minded pattern here will do wrong thing if stdio.h
751 dnl declares vsnprintf() but not snprintf(). Hopefully there are no
752 dnl systems that are *that* brain-damaged...
753 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
754 AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
756 # do this one the hard way in case isinf() is a macro
757 AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
761 [double x = 0.0; int res = isinf(x);],
762 [ac_cv_func_isinf=yes],
763 [ac_cv_func_isinf=no])])
765 if test $ac_cv_func_isinf = yes ; then
766 AC_DEFINE(HAVE_ISINF)
770 # Look for a way to implement a substitute for isinf()
771 AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
775 AC_CHECK_FUNC(getrusage,
776 AC_DEFINE(HAVE_GETRUSAGE),
777 GETRUSAGE='getrusage.o')
779 AC_CHECK_FUNC(srandom,
780 AC_DEFINE(HAVE_SRANDOM),
783 AC_CHECK_FUNC(gethostname,
784 AC_DEFINE(HAVE_GETHOSTNAME),
785 GETHOSTNAME='gethostname.o')
786 AC_SUBST(GETHOSTNAME)
787 AC_CHECK_FUNC(random,
788 AC_DEFINE(HAVE_RANDOM),
789 MISSING_RANDOM='random.o')
790 AC_SUBST(MISSING_RANDOM)
791 AC_CHECK_FUNC(inet_aton,
792 AC_DEFINE(HAVE_INET_ATON),
793 INET_ATON='inet_aton.o')
795 AC_CHECK_FUNC(strerror,
796 AC_DEFINE(HAVE_STRERROR),
797 [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
800 AC_CHECK_FUNC(strdup,
801 AC_DEFINE(HAVE_STRDUP),
802 STRDUP='../../utils/strdup.o')
804 AC_CHECK_FUNC(strtol,
805 AC_DEFINE(HAVE_STRTOL),
808 AC_CHECK_FUNC(strtoul,
809 AC_DEFINE(HAVE_STRTOUL),
812 AC_CHECK_FUNC(strcasecmp,
813 AC_DEFINE(HAVE_STRCASECMP),
814 STRCASECMP='strcasecmp.o')
817 AC_DEFINE(HAVE_CBRT),
818 AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
820 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
821 # this hackery with HPUXMATHLIB allows us to cope.
825 if [[ -r /lib/pa1.1/libm.a ]] ; then
826 HPUXMATHLIB="-L /lib/pa1.1 -lm"
829 AC_SUBST(HPUXMATHLIB)
832 AC_DEFINE(HAVE_RINT),
833 AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
835 dnl Some old versions of libreadline don't have rl_completion_append_character
836 AC_EGREP_HEADER(rl_completion_append_character, readline.h,
837 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER),
838 [AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h,
839 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
840 AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
842 dnl Check for readline's filename_completion_function.
843 dnl Some versions have it but it's not in the headers, so we have to take
844 dnl care of that, too.
845 AC_CHECK_FUNCS(filename_completion_function,
846 AC_EGREP_HEADER(filename_completion_function, readline.h,
847 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
848 [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
849 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
851 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
852 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
855 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
856 AC_MSG_CHECKING(for finite)
857 AC_TRY_LINK([#include <math.h>],
858 [int dummy=finite(1.0);],
859 [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
862 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
863 dnl (especially on GNU libc)
864 dnl See also comments in config.h.
865 AC_MSG_CHECKING(for sigsetjmp)
866 AC_TRY_LINK([#include <setjmp.h>],
867 [sigjmp_buf x; sigsetjmp(x, 1);],
868 [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
872 PGAC_ARG_BOOL(enable, syslog, no, [ --enable-syslog enable logging to syslog],
873 [AC_CHECK_FUNC(syslog,
874 [AC_DEFINE([ENABLE_SYSLOG], 1,
875 [Define to 1 if to enable the syslogging code])],
876 [AC_MSG_ERROR([no syslog interface found])])])
879 dnl Check to see if we have a working 64-bit integer type.
880 dnl This breaks down into two steps:
881 dnl (1) figure out if the compiler has a 64-bit int type with working
882 dnl arithmetic, and if so
883 dnl (2) see whether snprintf() can format the type correctly. (Currently,
884 dnl snprintf is the only library routine we really need for int8 support.)
885 dnl It's entirely possible to have a compiler that handles a 64-bit type
886 dnl when the C library doesn't; this is fairly likely when using gcc on
887 dnl an older platform, for example.
888 dnl If there is no native snprintf() or it does not handle the 64-bit type,
889 dnl we force our own version of snprintf() to be used instead.
890 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
892 PGAC_TYPE_64BIT_INT([long int])
894 if test x"$HAVE_LONG_INT_64" = x"no" ; then
895 PGAC_TYPE_64BIT_INT([long long int])
899 dnl If we found "long int" is 64 bits, assume snprintf handles it.
900 dnl If we found we need to use "long long int", better check.
901 dnl We cope with snprintfs that use either %lld or %qd as the format.
902 dnl If neither works, fall back to our own snprintf emulation (which we
905 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
906 if [[ x$SNPRINTF = x ]] ; then
907 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
908 AC_TRY_RUN([#include <stdio.h>
909 typedef long long int int64;
910 #define INT64_FORMAT "%lld"
915 int does_int64_snprintf_work()
920 if (sizeof(int64) != 8)
921 return 0; /* doesn't look like the right size */
924 snprintf(buf, 100, INT64_FORMAT, c);
925 if (strcmp(buf, "800000140000005") != 0)
926 return 0; /* either multiply or snprintf is busted */
930 exit(! does_int64_snprintf_work());
933 INT64_FORMAT='"%lld"'
936 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
937 AC_TRY_RUN([#include <stdio.h>
938 typedef long long int int64;
939 #define INT64_FORMAT "%qd"
944 int does_int64_snprintf_work()
949 if (sizeof(int64) != 8)
950 return 0; /* doesn't look like the right size */
953 snprintf(buf, 100, INT64_FORMAT, c);
954 if (strcmp(buf, "800000140000005") != 0)
955 return 0; /* either multiply or snprintf is busted */
959 exit(! does_int64_snprintf_work());
965 # Force usage of our own snprintf, since system snprintf is broken
966 SNPRINTF='snprintf.o'
967 INT64_FORMAT='"%lld"'
969 [ AC_MSG_RESULT(assuming not on target machine)
970 # Force usage of our own snprintf, since we cannot test foreign snprintf
971 SNPRINTF='snprintf.o'
972 INT64_FORMAT='"%lld"'
974 [ AC_MSG_RESULT(assuming not on target machine)
975 # Force usage of our own snprintf, since we cannot test foreign snprintf
976 SNPRINTF='snprintf.o'
977 INT64_FORMAT='"%lld"'
980 # here if we previously decided we needed to use our own snprintf
981 INT64_FORMAT='"%lld"'
984 # Here if we are not using 'long long int' at all
988 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
991 dnl Determine memory alignment requirements for the basic C datatypes.
993 PGAC_CHECK_ALIGNOF(short)
994 PGAC_CHECK_ALIGNOF(int)
995 PGAC_CHECK_ALIGNOF(long)
996 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
997 PGAC_CHECK_ALIGNOF(long long int)
999 PGAC_CHECK_ALIGNOF(double)
1001 dnl Compute maximum alignment of any basic type.
1002 dnl We assume long's alignment is at least as strong as char, short, or int;
1003 dnl but we must check long long (if it exists) and double.
1005 if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
1006 MAX_ALIGNOF=$pgac_cv_alignof_long
1007 if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1008 MAX_ALIGNOF=$pgac_cv_alignof_double
1010 if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1011 MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1014 dnl cross-compiling: assume that double's alignment is worst case
1015 MAX_ALIGNOF="$pgac_cv_alignof_double"
1017 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1019 PGAC_FUNC_POSIX_SIGNALS
1022 # Check for Tcl configuration script tclConfig.sh
1023 if test "$with_tcl" = yes; then
1024 PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
1027 # Check for Tk configuration script tkConfig.sh
1028 if test "$with_tk" = yes; then
1029 PGAC_PATH_TKCONFIGSH([$with_tkconfig $with_tclconfig])
1033 # Finally ready to produce output files ...
1040 src/backend/port/Makefile
1042 [echo "timestamp file" > src/include/stamp-h]