1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(src/backend/access/common/heaptuple.c)
3 AC_PREFIX_DEFAULT(/usr/local/pgsql)
4 AC_CONFIG_HEADER(src/include/config.h)
7 AC_CONFIG_AUX_DIR(`pwd`/config)
9 mkinstalldirs="\$(SHELL) \$(top_srcdir)/config/mkinstalldirs"
10 AC_SUBST(mkinstalldirs)
18 sparc) os=solaris_sparc need_tas=yes tas_file=solaris_sparc.s ;;
19 i386) os=solaris_i386 need_tas=yes tas_file=solaris_i386.s ;;
21 sunos*) os=sunos4 need_tas=no ;;
22 beos) os=beos need_tas=no ;;
23 aux*) os=aux need_tas=no ;;
24 linux*) os=linux need_tas=no ;;
25 bsdi*) os=bsdi need_tas=no ;;
26 freebsd1*|freebsd2*) os=freebsd need_tas=no ;;
27 freebsd*) os=freebsd need_tas=no elf=yes ;;
28 netbsd*) os=netbsd need_tas=no ;;
29 openbsd*) os=bsd need_tas=no ;;
30 dgux*) os=dgux need_tas=no ;;
31 aix*) os=aix need_tas=no ;;
32 nextstep*) os=nextstep need_tas=no ;;
33 ultrix*) os=ultrix4 need_tas=no ;;
34 irix*) os=irix5 need_tas=no ;;
35 hpux*) os=hpux need_tas=yes tas_file=hpux.s ;;
36 osf*) os=alpha need_tas=no ;;
37 sco*) os=sco need_tas=no ;;
38 machten*) os=machten need_tas=no ;;
39 cygwin*) os=win need_tas=no ;;
41 case "$host_vendor" in
42 univel) os=univel need_tas=no ;;
43 *) os=unknown need_tas=no ;;
45 sysv4*) os=svr4 need_tas=no ;;
46 sysv5uw*) os=unixware need_tas=no ;;
47 unixware*) os=unixware need_tas=no ;;
48 qnx*) os=qnx4 need_tas=no ;;
50 echo "*************************************************************"
51 echo "configure does not currently recognize your operating system,"
52 echo "therefore you must do a manual configuration of:"
54 echo "Please contact scrappy@hub.org to see about rectifying this, "
55 echo "including the above 'checking host system type...' line "
56 echo "*************************************************************"
63 AC_LINK_FILES(src/backend/port/dynloader/${os}.c, src/backend/port/dynloader.c)
64 AC_LINK_FILES(src/backend/port/dynloader/${os}.h, src/include/dynloader.h)
65 AC_LINK_FILES(src/include/port/${os}.h, src/include/os.h)
66 AC_LINK_FILES(src/makefiles/Makefile.${os}, src/Makefile.port)
68 if test "X$need_tas" = "Xyes"
70 AC_LINK_FILES(src/backend/port/tas/${tas_file}, src/backend/port/tas.s)
75 dnl this part selects the template from the ones in the template directory.
77 AC_MSG_CHECKING(setting template to)
79 [ --with-template=TEMPLATE
80 use operating system template file
81 see template directory],
82 [ TEMPLATE=$withval ],
86 host="`echo $host | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`"
88 # First, try for a template exactly matching $host
89 if test -f "src/template/$host"
92 # Scan template/.similar for a rule that tells us which template to use.
93 # The format of each line of the file is
94 # hostnamepattern=templatefilename
95 # where the hostnamepattern is evaluated per the rules of expr(1) ---
96 # namely, it is a standard regular expression with an implicit ^ at the
97 # start. If multiple lines match, we will end up using the last match.
99 # The tempfile hackery is needed because some shells will run the loop
100 # inside a subshell, whereupon shell variables set therein aren't seen
101 # outside the loop :-(
103 cat /dev/null > $TMPFILE
106 SIMHOST=`expr "$LINE" : '\(.*\)='`
107 MATCH=`expr "$host" : "$SIMHOST"`
108 if test "$MATCH" != 0
110 echo "$LINE" | sed 's/^.*=//' > $TMPFILE
112 done <src/template/.similar
116 then TEMPLATE="$GUESS"
118 # Last chance ... maybe uname -s will match an entry.
119 TEMPLATE=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
123 AC_MSG_RESULT($TEMPLATE)
126 if test ! -f "src/template/$TEMPLATE"; then
128 echo "$TEMPLATE does not exist"
130 echo "Available Templates (select one using --with-template):"
137 dnl Read the selected template file.
138 dnl For reasons of backwards compatibility, lines of the form
139 dnl IDENTIFIER: something
140 dnl should be treated as variable assignments. However, we also want to
141 dnl allow other shell commands in the template file (in case the file
142 dnl needs to make conditional tests, etc). So, generate a temp file with
143 dnl the IDENTIFIER: lines translated, then source it.
147 sed 's/^\([A-Za-z_]*\):\(.*\)$/\1="\2"/' "src/template/$TEMPLATE" >conftest.sh
153 dnl Add non-standard directories to the include path
155 AC_ARG_WITH(includes, [ --with-includes=DIRS add non-standard include paths],
156 [if test x"$withval" = x"yes" || test x"$withval" = x"no" ; then
157 AC_MSG_ERROR([You must supply an argument to the --with-includes option.])
160 # SRCH_INC comes from the template file
163 for dir in $with_includes $SRCH_INC; do
164 if test -d "$dir"; then
165 INCLUDES="$INCLUDES -I$dir"
167 AC_MSG_WARN([*** Include directory $dir does not exist.])
175 dnl Add non-standard directories to the library search path
177 AC_ARG_WITH(libraries,
178 [ --with-libraries=DIRS look for additional libraries in DIRS],
181 "" | y | ye | yes | n | no)
182 AC_MSG_ERROR([*** You must supply an argument to the --with-libraries option.])
185 LIBRARY_DIRS="$withval"
189 [ --with-libs=DIRS alternate spelling of --with-libraries],
192 "" | y | ye | yes | n | no)
193 AC_MSG_ERROR([*** You must supply an argument to the --with-libs option.])
196 LIBRARY_DIRS="$withval"
199 dnl LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
200 dnl Each can name one or more directories.
201 if test "$LIBRARY_DIRS" -o "$SRCH_LIB"; then
202 for dir in $LIBRARY_DIRS $SRCH_LIB; do
203 if test -d "$dir"; then
204 PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
206 AC_MSG_WARN([*** Library directory $dir does not exist.])
212 AC_MSG_CHECKING(whether to support locale)
215 [ --enable-locale enable locale support ],
216 [AC_DEFINE(USE_LOCALE) AC_MSG_RESULT(enabled)],
217 AC_MSG_RESULT(disabled)
220 dnl We exclude cyrillic recode support unless we override it with
221 dnl --enable-recode to explicitly enable it
222 dnl It defaults to disabled
223 AC_MSG_CHECKING(whether to support cyrillic recode)
226 [ --enable-recode enable cyrillic recode support ],
227 [AC_DEFINE(CYR_RECODE) AC_MSG_RESULT(enabled)],
228 AC_MSG_RESULT(disabled)
231 dnl Multibyte support
233 AC_MSG_CHECKING(whether to support multibyte)
234 AC_ARG_ENABLE(multibyte,
235 [ --enable-multibyte enable multibyte character support ],
238 if test "$enableval" != "yes"; then
240 SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
245 [Argument to --enable-multibyte must be one of:
246 SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW,
247 UNICODE, MULE_INTERNAL,
248 LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
250 Or do not specify an argument to the option to use the default.])
255 AC_MSG_RESULT(enabled)
257 AC_MSG_RESULT("disabled")
260 dnl Old option variant
261 if test "${with_mb}"; then
262 AC_MSG_ERROR([--with-mb is not supported anymore. Use --enable-multibyte instead.])
266 dnl We use the default value of 5432 for the DEF_PGPORT value. If
267 dnl we over-ride it with --with-pgport=port then we bypass this piece
268 AC_MSG_CHECKING(setting DEF_PGPORT)
271 [ --with-pgport=PORTNUM change default postmaster port ],
272 [default_port="$withval"],
275 dnl Need both of these because backend wants an integer and frontend a string
276 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
277 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
278 AC_MSG_RESULT(${default_port})
281 dnl DEF_MAXBACKENDS can be set by --with-maxbackends. Default value is 32.
282 AC_MSG_CHECKING(setting DEF_MAXBACKENDS)
285 [ --with-maxbackends=N set default maximum number of server processes ],
286 AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, ${withval}) AC_MSG_RESULT($with_maxbackends),
287 AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, 32) AC_MSG_RESULT(32)
291 dnl Check for C support (allow override if needed)
292 dnl Note: actually, setting CC environment variable works just as well.
294 [ --with-CC=compiler use specific C compiler],
297 "" | y | ye | yes | n | no)
298 AC_MSG_ERROR([*** You must supply an argument to the --with-CC option.])
304 dnl Find a compiler if CC is not already set.
306 dnl Find CPP, then check traditional.
307 dnl Caution: these macros must be called in this order...
309 AC_PROG_GCC_TRADITIONAL
312 if test "$CC" = "gcc"
314 CC_VERSION=`${CC} --version`
321 dnl We exclude tcl support unless user says --with-tcl
322 AC_MSG_CHECKING(setting USE_TCL)
325 [ --with-tcl build Tcl interfaces and pgtclsh ],
328 y | ye | yes) USE_TCL=true; USE_TK=true; AC_MSG_RESULT(enabled) ;;
329 *) USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ;;
332 [ USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ]
338 dnl We see if the path to the TCL/TK configuration scripts is specified.
339 dnl This will override the use of tclsh to find the paths to search.
341 AC_ARG_WITH(tclconfig,
342 [ --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR],
345 "" | y | ye | yes | n | no)
346 AC_MSG_ERROR([*** You must supply an argument to the --with-tclconfig option.])
353 dnl We see if the path to the TK configuration scripts is specified.
354 dnl This will override the use of tclsh to find the paths to search.
356 AC_ARG_WITH(tkconfig,
357 [ --with-tkconfig=DIR tkConfig.sh is in DIR],
360 "" | y | ye | yes | n | no)
361 AC_MSG_ERROR([*** You must supply an argument to the --with-tkconfig option.])
370 dnl Optionally build Perl modules (Pg.pm and PL/Perl)
372 AC_MSG_CHECKING(whether to build Perl modules)
373 AC_ARG_WITH(perl, [ --with-perl build Perl interface and plperl],
374 [if test x"${withval}" = x"yes" ; then
384 dnl Optionally build Python interface module
386 AC_MSG_CHECKING(whether to build Python modules)
387 AC_ARG_WITH(python, [ --with-python build Python interface module],
388 [if test x"${withval}" = x"yes" ; then
396 AC_SUBST(with_python)
400 dnl Optionally build with Kerberos 4 support
402 AC_MSG_CHECKING(whether to build with Kerberos 4 support)
403 AC_ARG_WITH(krb4, [ --with-krb4[=DIR] use Kerberos 4 [/usr/athena]],
404 [if test x"$withval" != x"no"; then
405 # If the user didn't give an argument, we take the Kerberos 4 default
406 # path /usr/athena. We look into lib/ and include/ for the Kerberos
407 # libraries and includes. If the user has a more complicated layout
408 # he can use --with-includes and --with-libraries.
409 if test x"$withval" = x"yes"; then
416 if test -d $krb4dir; then
417 if test -d "$krb4dir/include"; then
418 INCLUDES="$INCLUDES -I$krb4dir/include"
420 if test -d "$krb4dir/lib"; then
421 krb_libdir="-L$krb4dir/lib"
422 LIBS="$krb_libdir $LIBS"
425 AC_CHECK_LIB(des, main, [], [AC_MSG_ERROR([library \`des' is required for Kerberos 4])])
426 AC_CHECK_LIB(krb, main, [], [AC_MSG_ERROR([library \`krb' is required for Kerberos 4])])
427 KRB_LIBS="$krb_libdir -lkrb -ldes"
428 AC_DEFINE(KRB4,, [Define if you are building with Kerberos 4 support.])
437 dnl Optionally build with Kerberos 5 support
439 AC_MSG_CHECKING(whether to build with Kerberos 5 support)
440 AC_ARG_WITH(krb5, [ --with-krb5[=DIR] use Kerberos 5 [/usr/athena]],
441 [if test x"$withval" != x"no"; then
442 if test x"$withval" = x"yes"; then
449 if test -d $krb5dir; then
450 if test -d "$krb5dir/include"; then
451 INCLUDES="$INCLUDES -I$krb5dir/include"
453 if test -d "$krb5dir/lib"; then
454 krb_libdir="-L$krb5dir/lib"
455 LIBS="$krb_libdir $LIBS"
458 AC_CHECK_LIB(com_err, main, [], [AC_MSG_ERROR([library \`com_err' is required for Kerberos 5])])
459 AC_CHECK_LIB(crypto, main, [], [AC_MSG_ERROR([library \`crypto' is required for Kerberos 5])])
460 AC_CHECK_LIB(krb5, main, [], [AC_MSG_ERROR([library \`krb5' is required for Kerberos 5])])
461 KRB_LIBS="$krb_libdir -lkrb5 -lcrypto -lcom_err"
462 AC_DEFINE(KRB5,, [Define if you are building with Kerberos 5 support.])
469 dnl Necessary for special libpq link
474 dnl Kerberos configuration parameters
476 AC_ARG_WITH(krb-srvnam, [ --with-krb-srvnam=NAME name of the Postgres service principal in Kerberos],
477 [if test x"$withval" = x"yes"; then
478 AC_MSG_ERROR([argument required for --with-krb-srvnam])
482 [krb_srvnam="postgres"])
483 AC_DEFINE_UNQUOTED(PG_KRB_SRVNAM, ["$krb_srvnam"], [The name of the Postgres service principal])
485 AC_ARG_WITH(krb-srvtab, [ --with-krb-srvtab=FILE location of Kerberos server's keytab file],
486 [if test x"$withval" = x"yes"; then
487 AC_MSG_ERROR([argument required for --with-krb-srvtab])
491 [if test x"$with_krb5" = x"yes"; then
492 krb_srvtab="FILE:/usr/local/postgres/krb5.keytab"
494 krb_srvtab="/etc/srvtab"
496 AC_DEFINE_UNQUOTED(PG_KRB_SRVTAB, ["$krb_srvtab"], [The location of the Kerberos server's keytab file])
501 dnl Optionally enable the building of the ODBC driver
505 if test "x${with_odbc+set}" = xset && test "x${enable_odbc+set}" != xset; then
506 enable_odbc=$with_odbc
509 AC_MSG_CHECKING(whether to build the ODBC driver)
510 AC_ARG_ENABLE(odbc, [ --enable-odbc build the ODBC driver package],
511 [if test x"$enableval" = x"yes" ; then
517 AC_SUBST(enable_odbc)
520 dnl Allow for overriding the default location of the odbcinst.ini
521 dnl file which is normally ${datadir} (i.e., ${prefix}/share).
522 if test x"$enable_odbc" = x"yes" ; then
523 AC_ARG_WITH(odbcinst, [ --with-odbcinst=DIR default directory for odbcinst.ini [datadir]],
524 [if test x"$with_odbcinst" = x"yes" || test x"$with_odbcinst" = x"no" ; then
525 AC_MSG_ERROR([You must supply an argument to the --with-odbcinst option.])
527 odbcinst_ini_dir=$withval],
528 [odbcinst_ini_dir='${datadir}'])
530 odbcinst_ini_dir='${datadir}'
532 AC_SUBST(odbcinst_ini_dir)
536 dnl Unless we specify the command line options
537 dnl --enable cassert to explicitly enable it
538 dnl If you do not explicitly do it, it defaults to disabled
539 AC_MSG_CHECKING(setting ASSERT CHECKING)
542 [ --enable-cassert enable assertion checks (for debugging) ],
543 AC_DEFINE(USE_ASSERT_CHECKING) AC_MSG_RESULT(enabled),
544 AC_MSG_RESULT(disabled)
547 CPPFLAGS="$CPPFLAGS $INCLUDES"
548 echo "- setting CPPFLAGS=$CPPFLAGS"
550 LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
551 echo "- setting LDFLAGS=$LDFLAGS"
553 dnl --enable-debug adds -g to compiler flags
554 dnl --disable-debug will forcefully remove it
555 AC_MSG_CHECKING(setting debug compiler flag)
558 [ --enable-debug build with debugging symbols (-g) ],
563 AC_MSG_RESULT(enabled)
566 CFLAGS=`echo "$CFLAGS" | sed -e 's/ -g/ /g' | sed -e 's/^-g//'`
567 AC_MSG_RESULT(disabled)
571 AC_MSG_RESULT(using default)
574 # Assume system is ELF if it predefines __ELF__ as 1,
575 # otherwise believe "elf" setting from check of host_os above.
582 [if test "X$elf" = "Xyes"
607 dnl Optionally build C++ code (i.e., libpq++)
609 AC_MSG_CHECKING(whether to build C++ modules)
610 AC_ARG_WITH(CXX, [ --with-CXX build C++ modules (libpq++)],
611 [if test "x${withval+set}" = xset; then
613 if test x"$withval" != xyes ; then
619 PGAC_CXX_NAMESPACE_STD
628 dnl Figure out how to invoke "install" and what install options to use.
633 INSTL_EXE_OPTS="-m 555"
634 INSTL_SCRIPT_OPTS="-m 755"
635 INSTL_LIB_OPTS="-m 644"
636 INSTL_SHLIB_OPTS="-m 644"
638 dnl HPUX wants shared libs to be mode 555.
641 INSTL_SHLIB_OPTS="-m 555" ;;
645 AC_SUBST(INSTL_LIB_OPTS)
646 AC_SUBST(INSTL_SHLIB_OPTS)
647 AC_SUBST(INSTL_EXE_OPTS)
649 dnl Fix autoconf's brain-dead defaults for script and shlib installs.
651 INSTALL_SCRIPT="\${INSTALL} $INSTL_SCRIPT_OPTS"
652 AC_SUBST(INSTALL_SCRIPT)
654 INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
655 AC_SUBST(INSTALL_SHLIB)
661 if test "$LEX" = "flex"; then
662 $LEX --version 2> /dev/null | grep -s '2\.5\.3' > /dev/null 2>&1
663 if test $? -eq 0 ; then
666 You have flex version 2.5.3, which is broken. Get version 2.5.4 or
668 (If you are using the official distribution of PostgreSQL then you
669 do not need to worry about this because the lexer files are
670 pre-generated. However, other software using flex is likely to be
677 AC_PATH_PROG(find, find)
678 AC_PATH_PROG(tar, tar)
679 AC_PATH_PROG(split, split)
680 AC_PATH_PROG(etags, etags)
681 AC_PATH_PROG(xargs, xargs)
682 AC_PATH_PROGS(GZCAT, gzcat zcat, gzcat)
683 AC_CHECK_PROGS(PERL, perl,)
688 AC_CHECK_LIB(sfio, main)
689 AC_CHECK_LIB(ncurses, main, [], [AC_CHECK_LIB(curses, main)])
690 AC_CHECK_LIB(termcap, main)
691 AC_CHECK_LIB(readline, main)
692 AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
693 AC_CHECK_LIB(history, main) )
695 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
697 AC_CHECK_LIB(bsd, main)
699 AC_CHECK_LIB(util, main)
700 AC_CHECK_LIB(m, main)
701 AC_CHECK_LIB(dl, main)
702 AC_CHECK_LIB(socket, main)
703 AC_CHECK_LIB(nsl, main)
704 AC_CHECK_LIB(ipc, main)
705 AC_CHECK_LIB(IPC, main)
706 AC_CHECK_LIB(lc, main)
707 AC_CHECK_LIB(dld, main)
708 AC_CHECK_LIB(ln, main)
709 AC_CHECK_LIB(ld, main)
710 AC_CHECK_LIB(compat, main)
711 AC_CHECK_LIB(BSD, main)
712 AC_CHECK_LIB(crypt, main)
713 AC_CHECK_LIB(gen, main)
714 AC_CHECK_LIB(PW, main)
716 dnl Checks for header files.
719 AC_CHECK_HEADERS(arpa/inet.h)
720 AC_CHECK_HEADERS(crypt.h)
721 AC_CHECK_HEADERS(dld.h)
722 AC_CHECK_HEADERS(endian.h)
723 AC_CHECK_HEADERS(float.h)
724 AC_CHECK_HEADERS(fp_class.h)
725 AC_CHECK_HEADERS(getopt.h)
726 AC_CHECK_HEADERS(history.h)
727 AC_CHECK_HEADERS(ieeefp.h)
728 AC_CHECK_HEADERS(limits.h)
729 AC_CHECK_HEADERS(netdb.h)
730 AC_CHECK_HEADERS(netinet/in.h)
731 AC_CHECK_HEADERS(readline.h)
732 AC_CHECK_HEADERS(readline/history.h)
733 AC_CHECK_HEADERS(readline/readline.h)
734 AC_CHECK_HEADERS(sys/select.h)
735 AC_CHECK_HEADERS(termios.h)
736 AC_CHECK_HEADERS(unistd.h)
737 AC_CHECK_HEADERS(values.h)
738 AC_CHECK_HEADERS(sys/exec.h sys/pstat.h machine/vmparam.h)
739 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
740 AC_CHECK_HEADERS(sys/param.h pwd.h)
743 dnl Checks for typedefs, structures, and compiler characteristics.
754 AC_FUNC_ACCEPT_ARGTYPES
757 PGAC_VAR_INT_TIMEZONE
758 PGAC_FUNC_GETTIMEOFDAY_1ARG
762 AC_MSG_CHECKING(for fcntl(F_SETLK))
763 AC_TRY_LINK([#include <fcntl.h>],
765 lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
766 lck.l_type = F_WRLCK;
767 fcntl(0, F_SETLK, &lck);],
768 [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
771 dnl Checks for library functions.
775 AC_CHECK_FUNCS(memmove sysconf)
776 AC_CHECK_FUNCS(sigprocmask waitpid setsid fcvt)
777 AC_CHECK_FUNCS(setproctitle pstat)
779 AC_MSG_CHECKING(for PS_STRINGS)
781 [#ifdef HAVE_MACHINE_VMPARAM_H
782 # include <machine/vmparam.h>
784 #ifdef HAVE_SYS_EXEC_H
785 # include <sys/exec.h>
787 [PS_STRINGS->ps_nargvstr = 1;
788 PS_STRINGS->ps_argvstr = "foo";],
789 [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PS_STRINGS)],
792 AC_CHECK_FUNCS(fpclass fp_class fp_class_d class)
793 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
794 dnl is missing. Yes, there are machines that have only one.
795 dnl We may also decide to use snprintf.c if snprintf() is present but does
796 dnl not have working "long long int" support -- see below.
798 AC_CHECK_FUNC(snprintf,
799 AC_DEFINE(HAVE_SNPRINTF),
800 SNPRINTF='snprintf.o')
801 AC_CHECK_FUNC(vsnprintf,
802 AC_DEFINE(HAVE_VSNPRINTF),
803 SNPRINTF='snprintf.o')
805 dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
806 dnl include/c.h will provide declarations. Note this is a separate test
807 dnl from whether the functions exist in the C library --- there are systems
808 dnl that have the functions but don't bother to declare them :-(
809 dnl Note: simple-minded pattern here will do wrong thing if stdio.h
810 dnl declares vsnprintf() but not snprintf(). Hopefully there are no
811 dnl systems that are *that* brain-damaged...
812 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
813 AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
815 dnl do this one the hard way in case isinf() is a macro
816 AC_MSG_CHECKING(for isinf)
817 AC_CACHE_VAL(ac_cv_func_or_macro_isinf,
820 [double x = 0.0; int res = isinf(x);],
821 [ac_cv_func_or_macro_isinf=yes],
822 [ac_cv_func_or_macro_isinf=no])])
823 if [[ $ac_cv_func_or_macro_isinf = yes ]]; then
825 AC_DEFINE(HAVE_ISINF)
832 AC_CHECK_FUNC(getrusage,
833 AC_DEFINE(HAVE_GETRUSAGE),
834 GETRUSAGE='getrusage.o')
836 AC_CHECK_FUNC(srandom,
837 AC_DEFINE(HAVE_SRANDOM),
840 AC_CHECK_FUNC(gethostname,
841 AC_DEFINE(HAVE_GETHOSTNAME),
842 GETHOSTNAME='gethostname.o')
843 AC_SUBST(GETHOSTNAME)
844 AC_CHECK_FUNC(random,
845 AC_DEFINE(HAVE_RANDOM),
846 MISSING_RANDOM='random.o')
847 AC_SUBST(MISSING_RANDOM)
848 AC_CHECK_FUNC(inet_aton,
849 AC_DEFINE(HAVE_INET_ATON),
850 INET_ATON='inet_aton.o')
852 AC_CHECK_FUNC(strerror,
853 AC_DEFINE(HAVE_STRERROR),
854 [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
857 AC_CHECK_FUNC(strdup,
858 AC_DEFINE(HAVE_STRDUP),
859 STRDUP='../../utils/strdup.o')
861 AC_CHECK_FUNC(strtol,
862 AC_DEFINE(HAVE_STRTOL),
865 AC_CHECK_FUNC(strtoul,
866 AC_DEFINE(HAVE_STRTOUL),
869 AC_CHECK_FUNC(strcasecmp,
870 AC_DEFINE(HAVE_STRCASECMP),
871 STRCASECMP='strcasecmp.o')
874 AC_DEFINE(HAVE_CBRT),
875 AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
877 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
878 # this hackery with HPUXMATHLIB allows us to cope.
882 if [[ -r /lib/pa1.1/libm.a ]] ; then
883 HPUXMATHLIB="-L /lib/pa1.1 -lm"
886 AC_SUBST(HPUXMATHLIB)
889 AC_DEFINE(HAVE_RINT),
890 AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
892 dnl Some old versions of libreadline don't have rl_completion_append_character
893 AC_EGREP_HEADER(rl_completion_append_character, readline.h,
894 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER),
895 [AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h,
896 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
897 AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
899 dnl Check for readline's filename_completion_function.
900 dnl Some versions have it but it's not in the headers, so we have to take
901 dnl care of that, too.
902 AC_CHECK_FUNCS(filename_completion_function,
903 AC_EGREP_HEADER(filename_completion_function, readline.h,
904 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
905 [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
906 AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
908 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
909 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
911 dnl Check for GNU style long options support (getopt_long)
912 AC_CHECK_FUNCS(getopt_long)
914 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
915 AC_MSG_CHECKING(for finite)
916 AC_TRY_LINK([#include <math.h>],
917 [int dummy=finite(1.0);],
918 [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
921 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
922 dnl (especially on GNU libc)
923 dnl See also comments in config.h.
924 AC_MSG_CHECKING(for sigsetjmp)
925 AC_TRY_LINK([#include <setjmp.h>],
926 [sigjmp_buf x; sigsetjmp(x, 1);],
927 [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
930 AC_ARG_ENABLE(syslog, [ --enable-syslog enable logging to syslog],
931 [case $enableval in y|ye|yes)
932 AC_CHECK_FUNC(syslog, [AC_DEFINE(ENABLE_SYSLOG)], [AC_MSG_ERROR([no syslog interface found])])
937 dnl Check to see if we have a working 64-bit integer type.
938 dnl This breaks down into two steps:
939 dnl (1) figure out if the compiler has a 64-bit int type with working
940 dnl arithmetic, and if so
941 dnl (2) see whether snprintf() can format the type correctly. (Currently,
942 dnl snprintf is the only library routine we really need for int8 support.)
943 dnl It's entirely possible to have a compiler that handles a 64-bit type
944 dnl when the C library doesn't; this is fairly likely when using gcc on
945 dnl an older platform, for example.
946 dnl If there is no native snprintf() or it does not handle the 64-bit type,
947 dnl we force our own version of snprintf() to be used instead.
948 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
950 PGAC_TYPE_64BIT_INT([long int])
952 if test x"$HAVE_LONG_INT_64" = x"no" ; then
953 PGAC_TYPE_64BIT_INT([long long int])
957 dnl If we found "long int" is 64 bits, assume snprintf handles it.
958 dnl If we found we need to use "long long int", better check.
959 dnl We cope with snprintfs that use either %lld or %qd as the format.
960 dnl If neither works, fall back to our own snprintf emulation (which we
963 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
964 if [[ x$SNPRINTF = x ]] ; then
965 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
966 AC_TRY_RUN([#include <stdio.h>
967 typedef long long int int64;
968 #define INT64_FORMAT "%lld"
973 int does_int64_snprintf_work()
978 if (sizeof(int64) != 8)
979 return 0; /* doesn't look like the right size */
982 snprintf(buf, 100, INT64_FORMAT, c);
983 if (strcmp(buf, "800000140000005") != 0)
984 return 0; /* either multiply or snprintf is busted */
988 exit(! does_int64_snprintf_work());
991 INT64_FORMAT='"%lld"'
994 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
995 AC_TRY_RUN([#include <stdio.h>
996 typedef long long int int64;
997 #define INT64_FORMAT "%qd"
1002 int does_int64_snprintf_work()
1007 if (sizeof(int64) != 8)
1008 return 0; /* doesn't look like the right size */
1011 snprintf(buf, 100, INT64_FORMAT, c);
1012 if (strcmp(buf, "800000140000005") != 0)
1013 return 0; /* either multiply or snprintf is busted */
1017 exit(! does_int64_snprintf_work());
1019 [ AC_MSG_RESULT(yes)
1020 INT64_FORMAT='"%qd"'
1023 # Force usage of our own snprintf, since system snprintf is broken
1024 SNPRINTF='snprintf.o'
1025 INT64_FORMAT='"%lld"'
1027 [ AC_MSG_RESULT(assuming not on target machine)
1028 # Force usage of our own snprintf, since we cannot test foreign snprintf
1029 SNPRINTF='snprintf.o'
1030 INT64_FORMAT='"%lld"'
1032 [ AC_MSG_RESULT(assuming not on target machine)
1033 # Force usage of our own snprintf, since we cannot test foreign snprintf
1034 SNPRINTF='snprintf.o'
1035 INT64_FORMAT='"%lld"'
1038 # here if we previously decided we needed to use our own snprintf
1039 INT64_FORMAT='"%lld"'
1042 # Here if we are not using 'long long int' at all
1043 INT64_FORMAT='"%ld"'
1046 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
1049 dnl Determine memory alignment requirements for the basic C datatypes.
1051 PGAC_CHECK_ALIGNOF(short)
1052 PGAC_CHECK_ALIGNOF(int)
1053 PGAC_CHECK_ALIGNOF(long)
1054 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1055 PGAC_CHECK_ALIGNOF(long long int)
1057 PGAC_CHECK_ALIGNOF(double)
1059 dnl Compute maximum alignment of any basic type.
1060 dnl We assume long's alignment is at least as strong as char, short, or int;
1061 dnl but we must check long long (if it exists) and double.
1063 if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
1064 MAX_ALIGNOF=$pgac_cv_alignof_long
1065 if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1066 MAX_ALIGNOF=$pgac_cv_alignof_double
1068 if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1069 MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1072 dnl cross-compiling: assume that double's alignment is worst case
1073 MAX_ALIGNOF="$pgac_cv_alignof_double"
1075 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1077 PGAC_FUNC_POSIX_SIGNALS
1080 dnl Check for Tcl configuration script tclConfig.sh
1082 dnl If --with-tclconfig was given, don't check for tclsh, tcl
1083 if test -z "$TCL_DIRS"
1085 AC_PATH_PROG(TCLSH, tclsh)
1088 AC_PATH_PROG(TCLSH, tcl)
1091 AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
1097 if test "$USE_TCL" = true
1099 AC_MSG_CHECKING(for tclConfig.sh)
1102 if test -z "$TCL_DIRS"
1104 library_dirs=`echo 'puts $auto_path' | $TCLSH`
1106 library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
1107 for dir in $library_dirs; do
1108 if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
1109 TCL_CONFIG_SH=$dir/tclConfig.sh
1113 if test -z "$TCL_CONFIG_SH"; then
1115 AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
1118 AC_MSG_RESULT($TCL_CONFIG_SH)
1119 AC_SUBST(TCL_CONFIG_SH)
1123 USE_TK=$USE_TCL # If TCL is disabled, disable TK
1125 dnl Check for Tk configuration script tkConfig.sh
1126 if test "$USE_TK" = true
1128 AC_MSG_CHECKING(for tkConfig.sh)
1130 # library_dirs are set in the check for TCL
1131 for dir in $library_dirs
1133 if test -d "$dir" -a -r "$dir/tkConfig.sh"
1135 TK_CONFIG_SH=$dir/tkConfig.sh
1139 if test -z "$TK_CONFIG_SH"
1142 AC_MSG_WARN(TK support disabled; Tk configuration script missing)
1145 AC_MSG_RESULT($TK_CONFIG_SH)
1146 AC_SUBST(TK_CONFIG_SH)
1147 AC_PATH_PROG(WISH, wish)
1153 dnl Check for X libraries
1155 if test "$USE_X" = true; then
1157 ice_save_LIBS="$LIBS"
1158 ice_save_CFLAGS="$CFLAGS"
1159 ice_save_CPPFLAGS="$CPPFLAGS"
1160 ice_save_LDFLAGS="$LDFLAGS"
1164 LIBS="$LIBS $X_EXTRA_LIBS"
1165 CFLAGS="$CFLAGS $X_CFLAGS"
1166 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1167 LDFLAGS="$LDFLAGS $X_LIBS"
1169 dnl Check for X library
1172 AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
1173 if test "$X11_LIBS" = ""; then
1174 dnl Not having X is bad news for pgtksh. Let the user fix this.
1175 AC_MSG_WARN([The X11 library '-lX11' could not be found,
1176 so TK support will be disabled. To enable TK support,
1177 please use the configure options '--x-includes=DIR'
1178 and '--x-libraries=DIR' to specify the X location.
1179 See the file 'config.log' for further diagnostics.])
1184 AC_SUBST(X_PRE_LIBS)
1186 LIBS="$ice_save_LIBS"
1187 CFLAGS="$ice_save_CFLAGS"
1188 CPPFLAGS="$ice_save_CPPFLAGS"
1189 LDFLAGS="$ice_save_LDFLAGS"
1193 dnl Finally ready to produce output files ...
1199 src/backend/port/Makefile
1200 src/backend/catalog/genbki.sh
1201 src/backend/utils/Gen_fmgrtab.sh
1202 src/bin/pgtclsh/mkMakefile.tcldefs.sh
1203 src/bin/pgtclsh/mkMakefile.tkdefs.sh
1204 src/include/version.h
1205 src/pl/tcl/mkMakefile.tcldefs.sh
1206 src/test/regress/GNUmakefile