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")
38 AC_MSG_CHECKING([which template to use])
40 # check if --with-template was given
41 if test x"${with_template+set}" = xset ; then
42 case $with_template in
43 yes|no) AC_MSG_ERROR([You must supply an argument to the --with-template option.]);;
44 list) echo; ls "$srcdir/src/template"; exit;;
45 *) if test -f "$srcdir/src/template/$with_template" ; then
46 template=$with_template
48 AC_MSG_ERROR([\`$with_template' is not a valid template name. Use \`list' for a list.])
52 else # --with-template not given
56 bsdi*) template=bsdi ;;
57 cygwin*) template=win ;;
58 dgux*) template=dgux ;;
59 freebsd*) template=freebsd ;;
60 hpux*) template=hpux ;;
61 irix*) template=irix5 ;;
62 linux*) template=linux ;;
63 netbsd*) template=netbsd ;;
64 nextstep*) template=nextstep ;;
65 openbsd*) template=openbsd ;;
67 qnx*) template=qnx4 ;;
71 sparc) template=solaris_sparc ;;
72 i?86) template=solaris_i386 ;;
74 sunos*) template=sunos4 ;;
77 univel) template=univel ;;
79 sysv4*) template=svr4 ;;
80 sysv5uw*) template=unixware ;;
81 ultrix*) template=ultrix4 ;;
84 if test x"$template" = x"" ; then
86 *******************************************************************
87 PostgreSQL has apparently not been ported to your platform yet.
88 To try a manual configuration, look into the src/template directory
89 for a similar platform and use the \`--with-template=' option.
91 Please also contact <pgsql-ports@postgresql.org> to see about
92 rectifying this. Include the above \`checking host system type...'
94 *******************************************************************
98 fi # --with-template not given
100 AC_MSG_RESULT([$template])
107 AC_LINK_FILES([src/backend/port/dynloader/${template}.c], [src/backend/port/dynloader.c])
108 AC_LINK_FILES([src/backend/port/dynloader/${template}.h], [src/include/dynloader.h])
109 AC_LINK_FILES([src/include/port/${template}.h], [src/include/os.h])
110 AC_LINK_FILES([src/makefiles/Makefile.${template}], [src/Makefile.port])
112 # Pick right test-and-set (TAS) code. Most platforms have inline
113 # assembler code in their port include file, so we just use a dummy
118 hpux) need_tas=yes; tas_file=hpux.s ;;
119 solaris_sparc) need_tas=yes; tas_file=solaris_sparc.s ;;
120 solaris_i386) need_tas=yes; tas_file=solaris_i386.s ;;
123 if test "$need_tas" = yes ; then
124 AC_LINK_FILES([src/backend/port/tas/${tas_file}], [src/backend/port/tas.s])
132 ## Command line options
137 # Add non-standard directories to the include path
139 AC_ARG_WITH(includes, [ --with-includes=DIRS look for additional header files in DIRS],
142 yes | no) AC_MSG_ERROR([You must supply an argument to the --with-includes option.]);;
148 # Add non-standard directories to the library search path
150 AC_ARG_WITH(libraries, [ --with-libraries=DIRS look for additional libraries in DIRS],
153 yes | no) AC_MSG_ERROR([You must supply an argument to the --with-libraries option.]);;
155 LIBRARY_DIRS=$withval
158 AC_ARG_WITH(libs, [ --with-libs=DIRS alternative spelling of --with-libraries],
161 yes | no) AC_MSG_ERROR([You must supply an argument to the --with-libs option.]);;
163 LIBRARY_DIRS=$withval
168 # Locale (--enable-locale)
170 AC_MSG_CHECKING([whether to build with locale support])
171 AC_ARG_ENABLE(locale, [ --enable-locale enable locale support],
172 [if test x"$enable_locale" != x"no" ; then
174 AC_DEFINE(USE_LOCALE, 1, [Set to 1 if you want LOCALE support (--enable-locale)])
177 AC_MSG_RESULT([$enable_locale])
181 # Cyrillic recode (--enable-recode)
183 AC_MSG_CHECKING([whether to build with Cyrillic recode support])
184 AC_ARG_ENABLE(recode, [ --enable-recode enable cyrillic recode support],
185 [if test x"$enable_recode" != x"no" ; then
187 AC_DEFINE(CYR_RECODE, 1, [Set to 1 if you want cyrillic recode support (--enable-recode)])
190 AC_MSG_RESULT([$enable_recode])
197 AC_MSG_CHECKING([whether to build with multibyte character support])
198 AC_ARG_ENABLE(multibyte, [ --enable-multibyte enable multibyte character support],
201 no) enable_multibyte=no;;
202 yes) enable_multibyte=yes; MULTIBYTE=SQL_ASCII;;
203 SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
204 enable_multibyte=yes; MULTIBYTE=$enableval;;
206 [argument to --enable-multibyte must be one of:
207 SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW,
208 UNICODE, MULE_INTERNAL,
209 LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
211 Or do not specify an argument to the option to use the default.]) ;;
214 [enable_multibyte=no])
218 if test "$enable_multibyte" = yes ; then
219 AC_DEFINE(MULTIBYTE, 1, [Set to 1 if you want to use multibyte characters (--enable-multibyte)])
220 AC_MSG_RESULT([yes, default $MULTIBYTE])
227 # Default port number (--with-pgport), default 5432
229 AC_MSG_CHECKING([for default port number])
230 AC_ARG_WITH(pgport, [ --with-pgport=PORTNUM change default port number [5432]],
232 yes|no) AC_MSG_ERROR([You must supply an argument to the --with-pgport option]);;
233 *) default_port=$withval;;
237 # Need both of these because backend wants an integer and frontend a string
238 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
239 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
240 AC_MSG_RESULT([$default_port])
244 # Maximum number of allowed connections (--with-maxbackends), default 32
246 AC_MSG_CHECKING([for default soft limit on number of connections])
247 AC_ARG_WITH(maxbackends, [ --with-maxbackends=N set default maximum number of connections [32]],
249 yes|no) AC_MSG_ERROR([You must supply an argument to the --with-maxbackends option]);;
251 [with_maxbackends=32])
252 AC_MSG_RESULT([$with_maxbackends])
253 AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, [$with_maxbackends], [The default soft limit on the number of concurrent connections, i.e., the default for the postmaster -N switch (--with-maxbackends)])
260 # For historical reasons you can also use --with-CC to specify the C compiler
261 # to use, although the standard way to do this is to set the CC environment
263 if test "${with_CC+set}" = set; then
265 yes | no) AC_MSG_ERROR([You must supply an argument to the --with-CC option.]);;
270 # On AIX, default compiler to xlc.
271 if test "$template" = aix && test -z "$CC" ; then CC=xlc; fi
275 . "$srcdir/src/template/$template" || exit
276 echo "using CFLAGS=$CFLAGS"
277 # Check if the compiler still works with the template settings
280 AC_PROG_GCC_TRADITIONAL
288 # Create compiler version string
289 if test x"$GCC" = x"yes" ; then
290 cc_string="GCC `${CC} --version`"
294 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])
298 # Automatic dependency tracking
300 AC_ARG_ENABLE(depend, [ --enable-depend turn on automatic dependency tracking],
302 if test x"$enableval" = x"yes" ; then
309 # --enable-debug adds -g to compiler flags
310 # --disable-debug will forcefully remove it
311 AC_MSG_CHECKING(setting debug compiler flag)
312 AC_ARG_ENABLE(debug, [ --enable-debug build with debugging symbols (-g)],
315 yes) CFLAGS="$CFLAGS -g"
318 *) CFLAGS=`echo "$CFLAGS" | sed -e 's/ -g/ /g' -e 's/^-g//'`
323 [AC_MSG_RESULT(using default)])
327 # Include directories
331 # SRCH_INC comes from the template file
332 for dir in $with_includes $SRCH_INC; do
333 if test -d "$dir"; then
334 INCLUDES="$INCLUDES -I$dir"
336 AC_MSG_WARN([*** Include directory $dir does not exist.])
344 # Library directories
348 # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
349 for dir in $LIBRARY_DIRS $SRCH_LIB; do
350 if test -d "$dir"; then
351 PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
353 AC_MSG_WARN([*** Library directory $dir does not exist.])
360 dnl We exclude tcl support unless user says --with-tcl
361 AC_MSG_CHECKING(setting USE_TCL)
364 [ --with-tcl build Tcl interfaces and pgtclsh ],
367 y | ye | yes) USE_TCL=true; USE_TK=true; AC_MSG_RESULT(enabled) ;;
368 *) USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ;;
371 [ USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ]
377 dnl We see if the path to the TCL/TK configuration scripts is specified.
378 dnl This will override the use of tclsh to find the paths to search.
380 AC_ARG_WITH(tclconfig,
381 [ --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR],
384 "" | y | ye | yes | n | no)
385 AC_MSG_ERROR([*** You must supply an argument to the --with-tclconfig option.])
392 dnl We see if the path to the TK configuration scripts is specified.
393 dnl This will override the use of tclsh to find the paths to search.
395 AC_ARG_WITH(tkconfig,
396 [ --with-tkconfig=DIR tkConfig.sh is in DIR],
399 "" | y | ye | yes | n | no)
400 AC_MSG_ERROR([*** You must supply an argument to the --with-tkconfig option.])
409 dnl Optionally build Perl modules (Pg.pm and PL/Perl)
411 AC_MSG_CHECKING(whether to build Perl modules)
412 AC_ARG_WITH(perl, [ --with-perl build Perl interface and plperl],
413 [if test x"${withval}" = x"yes" ; then
423 dnl Optionally build Python interface module
425 AC_MSG_CHECKING(whether to build Python modules)
426 AC_ARG_WITH(python, [ --with-python build Python interface module],
427 [if test x"${withval}" = x"yes" ; then
435 AC_SUBST(with_python)
438 dnl A note on the Kerberos and OpenSSL options:
440 dnl The user can give an argument to the option in order the specify
441 dnl the base path of the respective installation (what he specified
442 dnl perhaps as --prefix). If no argument is given ($withval is "yes")
443 dnl then we take the path where the package installs by default. This
444 dnl way the user doesn't have to use redundant --with-includes and
445 dnl --with-libraries options, but he can still use them if the layout
451 AC_ARG_WITH(krb4, [ --with-krb4[=DIR] use Kerberos 4 [/usr/athena]],
452 [if test x"$withval" != x"no"; then
453 if test x"$withval" != x"yes"; then
456 krb4_prefix=/usr/athena
465 if test "$with_krb4" = yes ; then
466 AC_MSG_RESULT([building with Kerberos 4 support])
467 AC_DEFINE(KRB4, [], [Define if you are building with Kerberos 4 support.])
469 if test -d "$krb4_prefix"; then
470 if test -d "$krb4_prefix/include"; then
471 INCLUDES="$INCLUDES -I$krb4_prefix/include"
473 if test -d "$krb4_prefix/lib"; then
474 krb_libdir="-L$krb4_prefix/lib"
475 LIBS="$krb_libdir $LIBS"
478 dnl Test for these libraries is below
479 KRB_LIBS="$krb_libdir -lkrb -ldes"
481 krb_srvtab='/etc/srvtab'
488 AC_ARG_WITH(krb5, [ --with-krb5[=DIR] use Kerberos 5 [/usr/athena]],
489 [if test x"$withval" != x"no"; then
490 if test x"$withval" != x"yes"; then
493 krb5_prefix=/usr/athena
502 if test "$with_krb5" = yes ; then
503 AC_MSG_RESULT([building with Kerberos 5 support])
504 AC_DEFINE(KRB5,, [Define if you are building with Kerberos 5 support.])
506 if test -d $krb5_prefix; then
507 if test -d "$krb5_prefix/include"; then
508 INCLUDES="$INCLUDES -I$krb5_prefix/include"
510 if test -d "$krb5_prefix/lib"; then
511 krb_libdir="-L$krb5_prefix/lib"
512 LIBS="$krb_libdir $LIBS"
516 dnl Test for these libraries is below
517 KRB_LIBS="$krb_libdir -lkrb5 -lcrypto -lcom_err"
519 krb_srvtab='FILE:$(sysconfdir)/krb5.keytab'
523 # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
524 if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
525 AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
530 dnl Necessary for special libpq link
535 # Kerberos configuration parameters
537 AC_ARG_WITH(krb-srvnam, [ --with-krb-srvnam=NAME name of the Postgres service principal in Kerberos],
538 [if test x"$withval" = x"yes"; then
539 AC_MSG_ERROR([argument required for --with-krb-srvnam])
543 [krb_srvnam="postgres"])
544 AC_DEFINE_UNQUOTED(PG_KRB_SRVNAM, ["$krb_srvnam"], [The name of the Postgres service principal])
551 AC_ARG_WITH(openssl, [ --with-openssl[=DIR] build with OpenSSL support [/usr/local/ssl]],
552 [if test x"$withval" != x"no" ; then
553 if test x"$withval" != x"yes" ; then
554 openssl_prefix=$withval
556 openssl_prefix=/usr/local/ssl
564 AC_SUBST(with_openssl)
565 if test "$with_openssl" = yes ; then
566 AC_MSG_RESULT([building with OpenSSL support])
567 AC_DEFINE([USE_SSL], [], [Define to build with (Open)SSL support])
569 if test -d "${openssl_prefix}/include" ; then
570 INCLUDES="$INCLUDES -I${openssl_prefix}/include"
572 if test -d "${openssl_prefix}/lib" ; then
573 openssl_libdir="${openssl_prefix}/lib"
574 LIBS="$LIBS -L${openssl_prefix}/lib"
576 openssl_libdir="${openssl_prefix}"
577 LIBS="$LIBS -L${openssl_prefix}"
582 # OpenSSL and Kerberos 5 both have a `crypto' library, so if you want to
583 # use both of them you'll have to figure it out yourself.
584 if test "$with_openssl" = yes && test "$with_krb5" = yes ; then
585 AC_MSG_ERROR([OpenSSL and Kerberos 5 support cannot be combined])
590 dnl Optionally enable the building of the ODBC driver
594 if test "x${with_odbc+set}" = xset && test "x${enable_odbc+set}" != xset; then
595 enable_odbc=$with_odbc
598 AC_MSG_CHECKING(whether to build the ODBC driver)
599 AC_ARG_ENABLE(odbc, [ --enable-odbc build the ODBC driver package],
600 [if test x"$enableval" = x"yes" ; then
606 AC_SUBST(enable_odbc)
609 dnl Allow for overriding the default location of the odbcinst.ini
610 dnl file which is normally ${datadir} (i.e., ${prefix}/share).
611 if test x"$enable_odbc" = x"yes" ; then
612 AC_ARG_WITH(odbcinst, [ --with-odbcinst=DIR default directory for odbcinst.ini [sysconfdir]],
613 [if test x"$with_odbcinst" = x"yes" || test x"$with_odbcinst" = x"no" ; then
614 AC_MSG_ERROR([You must supply an argument to the --with-odbcinst option.])
616 odbcinst_ini_dir=$withval],
617 [odbcinst_ini_dir='${sysconfdir}'])
619 odbcinst_ini_dir='${sysconfdir}'
621 AC_SUBST(odbcinst_ini_dir)
625 dnl Unless we specify the command line options
626 dnl --enable cassert to explicitly enable it
627 dnl If you do not explicitly do it, it defaults to disabled
628 AC_MSG_CHECKING(setting ASSERT CHECKING)
631 [ --enable-cassert enable assertion checks (for debugging) ],
632 AC_DEFINE(USE_ASSERT_CHECKING) AC_MSG_RESULT(enabled),
633 AC_MSG_RESULT(disabled)
637 # Assume system is ELF if it predefines __ELF__ as 1,
638 # otherwise believe host_os based default.
640 freebsd1*|freebsd2*) elf=yes;;
649 [if test "X$elf" = "Xyes" ; then
659 dnl Optionally build C++ code (i.e., libpq++)
661 AC_MSG_CHECKING([whether to build C++ modules])
662 AC_ARG_WITH(CXX, [ --with-CXX build C++ modules (libpq++)],
663 [if test x"$withval" != x"no"; then
664 if test x"$withval" != x"yes" ; then
671 AC_MSG_RESULT([$with_CXX])
674 if test $with_CXX = yes; then
678 PGAC_CXX_NAMESPACE_STD
682 CPPFLAGS="$CPPFLAGS $INCLUDES"
683 LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
685 echo "using CPPFLAGS=$CPPFLAGS"
686 echo "using LDFLAGS=$LDFLAGS"
689 # Figure out how to invoke "install" and what install options to use.
692 # When Autoconf chooses install-sh as install program it tries to generate
693 # a relative path to it in each makefile where it subsitutes it. This clashes
694 # with our Makefile.global concept. This workaround helps.
696 *install-sh*) INSTALL='\${SHELL} \${top_srcdir}/config/install-sh -c';;
699 # Fix Autoconf's brain-dead defaults for script installs.
700 INSTALL_SCRIPT="\${INSTALL} -m 755"
702 # HPUX wants shared libs to be mode 555. Add your platform's special
703 # needs here if necessary.
705 hpux*) INSTL_SHLIB_OPTS="-m 555" ;;
706 *) INSTL_SHLIB_OPTS="-m 644" ;;
709 INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
710 AC_SUBST(INSTALL_SHLIB)
713 mkinstalldirs="\$(SHELL) \$(top_srcdir)/config/mkinstalldirs"
714 AC_SUBST(mkinstalldirs)
721 AC_PATH_PROG(tar, tar)
722 AC_CHECK_PROGS(PERL, perl,)
731 AC_CHECK_LIB(sfio, main)
732 AC_CHECK_LIB(ncurses, main, [], [AC_CHECK_LIB(curses, main)])
733 AC_CHECK_LIB(termcap, main)
734 AC_CHECK_LIB(readline, main)
735 AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
736 AC_CHECK_LIB(history, main) )
738 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
740 AC_CHECK_LIB(bsd, main)
742 AC_CHECK_LIB(util, setproctitle)
743 AC_CHECK_LIB(m, main)
744 AC_CHECK_LIB(dl, main)
745 AC_CHECK_LIB(socket, main)
746 AC_CHECK_LIB(nsl, main)
747 AC_CHECK_LIB(ipc, main)
748 AC_CHECK_LIB(IPC, main)
749 AC_CHECK_LIB(lc, main)
750 AC_CHECK_LIB(dld, main)
751 AC_CHECK_LIB(ln, main)
752 AC_CHECK_LIB(ld, main)
753 AC_CHECK_LIB(compat, main)
754 AC_CHECK_LIB(BSD, main)
755 AC_CHECK_LIB(gen, main)
756 AC_CHECK_LIB(PW, main)
757 AC_SEARCH_LIBS(crypt, crypt)
758 AC_CHECK_LIB(z, inflate)
760 if test "$with_krb4" = yes ; then
761 AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library \`des' is required for Kerberos 4])])
762 AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library \`krb' is required for Kerberos 4])])
765 if test "$with_krb5" = yes ; then
766 AC_CHECK_LIB(com_err, main, [], [AC_MSG_ERROR([library \`com_err' is required for Kerberos 5])])
767 AC_CHECK_LIB(crypto, main, [], [AC_MSG_ERROR([library \`crypto' is required for Kerberos 5])])
768 AC_CHECK_LIB(krb5, main, [], [AC_MSG_ERROR([library \`krb5' is required for Kerberos 5])])
771 if test "$with_openssl" = yes ; then
773 AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
774 AC_CHECK_LIB(ssl, [SSL_library_init], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
781 dnl sys/socket.h and sys/types.h are required by AC_FUNC_ACCEPT_ARGTYPES
782 AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h pwd.h sys/pstat.h sys/select.h sys/socket.h sys/types.h termios.h])
784 AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
785 AC_CHECK_HEADERS([readline/history.h history.h], [break])
787 if test "$with_krb4" = yes ; then
788 AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
791 if test "$with_krb5" = yes ; then
792 AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
793 AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
796 if test "$with_openssl" = yes ; then
797 AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
798 AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
803 ## Types, structures, compiler characteristics
815 ## Functions, global variables
817 PGAC_VAR_INT_TIMEZONE
818 AC_FUNC_ACCEPT_ARGTYPES
819 PGAC_FUNC_GETTIMEOFDAY_1ARG
821 AC_MSG_CHECKING([for fcntl(F_SETLK)])
823 linux*) AC_MSG_RESULT([broken on Linux]) ;;
830 lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
831 lck.l_type = F_WRLCK;
832 fcntl(0, F_SETLK, &lck);],
833 [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
838 AC_CHECK_FUNCS([fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid])
840 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
842 [#include <machine/vmparam.h>
843 #include <sys/exec.h>
845 [PS_STRINGS->ps_nargvstr = 1;
846 PS_STRINGS->ps_argvstr = "foo";],
847 [pgac_cv_var_PS_STRINGS=yes],
848 [pgac_cv_var_PS_STRINGS=no])])
849 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
850 AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
853 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
854 dnl is missing. Yes, there are machines that have only one.
855 dnl We may also decide to use snprintf.c if snprintf() is present but does
856 dnl not have working "long long int" support -- see below.
858 AC_CHECK_FUNC(snprintf,
859 AC_DEFINE(HAVE_SNPRINTF),
860 SNPRINTF='snprintf.o')
861 AC_CHECK_FUNC(vsnprintf,
862 AC_DEFINE(HAVE_VSNPRINTF),
863 SNPRINTF='snprintf.o')
865 dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
866 dnl include/c.h will provide declarations. Note this is a separate test
867 dnl from whether the functions exist in the C library --- there are systems
868 dnl that have the functions but don't bother to declare them :-(
869 dnl Note: simple-minded pattern here will do wrong thing if stdio.h
870 dnl declares vsnprintf() but not snprintf(). Hopefully there are no
871 dnl systems that are *that* brain-damaged...
872 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
873 AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
875 # do this one the hard way in case isinf() is a macro
876 AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
880 [double x = 0.0; int res = isinf(x);],
881 [ac_cv_func_isinf=yes],
882 [ac_cv_func_isinf=no])])
884 if test $ac_cv_func_isinf = yes ; then
885 AC_DEFINE(HAVE_ISINF)
889 # Look for a way to implement a substitute for isinf()
890 AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
894 AC_CHECK_FUNC(getrusage,
895 AC_DEFINE(HAVE_GETRUSAGE),
896 GETRUSAGE='getrusage.o')
898 AC_CHECK_FUNC(srandom,
899 AC_DEFINE(HAVE_SRANDOM),
902 AC_CHECK_FUNC(gethostname,
903 AC_DEFINE(HAVE_GETHOSTNAME),
904 GETHOSTNAME='gethostname.o')
905 AC_SUBST(GETHOSTNAME)
906 AC_CHECK_FUNC(random,
907 AC_DEFINE(HAVE_RANDOM),
908 MISSING_RANDOM='random.o')
909 AC_SUBST(MISSING_RANDOM)
910 AC_CHECK_FUNC(inet_aton,
911 AC_DEFINE(HAVE_INET_ATON),
912 INET_ATON='inet_aton.o')
914 AC_CHECK_FUNC(strerror,
915 AC_DEFINE(HAVE_STRERROR),
916 [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
919 AC_CHECK_FUNC(strdup,
920 AC_DEFINE(HAVE_STRDUP),
921 STRDUP='../../utils/strdup.o')
923 AC_CHECK_FUNC(strtol,
924 AC_DEFINE(HAVE_STRTOL),
927 AC_CHECK_FUNC(strtoul,
928 AC_DEFINE(HAVE_STRTOUL),
931 AC_CHECK_FUNC(strcasecmp,
932 AC_DEFINE(HAVE_STRCASECMP),
933 STRCASECMP='strcasecmp.o')
936 AC_DEFINE(HAVE_CBRT),
937 AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
939 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
940 # this hackery with HPUXMATHLIB allows us to cope.
944 if [[ -r /lib/pa1.1/libm.a ]] ; then
945 HPUXMATHLIB="-L /lib/pa1.1 -lm"
948 AC_SUBST(HPUXMATHLIB)
951 AC_DEFINE(HAVE_RINT),
952 AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
954 dnl Some old versions of libreadline don't have rl_completion_append_character
955 AC_EGREP_HEADER(rl_completion_append_character, readline.h,
956 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER),
957 [AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h,
958 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
959 AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
961 dnl Check for readline's filename_completion_function.
962 dnl Some versions have it but it's not in the headers, so we have to take
963 dnl care of that, too.
964 AC_CHECK_FUNCS(filename_completion_function,
965 AC_EGREP_HEADER(filename_completion_function, readline.h,
966 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
967 [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
968 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
970 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
971 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
974 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
975 AC_MSG_CHECKING(for finite)
976 AC_TRY_LINK([#include <math.h>],
977 [int dummy=finite(1.0);],
978 [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
981 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
982 dnl (especially on GNU libc)
983 dnl See also comments in config.h.
984 AC_MSG_CHECKING(for sigsetjmp)
985 AC_TRY_LINK([#include <setjmp.h>],
986 [sigjmp_buf x; sigsetjmp(x, 1);],
987 [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
990 AC_ARG_ENABLE(syslog, [ --enable-syslog enable logging to syslog],
991 [case $enableval in y|ye|yes)
992 AC_CHECK_FUNC(syslog, [AC_DEFINE(ENABLE_SYSLOG)], [AC_MSG_ERROR([no syslog interface found])])
997 dnl Check to see if we have a working 64-bit integer type.
998 dnl This breaks down into two steps:
999 dnl (1) figure out if the compiler has a 64-bit int type with working
1000 dnl arithmetic, and if so
1001 dnl (2) see whether snprintf() can format the type correctly. (Currently,
1002 dnl snprintf is the only library routine we really need for int8 support.)
1003 dnl It's entirely possible to have a compiler that handles a 64-bit type
1004 dnl when the C library doesn't; this is fairly likely when using gcc on
1005 dnl an older platform, for example.
1006 dnl If there is no native snprintf() or it does not handle the 64-bit type,
1007 dnl we force our own version of snprintf() to be used instead.
1008 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
1010 PGAC_TYPE_64BIT_INT([long int])
1012 if test x"$HAVE_LONG_INT_64" = x"no" ; then
1013 PGAC_TYPE_64BIT_INT([long long int])
1017 dnl If we found "long int" is 64 bits, assume snprintf handles it.
1018 dnl If we found we need to use "long long int", better check.
1019 dnl We cope with snprintfs that use either %lld or %qd as the format.
1020 dnl If neither works, fall back to our own snprintf emulation (which we
1021 dnl know uses %lld).
1023 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1024 if [[ x$SNPRINTF = x ]] ; then
1025 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
1026 AC_TRY_RUN([#include <stdio.h>
1027 typedef long long int int64;
1028 #define INT64_FORMAT "%lld"
1033 int does_int64_snprintf_work()
1038 if (sizeof(int64) != 8)
1039 return 0; /* doesn't look like the right size */
1042 snprintf(buf, 100, INT64_FORMAT, c);
1043 if (strcmp(buf, "800000140000005") != 0)
1044 return 0; /* either multiply or snprintf is busted */
1048 exit(! does_int64_snprintf_work());
1050 [ AC_MSG_RESULT(yes)
1051 INT64_FORMAT='"%lld"'
1054 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
1055 AC_TRY_RUN([#include <stdio.h>
1056 typedef long long int int64;
1057 #define INT64_FORMAT "%qd"
1062 int does_int64_snprintf_work()
1067 if (sizeof(int64) != 8)
1068 return 0; /* doesn't look like the right size */
1071 snprintf(buf, 100, INT64_FORMAT, c);
1072 if (strcmp(buf, "800000140000005") != 0)
1073 return 0; /* either multiply or snprintf is busted */
1077 exit(! does_int64_snprintf_work());
1079 [ AC_MSG_RESULT(yes)
1080 INT64_FORMAT='"%qd"'
1083 # Force usage of our own snprintf, since system snprintf is broken
1084 SNPRINTF='snprintf.o'
1085 INT64_FORMAT='"%lld"'
1087 [ AC_MSG_RESULT(assuming not on target machine)
1088 # Force usage of our own snprintf, since we cannot test foreign snprintf
1089 SNPRINTF='snprintf.o'
1090 INT64_FORMAT='"%lld"'
1092 [ AC_MSG_RESULT(assuming not on target machine)
1093 # Force usage of our own snprintf, since we cannot test foreign snprintf
1094 SNPRINTF='snprintf.o'
1095 INT64_FORMAT='"%lld"'
1098 # here if we previously decided we needed to use our own snprintf
1099 INT64_FORMAT='"%lld"'
1102 # Here if we are not using 'long long int' at all
1103 INT64_FORMAT='"%ld"'
1106 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
1109 dnl Determine memory alignment requirements for the basic C datatypes.
1111 PGAC_CHECK_ALIGNOF(short)
1112 PGAC_CHECK_ALIGNOF(int)
1113 PGAC_CHECK_ALIGNOF(long)
1114 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1115 PGAC_CHECK_ALIGNOF(long long int)
1117 PGAC_CHECK_ALIGNOF(double)
1119 dnl Compute maximum alignment of any basic type.
1120 dnl We assume long's alignment is at least as strong as char, short, or int;
1121 dnl but we must check long long (if it exists) and double.
1123 if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
1124 MAX_ALIGNOF=$pgac_cv_alignof_long
1125 if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1126 MAX_ALIGNOF=$pgac_cv_alignof_double
1128 if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1129 MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1132 dnl cross-compiling: assume that double's alignment is worst case
1133 MAX_ALIGNOF="$pgac_cv_alignof_double"
1135 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1137 PGAC_FUNC_POSIX_SIGNALS
1140 dnl Check for Tcl configuration script tclConfig.sh
1142 dnl If --with-tclconfig was given, don't check for tclsh, tcl
1143 if test -z "$TCL_DIRS"
1145 AC_PATH_PROG(TCLSH, tclsh)
1148 AC_PATH_PROG(TCLSH, tcl)
1151 AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
1157 if test "$USE_TCL" = true
1159 AC_MSG_CHECKING(for tclConfig.sh)
1162 if test -z "$TCL_DIRS"
1164 library_dirs=`echo 'puts $auto_path' | $TCLSH`
1166 library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
1167 for dir in $library_dirs; do
1168 if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
1169 TCL_CONFIG_SH=$dir/tclConfig.sh
1173 if test -z "$TCL_CONFIG_SH"; then
1175 AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
1178 AC_MSG_RESULT($TCL_CONFIG_SH)
1179 AC_SUBST(TCL_CONFIG_SH)
1183 USE_TK=$USE_TCL # If TCL is disabled, disable TK
1185 dnl Check for Tk configuration script tkConfig.sh
1186 if test "$USE_TK" = true
1188 AC_MSG_CHECKING(for tkConfig.sh)
1190 # library_dirs are set in the check for TCL
1191 for dir in $library_dirs
1193 if test -d "$dir" -a -r "$dir/tkConfig.sh"
1195 TK_CONFIG_SH=$dir/tkConfig.sh
1199 if test -z "$TK_CONFIG_SH"
1202 AC_MSG_WARN(TK support disabled; Tk configuration script missing)
1205 AC_MSG_RESULT($TK_CONFIG_SH)
1206 AC_SUBST(TK_CONFIG_SH)
1207 AC_PATH_PROG(WISH, wish)
1214 dnl Check for X libraries
1216 if test "$USE_X" = true; then
1218 ice_save_LIBS="$LIBS"
1219 ice_save_CFLAGS="$CFLAGS"
1220 ice_save_CPPFLAGS="$CPPFLAGS"
1221 ice_save_LDFLAGS="$LDFLAGS"
1225 LIBS="$LIBS $X_EXTRA_LIBS"
1226 CFLAGS="$CFLAGS $X_CFLAGS"
1227 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1228 LDFLAGS="$LDFLAGS $X_LIBS"
1230 dnl Check for X library
1233 AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
1234 if test "$X11_LIBS" = ""; then
1235 dnl Not having X is bad news for pgtksh. Let the user fix this.
1236 AC_MSG_WARN([The X11 library '-lX11' could not be found,
1237 so TK support will be disabled. To enable TK support,
1238 please use the configure options '--x-includes=DIR'
1239 and '--x-libraries=DIR' to specify the X location.
1240 See the file 'config.log' for further diagnostics.])
1245 AC_SUBST(X_PRE_LIBS)
1247 LIBS="$ice_save_LIBS"
1248 CFLAGS="$ice_save_CFLAGS"
1249 CPPFLAGS="$ice_save_CPPFLAGS"
1250 LDFLAGS="$ice_save_LDFLAGS"
1254 # Wait with these until we're done so no tests fail because of too
1256 if test x"$GCC" = x"yes" ; then
1257 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations"
1260 dnl Finally ready to produce output files ...
1267 src/backend/port/Makefile
1269 [echo timestamp > src/include/stamp-h]