1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(backend/access/common/heaptuple.c)
3 AC_PREFIX_DEFAULT(/usr/local/pgsql)
4 AC_CONFIG_HEADER(include/config.h)
6 dnl Autoconf 2.12, at least, generates a useless relative path to install-sh
8 AC_CONFIG_AUX_DIR(`pwd`)
16 sparc) os=solaris_sparc need_tas=yes tas_file=solaris_sparc.s ;;
17 i386) os=solaris_i386 need_tas=yes tas_file=solaris_i386.s ;;
19 sunos*) os=sunos4 need_tas=no ;;
20 beos) os=beos need_tas=no ;;
21 aux*) os=aux need_tas=no ;;
22 linux*) os=linux need_tas=no ;;
23 bsdi*) os=bsdi need_tas=no ;;
24 freebsd1*|freebsd2*) os=freebsd need_tas=no ;;
25 freebsd*) os=freebsd need_tas=no elf=yes ;;
31 openbsd*) os=bsd need_tas=no ;;
32 dgux*) os=dgux need_tas=no ;;
33 aix*) os=aix need_tas=no ;;
34 nextstep*) os=nextstep need_tas=no ;;
35 ultrix*) os=ultrix4 need_tas=no ;;
36 irix*) os=irix5 need_tas=no ;;
37 hpux*) os=hpux need_tas=yes tas_file=hpux.s ;;
38 osf*) os=alpha need_tas=no ;;
39 sco*) os=sco need_tas=no ;;
40 machten*) os=machten need_tas=no ;;
41 cygwin*) os=win need_tas=no ;;
43 case "$host_vendor" in
44 univel) os=univel need_tas=no ;;
45 *) os=unknown need_tas=no ;;
47 sysv4*) os=svr4 need_tas=no ;;
48 unixware*) os=unixware 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(backend/port/dynloader/${os}.c, backend/port/dynloader.c)
64 AC_LINK_FILES(backend/port/dynloader/${os}.h, include/dynloader.h)
65 AC_LINK_FILES(include/port/${os}.h, include/os.h)
66 AC_LINK_FILES(makefiles/Makefile.${os}, Makefile.port)
68 if test "X$need_tas" = "Xyes"
70 AC_LINK_FILES(backend/port/tas/${tas_file}, backend/port/tas.s)
75 echo "checking echo setting..."
76 if echo '\c' | grep -s c >/dev/null 2>&1
85 dnl this part selects the template from the ones in the template directory.
87 AC_MSG_CHECKING(setting template to)
89 [ --with-template=TEMPLATE
90 use operating system template file
91 see template directory],
92 [ TEMPLATE=$withval ],
94 # First, try for a template exactly matching $host
95 if test -f "template/$host"
98 # Next try for an exact match to a .similar entry.
99 # There shouldn't be multiple matches, but take the last if there are.
100 GUESS=`grep "^$host=" template/.similar | sed 's/^.*=//' | tail -1`
102 then TEMPLATE="$GUESS"
104 # Next look for a .similar entry that is a prefix of $host.
105 # If there are multiple matches, take the last one.
106 exec 4<template/.similar
109 SIMHOST=`expr "$LINE" : '\(.*\)='`
110 MATCH=`expr "$host" : "$SIMHOST"`
111 if test "$MATCH" != 0
112 then GUESS=`echo "$LINE" | sed 's/^.*=//'`
117 then TEMPLATE="$GUESS"
119 # Last chance ... maybe uname -s will match an entry.
120 TEMPLATE=`uname -s | tr A-Z a-z`
125 AC_MSG_RESULT($TEMPLATE)
128 if test ! -f "template/$TEMPLATE"; then
130 echo "$TEMPLATE does not exist"
132 echo "Available Templates (set using --with-template):"
139 dnl Read the selected template file.
140 dnl For reasons of backwards compatibility, lines of the form
141 dnl IDENTIFIER: something
142 dnl should be treated as variable assignments. However, we also want to
143 dnl allow other shell commands in the template file (in case the file
144 dnl needs to make conditional tests, etc). So, generate a temp file with
145 dnl the IDENTIFIER: lines translated, then source it.
149 sed 's/^\([A-Za-z_]*\):\(.*\)$/\1="\2"/' "template/$TEMPLATE" >conftest.sh
155 AC_ARG_WITH(includes,
156 [ --with-includes=DIR site header files for tk/tcl, etc in DIR],
159 "" | y | ye | yes | n | no)
160 AC_MSG_ERROR([*** You must supply an argument to the --with-includes option.])
163 INCLUDE_DIRS="$withval"
166 if test "$INCLUDE_DIRS" -o "$SRCH_INC"; then
167 for dir in $INCLUDE_DIRS $SRCH_INC; do
168 if test -d "$dir"; then
169 PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$dir"
171 AC_MSG_WARN([*** Include directory $dir does not exist.])
177 [ --with-libs=DIR also search for libraries in DIR],
180 "" | y | ye | yes | n | no)
181 AC_MSG_ERROR([*** You must supply an argument to the --with-libs option.])
184 LIBRARY_DIRS="$withval"
187 AC_ARG_WITH(libraries,
188 [ --with-libraries=DIR also search for libraries in DIR],
191 "" | y | ye | yes | n | no)
192 AC_MSG_ERROR([*** You must supply an argument to the --with-libraries option.])
195 LIBRARY_DIRS="$withval"
198 if test "$LIBRARY_DIRS" -o "$SRCH_LIB"; then
199 for dir in $LIBRARY_DIRS $SRCH_LIB; do
200 if test -d "$dir"; then
201 PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
203 AC_MSG_WARN([*** Library directory $dir does not exist.])
208 dnl We have read the default value of USE_LOCALE from the template
209 dnl file. We have a further option of using
210 dnl --enable-locale to explicitly enable it
211 dnl It defaults to disabled
212 AC_MSG_CHECKING(setting USE_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(setting CYR_RECODE)
226 [ --enable-recode enable cyrillic recode support ],
227 AC_DEFINE(CYR_RECODE) AC_MSG_RESULT(enabled),
228 AC_MSG_RESULT(disabled)
231 AC_MSG_CHECKING(setting MULTIBYTE)
233 [ --with-mb=<encoding> enable multi-byte support ],
236 EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
237 AC_MSG_RESULT("enabled with $withval")
240 AC_MSG_ERROR([*** You must supply an argument to the --with-mb option one of EUC_JP,EUC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL,LATIN1-5,KOI8,WIN,ALT])
245 AC_MSG_RESULT("disabled")
248 dnl We use the default value of 5432 for the DEF_PGPORT value. If
249 dnl we over-ride it with --with-pgport=port then we bypass this piece
250 AC_MSG_CHECKING(setting DEF_PGPORT)
253 [ --with-pgport=<portnum> change default startup port ],
254 AC_DEFINE_UNQUOTED(DEF_PGPORT, "${withval}") AC_MSG_RESULT($with_pgport),
255 AC_DEFINE_UNQUOTED(DEF_PGPORT, "5432") AC_MSG_RESULT(5432)
258 dnl DEF_MAXBACKENDS can be set by --with-maxbackends. Default value is 32.
259 AC_MSG_CHECKING(setting DEF_MAXBACKENDS)
262 [ --with-maxbackends=<n> set default maximum number of server processes ],
263 AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, ${withval}) AC_MSG_RESULT($with_maxbackends),
264 AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, 32) AC_MSG_RESULT(32)
267 dnl We exclude tcl support unless user says --with-tcl
268 AC_MSG_CHECKING(setting USE_TCL)
271 [ --with-tcl build Tcl interfaces and pgtclsh ],
274 y | ye | yes) USE_TCL=true; USE_TK=true; AC_MSG_RESULT(enabled) ;;
275 *) USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ;;
278 [ USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ]
284 dnl We see if the path to the TCL/TK configuration scripts is specified.
285 dnl This will overide the use of tclsh to find the paths to search.
287 AC_ARG_WITH(tclconfig,
288 [ --with-tclconfig=DIR tclConfig.sh and tkConfig.sh are in DIR],
291 "" | y | ye | yes | n | no)
292 AC_MSG_ERROR([*** You must supply an argument to the --with-tclconfig option.])
299 dnl We see if the path to the TK configuration scripts is specified.
300 dnl This will overide the use of tclsh to find the paths to search.
302 AC_ARG_WITH(tkconfig,
303 [ --with-tkconfig=DIR tkConfig.sh is in DIR],
306 "" | y | ye | yes | n | no)
307 AC_MSG_ERROR([*** You must supply an argument to the --with-tkconfig option.])
314 dnl We exclude perl support unless we override it with --with-perl
315 AC_MSG_CHECKING(setting USE_PERL)
318 [ --with-perl build Perl interface ],
321 y | ye | yes) USE_PERL=true; AC_MSG_RESULT(enabled) ;;
322 *) USE_PERL=false; AC_MSG_RESULT(disabled) ;;
325 [ USE_PERL=false; AC_MSG_RESULT(disabled) ]
328 dnl We include odbc support unless we disable it with --with-odbc=false
329 AC_MSG_CHECKING(setting USE_ODBC)
332 [ --with-odbc build ODBC driver package ],
335 y | ye | yes) USE_ODBC=true; AC_MSG_RESULT(enabled) ;;
336 *) USE_ODBC=false; AC_MSG_RESULT(disabled) ;;
339 [ USE_ODBC=false; AC_MSG_RESULT(disabled) ]
343 dnl Allow for overriding the default location of the odbcinst.ini
344 dnl file which is normally ${prefix}/share or ${prefix} if this is
345 dnl being compiled inside the postgres distribution.
346 dnl Link in the port and template directories
347 dnl to help build a "standalone ODBC" tar file
348 if test "X$USE_ODBC" = "Xtrue"
350 AC_LINK_FILES(include/port, interfaces/odbc/port)
351 AC_LINK_FILES(makefiles, interfaces/odbc/makefiles)
352 AC_LINK_FILES(template, interfaces/odbc/template)
353 AC_LINK_FILES(include/config.h, interfaces/odbc/config.h)
355 AC_MSG_CHECKING(setting ODBCINST)
358 [ --with-odbcinst=dir change default directory for odbcinst.ini],
359 AC_DEFINE_UNQUOTED(ODBCINST, ${with_odbcinst}) AC_MSG_RESULT($with_odbcinst),
360 AC_DEFINE_UNQUOTED(ODBCINST, ${ODBCINSTDIR}) AC_MSG_RESULT(${ODBCINSTDIR})
363 if test "X$with_odbcinst" != "X"
365 ODBCINSTDIR=$with_odbcinst
367 AC_SUBST(ODBCINSTDIR)
369 dnl Unless we specify the command line options
370 dnl --enable cassert to explicitly enable it
371 dnl If you do not explicitly do it, it defaults to disabled
372 AC_MSG_CHECKING(setting ASSERT CHECKING)
375 [ --enable-cassert enable assertion checks (debugging) ],
376 AC_DEFINE(USE_ASSERT_CHECKING) AC_MSG_RESULT(enabled),
377 AC_MSG_RESULT(disabled)
380 dnl Check for C support (allow override if needed)
381 dnl Note: actually, setting CC environment variable works just as well.
383 [ --with-CC=compiler use specific C compiler],
386 "" | y | ye | yes | n | no)
387 AC_MSG_ERROR([*** You must supply an argument to the --with-CC option.])
393 dnl Find a compiler if CC is not already set.
395 dnl Find CPP, then check traditional.
396 dnl Caution: these macros must be called in this order...
398 AC_PROG_GCC_TRADITIONAL
400 if test "$CC" = "gcc"
402 CC_VERSION=`${CC} --version`
408 CPPFLAGS="$CPPFLAGS $PGSQL_CPPFLAGS"
409 echo "- setting CPPFLAGS=$CPPFLAGS"
411 LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
412 echo "- setting LDFLAGS=$LDFLAGS"
414 dnl --enable-debug adds -g to compiler flags
415 dnl --disable-debug will forcefully remove it
416 AC_MSG_CHECKING(setting debug compiler flag)
419 [ --enable-debug build with debugging symbols (-g) ],
424 AC_MSG_RESULT(enabled)
427 CFLAGS=`echo "$CFLAGS" | sed -e 's/ -g/ /g' | sed -e 's/^-g//'`
428 AC_MSG_RESULT(disabled)
432 AC_MSG_RESULT(using default)
435 # Assume system is ELF if it predefines __ELF__ as 1,
436 # otherwise believe "elf" setting from check of host_os above.
443 [if test "X$elf" = "Xyes"
469 dnl Check for C++ support (allow override if needed)
470 HAVECXX='HAVE_Cplusplus=true'
472 [ --with-CXX=compiler use specific C++ compiler
473 --without-CXX prevent building C++ code ],
477 AC_MSG_ERROR([*** You must supply an argument to the --with-CC option.])
480 HAVECXX='HAVE_Cplusplus=false'
488 dnl make sure we revert to C compiler, not C++, for subsequent tests
491 dnl Figure out how to invoke "install" and what install options to use.
496 INSTL_EXE_OPTS="-m 555"
497 INSTL_LIB_OPTS="-m 644"
498 INSTL_SHLIB_OPTS="-m 644"
500 dnl HPUX wants shared libs to be mode 555.
503 INSTL_SHLIB_OPTS="-m 555" ;;
508 AC_SUBST(INSTL_LIB_OPTS)
509 AC_SUBST(INSTL_SHLIB_OPTS)
510 AC_SUBST(INSTL_EXE_OPTS)
512 dnl Check the option to echo to inhibit newlines.
513 ECHO_N_OUT=`echo -n "" | wc -c`
514 ECHO_C_OUT=`echo "\c" | wc -c`
515 if test "$ECHO_N_OUT" -eq 0; then
519 if test "ECHO_C_OUT" -eq 0; then
523 AC_MSG_ERROR("echo behaviour undetermined")
527 AC_SUBST(BACKSLASH_C)
533 AC_PATH_PROG(find, find)
534 AC_PATH_PROG(tar, tar)
535 AC_PATH_PROG(split, split)
536 AC_PATH_PROG(etags, etags)
537 AC_PATH_PROG(xargs, xargs)
538 AC_PATH_PROG(ipcs, ipcs)
539 AC_PATH_PROG(ipcrm, ipcrm)
540 AC_PATH_PROGS(TR, trbsd tr, NOT_FOUND)
541 AC_PATH_PROGS(GZCAT, gzcat zcat, gzcat)
543 dnl Check tr flags to convert from lower to upper case
544 TRSTRINGS="`echo ABCdef | $TR '[[a-z]]' '[[A-Z]]' 2>/dev/null | grep ABCDEF`"
545 TRCLASS="`echo ABCdef | $TR '[[:lower:]]' '[[:upper:]]' 2>/dev/null | grep ABCDEF`"
547 if test "$TRSTRINGS" = "ABCDEF"; then
548 TRARGS="'[[a-z]]' '[[A-Z]]'"
549 elif test "$TRCLASS" = "ABCDEF"; then
550 TRARGS="'[[:lower:]]' '[[:upper:]]'"
552 AC_MSG_ERROR("Can\'t find method to convert from upper to lower case with tr")
556 dnl Changes to look for YACC. We have three choices (in order of pref.)
557 dnl (1) We specify in YACC and YFLAGS what we want
558 dnl (2) We have bison and we use bison -y
559 dnl (3) We have yacc and use it
563 echo "- Using $YACC $YFLAGS"
565 AC_PATH_PROG(bison, bison)
568 echo "- Using $bison -y $YFLAGS"
572 AC_PATH_PROG(yacc, yacc)
573 echo "- Using $yacc $YFLAGS"
580 AC_CHECK_LIB(sfio, main)
581 for curses in ncurses curses ; do
582 AC_CHECK_LIB(${curses}, main,
583 [LIBS="-l${curses} $LIBS"; break])
585 AC_CHECK_LIB(termcap, main)
586 AC_CHECK_LIB(history, main)
587 AC_CHECK_LIB(readline, main)
588 AC_CHECK_LIB(readline, write_history, AC_DEFINE(HAVE_HISTORY))
589 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
591 AC_CHECK_LIB(bsd, main)
593 AC_CHECK_LIB(m, main)
594 AC_CHECK_LIB(dl, main)
595 AC_CHECK_LIB(socket, main)
596 AC_CHECK_LIB(nsl, main)
597 AC_CHECK_LIB(ipc, main)
598 AC_CHECK_LIB(IPC, main)
599 AC_CHECK_LIB(lc, main)
600 AC_CHECK_LIB(dld, main)
601 AC_CHECK_LIB(ln, main)
602 AC_CHECK_LIB(ld, main)
603 AC_CHECK_LIB(compat, main)
604 AC_CHECK_LIB(BSD, main)
605 AC_CHECK_LIB(crypt, main)
606 AC_CHECK_LIB(gen, main)
607 AC_CHECK_LIB(PW, main)
609 dnl Checks for header files.
612 AC_CHECK_HEADERS(arpa/inet.h)
613 AC_CHECK_HEADERS(crypt.h)
614 AC_CHECK_HEADERS(dld.h)
615 AC_CHECK_HEADERS(endian.h)
616 AC_CHECK_HEADERS(float.h)
617 AC_CHECK_HEADERS(fp_class.h)
618 AC_CHECK_HEADERS(getopt.h)
619 AC_CHECK_HEADERS(history.h)
620 AC_CHECK_HEADERS(ieeefp.h)
621 AC_CHECK_HEADERS(limits.h)
622 AC_CHECK_HEADERS(netdb.h)
623 AC_CHECK_HEADERS(netinet/in.h)
624 AC_CHECK_HEADERS(readline.h)
625 AC_CHECK_HEADERS(readline/history.h)
626 AC_CHECK_HEADERS(readline/readline.h)
627 AC_CHECK_HEADERS(sys/select.h)
628 AC_CHECK_HEADERS(termios.h)
629 AC_CHECK_HEADERS(unistd.h)
630 AC_CHECK_HEADERS(values.h)
632 AC_CHECK_HEADERS(sys/param.h pwd.h)
635 dnl Checks for typedefs, structures, and compiler characteristics.
647 AC_MSG_CHECKING(for signed types)
649 [signed char c; signed short s; signed int i;],
650 [AC_MSG_RESULT(yes)],
651 [AC_DEFINE(signed, ) AC_MSG_RESULT(no)])
653 AC_MSG_CHECKING(for volatile)
655 [extern volatile int i;],
656 [AC_MSG_RESULT(yes)],
657 [AC_DEFINE(volatile, ) AC_MSG_RESULT(no)])
659 AC_MSG_CHECKING(for type of last arg to accept)
660 AC_TRY_COMPILE([#include <stdlib.h>
661 #include <sys/types.h>
662 #include <sys/socket.h>
664 [int a = accept(1, (struct sockaddr *) 0, (size_t *) 0);],
665 [AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)],
666 [AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)])
668 dnl Check for any "odd" conditions
669 AC_MSG_CHECKING(for int timezone)
670 AC_TRY_LINK([#include <time.h>],
671 [int res = timezone / 60; ],
672 [AC_DEFINE(HAVE_INT_TIMEZONE) AC_MSG_RESULT(yes)],
675 AC_MSG_CHECKING(for gettimeofday args)
676 AC_TRY_LINK([#include <sys/time.h>],
677 [struct timeval *tp; struct timezone *tzp; gettimeofday(tp,tzp); ],
678 [AC_DEFINE(HAVE_GETTIMEOFDAY_2_ARGS) AC_MSG_RESULT(2 args)],
681 AC_MSG_CHECKING(for union semun)
682 AC_TRY_LINK([#include <sys/types.h>
684 #include <sys/sem.h>],
685 [union semun semun;],
686 [AC_DEFINE(HAVE_UNION_SEMUN) AC_MSG_RESULT(yes)],
689 AC_MSG_CHECKING(for fcntl(F_SETLK))
690 AC_TRY_LINK([#include <fcntl.h>],
692 lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
693 lck.l_type = F_WRLCK;
694 fcntl(0, F_SETLK, &lck);],
695 [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
698 dnl Checks for library functions.
702 AC_CHECK_FUNCS(memmove sigsetjmp sysconf)
703 AC_CHECK_FUNCS(sigprocmask waitpid setsid fcvt)
704 AC_CHECK_FUNCS(fpclass fp_class fp_class_d class)
705 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
706 dnl is missing. Yes, there are machines that have only one.
707 dnl We may also decide to use snprintf.c if snprintf() is present but does
708 dnl not have working "long long int" support -- see below.
710 AC_CHECK_FUNC(snprintf,
711 AC_DEFINE(HAVE_SNPRINTF),
712 SNPRINTF='snprintf.o')
713 AC_CHECK_FUNC(vsnprintf,
714 AC_DEFINE(HAVE_VSNPRINTF),
715 SNPRINTF='snprintf.o')
717 dnl do this one the hard way in case isinf() is a macro
718 AC_MSG_CHECKING(for isinf)
719 AC_CACHE_VAL(ac_cv_func_or_macro_isinf,
722 [double x = 0.0; int res = isinf(x);],
723 [ac_cv_func_or_macro_isinf=yes],
724 [ac_cv_func_or_macro_isinf=no])])
725 if [[ $ac_cv_func_or_macro_isinf = yes ]]; then
727 AC_DEFINE(HAVE_ISINF)
734 AC_CHECK_FUNC(getrusage,
735 AC_DEFINE(HAVE_GETRUSAGE),
736 GETRUSAGE='getrusage.o')
738 AC_CHECK_FUNC(srandom,
739 AC_DEFINE(HAVE_SRANDOM),
742 AC_CHECK_FUNC(gethostname,
743 AC_DEFINE(HAVE_GETHOSTNAME),
744 GETHOSTNAME='gethostname.o')
745 AC_SUBST(GETHOSTNAME)
746 AC_CHECK_FUNC(random,
747 AC_DEFINE(HAVE_RANDOM),
748 MISSING_RANDOM='random.o')
749 AC_SUBST(MISSING_RANDOM)
750 AC_CHECK_FUNC(inet_aton,
751 AC_DEFINE(HAVE_INET_ATON),
752 INET_ATON='inet_aton.o')
754 AC_CHECK_FUNC(strerror,
755 AC_DEFINE(HAVE_STRERROR),
756 [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
759 AC_CHECK_FUNC(strdup,
760 AC_DEFINE(HAVE_STRDUP),
761 STRDUP='../../utils/strdup.o')
763 AC_CHECK_FUNC(strtol,
764 AC_DEFINE(HAVE_STRTOL),
767 AC_CHECK_FUNC(strtoul,
768 AC_DEFINE(HAVE_STRTOUL),
771 AC_CHECK_FUNC(strcasecmp,
772 AC_DEFINE(HAVE_STRCASECMP),
773 STRCASECMP='strcasecmp.o')
776 AC_DEFINE(HAVE_CBRT),
777 AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
779 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
780 # this hackery with HPUXMATHLIB allows us to cope.
784 if [[ -r /lib/pa1.1/libm.a ]] ; then
785 HPUXMATHLIB="-L /lib/pa1.1 -lm"
788 AC_SUBST(HPUXMATHLIB)
791 AC_DEFINE(HAVE_RINT),
792 AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
794 AC_MSG_CHECKING(for finite() macro or function)
795 AC_TRY_LINK([#include <math.h>],
796 [int dummy=finite(1.0);],
797 [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
800 dnl Check to see if we have a working 64-bit integer type.
801 dnl This breaks down into two steps:
802 dnl (1) figure out if the compiler has a 64-bit int type with working
803 dnl arithmetic, and if so
804 dnl (2) see whether snprintf() can format the type correctly. (Currently,
805 dnl snprintf is the only library routine we really need for int8 support.)
806 dnl It's entirely possible to have a compiler that handles a 64-bit type
807 dnl when the C library doesn't; this is fairly likely when using gcc on
808 dnl an older platform, for example.
809 dnl If there is no native snprintf() or it does not handle the 64-bit type,
810 dnl we force our own version of snprintf() to be used instead.
811 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
814 AC_MSG_CHECKING(whether 'long int' is 64 bits)
815 AC_TRY_RUN([typedef long int int64;
817 /* These are globals to discourage the compiler from folding all the
818 * arithmetic tests down to compile-time constants.
823 int does_int64_work()
827 if (sizeof(int64) != 8)
828 return 0; /* doesn't look like the right size */
830 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
838 exit(! does_int64_work());
841 AC_DEFINE(HAVE_LONG_INT_64)
844 AC_MSG_RESULT(assuming not on target machine))
846 HAVE_LONG_LONG_INT_64=0
847 if [[ $HAVE_LONG_INT_64 -eq 0 ]] ; then
848 AC_MSG_CHECKING(whether 'long long int' is 64 bits)
849 AC_TRY_RUN([typedef long long int int64;
851 /* These are globals to discourage the compiler from folding all the
852 * arithmetic tests down to compile-time constants.
857 int does_int64_work()
861 if (sizeof(int64) != 8)
862 return 0; /* doesn't look like the right size */
864 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
872 exit(! does_int64_work());
874 [HAVE_LONG_LONG_INT_64=1
875 AC_DEFINE(HAVE_LONG_LONG_INT_64)
878 AC_MSG_RESULT(assuming not on target machine))
881 dnl If we found "long int" is 64 bits, assume snprintf handles it.
882 dnl If we found we need to use "long long int", better check.
883 dnl We cope with snprintfs that use either %lld or %qd as the format.
884 dnl If neither works, fall back to our own snprintf emulation (which we
887 if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then
888 if [[ x$SNPRINTF = x ]] ; then
889 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
890 AC_TRY_RUN([#include <stdio.h>
891 typedef long long int int64;
892 #define INT64_FORMAT "%lld"
897 int does_int64_snprintf_work()
902 if (sizeof(int64) != 8)
903 return 0; /* doesn't look like the right size */
906 snprintf(buf, 100, INT64_FORMAT, c);
907 if (strcmp(buf, "800000140000005") != 0)
908 return 0; /* either multiply or snprintf is busted */
912 exit(! does_int64_snprintf_work());
915 INT64_FORMAT='"%lld"'
918 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
919 AC_TRY_RUN([#include <stdio.h>
920 typedef long long int int64;
921 #define INT64_FORMAT "%qd"
926 int does_int64_snprintf_work()
931 if (sizeof(int64) != 8)
932 return 0; /* doesn't look like the right size */
935 snprintf(buf, 100, INT64_FORMAT, c);
936 if (strcmp(buf, "800000140000005") != 0)
937 return 0; /* either multiply or snprintf is busted */
941 exit(! does_int64_snprintf_work());
947 # Force usage of our own snprintf, since system snprintf is broken
948 SNPRINTF='snprintf.o'
949 INT64_FORMAT='"%lld"'
951 [ AC_MSG_RESULT(assuming not on target machine)
952 # Force usage of our own snprintf, since we cannot test foreign snprintf
953 SNPRINTF='snprintf.o'
954 INT64_FORMAT='"%lld"'
956 [ AC_MSG_RESULT(assuming not on target machine)
957 # Force usage of our own snprintf, since we cannot test foreign snprintf
958 SNPRINTF='snprintf.o'
959 INT64_FORMAT='"%lld"'
962 # here if we previously decided we needed to use our own snprintf
963 INT64_FORMAT='"%lld"'
966 # Here if we are not using 'long long int' at all
970 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
973 dnl Determine memory alignment requirements for the basic C datatypes.
975 dnl CHECK_ALIGNOF(TYPE)
976 dnl This is modeled on the standard autoconf macro AC_CHECK_SIZEOF,
977 dnl except it finds the alignment requirement of the type instead of the size.
978 dnl The defined symbol is named ALIGNOF_TYPE, where the type name is
979 dnl converted in the same way as for AC_CHECK_SIZEOF.
980 dnl If cross-compiling, sizeof(type) is used as a default assumption.
982 AC_DEFUN(CHECK_ALIGNOF,
983 [changequote(<<, >>)dnl
984 dnl The name to #define.
985 define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
986 dnl The cache variable name.
987 define(<<AC_CV_NAME>>, translit(ac_cv_alignof_$1, [ *], [_p]))dnl
989 AC_MSG_CHECKING(alignment of $1)
990 AC_CACHE_VAL(AC_CV_NAME,
991 [AC_TRY_RUN([#include <stdio.h>
992 struct { char filler; $1 field; } mystruct;
995 FILE *f=fopen("conftestval", "w");
997 fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct));
999 }], AC_CV_NAME=`cat conftestval`,
1000 AC_CV_NAME='sizeof($1)',
1001 AC_CV_NAME='sizeof($1)')])dnl
1002 AC_MSG_RESULT($AC_CV_NAME)
1003 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
1004 undefine([AC_TYPE_NAME])dnl
1005 undefine([AC_CV_NAME])dnl
1008 CHECK_ALIGNOF(short)
1011 if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then
1012 CHECK_ALIGNOF(long long int)
1014 CHECK_ALIGNOF(double)
1016 dnl Compute maximum alignment of any basic type.
1017 dnl We assume long's alignment is at least as strong as char, short, or int;
1018 dnl but we must check long long (if it exists) and double.
1020 if [[ $ac_cv_alignof_double != 'sizeof(double)' ]] ; then
1021 MAX_ALIGNOF="$ac_cv_alignof_long"
1022 if [[ $MAX_ALIGNOF -lt $ac_cv_alignof_double ]] ; then
1023 MAX_ALIGNOF="$ac_cv_alignof_double"
1025 if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then
1026 if [[ $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ]] ; then
1027 MAX_ALIGNOF="$ac_cv_alignof_long_long_int"
1031 dnl cross-compiling: assume that double's alignment is worst case
1032 MAX_ALIGNOF="$ac_cv_alignof_double"
1034 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF)
1037 dnl Check to see if platform has POSIX signal interface.
1038 dnl NOTE: if this test fails then POSIX signals definitely don't work.
1039 dnl It could be that the test compiles but the POSIX routines don't
1040 dnl really work ... in that case the platform-specific port files
1041 dnl can unset USE_POSIX_SIGNALS and HAVE_POSIX_SIGNALS. (The former
1042 dnl goes into config.h, the latter into Makefile.global.)
1044 AC_MSG_CHECKING(for POSIX signal interface)
1045 AC_TRY_LINK([#include <signal.h>],
1046 [struct sigaction act, oact;
1047 sigemptyset(&act.sa_mask);
1048 act.sa_flags = SA_RESTART;
1049 sigaction(0, &act, &oact);],
1050 [AC_DEFINE(USE_POSIX_SIGNALS)
1051 HAVE_POSIX_SIGNALS="1"
1052 AC_MSG_RESULT(yes)],
1053 [HAVE_POSIX_SIGNALS=""
1055 AC_SUBST(HAVE_POSIX_SIGNALS)
1057 dnl Check for Tcl configuration script tclConfig.sh
1059 dnl If --with-tclconfig was given, don't check for tclsh, tcl
1060 if test -z "$TCL_DIRS"
1062 AC_PATH_PROG(TCLSH, tclsh)
1065 AC_PATH_PROG(TCLSH, tcl)
1068 AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
1074 if test "$USE_TCL" = true
1076 AC_MSG_CHECKING(for tclConfig.sh)
1079 if test -z "$TCL_DIRS"
1081 library_dirs=`echo 'puts $auto_path' | $TCLSH`
1083 library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
1084 for dir in $library_dirs; do
1085 if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
1086 TCL_CONFIG_SH=$dir/tclConfig.sh
1090 if test -z "$TCL_CONFIG_SH"; then
1092 AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
1095 AC_MSG_RESULT($TCL_CONFIG_SH)
1096 AC_SUBST(TCL_CONFIG_SH)
1100 USE_TK=$USE_TCL # If TCL is disabled, disable TK
1102 dnl Check for Tk configuration script tkConfig.sh
1103 if test "$USE_TK" = true
1105 AC_MSG_CHECKING(for tkConfig.sh)
1107 # library_dirs are set in the check for TCL
1108 for dir in $library_dirs
1110 if test -d "$dir" -a -r "$dir/tkConfig.sh"
1112 TK_CONFIG_SH=$dir/tkConfig.sh
1116 if test -z "$TK_CONFIG_SH"
1119 AC_MSG_WARN(TK support disabled; Tk configuration script missing)
1122 AC_MSG_RESULT($TK_CONFIG_SH)
1123 AC_SUBST(TK_CONFIG_SH)
1124 AC_PATH_PROG(WISH, wish)
1130 dnl Check for X libraries
1132 if test "$USE_X" = true; then
1134 ice_save_LIBS="$LIBS"
1135 ice_save_CFLAGS="$CFLAGS"
1136 ice_save_CPPFLAGS="$CPPFLAGS"
1137 ice_save_LDFLAGS="$LDFLAGS"
1141 LIBS="$LIBS $X_EXTRA_LIBS"
1142 CFLAGS="$CFLAGS $X_CFLAGS"
1143 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1144 LDFLAGS="$LDFLAGS $X_LIBS"
1146 dnl Check for X library
1149 AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
1150 if test "$X11_LIBS" = ""; then
1151 dnl Not having X is bad news for pgtksh. Let the user fix this.
1152 AC_MSG_WARN([The X11 library '-lX11' could not be found,
1153 so TK support will be disabled. To enable TK support,
1154 please use the configure options '--x-includes=DIR'
1155 and '--x-libraries=DIR' to specify the X location.
1156 See the file 'config.log' for further diagnostics.])
1161 AC_SUBST(X_PRE_LIBS)
1163 LIBS="$ice_save_LIBS"
1164 CFLAGS="$ice_save_CFLAGS"
1165 CPPFLAGS="$ice_save_CPPFLAGS"
1166 LDFLAGS="$ice_save_LDFLAGS"
1169 dnl cause configure to recurse into subdirectories with their own configure
1170 dnl Darn, setting AC_CONFIG_SUBDIRS sets a list $subdirs$ in the configure output
1171 dnl file, but then configure doesn't bother using that list. Probably a bug in
1172 dnl this version of autoconf.
1173 dnl So at the moment interfaces/odbc gets configured unconditionally.
1174 dnl - thomas 1998-10-05
1175 #if test "X$USE_ODBC" = "Xtrue"
1177 # AC_CONFIG_SUBDIRS(interfaces/odbc)
1179 if test "$USE_ODBC" = "true"
1182 AC_CHECK_HEADER(pwd.h, PWD_INCDIR=yes)
1183 if test "$PWD_INCDIR" = "no"; then
1184 AC_MSG_WARN(odbc support disabled; pwd.h missing)
1190 dnl Output files that are neither makefiles nor shell scripts probably
1191 dnl need fully-expanded substitutions, rather than partial expansions
1192 dnl that include references to other variables. Currently the only
1193 dnl such item that's needed is an expanded version of libdir, but
1194 dnl others may be needed someday. NOTE: 'eval' technique only copes
1195 dnl with one level of indirect reference per expansion; two levels is
1196 dnl currently enough for libdir, but it's ugly...
1198 dnl First we have to force 'NONE' prefix to be expanded itself.
1199 dnl For some reason, autoconf 2.13 doesn't do this until AC_OUTPUT,
1200 dnl which is too late...
1201 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1202 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
1204 eval expanded_libdir="$libdir"
1205 eval expanded_libdir="$expanded_libdir"
1206 AC_SUBST(expanded_libdir)
1208 dnl Finally ready to produce output files ...
1213 backend/port/Makefile
1214 backend/catalog/genbki.sh
1215 backend/utils/Gen_fmgrtab.sh
1216 bin/pg_dump/Makefile
1217 bin/pg_version/Makefile
1218 bin/pgtclsh/mkMakefile.tcldefs.sh
1219 bin/pgtclsh/mkMakefile.tkdefs.sh
1222 interfaces/libpq/Makefile
1223 interfaces/ecpg/lib/Makefile
1224 interfaces/libpq++/Makefile
1225 interfaces/libpgeasy/Makefile
1226 interfaces/libpgtcl/Makefile
1227 interfaces/odbc/GNUmakefile
1228 interfaces/odbc/Makefile.global
1229 pl/plpgsql/src/Makefile
1230 pl/plpgsql/src/mklang.sql
1231 pl/tcl/mkMakefile.tcldefs.sh