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(readline, main)
587 AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
588 AC_CHECK_LIB(history, main) )
590 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
592 AC_CHECK_LIB(bsd, main)
594 AC_CHECK_LIB(m, main)
595 AC_CHECK_LIB(dl, main)
596 AC_CHECK_LIB(socket, main)
597 AC_CHECK_LIB(nsl, main)
598 AC_CHECK_LIB(ipc, main)
599 AC_CHECK_LIB(IPC, main)
600 AC_CHECK_LIB(lc, main)
601 AC_CHECK_LIB(dld, main)
602 AC_CHECK_LIB(ln, main)
603 AC_CHECK_LIB(ld, main)
604 AC_CHECK_LIB(compat, main)
605 AC_CHECK_LIB(BSD, main)
606 AC_CHECK_LIB(crypt, main)
607 AC_CHECK_LIB(gen, main)
608 AC_CHECK_LIB(PW, main)
610 dnl Checks for header files.
613 AC_CHECK_HEADERS(arpa/inet.h)
614 AC_CHECK_HEADERS(crypt.h)
615 AC_CHECK_HEADERS(dld.h)
616 AC_CHECK_HEADERS(endian.h)
617 AC_CHECK_HEADERS(float.h)
618 AC_CHECK_HEADERS(fp_class.h)
619 AC_CHECK_HEADERS(getopt.h)
620 AC_CHECK_HEADERS(history.h)
621 AC_CHECK_HEADERS(ieeefp.h)
622 AC_CHECK_HEADERS(limits.h)
623 AC_CHECK_HEADERS(netdb.h)
624 AC_CHECK_HEADERS(netinet/in.h)
625 AC_CHECK_HEADERS(readline.h)
626 AC_CHECK_HEADERS(readline/history.h)
627 AC_CHECK_HEADERS(readline/readline.h)
628 AC_CHECK_HEADERS(sys/select.h)
629 AC_CHECK_HEADERS(termios.h)
630 AC_CHECK_HEADERS(unistd.h)
631 AC_CHECK_HEADERS(values.h)
633 AC_CHECK_HEADERS(sys/param.h pwd.h)
636 dnl Checks for typedefs, structures, and compiler characteristics.
648 AC_MSG_CHECKING(for signed types)
650 [signed char c; signed short s; signed int i;],
651 [AC_MSG_RESULT(yes)],
652 [AC_DEFINE(signed, ) AC_MSG_RESULT(no)])
654 AC_MSG_CHECKING(for volatile)
656 [extern volatile int i;],
657 [AC_MSG_RESULT(yes)],
658 [AC_DEFINE(volatile, ) AC_MSG_RESULT(no)])
660 AC_MSG_CHECKING(for type of last arg to accept)
661 AC_TRY_COMPILE([#include <stdlib.h>
662 #include <sys/types.h>
663 #include <sys/socket.h>
665 [int a = accept(1, (struct sockaddr *) 0, (size_t *) 0);],
666 [AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)],
667 [AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)])
669 dnl Check for any "odd" conditions
670 AC_MSG_CHECKING(for int timezone)
671 AC_TRY_LINK([#include <time.h>],
672 [int res = timezone / 60; ],
673 [AC_DEFINE(HAVE_INT_TIMEZONE) AC_MSG_RESULT(yes)],
676 AC_MSG_CHECKING(for gettimeofday args)
677 AC_TRY_LINK([#include <sys/time.h>],
678 [struct timeval *tp; struct timezone *tzp; gettimeofday(tp,tzp); ],
679 [AC_DEFINE(HAVE_GETTIMEOFDAY_2_ARGS) AC_MSG_RESULT(2 args)],
682 AC_MSG_CHECKING(for union semun)
683 AC_TRY_LINK([#include <sys/types.h>
685 #include <sys/sem.h>],
686 [union semun semun;],
687 [AC_DEFINE(HAVE_UNION_SEMUN) AC_MSG_RESULT(yes)],
690 AC_MSG_CHECKING(for fcntl(F_SETLK))
691 AC_TRY_LINK([#include <fcntl.h>],
693 lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
694 lck.l_type = F_WRLCK;
695 fcntl(0, F_SETLK, &lck);],
696 [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
699 dnl Checks for library functions.
703 AC_CHECK_FUNCS(memmove sigsetjmp sysconf)
704 AC_CHECK_FUNCS(sigprocmask waitpid setsid fcvt)
705 AC_CHECK_FUNCS(fpclass fp_class fp_class_d class)
706 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
707 dnl is missing. Yes, there are machines that have only one.
708 dnl We may also decide to use snprintf.c if snprintf() is present but does
709 dnl not have working "long long int" support -- see below.
711 AC_CHECK_FUNC(snprintf,
712 AC_DEFINE(HAVE_SNPRINTF),
713 SNPRINTF='snprintf.o')
714 AC_CHECK_FUNC(vsnprintf,
715 AC_DEFINE(HAVE_VSNPRINTF),
716 SNPRINTF='snprintf.o')
718 dnl do this one the hard way in case isinf() is a macro
719 AC_MSG_CHECKING(for isinf)
720 AC_CACHE_VAL(ac_cv_func_or_macro_isinf,
723 [double x = 0.0; int res = isinf(x);],
724 [ac_cv_func_or_macro_isinf=yes],
725 [ac_cv_func_or_macro_isinf=no])])
726 if [[ $ac_cv_func_or_macro_isinf = yes ]]; then
728 AC_DEFINE(HAVE_ISINF)
735 AC_CHECK_FUNC(getrusage,
736 AC_DEFINE(HAVE_GETRUSAGE),
737 GETRUSAGE='getrusage.o')
739 AC_CHECK_FUNC(srandom,
740 AC_DEFINE(HAVE_SRANDOM),
743 AC_CHECK_FUNC(gethostname,
744 AC_DEFINE(HAVE_GETHOSTNAME),
745 GETHOSTNAME='gethostname.o')
746 AC_SUBST(GETHOSTNAME)
747 AC_CHECK_FUNC(random,
748 AC_DEFINE(HAVE_RANDOM),
749 MISSING_RANDOM='random.o')
750 AC_SUBST(MISSING_RANDOM)
751 AC_CHECK_FUNC(inet_aton,
752 AC_DEFINE(HAVE_INET_ATON),
753 INET_ATON='inet_aton.o')
755 AC_CHECK_FUNC(strerror,
756 AC_DEFINE(HAVE_STRERROR),
757 [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
760 AC_CHECK_FUNC(strdup,
761 AC_DEFINE(HAVE_STRDUP),
762 STRDUP='../../utils/strdup.o')
764 AC_CHECK_FUNC(strtol,
765 AC_DEFINE(HAVE_STRTOL),
768 AC_CHECK_FUNC(strtoul,
769 AC_DEFINE(HAVE_STRTOUL),
772 AC_CHECK_FUNC(strcasecmp,
773 AC_DEFINE(HAVE_STRCASECMP),
774 STRCASECMP='strcasecmp.o')
777 AC_DEFINE(HAVE_CBRT),
778 AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
780 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
781 # this hackery with HPUXMATHLIB allows us to cope.
785 if [[ -r /lib/pa1.1/libm.a ]] ; then
786 HPUXMATHLIB="-L /lib/pa1.1 -lm"
789 AC_SUBST(HPUXMATHLIB)
792 AC_DEFINE(HAVE_RINT),
793 AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
796 dnl Check for GNU style long options support (getopt_long)
797 AC_CHECK_FUNCS(getopt_long)
800 AC_MSG_CHECKING(for finite() macro or function)
801 AC_TRY_LINK([#include <math.h>],
802 [int dummy=finite(1.0);],
803 [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
806 dnl Check to see if we have a working 64-bit integer type.
807 dnl This breaks down into two steps:
808 dnl (1) figure out if the compiler has a 64-bit int type with working
809 dnl arithmetic, and if so
810 dnl (2) see whether snprintf() can format the type correctly. (Currently,
811 dnl snprintf is the only library routine we really need for int8 support.)
812 dnl It's entirely possible to have a compiler that handles a 64-bit type
813 dnl when the C library doesn't; this is fairly likely when using gcc on
814 dnl an older platform, for example.
815 dnl If there is no native snprintf() or it does not handle the 64-bit type,
816 dnl we force our own version of snprintf() to be used instead.
817 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
820 AC_MSG_CHECKING(whether 'long int' is 64 bits)
821 AC_TRY_RUN([typedef long int int64;
823 /* These are globals to discourage the compiler from folding all the
824 * arithmetic tests down to compile-time constants.
829 int does_int64_work()
833 if (sizeof(int64) != 8)
834 return 0; /* doesn't look like the right size */
836 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
844 exit(! does_int64_work());
847 AC_DEFINE(HAVE_LONG_INT_64)
850 AC_MSG_RESULT(assuming not on target machine))
852 HAVE_LONG_LONG_INT_64=0
853 if [[ $HAVE_LONG_INT_64 -eq 0 ]] ; then
854 AC_MSG_CHECKING(whether 'long long int' is 64 bits)
855 AC_TRY_RUN([typedef long long int int64;
857 /* These are globals to discourage the compiler from folding all the
858 * arithmetic tests down to compile-time constants.
863 int does_int64_work()
867 if (sizeof(int64) != 8)
868 return 0; /* doesn't look like the right size */
870 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
878 exit(! does_int64_work());
880 [HAVE_LONG_LONG_INT_64=1
881 AC_DEFINE(HAVE_LONG_LONG_INT_64)
884 AC_MSG_RESULT(assuming not on target machine))
887 dnl If we found "long int" is 64 bits, assume snprintf handles it.
888 dnl If we found we need to use "long long int", better check.
889 dnl We cope with snprintfs that use either %lld or %qd as the format.
890 dnl If neither works, fall back to our own snprintf emulation (which we
893 if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then
894 if [[ x$SNPRINTF = x ]] ; then
895 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
896 AC_TRY_RUN([#include <stdio.h>
897 typedef long long int int64;
898 #define INT64_FORMAT "%lld"
903 int does_int64_snprintf_work()
908 if (sizeof(int64) != 8)
909 return 0; /* doesn't look like the right size */
912 snprintf(buf, 100, INT64_FORMAT, c);
913 if (strcmp(buf, "800000140000005") != 0)
914 return 0; /* either multiply or snprintf is busted */
918 exit(! does_int64_snprintf_work());
921 INT64_FORMAT='"%lld"'
924 AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
925 AC_TRY_RUN([#include <stdio.h>
926 typedef long long int int64;
927 #define INT64_FORMAT "%qd"
932 int does_int64_snprintf_work()
937 if (sizeof(int64) != 8)
938 return 0; /* doesn't look like the right size */
941 snprintf(buf, 100, INT64_FORMAT, c);
942 if (strcmp(buf, "800000140000005") != 0)
943 return 0; /* either multiply or snprintf is busted */
947 exit(! does_int64_snprintf_work());
953 # Force usage of our own snprintf, since system snprintf is broken
954 SNPRINTF='snprintf.o'
955 INT64_FORMAT='"%lld"'
957 [ AC_MSG_RESULT(assuming not on target machine)
958 # Force usage of our own snprintf, since we cannot test foreign snprintf
959 SNPRINTF='snprintf.o'
960 INT64_FORMAT='"%lld"'
962 [ AC_MSG_RESULT(assuming not on target machine)
963 # Force usage of our own snprintf, since we cannot test foreign snprintf
964 SNPRINTF='snprintf.o'
965 INT64_FORMAT='"%lld"'
968 # here if we previously decided we needed to use our own snprintf
969 INT64_FORMAT='"%lld"'
972 # Here if we are not using 'long long int' at all
976 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
979 dnl Determine memory alignment requirements for the basic C datatypes.
981 dnl CHECK_ALIGNOF(TYPE)
982 dnl This is modeled on the standard autoconf macro AC_CHECK_SIZEOF,
983 dnl except it finds the alignment requirement of the type instead of the size.
984 dnl The defined symbol is named ALIGNOF_TYPE, where the type name is
985 dnl converted in the same way as for AC_CHECK_SIZEOF.
986 dnl If cross-compiling, sizeof(type) is used as a default assumption.
988 AC_DEFUN(CHECK_ALIGNOF,
989 [changequote(<<, >>)dnl
990 dnl The name to #define.
991 define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
992 dnl The cache variable name.
993 define(<<AC_CV_NAME>>, translit(ac_cv_alignof_$1, [ *], [_p]))dnl
995 AC_MSG_CHECKING(alignment of $1)
996 AC_CACHE_VAL(AC_CV_NAME,
997 [AC_TRY_RUN([#include <stdio.h>
998 struct { char filler; $1 field; } mystruct;
1001 FILE *f=fopen("conftestval", "w");
1003 fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct));
1005 }], AC_CV_NAME=`cat conftestval`,
1006 AC_CV_NAME='sizeof($1)',
1007 AC_CV_NAME='sizeof($1)')])dnl
1008 AC_MSG_RESULT($AC_CV_NAME)
1009 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
1010 undefine([AC_TYPE_NAME])dnl
1011 undefine([AC_CV_NAME])dnl
1014 CHECK_ALIGNOF(short)
1017 if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then
1018 CHECK_ALIGNOF(long long int)
1020 CHECK_ALIGNOF(double)
1022 dnl Compute maximum alignment of any basic type.
1023 dnl We assume long's alignment is at least as strong as char, short, or int;
1024 dnl but we must check long long (if it exists) and double.
1026 if [[ $ac_cv_alignof_double != 'sizeof(double)' ]] ; then
1027 MAX_ALIGNOF="$ac_cv_alignof_long"
1028 if [[ $MAX_ALIGNOF -lt $ac_cv_alignof_double ]] ; then
1029 MAX_ALIGNOF="$ac_cv_alignof_double"
1031 if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then
1032 if [[ $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ]] ; then
1033 MAX_ALIGNOF="$ac_cv_alignof_long_long_int"
1037 dnl cross-compiling: assume that double's alignment is worst case
1038 MAX_ALIGNOF="$ac_cv_alignof_double"
1040 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF)
1043 dnl Check to see if platform has POSIX signal interface.
1044 dnl NOTE: if this test fails then POSIX signals definitely don't work.
1045 dnl It could be that the test compiles but the POSIX routines don't
1046 dnl really work ... in that case the platform-specific port files
1047 dnl can unset USE_POSIX_SIGNALS and HAVE_POSIX_SIGNALS. (The former
1048 dnl goes into config.h, the latter into Makefile.global.)
1050 AC_MSG_CHECKING(for POSIX signal interface)
1051 AC_TRY_LINK([#include <signal.h>],
1052 [struct sigaction act, oact;
1053 sigemptyset(&act.sa_mask);
1054 act.sa_flags = SA_RESTART;
1055 sigaction(0, &act, &oact);],
1056 [AC_DEFINE(USE_POSIX_SIGNALS)
1057 HAVE_POSIX_SIGNALS="1"
1058 AC_MSG_RESULT(yes)],
1059 [HAVE_POSIX_SIGNALS=""
1061 AC_SUBST(HAVE_POSIX_SIGNALS)
1063 dnl Check for Tcl configuration script tclConfig.sh
1065 dnl If --with-tclconfig was given, don't check for tclsh, tcl
1066 if test -z "$TCL_DIRS"
1068 AC_PATH_PROG(TCLSH, tclsh)
1071 AC_PATH_PROG(TCLSH, tcl)
1074 AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
1080 if test "$USE_TCL" = true
1082 AC_MSG_CHECKING(for tclConfig.sh)
1085 if test -z "$TCL_DIRS"
1087 library_dirs=`echo 'puts $auto_path' | $TCLSH`
1089 library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
1090 for dir in $library_dirs; do
1091 if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
1092 TCL_CONFIG_SH=$dir/tclConfig.sh
1096 if test -z "$TCL_CONFIG_SH"; then
1098 AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
1101 AC_MSG_RESULT($TCL_CONFIG_SH)
1102 AC_SUBST(TCL_CONFIG_SH)
1106 USE_TK=$USE_TCL # If TCL is disabled, disable TK
1108 dnl Check for Tk configuration script tkConfig.sh
1109 if test "$USE_TK" = true
1111 AC_MSG_CHECKING(for tkConfig.sh)
1113 # library_dirs are set in the check for TCL
1114 for dir in $library_dirs
1116 if test -d "$dir" -a -r "$dir/tkConfig.sh"
1118 TK_CONFIG_SH=$dir/tkConfig.sh
1122 if test -z "$TK_CONFIG_SH"
1125 AC_MSG_WARN(TK support disabled; Tk configuration script missing)
1128 AC_MSG_RESULT($TK_CONFIG_SH)
1129 AC_SUBST(TK_CONFIG_SH)
1130 AC_PATH_PROG(WISH, wish)
1136 dnl Check for X libraries
1138 if test "$USE_X" = true; then
1140 ice_save_LIBS="$LIBS"
1141 ice_save_CFLAGS="$CFLAGS"
1142 ice_save_CPPFLAGS="$CPPFLAGS"
1143 ice_save_LDFLAGS="$LDFLAGS"
1147 LIBS="$LIBS $X_EXTRA_LIBS"
1148 CFLAGS="$CFLAGS $X_CFLAGS"
1149 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1150 LDFLAGS="$LDFLAGS $X_LIBS"
1152 dnl Check for X library
1155 AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
1156 if test "$X11_LIBS" = ""; then
1157 dnl Not having X is bad news for pgtksh. Let the user fix this.
1158 AC_MSG_WARN([The X11 library '-lX11' could not be found,
1159 so TK support will be disabled. To enable TK support,
1160 please use the configure options '--x-includes=DIR'
1161 and '--x-libraries=DIR' to specify the X location.
1162 See the file 'config.log' for further diagnostics.])
1167 AC_SUBST(X_PRE_LIBS)
1169 LIBS="$ice_save_LIBS"
1170 CFLAGS="$ice_save_CFLAGS"
1171 CPPFLAGS="$ice_save_CPPFLAGS"
1172 LDFLAGS="$ice_save_LDFLAGS"
1175 dnl cause configure to recurse into subdirectories with their own configure
1176 dnl Darn, setting AC_CONFIG_SUBDIRS sets a list $subdirs$ in the configure output
1177 dnl file, but then configure doesn't bother using that list. Probably a bug in
1178 dnl this version of autoconf.
1179 dnl So at the moment interfaces/odbc gets configured unconditionally.
1180 dnl - thomas 1998-10-05
1181 #if test "X$USE_ODBC" = "Xtrue"
1183 # AC_CONFIG_SUBDIRS(interfaces/odbc)
1185 if test "$USE_ODBC" = "true"
1188 AC_CHECK_HEADER(pwd.h, PWD_INCDIR=yes)
1189 if test "$PWD_INCDIR" = "no"; then
1190 AC_MSG_WARN(odbc support disabled; pwd.h missing)
1196 dnl Output files that are neither makefiles nor shell scripts probably
1197 dnl need fully-expanded substitutions, rather than partial expansions
1198 dnl that include references to other variables. Currently the only
1199 dnl such item that's needed is an expanded version of libdir, but
1200 dnl others may be needed someday. NOTE: 'eval' technique only copes
1201 dnl with one level of indirect reference per expansion; two levels is
1202 dnl currently enough for libdir, but it's ugly...
1204 dnl First we have to force 'NONE' prefix to be expanded itself.
1205 dnl For some reason, autoconf 2.13 doesn't do this until AC_OUTPUT,
1206 dnl which is too late...
1207 test "x$prefix" = xNONE && prefix=$ac_default_prefix
1208 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
1210 eval expanded_libdir="$libdir"
1211 eval expanded_libdir="$expanded_libdir"
1212 AC_SUBST(expanded_libdir)
1214 dnl Finally ready to produce output files ...
1219 backend/port/Makefile
1220 backend/catalog/genbki.sh
1221 backend/utils/Gen_fmgrtab.sh
1222 bin/pg_dump/Makefile
1223 bin/pg_version/Makefile
1224 bin/pgtclsh/mkMakefile.tcldefs.sh
1225 bin/pgtclsh/mkMakefile.tkdefs.sh
1228 interfaces/libpq/Makefile
1229 interfaces/ecpg/lib/Makefile
1230 interfaces/libpq++/Makefile
1231 interfaces/libpgeasy/Makefile
1232 interfaces/libpgtcl/Makefile
1233 interfaces/odbc/GNUmakefile
1234 interfaces/odbc/Makefile.global
1235 pl/plpgsql/src/Makefile
1236 pl/plpgsql/src/mklang.sql
1237 pl/tcl/mkMakefile.tcldefs.sh