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 AC_INIT(src/backend/access/common/heaptuple.c)
18 AC_PREFIX_DEFAULT(/usr/local/pgsql)
19 AC_CONFIG_HEADER(src/include/config.h)
22 AC_CONFIG_AUX_DIR(config)
26 AC_DEFINE_UNQUOTED(PG_VERSION, "$VERSION")
34 sparc) os=solaris_sparc need_tas=yes tas_file=solaris_sparc.s ;;
35 i386) os=solaris_i386 need_tas=yes tas_file=solaris_i386.s ;;
37 sunos*) os=sunos4 need_tas=no ;;
38 beos) os=beos need_tas=no ;;
39 aux*) os=aux need_tas=no ;;
40 linux*) os=linux need_tas=no ;;
41 bsdi*) os=bsdi need_tas=no ;;
42 freebsd1*|freebsd2*) os=freebsd need_tas=no ;;
43 freebsd*) os=freebsd need_tas=no elf=yes ;;
44 netbsd*) os=netbsd need_tas=no ;;
45 openbsd*) os=bsd need_tas=no ;;
46 dgux*) os=dgux need_tas=no ;;
47 aix*) os=aix need_tas=no ;;
48 nextstep*) os=nextstep need_tas=no ;;
49 ultrix*) os=ultrix4 need_tas=no ;;
50 irix*) os=irix5 need_tas=no ;;
51 hpux*) os=hpux need_tas=yes tas_file=hpux.s ;;
52 osf*) os=alpha need_tas=no ;;
53 sco*) os=sco need_tas=no ;;
54 machten*) os=machten need_tas=no ;;
55 cygwin*) os=win need_tas=no ;;
57 case "$host_vendor" in
58 univel) os=univel need_tas=no ;;
59 *) os=unknown need_tas=no ;;
61 sysv4*) os=svr4 need_tas=no ;;
62 sysv5uw*) os=unixware need_tas=no ;;
63 unixware*) os=unixware need_tas=no ;;
64 qnx*) os=qnx4 need_tas=no ;;
66 echo "*************************************************************"
67 echo "configure does not currently recognize your operating system,"
68 echo "therefore you must do a manual configuration of:"
70 echo "Please contact scrappy@hub.org to see about rectifying this, "
71 echo "including the above 'checking host system type...' line "
72 echo "*************************************************************"
79 AC_LINK_FILES(src/backend/port/dynloader/${os}.c, src/backend/port/dynloader.c)
80 AC_LINK_FILES(src/backend/port/dynloader/${os}.h, src/include/dynloader.h)
81 AC_LINK_FILES(src/include/port/${os}.h, src/include/os.h)
82 AC_LINK_FILES(src/makefiles/Makefile.${os}, src/Makefile.port)
84 if test "X$need_tas" = "Xyes"
86 AC_LINK_FILES(src/backend/port/tas/${tas_file}, src/backend/port/tas.s)
91 dnl this part selects the template from the ones in the template directory.
93 AC_MSG_CHECKING(setting template to)
95 [ --with-template=TEMPLATE
96 use operating system template file
97 see template directory],
98 [ TEMPLATE=$withval ],
102 host="`echo $host | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`"
104 # First, try for a template exactly matching $host
105 if test -f "src/template/$host"
106 then TEMPLATE="$host"
108 # Scan template/.similar for a rule that tells us which template to use.
109 # The format of each line of the file is
110 # hostnamepattern=templatefilename
111 # where the hostnamepattern is evaluated per the rules of expr(1) ---
112 # namely, it is a standard regular expression with an implicit ^ at the
113 # start. If multiple lines match, we will end up using the last match.
115 # The tempfile hackery is needed because some shells will run the loop
116 # inside a subshell, whereupon shell variables set therein aren't seen
117 # outside the loop :-(
119 cat /dev/null > $TMPFILE
122 SIMHOST=`expr "$LINE" : '\(.*\)='`
123 MATCH=`expr "$host" : "$SIMHOST"`
124 if test "$MATCH" != 0
126 echo "$LINE" | sed 's/^.*=//' > $TMPFILE
128 done <src/template/.similar
132 then TEMPLATE="$GUESS"
134 # Last chance ... maybe uname -s will match an entry.
135 TEMPLATE=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
139 AC_MSG_RESULT($TEMPLATE)
142 if test ! -f "src/template/$TEMPLATE"; then
144 echo "$TEMPLATE does not exist"
146 echo "Available Templates (select one using --with-template):"
153 dnl Read the selected template file.
154 dnl For reasons of backwards compatibility, lines of the form
155 dnl IDENTIFIER: something
156 dnl should be treated as variable assignments. However, we also want to
157 dnl allow other shell commands in the template file (in case the file
158 dnl needs to make conditional tests, etc). So, generate a temp file with
159 dnl the IDENTIFIER: lines translated, then source it.
163 sed 's/^\([A-Za-z_]*\):\(.*\)$/\1="\2"/' "src/template/$TEMPLATE" >conftest.sh
169 dnl Add non-standard directories to the include path
171 AC_ARG_WITH(includes, [ --with-includes=DIRS add non-standard include paths],
172 [if test x"$withval" = x"yes" || test x"$withval" = x"no" ; then
173 AC_MSG_ERROR([You must supply an argument to the --with-includes option.])
176 # SRCH_INC comes from the template file
179 for dir in $with_includes $SRCH_INC; do
180 if test -d "$dir"; then
181 INCLUDES="$INCLUDES -I$dir"
183 AC_MSG_WARN([*** Include directory $dir does not exist.])
191 dnl Add non-standard directories to the library search path
193 AC_ARG_WITH(libraries,
194 [ --with-libraries=DIRS look for additional libraries in DIRS],
197 "" | y | ye | yes | n | no)
198 AC_MSG_ERROR([*** You must supply an argument to the --with-libraries option.])
201 LIBRARY_DIRS="$withval"
205 [ --with-libs=DIRS alternate spelling of --with-libraries],
208 "" | y | ye | yes | n | no)
209 AC_MSG_ERROR([*** You must supply an argument to the --with-libs option.])
212 LIBRARY_DIRS="$withval"
215 dnl LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
216 dnl Each can name one or more directories.
217 if test "$LIBRARY_DIRS" -o "$SRCH_LIB"; then
218 for dir in $LIBRARY_DIRS $SRCH_LIB; do
219 if test -d "$dir"; then
220 PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
222 AC_MSG_WARN([*** Library directory $dir does not exist.])
228 AC_MSG_CHECKING(whether to support locale)
231 [ --enable-locale enable locale support ],
232 [AC_DEFINE(USE_LOCALE) AC_MSG_RESULT(enabled)],
233 AC_MSG_RESULT(disabled)
236 dnl We exclude cyrillic recode support unless we override it with
237 dnl --enable-recode to explicitly enable it
238 dnl It defaults to disabled
239 AC_MSG_CHECKING(whether to support cyrillic recode)
242 [ --enable-recode enable cyrillic recode support ],
243 [AC_DEFINE(CYR_RECODE) AC_MSG_RESULT(enabled)],
244 AC_MSG_RESULT(disabled)
247 dnl Multibyte support
249 AC_MSG_CHECKING(whether to support multibyte)
250 AC_ARG_ENABLE(multibyte,
251 [ --enable-multibyte enable multibyte character support ],
254 if test "$enableval" != "yes"; then
256 SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
261 [Argument to --enable-multibyte must be one of:
262 SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW,
263 UNICODE, MULE_INTERNAL,
264 LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
266 Or do not specify an argument to the option to use the default.])
271 AC_MSG_RESULT(enabled)
273 AC_MSG_RESULT("disabled")
276 dnl Old option variant
277 if test "${with_mb}"; then
278 AC_MSG_ERROR([--with-mb is not supported anymore. Use --enable-multibyte instead.])
282 dnl We use the default value of 5432 for the DEF_PGPORT value. If
283 dnl we over-ride it with --with-pgport=port then we bypass this piece
284 AC_MSG_CHECKING(setting DEF_PGPORT)
287 [ --with-pgport=PORTNUM change default postmaster port ],
288 [default_port="$withval"],
291 dnl Need both of these because backend wants an integer and frontend a string
292 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
293 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
294 AC_MSG_RESULT(${default_port})
297 dnl DEF_MAXBACKENDS can be set by --with-maxbackends. Default value is 32.
298 AC_MSG_CHECKING(setting DEF_MAXBACKENDS)
301 [ --with-maxbackends=N set default maximum number of server processes ],
302 AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, ${withval}) AC_MSG_RESULT($with_maxbackends),
303 AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, 32) AC_MSG_RESULT(32)
307 dnl Check for C support (allow override if needed)
308 dnl Note: actually, setting CC environment variable works just as well.
310 [ --with-CC=compiler use specific C compiler],
313 "" | y | ye | yes | n | no)
314 AC_MSG_ERROR([*** You must supply an argument to the --with-CC option.])
320 dnl Find a compiler if CC is not already set.
322 dnl Find CPP, then check traditional.
323 dnl Caution: these macros must be called in this order...
325 AC_PROG_GCC_TRADITIONAL
328 if test x"$GCC" = x"yes" ; then
329 cc_string="GCC `${CC} --version`"
333 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])
337 dnl We exclude tcl support unless user says --with-tcl
338 AC_MSG_CHECKING(setting USE_TCL)
341 [ --with-tcl build Tcl interfaces and pgtclsh ],
344 y | ye | yes) USE_TCL=true; USE_TK=true; AC_MSG_RESULT(enabled) ;;
345 *) USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ;;
348 [ USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ]
354 dnl We see if the path to the TCL/TK configuration scripts is specified.
355 dnl This will override the use of tclsh to find the paths to search.
357 AC_ARG_WITH(tclconfig,
358 [ --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR],
361 "" | y | ye | yes | n | no)
362 AC_MSG_ERROR([*** You must supply an argument to the --with-tclconfig option.])
369 dnl We see if the path to the TK configuration scripts is specified.
370 dnl This will override the use of tclsh to find the paths to search.
372 AC_ARG_WITH(tkconfig,
373 [ --with-tkconfig=DIR tkConfig.sh is in DIR],
376 "" | y | ye | yes | n | no)
377 AC_MSG_ERROR([*** You must supply an argument to the --with-tkconfig option.])
386 dnl Optionally build Perl modules (Pg.pm and PL/Perl)
388 AC_MSG_CHECKING(whether to build Perl modules)
389 AC_ARG_WITH(perl, [ --with-perl build Perl interface and plperl],
390 [if test x"${withval}" = x"yes" ; then
400 dnl Optionally build Python interface module
402 AC_MSG_CHECKING(whether to build Python modules)
403 AC_ARG_WITH(python, [ --with-python build Python interface module],
404 [if test x"${withval}" = x"yes" ; then
412 AC_SUBST(with_python)
415 dnl A note on the Kerberos and OpenSSL options:
417 dnl The user can give an argument to the option in order the specify
418 dnl the base path of the respective installation (what he specified
419 dnl perhaps as --prefix). If no argument is given ($withval is "yes")
420 dnl then we take the path where the package installs by default. This
421 dnl way the user doesn't have to use redundant --with-includes and
422 dnl --with-libraries options, but he can still use them if the layout
428 AC_ARG_WITH(krb4, [ --with-krb4[=DIR] use Kerberos 4 [/usr/athena]],
429 [if test x"$withval" != x"no"; then
430 if test x"$withval" != x"yes"; then
433 krb4_prefix=/usr/athena
442 if test "$with_krb4" = yes ; then
443 AC_MSG_RESULT([building with Kerberos 4 support])
444 AC_DEFINE(KRB4, [], [Define if you are building with Kerberos 4 support.])
446 if test -d "$krb4_prefix"; then
447 if test -d "$krb4_prefix/include"; then
448 INCLUDES="$INCLUDES -I$krb4_prefix/include"
450 if test -d "$krb4_prefix/lib"; then
451 krb_libdir="-L$krb4_prefix/lib"
452 LIBS="$krb_libdir $LIBS"
455 dnl Test for these libraries is below
456 KRB_LIBS="$krb_libdir -lkrb -ldes"
463 AC_ARG_WITH(krb5, [ --with-krb5[=DIR] use Kerberos 5 [/usr/athena]],
464 [if test x"$withval" != x"no"; then
465 if test x"$withval" != x"yes"; then
468 krb5_prefix=/usr/athena
477 if test "$with_krb5" = yes ; then
478 AC_MSG_RESULT([building with Kerberos 5 support])
479 AC_DEFINE(KRB5,, [Define if you are building with Kerberos 5 support.])
481 if test -d $krb5_prefix; then
482 if test -d "$krb5_prefix/include"; then
483 INCLUDES="$INCLUDES -I$krb5_prefix/include"
485 if test -d "$krb5_prefix/lib"; then
486 krb_libdir="-L$krb5_prefix/lib"
487 LIBS="$krb_libdir $LIBS"
491 dnl Test for these libraries is below
492 KRB_LIBS="$krb_libdir -lkrb5 -lcrypto -lcom_err"
496 # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
497 if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
498 AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
501 dnl Necessary for special libpq link
506 # Kerberos configuration parameters
508 AC_ARG_WITH(krb-srvnam, [ --with-krb-srvnam=NAME name of the Postgres service principal in Kerberos],
509 [if test x"$withval" = x"yes"; then
510 AC_MSG_ERROR([argument required for --with-krb-srvnam])
514 [krb_srvnam="postgres"])
515 AC_DEFINE_UNQUOTED(PG_KRB_SRVNAM, ["$krb_srvnam"], [The name of the Postgres service principal])
517 AC_ARG_WITH(krb-srvtab, [ --with-krb-srvtab=FILE location of Kerberos server's keytab file],
518 [if test x"$withval" = x"yes"; then
519 AC_MSG_ERROR([argument required for --with-krb-srvtab])
523 [if test "$with_krb5" = yes ; then
524 krb_srvtab='FILE:${sysconfdir}/krb5.keytab'
525 elif test "$with_krb4" = yes ; then
526 krb_srvtab='/etc/srvtab'
536 AC_ARG_WITH(openssl, [ --with-openssl[=DIR] build with OpenSSL support [/usr/local/ssl]],
537 [if test x"$withval" != x"no" ; then
538 if test x"$withval" != x"yes" ; then
539 openssl_prefix=$withval
541 openssl_prefix=/usr/local/ssl
549 AC_SUBST(with_openssl)
550 if test "$with_openssl" = yes ; then
551 AC_MSG_RESULT([building with OpenSSL support])
552 AC_DEFINE([USE_SSL], [], [Define to build with (Open)SSL support])
554 if test -d "${openssl_prefix}/include" ; then
555 INCLUDES="$INCLUDES -I${openssl_prefix}/include"
557 if test -d "${openssl_prefix}/lib" ; then
558 openssl_libdir="${openssl_prefix}/lib"
559 LIBS="$LIBS -L${openssl_prefix}/lib"
564 # OpenSSL and Kerberos 5 both have a `crypto' library, so if you want to
565 # use both of them you'll have to figure it out yourself.
566 if test "$with_openssl" = yes && test "$with_krb5" = yes ; then
567 AC_MSG_ERROR([OpenSSL and Kerberos 5 support cannot be combined])
572 dnl Optionally enable the building of the ODBC driver
576 if test "x${with_odbc+set}" = xset && test "x${enable_odbc+set}" != xset; then
577 enable_odbc=$with_odbc
580 AC_MSG_CHECKING(whether to build the ODBC driver)
581 AC_ARG_ENABLE(odbc, [ --enable-odbc build the ODBC driver package],
582 [if test x"$enableval" = x"yes" ; then
588 AC_SUBST(enable_odbc)
591 dnl Allow for overriding the default location of the odbcinst.ini
592 dnl file which is normally ${datadir} (i.e., ${prefix}/share).
593 if test x"$enable_odbc" = x"yes" ; then
594 AC_ARG_WITH(odbcinst, [ --with-odbcinst=DIR default directory for odbcinst.ini [sysconfdir]],
595 [if test x"$with_odbcinst" = x"yes" || test x"$with_odbcinst" = x"no" ; then
596 AC_MSG_ERROR([You must supply an argument to the --with-odbcinst option.])
598 odbcinst_ini_dir=$withval],
599 [odbcinst_ini_dir='${sysconfdir}'])
601 odbcinst_ini_dir='${sysconfdir}'
603 AC_SUBST(odbcinst_ini_dir)
607 dnl Unless we specify the command line options
608 dnl --enable cassert to explicitly enable it
609 dnl If you do not explicitly do it, it defaults to disabled
610 AC_MSG_CHECKING(setting ASSERT CHECKING)
613 [ --enable-cassert enable assertion checks (for debugging) ],
614 AC_DEFINE(USE_ASSERT_CHECKING) AC_MSG_RESULT(enabled),
615 AC_MSG_RESULT(disabled)
618 CPPFLAGS="$CPPFLAGS $INCLUDES"
619 echo "- setting CPPFLAGS=$CPPFLAGS"
621 LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
622 echo "- setting LDFLAGS=$LDFLAGS"
624 dnl --enable-debug adds -g to compiler flags
625 dnl --disable-debug will forcefully remove it
626 AC_MSG_CHECKING(setting debug compiler flag)
629 [ --enable-debug build with debugging symbols (-g) ],
634 AC_MSG_RESULT(enabled)
637 CFLAGS=`echo "$CFLAGS" | sed -e 's/ -g/ /g' | sed -e 's/^-g//'`
638 AC_MSG_RESULT(disabled)
642 AC_MSG_RESULT(using default)
645 # Assume system is ELF if it predefines __ELF__ as 1,
646 # otherwise believe "elf" setting from check of host_os above.
653 [if test "X$elf" = "Xyes"
678 dnl Optionally build C++ code (i.e., libpq++)
680 AC_MSG_CHECKING(whether to build C++ modules)
681 AC_ARG_WITH(CXX, [ --with-CXX build C++ modules (libpq++)],
682 [if test "x${withval+set}" = xset; then
684 if test x"$withval" != xyes ; then
690 PGAC_CXX_NAMESPACE_STD
698 # Figure out how to invoke "install" and what install options to use.
701 # When Autoconf chooses install-sh as install program it tries to generate
702 # a relative path to it in each makefile where it subsitutes it. This clashes
703 # with our Makefile.global concept. This workaround helps.
705 *install-sh*) INSTALL='\${SHELL} \${top_srcdir}/config/install-sh -c';;
708 # Fix Autoconf's brain-dead defaults for script installs.
709 INSTALL_SCRIPT="\${INSTALL} -m 755"
711 # HPUX wants shared libs to be mode 555. Add your platform's special
712 # needs here if necessary.
714 hpux*) INSTL_SHLIB_OPTS="-m 555" ;;
715 *) INSTL_SHLIB_OPTS="-m 644" ;;
718 INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
719 AC_SUBST(INSTALL_SHLIB)
722 mkinstalldirs="\$(SHELL) \$(top_srcdir)/config/mkinstalldirs"
723 AC_SUBST(mkinstalldirs)
729 if test "$LEX" = "flex"; then
730 $LEX --version 2> /dev/null | grep -s '2\.5\.3' > /dev/null 2>&1
731 if test $? -eq 0 ; then
734 You have flex version 2.5.3, which is broken. Get version 2.5.4 or
736 (If you are using the official distribution of PostgreSQL then you
737 do not need to worry about this because the lexer files are
738 pre-generated. However, other software using flex is likely to be
745 AC_PATH_PROG(tar, tar)
746 AC_CHECK_PROGS(PERL, perl,)
751 AC_CHECK_LIB(sfio, main)
752 AC_CHECK_LIB(ncurses, main, [], [AC_CHECK_LIB(curses, main)])
753 AC_CHECK_LIB(termcap, main)
754 AC_CHECK_LIB(readline, main)
755 AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
756 AC_CHECK_LIB(history, main) )
758 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
760 AC_CHECK_LIB(bsd, main)
762 AC_CHECK_LIB(util, setproctitle)
763 AC_CHECK_LIB(m, main)
764 AC_CHECK_LIB(dl, main)
765 AC_CHECK_LIB(socket, main)
766 AC_CHECK_LIB(nsl, main)
767 AC_CHECK_LIB(ipc, main)
768 AC_CHECK_LIB(IPC, main)
769 AC_CHECK_LIB(lc, main)
770 AC_CHECK_LIB(dld, main)
771 AC_CHECK_LIB(ln, main)
772 AC_CHECK_LIB(ld, main)
773 AC_CHECK_LIB(compat, main)
774 AC_CHECK_LIB(BSD, main)
775 AC_CHECK_LIB(gen, main)
776 AC_CHECK_LIB(PW, main)
777 AC_SEARCH_LIBS(crypt, crypt)
778 AC_CHECK_LIB(z, inflate)
780 if test "$with_krb4" = yes ; then
781 AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library \`des' is required for Kerberos 4])])
782 AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library \`krb' is required for Kerberos 4])])
785 if test "$with_krb5" = yes ; then
786 AC_CHECK_LIB(com_err, main, [], [AC_MSG_ERROR([library \`com_err' is required for Kerberos 5])])
787 AC_CHECK_LIB(crypto, main, [], [AC_MSG_ERROR([library \`crypto' is required for Kerberos 5])])
788 AC_CHECK_LIB(krb5, main, [], [AC_MSG_ERROR([library \`krb5' is required for Kerberos 5])])
791 if test "$with_openssl" = yes ; then
793 AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
794 AC_CHECK_LIB(ssl, [SSL_library_init], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
799 dnl Checks for header files.
803 AC_CHECK_HEADERS(arpa/inet.h)
804 AC_CHECK_HEADERS(crypt.h)
805 AC_CHECK_HEADERS(dld.h)
806 AC_CHECK_HEADERS(endian.h)
807 AC_CHECK_HEADERS(float.h)
808 AC_CHECK_HEADERS(fp_class.h)
809 AC_CHECK_HEADERS(getopt.h)
810 AC_CHECK_HEADERS(ieeefp.h)
811 AC_CHECK_HEADERS(limits.h)
812 AC_CHECK_HEADERS(netdb.h)
813 AC_CHECK_HEADERS(netinet/in.h)
814 AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
815 AC_CHECK_HEADERS([readline/history.h history.h], [break])
816 AC_CHECK_HEADERS(sys/select.h)
817 AC_CHECK_HEADERS(termios.h)
818 AC_CHECK_HEADERS(unistd.h)
819 AC_CHECK_HEADERS(values.h)
820 AC_CHECK_HEADERS(sys/pstat.h)
821 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
822 AC_CHECK_HEADERS(sys/param.h pwd.h)
824 if test "$with_krb4" = yes ; then
825 AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
828 if test "$with_krb5" = yes ; then
829 AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
830 AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
833 if test "$with_openssl" = yes ; then
834 AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
835 AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
840 dnl Checks for typedefs, structures, and compiler characteristics.
852 AC_FUNC_ACCEPT_ARGTYPES
855 PGAC_VAR_INT_TIMEZONE
856 PGAC_FUNC_GETTIMEOFDAY_1ARG
860 AC_MSG_CHECKING(for fcntl(F_SETLK))
861 if test "$os" != linux ; then
862 AC_TRY_LINK([#include <stdio.h>
865 lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
866 lck.l_type = F_WRLCK;
867 fcntl(0, F_SETLK, &lck);],
868 [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
871 AC_MSG_RESULT([broken on Linux])
874 dnl Checks for library functions.
878 AC_CHECK_FUNCS(memmove sysconf)
879 AC_CHECK_FUNCS(sigprocmask waitpid setsid fcvt)
880 AC_CHECK_FUNCS(setproctitle pstat)
882 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
884 [#include <machine/vmparam.h>
885 #include <sys/exec.h>
887 [PS_STRINGS->ps_nargvstr = 1;
888 PS_STRINGS->ps_argvstr = "foo";],
889 [pgac_cv_var_PS_STRINGS=yes],
890 [pgac_cv_var_PS_STRINGS=no])])
891 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
892 AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
895 AC_CHECK_FUNCS(fpclass fp_class fp_class_d class)
896 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
897 dnl is missing. Yes, there are machines that have only one.
898 dnl We may also decide to use snprintf.c if snprintf() is present but does
899 dnl not have working "long long int" support -- see below.
901 AC_CHECK_FUNC(snprintf,
902 AC_DEFINE(HAVE_SNPRINTF),
903 SNPRINTF='snprintf.o')
904 AC_CHECK_FUNC(vsnprintf,
905 AC_DEFINE(HAVE_VSNPRINTF),
906 SNPRINTF='snprintf.o')
908 dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
909 dnl include/c.h will provide declarations. Note this is a separate test
910 dnl from whether the functions exist in the C library --- there are systems
911 dnl that have the functions but don't bother to declare them :-(
912 dnl Note: simple-minded pattern here will do wrong thing if stdio.h
913 dnl declares vsnprintf() but not snprintf(). Hopefully there are no
914 dnl systems that are *that* brain-damaged...
915 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
916 AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
918 dnl do this one the hard way in case isinf() is a macro
919 AC_MSG_CHECKING(for isinf)
920 AC_CACHE_VAL(ac_cv_func_or_macro_isinf,
923 [double x = 0.0; int res = isinf(x);],
924 [ac_cv_func_or_macro_isinf=yes],
925 [ac_cv_func_or_macro_isinf=no])])
926 if [[ $ac_cv_func_or_macro_isinf = yes ]]; then
928 AC_DEFINE(HAVE_ISINF)
935 AC_CHECK_FUNC(getrusage,
936 AC_DEFINE(HAVE_GETRUSAGE),
937 GETRUSAGE='getrusage.o')
939 AC_CHECK_FUNC(srandom,
940 AC_DEFINE(HAVE_SRANDOM),
943 AC_CHECK_FUNC(gethostname,
944 AC_DEFINE(HAVE_GETHOSTNAME),
945 GETHOSTNAME='gethostname.o')
946 AC_SUBST(GETHOSTNAME)
947 AC_CHECK_FUNC(random,
948 AC_DEFINE(HAVE_RANDOM),
949 MISSING_RANDOM='random.o')
950 AC_SUBST(MISSING_RANDOM)
951 AC_CHECK_FUNC(inet_aton,
952 AC_DEFINE(HAVE_INET_ATON),
953 INET_ATON='inet_aton.o')
955 AC_CHECK_FUNC(strerror,
956 AC_DEFINE(HAVE_STRERROR),
957 [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
960 AC_CHECK_FUNC(strdup,
961 AC_DEFINE(HAVE_STRDUP),
962 STRDUP='../../utils/strdup.o')
964 AC_CHECK_FUNC(strtol,
965 AC_DEFINE(HAVE_STRTOL),
968 AC_CHECK_FUNC(strtoul,
969 AC_DEFINE(HAVE_STRTOUL),
972 AC_CHECK_FUNC(strcasecmp,
973 AC_DEFINE(HAVE_STRCASECMP),
974 STRCASECMP='strcasecmp.o')
977 AC_DEFINE(HAVE_CBRT),
978 AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
980 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
981 # this hackery with HPUXMATHLIB allows us to cope.
985 if [[ -r /lib/pa1.1/libm.a ]] ; then
986 HPUXMATHLIB="-L /lib/pa1.1 -lm"
989 AC_SUBST(HPUXMATHLIB)
992 AC_DEFINE(HAVE_RINT),
993 AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
995 dnl Some old versions of libreadline don't have rl_completion_append_character
996 AC_EGREP_HEADER(rl_completion_append_character, readline.h,
997 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER),
998 [AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h,
999 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
1000 AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
1002 dnl Check for readline's filename_completion_function.
1003 dnl Some versions have it but it's not in the headers, so we have to take
1004 dnl care of that, too.
1005 AC_CHECK_FUNCS(filename_completion_function,
1006 AC_EGREP_HEADER(filename_completion_function, readline.h,
1007 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
1008 [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
1009 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
1011 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
1012 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
1014 dnl Check for GNU style long options support (getopt_long)
1015 AC_CHECK_FUNCS(getopt_long)
1017 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
1018 AC_MSG_CHECKING(for finite)
1019 AC_TRY_LINK([#include <math.h>],
1020 [int dummy=finite(1.0);],
1021 [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
1024 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
1025 dnl (especially on GNU libc)
1026 dnl See also comments in config.h.
1027 AC_MSG_CHECKING(for sigsetjmp)
1028 AC_TRY_LINK([#include <setjmp.h>],
1029 [sigjmp_buf x; sigsetjmp(x, 1);],
1030 [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
1033 AC_ARG_ENABLE(syslog, [ --enable-syslog enable logging to syslog],
1034 [case $enableval in y|ye|yes)
1035 AC_CHECK_FUNC(syslog, [AC_DEFINE(ENABLE_SYSLOG)], [AC_MSG_ERROR([no syslog interface found])])
1040 dnl Check to see if we have a working 64-bit integer type.
1041 dnl This breaks down into two steps:
1042 dnl (1) figure out if the compiler has a 64-bit int type with working
1043 dnl arithmetic, and if so
1044 dnl (2) see whether snprintf() can format the type correctly. (Currently,
1045 dnl snprintf is the only library routine we really need for int8 support.)
1046 dnl It's entirely possible to have a compiler that handles a 64-bit type
1047 dnl when the C library doesn't; this is fairly likely when using gcc on
1048 dnl an older platform, for example.
1049 dnl If there is no native snprintf() or it does not handle the 64-bit type,
1050 dnl we force our own version of snprintf() to be used instead.
1051 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
1053 PGAC_TYPE_64BIT_INT([long int])
1055 if test x"$HAVE_LONG_INT_64" = x"no" ; then
1056 PGAC_TYPE_64BIT_INT([long long int])
1060 dnl If we found "long int" is 64 bits, assume snprintf handles it.
1061 dnl If we found we need to use "long long int", better check.
1062 dnl We cope with snprintfs that use either %lld or %qd as the format.
1063 dnl If neither works, fall back to our own snprintf emulation (which we
1064 dnl know uses %lld).
1066 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1067 if [[ x$SNPRINTF = x ]] ; then
1068 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
1069 AC_TRY_RUN([#include <stdio.h>
1070 typedef long long int int64;
1071 #define INT64_FORMAT "%lld"
1076 int does_int64_snprintf_work()
1081 if (sizeof(int64) != 8)
1082 return 0; /* doesn't look like the right size */
1085 snprintf(buf, 100, INT64_FORMAT, c);
1086 if (strcmp(buf, "800000140000005") != 0)
1087 return 0; /* either multiply or snprintf is busted */
1091 exit(! does_int64_snprintf_work());
1093 [ AC_MSG_RESULT(yes)
1094 INT64_FORMAT='"%lld"'
1097 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
1098 AC_TRY_RUN([#include <stdio.h>
1099 typedef long long int int64;
1100 #define INT64_FORMAT "%qd"
1105 int does_int64_snprintf_work()
1110 if (sizeof(int64) != 8)
1111 return 0; /* doesn't look like the right size */
1114 snprintf(buf, 100, INT64_FORMAT, c);
1115 if (strcmp(buf, "800000140000005") != 0)
1116 return 0; /* either multiply or snprintf is busted */
1120 exit(! does_int64_snprintf_work());
1122 [ AC_MSG_RESULT(yes)
1123 INT64_FORMAT='"%qd"'
1126 # Force usage of our own snprintf, since system snprintf is broken
1127 SNPRINTF='snprintf.o'
1128 INT64_FORMAT='"%lld"'
1130 [ AC_MSG_RESULT(assuming not on target machine)
1131 # Force usage of our own snprintf, since we cannot test foreign snprintf
1132 SNPRINTF='snprintf.o'
1133 INT64_FORMAT='"%lld"'
1135 [ AC_MSG_RESULT(assuming not on target machine)
1136 # Force usage of our own snprintf, since we cannot test foreign snprintf
1137 SNPRINTF='snprintf.o'
1138 INT64_FORMAT='"%lld"'
1141 # here if we previously decided we needed to use our own snprintf
1142 INT64_FORMAT='"%lld"'
1145 # Here if we are not using 'long long int' at all
1146 INT64_FORMAT='"%ld"'
1149 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
1152 dnl Determine memory alignment requirements for the basic C datatypes.
1154 PGAC_CHECK_ALIGNOF(short)
1155 PGAC_CHECK_ALIGNOF(int)
1156 PGAC_CHECK_ALIGNOF(long)
1157 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1158 PGAC_CHECK_ALIGNOF(long long int)
1160 PGAC_CHECK_ALIGNOF(double)
1162 dnl Compute maximum alignment of any basic type.
1163 dnl We assume long's alignment is at least as strong as char, short, or int;
1164 dnl but we must check long long (if it exists) and double.
1166 if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
1167 MAX_ALIGNOF=$pgac_cv_alignof_long
1168 if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1169 MAX_ALIGNOF=$pgac_cv_alignof_double
1171 if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1172 MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1175 dnl cross-compiling: assume that double's alignment is worst case
1176 MAX_ALIGNOF="$pgac_cv_alignof_double"
1178 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1180 PGAC_FUNC_POSIX_SIGNALS
1183 dnl Check for Tcl configuration script tclConfig.sh
1185 dnl If --with-tclconfig was given, don't check for tclsh, tcl
1186 if test -z "$TCL_DIRS"
1188 AC_PATH_PROG(TCLSH, tclsh)
1191 AC_PATH_PROG(TCLSH, tcl)
1194 AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
1200 if test "$USE_TCL" = true
1202 AC_MSG_CHECKING(for tclConfig.sh)
1205 if test -z "$TCL_DIRS"
1207 library_dirs=`echo 'puts $auto_path' | $TCLSH`
1209 library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
1210 for dir in $library_dirs; do
1211 if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
1212 TCL_CONFIG_SH=$dir/tclConfig.sh
1216 if test -z "$TCL_CONFIG_SH"; then
1218 AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
1221 AC_MSG_RESULT($TCL_CONFIG_SH)
1222 AC_SUBST(TCL_CONFIG_SH)
1226 USE_TK=$USE_TCL # If TCL is disabled, disable TK
1228 dnl Check for Tk configuration script tkConfig.sh
1229 if test "$USE_TK" = true
1231 AC_MSG_CHECKING(for tkConfig.sh)
1233 # library_dirs are set in the check for TCL
1234 for dir in $library_dirs
1236 if test -d "$dir" -a -r "$dir/tkConfig.sh"
1238 TK_CONFIG_SH=$dir/tkConfig.sh
1242 if test -z "$TK_CONFIG_SH"
1245 AC_MSG_WARN(TK support disabled; Tk configuration script missing)
1248 AC_MSG_RESULT($TK_CONFIG_SH)
1249 AC_SUBST(TK_CONFIG_SH)
1250 AC_PATH_PROG(WISH, wish)
1256 dnl Check for X libraries
1258 if test "$USE_X" = true; then
1260 ice_save_LIBS="$LIBS"
1261 ice_save_CFLAGS="$CFLAGS"
1262 ice_save_CPPFLAGS="$CPPFLAGS"
1263 ice_save_LDFLAGS="$LDFLAGS"
1267 LIBS="$LIBS $X_EXTRA_LIBS"
1268 CFLAGS="$CFLAGS $X_CFLAGS"
1269 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1270 LDFLAGS="$LDFLAGS $X_LIBS"
1272 dnl Check for X library
1275 AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
1276 if test "$X11_LIBS" = ""; then
1277 dnl Not having X is bad news for pgtksh. Let the user fix this.
1278 AC_MSG_WARN([The X11 library '-lX11' could not be found,
1279 so TK support will be disabled. To enable TK support,
1280 please use the configure options '--x-includes=DIR'
1281 and '--x-libraries=DIR' to specify the X location.
1282 See the file 'config.log' for further diagnostics.])
1287 AC_SUBST(X_PRE_LIBS)
1289 LIBS="$ice_save_LIBS"
1290 CFLAGS="$ice_save_CFLAGS"
1291 CPPFLAGS="$ice_save_CPPFLAGS"
1292 LDFLAGS="$ice_save_LDFLAGS"
1296 # Wait with these until we're done so no tests fail because of too
1298 if test x"$GCC" = x"yes" ; then
1299 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations"
1302 dnl Finally ready to produce output files ...
1308 src/backend/port/Makefile
1309 src/test/regress/GNUmakefile