Annotation of pgsql/configure.in, revision 1.296

1.292     momjian     1: dnl Process this file with autoconf to produce a configure script.
1.296   ! tgl         2: dnl $Header: /cvsroot/pgsql-server/configure.in,v 1.295 2003/10/14 00:48:09 momjian Exp $
1.185     petere      3: dnl
1.28      petere      4: dnl Developers, please strive to achieve this order:
                      5: dnl
                      6: dnl 0. Initialization and options processing
                      7: dnl 1. Programs
                      8: dnl 2. Libraries
                      9: dnl 3. Header files
                     10: dnl 4. Types
                     11: dnl 5. Structures
                     12: dnl 6. Compiler characteristics
                     13: dnl 7. Functions, global variables
                     14: dnl 8. System services
                     15: dnl
                     16: dnl Read the Autoconf manual for details.
1.185     petere     17: dnl
                     18: m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
                     19: dnl
1.32      petere     20: dnl The GNU folks apparently haven't heard that some people don't use
                     21: dnl Texinfo. Use this sorcery to use "docdir" instead of "infodir".
1.171     petere     22: m4_define([info], [doc])
                     23: m4_define([infodir], [docdir])
1.293     pgsql      24: AC_INIT([PostgreSQL], [7.4beta4], [[email protected]])
1.171     petere     25: m4_undefine([infodir])
                     26: m4_undefine([info])
                     27: AC_SUBST(docdir)
                     28: 
                     29: AC_PREREQ(2.53)
1.277     pgsql      30: AC_COPYRIGHT([Copyright 2003 PostgreSQL Global Development Group])
1.171     petere     31: AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
                     32: AC_CONFIG_AUX_DIR(config)
1.1       petere     33: AC_PREFIX_DEFAULT(/usr/local/pgsql)
1.171     petere     34: AC_SUBST(configure_args, [$ac_configure_args])
1.5       petere     35: 
1.171     petere     36: AC_DEFINE_UNQUOTED(PG_VERSION, "$PACKAGE_VERSION", [PostgreSQL version])
1.61      petere     37: 
1.1       petere     38: AC_CANONICAL_HOST
                     39: 
1.30      petere     40: template=
                     41: AC_MSG_CHECKING([which template to use])
                     42: 
1.42      petere     43: PGAC_ARG_REQ(with, template, [],
                     44: [
                     45:   case $withval in
1.30      petere     46:     list)   echo; ls "$srcdir/src/template"; exit;;
                     47:     *)      if test -f "$srcdir/src/template/$with_template" ; then
1.42      petere     48:               template=$withval
1.30      petere     49:             else
1.80      petere     50:               AC_MSG_ERROR(['$withval' is not a valid template name. Use 'list' for a list.])
1.30      petere     51:             fi;;
                     52:   esac
1.42      petere     53: ],
                     54: [
1.280     tgl        55: # --with-template not given
1.30      petere     56: 
                     57: case $host_os in
                     58:      aix*) template=aix ;;
1.54      momjian    59:     beos*) template=beos ;;
1.30      petere     60:     bsdi*) template=bsdi ;;
1.239     petere     61:   cygwin*) template=cygwin ;;
1.72      petere     62:   darwin*) template=darwin ;;
1.30      petere     63:     dgux*) template=dgux ;;
                     64:  freebsd*) template=freebsd ;;
                     65:     hpux*) template=hpux ;;
                     66:     irix*) template=irix5 ;;
                     67:    linux*) template=linux ;;
1.250     momjian    68:    mingw*) template=win32 ;;
1.30      petere     69:   netbsd*) template=netbsd ;;
                     70: nextstep*) template=nextstep ;;
                     71:  openbsd*) template=openbsd ;;
                     72:      osf*) template=osf ;;
                     73:      qnx*) template=qnx4 ;;
                     74:      sco*) template=sco ;;
1.58      petere     75:  solaris*) template=solaris ;;
1.30      petere     76:    sunos*) template=sunos4 ;;
1.1       petere     77:  sysv4.2*)
1.30      petere     78:         case $host_vendor in
                     79:           univel) template=univel ;;
                     80:         esac ;;
                     81:    sysv4*) template=svr4 ;;
1.133     petere     82:    sysv5*) template=unixware ;;
1.30      petere     83:   ultrix*) template=ultrix4 ;;
1.1       petere     84: esac
                     85: 
1.30      petere     86:   if test x"$template" = x"" ; then
1.80      petere     87:     AC_MSG_ERROR([[
1.30      petere     88: *******************************************************************
                     89: PostgreSQL has apparently not been ported to your platform yet.
1.32      petere     90: To try a manual configuration, look into the src/template directory
1.80      petere     91: for a similar platform and use the '--with-template=' option.
1.30      petere     92: 
                     93: Please also contact <[email protected]> to see about
1.80      petere     94: rectifying this.  Include the above 'checking host system type...'
1.30      petere     95: line.
                     96: *******************************************************************
1.80      petere     97: ]])
1.30      petere     98:   fi
                     99: 
1.42      petere    100: ])
1.1       petere    101: 
1.30      petere    102: AC_MSG_RESULT([$template])
1.1       petere    103: 
1.30      petere    104: PORTNAME=$template
                    105: AC_SUBST(PORTNAME)
1.1       petere    106: 
1.58      petere    107: # Pick right test-and-set (TAS) code.  Most platforms have inline
                    108: # assembler code in src/include/storage/s_lock.h, so we just use
                    109: # a dummy file here.
                    110: case $host in
1.272     tgl       111:   hppa*-*-hpux*)        need_tas=yes; tas_file=hpux_hppa.s ;;
1.58      petere    112:   sparc-*-solaris*) need_tas=yes; tas_file=solaris_sparc.s ;;
1.147     momjian   113:   i?86-*-solaris*)   need_tas=yes; tas_file=solaris_i386.s ;;
1.63      petere    114:   *)                need_tas=no;  tas_file=dummy.s ;;
1.30      petere    115: esac
1.171     petere    116: AC_CONFIG_LINKS([src/backend/port/tas.s:src/backend/port/tas/${tas_file}])
1.1       petere    117: 
1.30      petere    118: if test "$need_tas" = yes ; then
                    119:   TAS=tas.o
1.1       petere    120: fi
1.30      petere    121: AC_SUBST(TAS)
1.1       petere    122: 
                    123: 
                    124: 
1.30      petere    125: ##
                    126: ## Command line options
                    127: ##
1.13      petere    128: 
1.1       petere    129: 
1.30      petere    130: #
                    131: # Add non-standard directories to the include path
                    132: #
1.42      petere    133: PGAC_ARG_REQ(with, includes, [  --with-includes=DIRS    look for additional header files in DIRS])
1.1       petere    134: 
                    135: 
1.30      petere    136: #
                    137: # Add non-standard directories to the library search path
                    138: #
1.42      petere    139: PGAC_ARG_REQ(with, libraries, [  --with-libraries=DIRS   look for additional libraries in DIRS],
                    140:              [LIBRARY_DIRS=$withval])
1.1       petere    141: 
1.42      petere    142: PGAC_ARG_REQ(with, libs,      [  --with-libs=DIRS        alternative spelling of --with-libraries],
                    143:              [LIBRARY_DIRS=$withval])
1.2       petere    144: 
1.1       petere    145: 
1.29      petere    146: #
1.180     thomas    147: # 64-bit integer date/time storage (--enable-integer-datetimes)
                    148: #
                    149: AC_MSG_CHECKING([whether to build with 64-bit integer date/time support])
                    150: PGAC_ARG_BOOL(enable, integer-datetimes, no, [  --enable-integer-datetimes  enable 64-bit integer date/time support],
                    151:               [AC_DEFINE([USE_INTEGER_DATETIMES], 1,
1.242     petere    152:                          [Define to 1 if you want 64-bit integer timestamp and interval support. (--enable-integer-datetimes)])])
1.180     thomas    153: AC_MSG_RESULT([$enable_integer_datetimes])
1.1       petere    154: 
                    155: 
1.70      ishii     156: #
1.128     petere    157: # NLS
                    158: #
                    159: AC_MSG_CHECKING([whether NLS is wanted])
                    160: PGAC_ARG_OPTARG(enable, nls,
1.171     petere    161:                 [[  --enable-nls[=LANGUAGES]  enable Native Language Support]],
1.128     petere    162:                 [],
                    163:                 [WANTED_LANGUAGES=$enableval],
1.171     petere    164:                 [AC_DEFINE(ENABLE_NLS, 1,
1.242     petere    165:                            [Define to 1 if you want National Language Support. (--enable-nls)])])
1.128     petere    166: AC_MSG_RESULT([$enable_nls])
                    167: AC_SUBST(enable_nls)
                    168: AC_SUBST(WANTED_LANGUAGES)
                    169: 
                    170: #
1.29      petere    171: # Default port number (--with-pgport), default 5432
                    172: #
                    173: AC_MSG_CHECKING([for default port number])
1.42      petere    174: PGAC_ARG_REQ(with, pgport, [  --with-pgport=PORTNUM   change default port number [5432]],
                    175:              [default_port=$withval],
                    176:              [default_port=5432])
1.97      tgl       177: AC_MSG_RESULT([$default_port])
                    178: # Need both of these because some places want an integer and some a string
1.171     petere    179: AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port},
1.242     petere    180: [Define to the default TCP port number on which the server listens and
1.280     tgl       181: to which clients will try to connect.  This can be overridden at run-time,
                    182: but it's convenient if your clients have the right default compiled in.
                    183: (--with-pgport=PORTNUM)])
1.171     petere    184: AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}",
1.280     tgl       185:                    [Define to the default TCP port number as a string constant.])
1.97      tgl       186: AC_SUBST(default_port)
1.1       petere    187: 
1.29      petere    188: #
1.65      petere    189: # Option to disable shared libraries
                    190: #
                    191: PGAC_ARG_BOOL(enable, shared, yes,
1.68      petere    192:               [  --disable-shared        do not build shared libraries])
1.65      petere    193: AC_SUBST(enable_shared)
                    194: 
1.69      petere    195: #
                    196: # '-rpath'-like feature can be disabled
                    197: #
                    198: PGAC_ARG_BOOL(enable, rpath, yes,
                    199:               [  --disable-rpath         do not embed shared library search path in executables])
                    200: AC_SUBST(enable_rpath)
                    201: 
1.289     momjian   202: #
                    203: # Spinlocks
                    204: #
                    205: PGAC_ARG_BOOL(enable, spinlocks, yes,
                    206:               [  --disable-spinlocks     do not use Spinlocks])
1.65      petere    207: 
                    208: #
1.74      petere    209: # --enable-debug adds -g to compiler flags
                    210: #
                    211: PGAC_ARG_BOOL(enable, debug, no,
                    212:               [  --enable-debug          build with debugging symbols (-g)])
1.168     momjian   213: AC_SUBST(enable_debug)
1.74      petere    214: 
                    215: #
1.30      petere    216: # C compiler
                    217: #
                    218: 
1.29      petere    219: # For historical reasons you can also use --with-CC to specify the C compiler
                    220: # to use, although the standard way to do this is to set the CC environment
                    221: # variable.
1.42      petere    222: PGAC_ARG_REQ(with, CC, [], [CC=$with_CC])
1.4       tgl       223: 
1.171     petere    224: case $template in
                    225:   aix) pgac_cc_list="gcc xlc";;
                    226:  irix) pgac_cc_list="cc";; # no gcc
                    227:     *) pgac_cc_list="gcc cc";;
                    228: esac
1.4       tgl       229: 
1.171     petere    230: AC_PROG_CC([$pgac_cc_list])
1.280     tgl       231: 
                    232: #
1.30      petere    233: # Read the template
1.280     tgl       234: #
1.30      petere    235: . "$srcdir/src/template/$template" || exit
1.74      petere    236: 
1.296   ! tgl       237: # The template may have supplied a default setting for CFLAGS.
        !           238: # Override this if CFLAGS was set in the original environment.
1.171     petere    239: if test "$ac_env_CFLAGS_set" = set; then
                    240:   CFLAGS=$ac_env_CFLAGS_value
1.296   ! tgl       241: else
        !           242:   # autoconf already set the default CFLAGS for gcc to be -O2, but we
        !           243:   # need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
        !           244:   if test "$GCC" = yes; then
        !           245:     CFLAGS="$CFLAGS -fno-strict-aliasing"
        !           246:   fi
1.294     momjian   247: fi
1.296   ! tgl       248: # supply -g if --enable-debug
        !           249: if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
1.74      petere    250:   CFLAGS="$CFLAGS -g"
1.296   ! tgl       251: fi
        !           252: # default to -O rather than empty CFLAGS; this path will not be taken for
        !           253: # gcc (since autoconf supplies -O2), nor if --enable-debug (because -O -g
        !           254: # doesn't work on most non-gcc compilers), nor if the template provided
        !           255: # some CFLAGS.
        !           256: if test "$ac_env_CFLAGS_set" != set -a x"$CFLAGS" = x""; then
        !           257:   CFLAGS="-O"
1.74      petere    258: fi
1.171     petere    259: AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
1.285     momjian   260: 
                    261: # We already have this in Makefile.win32, but configure needs it too
                    262: if test "$PORTNAME" = "win32"
                    263: then
1.286     momjian   264:        CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
1.285     momjian   265: fi
1.210     petere    266: 
1.30      petere    267: # Check if the compiler still works with the template settings
1.171     petere    268: AC_MSG_CHECKING([whether the C compiler still works])
                    269: AC_TRY_LINK([], [return 0;],
                    270:   [AC_MSG_RESULT(yes)],
                    271:   [AC_MSG_RESULT(no)
                    272:    AC_MSG_ERROR([cannot proceed])])
1.210     petere    273: 
1.296   ! tgl       274: # Defend against gcc -ffast-math
1.210     petere    275: if test "$GCC" = yes; then
                    276: AC_TRY_COMPILE([], [@%:@ifdef __FAST_MATH__
                    277: choke me
                    278: @%:@endif], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
                    279: fi
                    280: 
1.4       tgl       281: AC_PROG_CPP
1.6       petere    282: AC_SUBST(GCC)
1.4       tgl       283: 
1.29      petere    284: # Create compiler version string
1.24      petere    285: if test x"$GCC" = x"yes" ; then
1.169     momjian   286:   cc_string="GCC `${CC} --version | sed q`"
1.4       tgl       287: else
1.24      petere    288:   cc_string=$CC
1.4       tgl       289: fi
1.242     petere    290: AC_DEFINE_UNQUOTED(PG_VERSION_STR,
                    291:                    ["PostgreSQL $PACKAGE_VERSION on $host, compiled by $cc_string"],
                    292:                    [A string containing the version number, platform, and C compiler])
1.24      petere    293: 
1.4       tgl       294: 
1.31      petere    295: #
                    296: # Automatic dependency tracking
                    297: #
1.42      petere    298: PGAC_ARG_BOOL(enable, depend, no, [  --enable-depend         turn on automatic dependency tracking],
                    299:               [autodepend=yes])
1.31      petere    300: AC_SUBST(autodepend)
                    301: 
                    302: 
1.42      petere    303: #
                    304: # Enable assert checks
                    305: #
                    306: PGAC_ARG_BOOL(enable, cassert, no, [  --enable-cassert        enable assertion checks (for debugging)],
                    307:               [AC_DEFINE([USE_ASSERT_CHECKING], 1,
1.242     petere    308:                          [Define to 1 to build with assertion checks. (--enable-cassert)])])
1.30      petere    309: 
                    310: 
                    311: #
                    312: # Include directories
                    313: #
                    314: ac_save_IFS=$IFS
1.80      petere    315: IFS="${IFS}:"
1.30      petere    316: # SRCH_INC comes from the template file
                    317: for dir in $with_includes $SRCH_INC; do
                    318:   if test -d "$dir"; then
                    319:     INCLUDES="$INCLUDES -I$dir"
                    320:   else
                    321:     AC_MSG_WARN([*** Include directory $dir does not exist.])
                    322:   fi
                    323: done
                    324: IFS=$ac_save_IFS
                    325: AC_SUBST(INCLUDES)
                    326: 
                    327: 
                    328: #
                    329: # Library directories
                    330: #
                    331: ac_save_IFS=$IFS
1.80      petere    332: IFS="${IFS}:"
1.30      petere    333: # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
                    334: for dir in $LIBRARY_DIRS $SRCH_LIB; do
                    335:   if test -d "$dir"; then
1.68      petere    336:     LIBDIRS="$LIBDIRS -L$dir"
1.30      petere    337:   else
                    338:     AC_MSG_WARN([*** Library directory $dir does not exist.])
                    339:   fi
                    340: done
                    341: IFS=$ac_save_IFS
                    342: 
1.43      petere    343: #
1.280     tgl       344: # Enable thread-safe client libraries
1.261     momjian   345: #
1.280     tgl       346: AC_MSG_CHECKING([allow thread-safe client libraries])
                    347: PGAC_ARG_BOOL(enable, thread-safety, no, [  --enable-thread-safety  make client libraries thread-safe],
                    348:               [AC_DEFINE([USE_THREADS], 1,
                    349:                          [Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])])
1.271     momjian   350: AC_MSG_RESULT([$enable_thread_safety])
                    351: AC_SUBST(enable_thread_safety)
1.261     momjian   352: 
                    353: #
1.43      petere    354: # Tcl/Tk
                    355: #
                    356: AC_MSG_CHECKING([whether to build with Tcl])
                    357: PGAC_ARG_BOOL(with, tcl, no, [  --with-tcl              build Tcl and Tk interfaces])
                    358: AC_MSG_RESULT([$with_tcl])
                    359: AC_SUBST([with_tcl])
                    360: 
                    361: # If Tcl is enabled (above) then Tk is also, unless the user disables it using --without-tk
                    362: AC_MSG_CHECKING([whether to build with Tk])
                    363: if test "$with_tcl" = yes; then
                    364:   PGAC_ARG_BOOL(with, tk, yes, [  --without-tk            do not build Tk interfaces if Tcl is enabled])
                    365: else
                    366:   with_tk=no
                    367: fi
                    368: AC_MSG_RESULT([$with_tk])
                    369: AC_SUBST([with_tk])
1.1       petere    370: 
                    371: 
1.171     petere    372: # We see if the path to the Tcl/Tk configuration scripts is specified.
1.42      petere    373: # This will override the use of tclsh to find the paths to search.
                    374: 
1.43      petere    375: PGAC_ARG_REQ(with, tclconfig, [  --with-tclconfig=DIR    tclConfig.sh and tkConfig.sh are in DIR])
1.1       petere    376: 
1.171     petere    377: # We see if the path to the Tk configuration scripts is specified.
1.42      petere    378: # This will override the use of tclsh to find the paths to search.
1.1       petere    379: 
1.43      petere    380: PGAC_ARG_REQ(with, tkconfig,  [  --with-tkconfig=DIR     tkConfig.sh is in DIR])
1.125     petere    381: 
1.42      petere    382: #
1.205     petere    383: # Optionally build Perl modules (PL/Perl)
1.199     momjian   384: #
                    385: AC_MSG_CHECKING([whether to build Perl modules])
1.205     petere    386: PGAC_ARG_BOOL(with, perl, no, [  --with-perl             build Perl modules (PL/Perl)])
1.199     momjian   387: AC_MSG_RESULT([$with_perl])
                    388: AC_SUBST(with_perl)
                    389: 
                    390: #
1.283     petere    391: # Optionally build Python modules (PL/Python)
1.42      petere    392: #
                    393: AC_MSG_CHECKING([whether to build Python modules])
1.283     petere    394: PGAC_ARG_BOOL(with, python, no, [  --with-python           build Python modules (PL/Python)])
1.126     petere    395: AC_MSG_RESULT([$with_python])
1.5       petere    396: AC_SUBST(with_python)
1.1       petere    397: 
1.105     peter     398: #
                    399: # Optionally build the Java/JDBC tools
                    400: #
                    401: AC_MSG_CHECKING([whether to build Java/JDBC tools])
1.108     petere    402: PGAC_ARG_BOOL(with, java, no, [  --with-java             build JDBC interface and Java tools],
1.105     peter     403: [AC_MSG_RESULT(yes)
1.108     petere    404: PGAC_PATH_ANT
                    405: if test -z "$ANT"; then
1.208     momjian   406:   AC_MSG_ERROR([Ant is required to build Java components
                    407: If you have Ant already installed, see config.log for details on the failure.])
1.201     momjian   408: fi
                    409: if "$ANT" -version | sed q | egrep -v ' 1\.[[5-9]]| [[2-9]]\.' >/dev/null ; then
                    410:   AC_MSG_ERROR([Ant version >= 1.5 is required to build Java components])
1.108     petere    411: fi],
1.105     peter     412: [AC_MSG_RESULT(no)])
                    413: AC_SUBST(with_java)
1.13      petere    414: 
1.28      petere    415: dnl A note on the Kerberos and OpenSSL options:
1.13      petere    416: dnl
1.28      petere    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
                    423: dnl is non-standard.
                    424: 
                    425: #
                    426: # Kerberos 4
                    427: #
1.171     petere    428: AC_MSG_CHECKING([whether to build with Kerberos 4 support])
                    429: PGAC_ARG_OPTARG(with, krb4, [[  --with-krb4[=DIR]       build with Kerberos 4 support [/usr/athena]]],
1.42      petere    430:                 [krb4_prefix=/usr/athena],
                    431:                 [krb4_prefix=$withval],
                    432: [
1.171     petere    433:   AC_MSG_RESULT(yes)
1.242     petere    434:   AC_DEFINE(KRB4, 1, [Define to build with Kerberos 4 support. (--with-krb4)])
1.28      petere    435: 
1.68      petere    436:   if test -d "$krb4_prefix/include"; then
                    437:     INCLUDES="$INCLUDES -I$krb4_prefix/include"
                    438:   fi
                    439:   if test -d "$krb4_prefix/lib"; then
                    440:     LIBDIRS="$LIBDIRS -L$krb4_prefix/lib"
1.13      petere    441:   fi
1.37      petere    442: 
1.42      petere    443:   krb_srvtab="/etc/srvtab"
1.171     petere    444: ],
                    445: [AC_MSG_RESULT(no)])
1.42      petere    446: 
                    447: AC_SUBST(with_krb4)
1.13      petere    448: 
                    449: 
1.28      petere    450: #
                    451: # Kerberos 5
                    452: #
1.171     petere    453: AC_MSG_CHECKING([whether to build with Kerberos 5 support])
                    454: PGAC_ARG_OPTARG(with, krb5, [[  --with-krb5[=DIR]       build with Kerberos 5 support [/usr/athena]]],
1.42      petere    455:               [krb5_prefix=/usr/athena],
                    456:               [krb5_prefix=$withval],
                    457: [
1.171     petere    458:   AC_MSG_RESULT([yes])
1.242     petere    459:   AC_DEFINE(KRB5, 1, [Define to build with Kerberos 5 support. (--with-krb5)])
1.28      petere    460: 
1.68      petere    461:   if test -d "$krb5_prefix/include"; then
                    462:     INCLUDES="$INCLUDES -I$krb5_prefix/include"
                    463:   fi
                    464:   if test -d "$krb5_prefix/lib"; then
                    465:     LIBDIRS="$LIBDIRS -L$krb5_prefix/lib"
1.13      petere    466:   fi
1.28      petere    467: 
1.42      petere    468:   krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
1.171     petere    469: ],
                    470: [AC_MSG_RESULT(no)])
1.42      petere    471: 
                    472: AC_SUBST(with_krb5)
1.28      petere    473: 
                    474: 
                    475: # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
                    476: if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
                    477:   AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
                    478: fi
1.13      petere    479: 
1.37      petere    480: AC_SUBST(krb_srvtab)
1.13      petere    481: 
                    482: 
1.28      petere    483: #
                    484: # Kerberos configuration parameters
                    485: #
1.42      petere    486: PGAC_ARG_REQ(with, krb-srvnam,
1.68      petere    487:              [  --with-krb-srvnam=NAME  name of the service principal in Kerberos [postgres]],
1.42      petere    488:              [],
                    489:              [with_krb_srvnam="postgres"])
                    490: AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
1.242     petere    491:                    [Define to the name of the PostgreSQL service principal in Kerberos. (--with-krb-srvnam=NAME)])
1.13      petere    492: 
1.28      petere    493: 
1.136     momjian   494: #
                    495: # PAM
                    496: #
                    497: AC_MSG_CHECKING([whether to build with PAM support])
1.158     petere    498: PGAC_ARG_BOOL(with, pam, no,
                    499:               [  --with-pam              build with PAM support],
1.242     petere    500:               [AC_DEFINE([USE_PAM], 1, [Define to 1 to build with PAM support. (--with-pam)])])
1.158     petere    501: AC_MSG_RESULT([$with_pam])
1.136     momjian   502: AC_SUBST(with_pam)
                    503: 
1.28      petere    504: 
                    505: #
1.258     momjian   506: # Rendezvous
                    507: #
                    508: AC_MSG_CHECKING([whether to build with Rendezvous support])
                    509: PGAC_ARG_BOOL(with, rendezvous, no,
                    510:               [  --with-rendezvous       build with Rendezvous support],
                    511:               [AC_DEFINE([USE_RENDEZVOUS], 1, [Define to 1 to build with Rendezvous support. (--with-rendezvous)])])
                    512: AC_MSG_RESULT([$with_rendezvous])
                    513: AC_SUBST(with_rendezvous)
                    514: 
                    515: 
                    516: #
1.28      petere    517: # OpenSSL
                    518: #
1.42      petere    519: PGAC_ARG_OPTARG(with, openssl,
1.171     petere    520:                 [[  --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]]],
1.42      petere    521:                 [openssl_prefix=/usr/local/ssl],
                    522:                 [openssl_prefix=$withval],
                    523: [
1.28      petere    524:   AC_MSG_RESULT([building with OpenSSL support])
1.242     petere    525:   AC_DEFINE([USE_SSL], 1, [Define to build with (Open)SSL support. (--with-openssl)])
1.28      petere    526: 
                    527:   if test -d "${openssl_prefix}/include" ; then
                    528:     INCLUDES="$INCLUDES -I${openssl_prefix}/include"
                    529:   fi
                    530:   if test -d "${openssl_prefix}/lib" ; then
1.68      petere    531:     LIBDIRS="$LIBDIRS -L${openssl_prefix}/lib"
1.28      petere    532:   fi
1.42      petere    533: ])
                    534: 
                    535: AC_SUBST(with_openssl)
1.28      petere    536: 
1.13      petere    537: 
1.177     petere    538: #
                    539: # Readline
                    540: #
                    541: PGAC_ARG_BOOL(with, readline, yes,
                    542:               [  --without-readline      do not use Readline])
                    543: 
                    544: #
                    545: # Zlib
                    546: #
                    547: PGAC_ARG_BOOL(with, zlib, yes,
                    548:               [  --without-zlib          do not use Zlib])
1.3       momjian   549: 
1.254     momjian   550: #
                    551: # Elf
                    552: #
1.3       momjian   553: 
1.30      petere    554: # Assume system is ELF if it predefines __ELF__ as 1,
                    555: # otherwise believe host_os based default.
                    556: case $host_os in
1.127     momjian   557:     freebsd1*|freebsd2*) elf=no;;
                    558:     freebsd3*|freebsd4*) elf=yes;;
1.30      petere    559: esac
1.1       petere    560: 
                    561: AC_EGREP_CPP(yes,
                    562: [#if __ELF__
                    563:   yes
                    564: #endif
                    565: ],
1.30      petere    566: [ELF_SYS=true],
                    567: [if test "X$elf" = "Xyes" ; then
                    568:   ELF_SYS=true
1.1       petere    569: else
1.30      petere    570:   ELF_SYS=
                    571: fi])
                    572: AC_SUBST(ELF_SYS)
1.1       petere    573: 
1.254     momjian   574: #
                    575: # Assignments
                    576: #
1.1       petere    577: 
1.30      petere    578: CPPFLAGS="$CPPFLAGS $INCLUDES"
1.68      petere    579: LDFLAGS="$LDFLAGS $LIBDIRS"
1.30      petere    580: 
1.171     petere    581: AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
                    582: AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
1.30      petere    583: 
                    584: 
1.2       petere    585: AC_PROG_AWK
1.39      petere    586: PGAC_PATH_FLEX
1.1       petere    587: AC_PROG_LN_S
1.62      petere    588: AC_PROG_LD
1.67      petere    589: AC_SUBST(LD)
                    590: AC_SUBST(with_gnu_ld)
1.130     momjian   591: case $host_os in sysv5*)
1.77      petere    592:   AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R],
                    593:   [
                    594:     pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,-R/usr/lib"
                    595:     AC_TRY_LINK([], [], [pgac_cv_prog_ld_R=yes], [pgac_cv_prog_ld_R=no])
                    596:     LDFLAGS=$pgac_save_LDFLAGS
                    597:   ])
                    598:   ld_R_works=$pgac_cv_prog_ld_R
                    599:   AC_SUBST(ld_R_works)
                    600: esac
1.1       petere    601: AC_PROG_RANLIB
1.58      petere    602: AC_CHECK_PROGS(LORDER, lorder)
1.56      petere    603: AC_PATH_PROG(TAR, tar)
1.176     petere    604: PGAC_CHECK_STRIP
1.98      petere    605: 
                    606: AC_CHECK_PROGS(YACC, ['bison -y'])
1.255     momjian   607: 
                    608: if test "$YACC"; then
1.257     tgl       609:   if $YACC --version | sed q | $AWK '{ if ($4 < 1.875) exit 0; else exit 1;}'; then
1.255     momjian   610:     AC_MSG_WARN([
                    611: *** The installed version of Bison is too old.  PostgreSQL needs
                    612: *** Bison version 1.875 or later.])
                    613:   fi
                    614: fi
                    615: 
1.98      petere    616: if test -z "$YACC"; then
                    617:   AC_MSG_WARN([
                    618: *** Without Bison you will not be able to build PostgreSQL from CVS or
                    619: *** change any of the parser definition files.  You can obtain Bison from
                    620: *** a GNU mirror site.  (If you are using the official distribution of
                    621: *** PostgreSQL then you do not need to worry about this because the Bison
                    622: *** output is pre-generated.)  To use a different yacc program (possible,
                    623: *** but not recommended), set the environment variable YACC before running
                    624: *** 'configure'.])
                    625: fi
1.6       petere    626: AC_SUBST(YFLAGS)
1.98      petere    627: 
1.199     momjian   628: PGAC_PATH_PERL
                    629: if test "$with_perl" = yes; then
1.205     petere    630:   PGAC_CHECK_PERL_CONFIGS([archlibexp,privlibexp,useshrplib])
1.199     momjian   631:   PGAC_CHECK_PERL_EMBED_LDFLAGS
1.126     petere    632: fi
                    633: 
                    634: if test "$with_python" = yes; then
                    635:   PGAC_PATH_PYTHON
                    636:   PGAC_CHECK_PYTHON_EMBED_SETUP
1.43      petere    637: fi
1.1       petere    638: 
                    639: 
1.183     tgl       640: ##
1.29      petere    641: ## Libraries
                    642: ##
                    643: 
1.1       petere    644: if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
                    645: then
                    646:        AC_CHECK_LIB(bsd,      main)
                    647: fi
1.21      petere    648: AC_CHECK_LIB(util,     setproctitle)
1.1       petere    649: AC_CHECK_LIB(m,        main)
                    650: AC_CHECK_LIB(dl,       main)
1.181     momjian   651: AC_CHECK_LIB(nsl,      main)
1.1       petere    652: AC_CHECK_LIB(socket,   main)
                    653: AC_CHECK_LIB(ipc,      main)
                    654: AC_CHECK_LIB(IPC,      main)
                    655: AC_CHECK_LIB(lc,       main)
                    656: AC_CHECK_LIB(dld,      main)
                    657: AC_CHECK_LIB(ld,       main)
                    658: AC_CHECK_LIB(compat,   main)
                    659: AC_CHECK_LIB(BSD,      main)
                    660: AC_CHECK_LIB(gen,      main)
                    661: AC_CHECK_LIB(PW,       main)
1.95      petere    662: AC_CHECK_LIB(resolv,   main)
1.209     momjian   663: AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
1.139     petere    664: # QNX:
1.223     momjian   665: AC_CHECK_LIB(unix, main)
1.21      petere    666: AC_SEARCH_LIBS(crypt,  crypt)
1.139     petere    667: # BeOS:
1.273     tgl       668: if test "$PORTNAME" = "beos"
                    669: then
                    670:        AC_CHECK_LIB(bind, __inet_ntoa)
                    671: fi
1.139     petere    672: # Solaris:
1.140     petere    673: AC_SEARCH_LIBS(fdatasync, [rt posix4])
1.206     petere    674: # Cygwin:
                    675: AC_CHECK_LIB(cygipc, shmget)
1.280     tgl       676: # WIN32:
                    677: if test "$PORTNAME" = "win32"
                    678: then
                    679:        AC_CHECK_LIB(wsock32, main)
                    680: fi
1.28      petere    681: 
1.177     petere    682: if test "$with_readline" = yes; then
                    683:   PGAC_CHECK_READLINE
                    684:   if test x"$pgac_cv_check_readline" = x"no"; then
                    685:     AC_MSG_ERROR([readline library not found
1.208     momjian   686: If you have readline already installed, see config.log for details on the
                    687: failure.  It is possible the compiler isn't looking in the proper directory.
1.177     petere    688: Use --without-readline to disable readline support.])
                    689:   fi
                    690: fi
                    691: 
                    692: if test "$with_zlib" = yes; then
                    693:   AC_CHECK_LIB(z, inflate, [],
                    694:                [AC_MSG_ERROR([zlib library not found
1.208     momjian   695: If you have zlib already installed, see config.log for details on the
                    696: failure.  It is possible the compiler isn't looking in the proper directory.
1.177     petere    697: Use --without-zlib to disable zlib support.])])
1.287     momjian   698: fi
                    699: 
1.289     momjian   700: if test "$enable_spinlocks" = yes; then
1.287     momjian   701:   AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
                    702: else
                    703:   AC_MSG_WARN([
                    704: *** Not using spinlocks will cause poor performance.])
1.177     petere    705: fi
                    706: 
1.28      petere    707: if test "$with_krb4" = yes ; then
1.223     momjian   708:   AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])])
                    709:   AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])])
1.250     momjian   710:   AC_REPLACE_FUNCS([gethostname])
1.28      petere    711: fi
                    712: 
                    713: if test "$with_krb5" = yes ; then
1.166     petere    714:   AC_SEARCH_LIBS(com_err, [krb5 'krb5 -ldes -lasn1 -lroken' com_err], [],
                    715:                  [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
                    716:   AC_SEARCH_LIBS(krb5_encrypt, [krb5 'krb5 -ldes -lasn1 -lroken' crypto k5crypto], [],
                    717:                  [AC_MSG_ERROR([could not find function 'krb5_encrypt' required for Kerberos 5])])
                    718:   AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -ldes -lasn1 -lroken'], [],
                    719:                  [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
1.28      petere    720: fi
                    721: 
                    722: if test "$with_openssl" = yes ; then
                    723:   dnl Order matters!
1.223     momjian   724:   AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
                    725:   AC_CHECK_LIB(ssl,    SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
1.128     petere    726: fi
                    727: 
1.136     momjian   728: if test "$with_pam" = yes ; then
1.223     momjian   729:   AC_CHECK_LIB(pam,    pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])])
1.136     momjian   730: fi
                    731: 
1.171     petere    732: 
1.29      petere    733: ##
                    734: ## Header files
                    735: ##
1.194     petere    736: 
1.171     petere    737: dnl sys/socket.h is required by AC_FUNC_ACCEPT_ARGTYPES
1.238     tgl       738: AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h poll.h pwd.h sys/ipc.h sys/poll.h sys/pstat.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/un.h termios.h utime.h kernel/OS.h kernel/image.h SupportDefs.h])
1.66      tgl       739: 
1.171     petere    740: # At least on IRIX, cpp test for netinet/tcp.h will fail unless
                    741: # netinet/in.h is included first.
1.223     momjian   742: AC_CHECK_HEADERS(netinet/in.h)
                    743: AC_CHECK_HEADERS(netinet/tcp.h, [], [],
1.173     petere    744: [AC_INCLUDES_DEFAULT
                    745: #ifdef HAVE_NETINET_IN_H
1.66      tgl       746: #include <netinet/in.h>
                    747: #endif
1.171     petere    748: ])
1.73      petere    749: 
1.177     petere    750: if test "$with_readline" = yes; then
1.223     momjian   751:   AC_CHECK_HEADERS(readline/readline.h, [],
1.237     momjian   752:                    [AC_CHECK_HEADERS(editline/readline.h, [],
                    753:                          [AC_CHECK_HEADERS(readline.h, [],
1.177     petere    754:                                      [AC_MSG_ERROR([readline header not found
1.208     momjian   755: If you have readline already installed, see config.log for details on the
                    756: failure.  It is possible the compiler isn't looking in the proper directory.
1.237     momjian   757: Use --without-readline to disable readline support.])])])])
1.223     momjian   758:   AC_CHECK_HEADERS(readline/history.h, [],
1.237     momjian   759:                    [AC_CHECK_HEADERS(editline/history.h, [],
                    760:                          [AC_CHECK_HEADERS(history.h, [],
1.177     petere    761:                                      [AC_MSG_ERROR([history header not found
1.208     momjian   762: If you have readline already installed, see config.log for details on the
                    763: failure.  It is possible the compiler isn't looking in the proper directory.
1.237     momjian   764: Use --without-readline to disable readline support.])])])])
1.177     petere    765: fi
                    766: 
                    767: if test "$with_zlib" = yes; then
                    768:   AC_CHECK_HEADER(zlib.h, [], [AC_MSG_ERROR([zlib header not found
1.232     momjian   769: If you have zlib already installed, see config.log for details on the
1.208     momjian   770: failure.  It is possible the compiler isn't looking in the proper directory.
1.177     petere    771: Use --without-zlib to disable zlib support.])])
                    772: fi
1.15      petere    773: 
1.28      petere    774: if test "$with_krb4" = yes ; then
                    775:   AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
                    776: fi
                    777: 
                    778: if test "$with_krb5" = yes ; then
                    779:   AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
                    780:   AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
                    781: fi
                    782: 
                    783: if test "$with_openssl" = yes ; then
1.223     momjian   784:   AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
                    785:   AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
1.136     momjian   786: fi
                    787: 
                    788: if test "$with_pam" = yes ; then
1.236     momjian   789:   AC_CHECK_HEADERS(security/pam_appl.h, [],
                    790:                    [AC_CHECK_HEADERS(pam/pam_appl.h, [],
                    791:                                      [AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required for PAM.])])])
1.258     momjian   792: fi
                    793: 
                    794: if test "$with_rendezvous" = yes ; then
                    795:   AC_CHECK_HEADER(DNSServiceDiscovery/DNSServiceDiscovery.h, [], [AC_MSG_ERROR([header file <DNSServiceDiscovery/DNSServiceDiscovery.h> is required for Rendezvous])])
1.28      petere    796: fi
                    797: 
1.1       petere    798: 
1.29      petere    799: ##
                    800: ## Types, structures, compiler characteristics
                    801: ##
1.194     petere    802: 
1.171     petere    803: m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
1.1       petere    804: AC_C_CONST
                    805: AC_C_INLINE
                    806: AC_C_STRINGIZE
1.40      petere    807: PGAC_C_SIGNED
1.171     petere    808: AC_C_VOLATILE
1.244     tgl       809: PGAC_C_FUNCNAME_SUPPORT
1.253     tgl       810: PGAC_STRUCT_TIMEZONE
1.29      petere    811: PGAC_UNION_SEMUN
1.44      petere    812: PGAC_STRUCT_SOCKADDR_UN
1.259     momjian   813: PGAC_STRUCT_SOCKADDR_STORAGE
1.270     tgl       814: PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
1.241     tgl       815: PGAC_STRUCT_ADDRINFO
1.166     petere    816: 
1.171     petere    817: AC_CHECK_TYPES([struct cmsgcred, struct fcred, struct sockcred], [], [],
                    818: [#include <sys/param.h>
1.260     tgl       819: #include <sys/types.h>
1.171     petere    820: #include <sys/socket.h>
                    821: #include <sys/ucred.h>])
                    822: 
1.278     tgl       823: AC_CHECK_TYPES([struct option], [], [],
                    824: [#ifdef HAVE_GETOPT_H
1.279     tgl       825: #include <getopt.h>
1.278     tgl       826: #endif])
                    827: 
1.177     petere    828: if test "$with_zlib" = yes; then
                    829:   # Check that <zlib.h> defines z_streamp (versions before about 1.0.4
                    830:   # did not).  While we could work around the lack of z_streamp, it
                    831:   # seems unwise to encourage people to use such old zlib versions...
                    832:   AC_CHECK_TYPE(z_streamp, [], [AC_MSG_ERROR([zlib version is too old
                    833: Use --without-zlib to disable zlib support.])],
                    834:                 [#include <zlib.h>])
                    835: fi
                    836: 
1.166     petere    837: if test "$with_krb5" = yes; then
                    838: # Check for differences between MIT and Heimdal (KTH) releases
1.223     momjian   839:   AC_CHECK_MEMBERS(krb5_ticket.enc_part2, [],
1.229     momjian   840:                    [AC_CHECK_MEMBERS(krb5_ticket.client, [],
1.171     petere    841:                                      [AC_MSG_ERROR([could not determine how to get client name from Kerberos 5 ticket])],
                    842:                                      [#include <krb5.h>])],
                    843:                    [#include <krb5.h>])
1.223     momjian   844:   AC_CHECK_MEMBERS(krb5_error.text.data, [],
                    845:                    [AC_CHECK_MEMBERS(krb5_error.e_data, [],
1.205     petere    846:                                      [AC_MSG_ERROR([could not determine how to extract Kerberos 5 error messages])],
                    847:                                      [#include <krb5.h>])],
1.171     petere    848:                    [#include <krb5.h>])
1.166     petere    849: fi
                    850: 
1.1       petere    851: 
1.29      petere    852: ##
                    853: ## Functions, global variables
                    854: ##
1.194     petere    855: 
1.6       petere    856: PGAC_VAR_INT_TIMEZONE
1.29      petere    857: AC_FUNC_ACCEPT_ARGTYPES
1.6       petere    858: PGAC_FUNC_GETTIMEOFDAY_1ARG
1.1       petere    859: 
1.159     momjian   860: # SunOS doesn't handle negative byte comparisons properly with +/- return
1.194     petere    861: AC_FUNC_MEMCMP
1.159     momjian   862: 
1.245     momjian   863: AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getpeereid memmove poll pstat setproctitle setsid sigprocmask symlink sysconf utime utimes waitpid])
1.99      tgl       864: 
1.171     petere    865: AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
1.226     momjian   866: 
1.284     tgl       867: HAVE_IPV6=no
1.240     petere    868: AC_CHECK_TYPE([struct sockaddr_in6],
                    869:               [AC_CHECK_FUNC(inet_ntop,
1.284     tgl       870:                              [AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])
                    871:                                                          HAVE_IPV6=yes])],
1.240     petere    872:               [],
1.231     petere    873: [$ac_includes_default
1.240     petere    874: #include <netinet/in.h>])
1.284     tgl       875: AC_SUBST(HAVE_IPV6)
1.1       petere    876: 
1.28      petere    877: AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
                    878: [AC_TRY_LINK(
                    879: [#include <machine/vmparam.h>
                    880: #include <sys/exec.h>
                    881: ],
1.1       petere    882: [PS_STRINGS->ps_nargvstr = 1;
                    883: PS_STRINGS->ps_argvstr = "foo";],
1.28      petere    884: [pgac_cv_var_PS_STRINGS=yes],
                    885: [pgac_cv_var_PS_STRINGS=no])])
                    886: if test "$pgac_cv_var_PS_STRINGS" = yes ; then
1.242     petere    887:   AC_DEFINE([HAVE_PS_STRINGS], [], [Define to 1 if the PS_STRINGS thing exists.])
1.28      petere    888: fi
1.1       petere    889: 
1.171     petere    890: 
                    891: # We use our snprintf.c emulation if either snprintf() or vsnprintf()
                    892: # is missing.  Yes, there are machines that have only one.  We may
                    893: # also decide to use snprintf.c if snprintf() is present but does not
                    894: # have working "long long int" support -- see below.
                    895: 
1.194     petere    896: pgac_need_repl_snprintf=no
                    897: AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
                    898: AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
1.171     petere    899: 
                    900: 
                    901: # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
                    902: # include/c.h will provide declarations.  Note this is a separate test
                    903: # from whether the functions exist in the C library --- there are
                    904: # systems that have the functions but don't bother to declare them :-(
                    905: 
                    906: AC_CHECK_DECLS([snprintf, vsnprintf])
                    907: 
1.29      petere    908: 
                    909: # do this one the hard way in case isinf() is a macro
                    910: AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
1.1       petere    911: [AC_TRY_LINK(
1.29      petere    912: [#include <math.h>
                    913: ],
1.1       petere    914: [double x = 0.0; int res = isinf(x);],
1.29      petere    915: [ac_cv_func_isinf=yes],
                    916: [ac_cv_func_isinf=no])])
                    917: 
                    918: if test $ac_cv_func_isinf = yes ; then
1.242     petere    919:   AC_DEFINE(HAVE_ISINF, 1, [Define to 1 if you have isinf().])
1.1       petere    920: else
1.194     petere    921:   AC_LIBOBJ(isinf)
1.29      petere    922:   # Look for a way to implement a substitute for isinf()
                    923:   AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
1.1       petere    924: fi
1.171     petere    925: 
1.278     tgl       926: AC_REPLACE_FUNCS([crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
1.241     tgl       927: 
                    928: # system's version of getaddrinfo(), if any, may be used only if we found
                    929: # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
                    930: if test x"$ac_cv_type_struct_addrinfo" = xyes ; then
                    931:   AC_REPLACE_FUNCS([getaddrinfo])
                    932: else
                    933:   AC_LIBOBJ(getaddrinfo)
1.278     tgl       934: fi
                    935: 
                    936: # similarly, use system's getopt_long() only if system provides struct option.
                    937: if test x"$ac_cv_type_struct_option" = xyes ; then
                    938:   AC_REPLACE_FUNCS([getopt_long])
                    939: else
                    940:   AC_LIBOBJ(getopt_long)
1.241     tgl       941: fi
1.193     momjian   942: 
1.216     momjian   943: # BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
1.214     momjian   944: # We override the previous test that said fseeko/ftello didn't exist
1.216     momjian   945: # OS tests are also done in include/c.h and port/fseeko.c
                    946: case $host_os in bsdi*|netbsd*)
1.214     momjian   947: ac_cv_func_fseeko=yes
                    948: esac
                    949: 
1.222     momjian   950: # Solaris has a very slow qsort in certain cases, so we replace it.
1.243     momjian   951: case $host_os in solaris*) 
                    952: AC_LIBOBJ(qsort) ;;
                    953: esac
                    954: 
                    955: # Win32 can't to rename or unlink on an open file
1.251     momjian   956: case $host_os in mingw*)
                    957: AC_LIBOBJ(dirmod)
1.252     momjian   958: AC_LIBOBJ(copydir)
                    959: AC_LIBOBJ(gettimeofday) ;;
1.193     momjian   960: esac
1.52      petere    961: 
1.177     petere    962: if test "$with_readline" = yes; then
                    963:   PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
                    964:   AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function])
1.237     momjian   965:   AC_CHECK_FUNCS([replace_history_entry])
1.177     petere    966: fi
1.1       petere    967: 
                    968: 
                    969: dnl Cannot use AC_CHECK_FUNC because finite may be a macro
                    970: AC_MSG_CHECKING(for finite)
                    971: AC_TRY_LINK([#include <math.h>],
1.171     petere    972:             [int dummy=finite(1.0);],
1.242     petere    973:             [AC_DEFINE(HAVE_FINITE, 1, [Define to 1 if you have finite().])
1.171     petere    974: AC_MSG_RESULT(yes)],
                    975:             [AC_MSG_RESULT(no)])
1.1       petere    976: 
                    977: dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
                    978: dnl (especially on GNU libc)
1.242     petere    979: dnl See also comments in c.h.
1.1       petere    980: AC_MSG_CHECKING(for sigsetjmp)
                    981: AC_TRY_LINK([#include <setjmp.h>],
1.171     petere    982:             [sigjmp_buf x; sigsetjmp(x, 1);],
1.242     petere    983:             [AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have sigsetjmp().])
1.171     petere    984: AC_MSG_RESULT(yes)],
                    985:             [AC_MSG_RESULT(no)])
1.1       petere    986: 
1.222     momjian   987: AC_CHECK_FUNC(syslog,
1.242     petere    988:               [AC_CHECK_HEADER(syslog.h,
                    989:                                [AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])
1.1       petere    990: 
1.76      petere    991: AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
                    992: [AC_TRY_LINK([#include <unistd.h>],
                    993:   [extern int optreset; optreset = 1;],
                    994:   [pgac_cv_var_int_optreset=yes],
                    995:   [pgac_cv_var_int_optreset=no])])
                    996: if test x"$pgac_cv_var_int_optreset" = x"yes"; then
1.242     petere    997:   AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
1.76      petere    998: fi
                    999: 
1.194     petere   1000: AC_CHECK_FUNCS([strtoll strtoq], [break])
                   1001: AC_CHECK_FUNCS([strtoull strtouq], [break])
                   1002: 
                   1003: # Check for one of atexit() or on_exit()
                   1004: AC_CHECK_FUNCS(atexit, [],
                   1005:                [AC_CHECK_FUNCS(on_exit, [],
1.225     momjian  1006:                [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
1.213     momjian  1007: 
1.195     petere   1008: AC_FUNC_FSEEKO
1.266     momjian  1009: 
                   1010: #
                   1011: # Pthreads
                   1012: #
                   1013: # For each platform, we need to know about any special compile and link
                   1014: # libraries, and whether the normal C function names are thread-safe.
1.281     momjian  1015: # See the comment at the top of src/port/thread.c for more information.
1.266     momjian  1016: #
1.271     momjian  1017: if test "$enable_thread_safety" = yes; then
1.281     momjian  1018: AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safetys])])
1.266     momjian  1019: 
1.292     momjian  1020: if test "$THREAD_SUPPORT" != yes; then
1.266     momjian  1021: AC_MSG_ERROR([
                   1022: Cannot enable threads on your platform.
                   1023: Please report your platform threading info to the PostgreSQL mailing lists
1.268     momjian  1024: so it can be added to the next release.  Report all compile flags, link flags,
1.266     momjian  1025: functions, or libraries required for threading support.
1.281     momjian  1026: See the comment at the top of src/port/thread.c for more information.
1.266     momjian  1027: ])
                   1028: fi
1.275     momjian  1029: else
                   1030: # do not use values from template file
1.291     momjian  1031: THREAD_CPPFLAGS=
1.275     momjian  1032: THREAD_LIBS=
1.266     momjian  1033: fi
1.292     momjian  1034: AC_SUBST(THREAD_SUPPORT)
1.291     momjian  1035: AC_SUBST(THREAD_CPPFLAGS)
1.266     momjian  1036: AC_SUBST(THREAD_LIBS)
                   1037: 
1.262     momjian  1038: 
                   1039: #
                   1040: # Check for re-entrant versions of certain functions
                   1041: #
1.263     momjian  1042: # Include special flags if threads are enabled _and_ if required for 
                   1043: # threading on this platform.  Some platforms have *_r functions but
                   1044: # their natively named funcs are threadsafe, and should be used instead.
                   1045: #
1.268     momjian  1046: # One trick here is that if we don't call AC_CHECK_FUNCS, the
1.263     momjian  1047: # functions are marked "not found", which is perfect.
1.262     momjian  1048: #
1.288     momjian  1049: if test "$enable_thread_safety" = yes -a "$NEED_REENTRANT_FUNCS" = yes ; then
1.262     momjian  1050: _CFLAGS="$CFLAGS"
1.275     momjian  1051: _LIBS="$LIBS"
1.291     momjian  1052: CFLAGS="$CFLAGS $THREAD_CPPFLAGS"
1.262     momjian  1053: LIBS="$LIBS $THREAD_LIBS"
1.288     momjian  1054: AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
1.262     momjian  1055: CFLAGS="$_CFLAGS"
1.275     momjian  1056: LIBS="$_LIBS"
1.263     momjian  1057: fi
1.195     petere   1058: 
1.109     petere   1059: 
                   1060: # This test makes sure that run tests work at all.  Sometimes a shared
                   1061: # library is found by the linker, but the runtime linker can't find it.
                   1062: # This check should come after all modifications of compiler or linker
                   1063: # variables, and before any other run tests.
                   1064: AC_MSG_CHECKING([test program])
                   1065: AC_TRY_RUN([int main() { return 0; }],
                   1066: [AC_MSG_RESULT(ok)],
                   1067: [AC_MSG_RESULT(failed)
                   1068: AC_MSG_ERROR([[
                   1069: *** Could not execute a simple test program.  This may be a problem
                   1070: *** related to locating shared libraries.  Check the file 'config.log'
                   1071: *** for the exact reason.]])],
                   1072: [AC_MSG_RESULT([cross-compiling])])
                   1073: 
                   1074: 
1.1       petere   1075: dnl Check to see if we have a working 64-bit integer type.
                   1076: dnl This breaks down into two steps:
                   1077: dnl (1) figure out if the compiler has a 64-bit int type with working
                   1078: dnl arithmetic, and if so
                   1079: dnl (2) see whether snprintf() can format the type correctly.  (Currently,
                   1080: dnl snprintf is the only library routine we really need for int8 support.)
                   1081: dnl It's entirely possible to have a compiler that handles a 64-bit type
                   1082: dnl when the C library doesn't; this is fairly likely when using gcc on
                   1083: dnl an older platform, for example.
                   1084: dnl If there is no native snprintf() or it does not handle the 64-bit type,
                   1085: dnl we force our own version of snprintf() to be used instead.
                   1086: dnl Note this test must be run after our initial check for snprintf/vsnprintf.
                   1087: 
1.6       petere   1088: PGAC_TYPE_64BIT_INT([long int])
1.1       petere   1089: 
1.6       petere   1090: if test x"$HAVE_LONG_INT_64" = x"no" ; then
                   1091:   PGAC_TYPE_64BIT_INT([long long int])
                   1092: fi
1.1       petere   1093: 
                   1094: 
1.112     tgl      1095: dnl If we need to use "long long int", figure out whether nnnLL notation works.
                   1096: 
1.201     momjian  1097: if test x"$HAVE_LONG_LONG_INT_64" = xyes ; then
1.112     tgl      1098:   AC_TRY_COMPILE([
                   1099: #define INT64CONST(x)  x##LL
                   1100: long long int foo = INT64CONST(0x1234567890123456);
                   1101: ],
                   1102:        [],
1.242     petere   1103:        [AC_DEFINE(HAVE_LL_CONSTANTS, 1, [Define to 1 if constants of type 'long long int' should have the suffix LL.])],
1.112     tgl      1104:        [])
                   1105: fi
                   1106: 
                   1107: 
1.234     petere   1108: # If we found "long int" is 64 bits, assume snprintf handles it.  If
                   1109: # we found we need to use "long long int", better check.  We cope with
                   1110: # snprintfs that use either %lld, %qd, or %I64d as the format.  If
                   1111: # neither works, fall back to our own snprintf emulation (which we
                   1112: # know uses %lld).
1.1       petere   1113: 
1.234     petere   1114: if test "$HAVE_LONG_LONG_INT_64" = yes ; then
1.194     petere   1115:   if test $pgac_need_repl_snprintf = no; then
1.234     petere   1116:     PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
                   1117:     if test "$LONG_LONG_INT_FORMAT" = ""; then
                   1118:       # Force usage of our own snprintf, since system snprintf is broken
                   1119:       pgac_need_repl_snprintf=yes
                   1120:       LONG_LONG_INT_FORMAT='%lld'
                   1121:     fi
1.1       petere   1122:   else
1.234     petere   1123:     # Here if we previously decided we needed to use our own snprintf
                   1124:     LONG_LONG_INT_FORMAT='%lld'
1.1       petere   1125:   fi
1.234     petere   1126:   INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
1.1       petere   1127: else
                   1128:   # Here if we are not using 'long long int' at all
                   1129:   INT64_FORMAT='"%ld"'
                   1130: fi
                   1131: 
1.171     petere   1132: AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT,
1.242     petere   1133:                    [Define to the appropriate snprintf format for 64-bit ints, if any.])
1.1       petere   1134: 
1.194     petere   1135: if test $pgac_need_repl_snprintf = yes; then
                   1136:   AC_LIBOBJ(snprintf)
                   1137: fi
1.78      petere   1138: 
1.242     petere   1139: # Need a #define for the size of Datum (unsigned long)
1.171     petere   1140: AC_CHECK_SIZEOF([unsigned long])
1.84      tgl      1141: 
1.171     petere   1142: # Determine memory alignment requirements for the basic C data types.
1.1       petere   1143: 
1.6       petere   1144: PGAC_CHECK_ALIGNOF(short)
                   1145: PGAC_CHECK_ALIGNOF(int)
                   1146: PGAC_CHECK_ALIGNOF(long)
1.171     petere   1147: if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
1.6       petere   1148:   PGAC_CHECK_ALIGNOF(long long int)
1.1       petere   1149: fi
1.6       petere   1150: PGAC_CHECK_ALIGNOF(double)
1.1       petere   1151: 
1.171     petere   1152: # Compute maximum alignment of any basic type.
                   1153: # We assume long's alignment is at least as strong as char, short, or int;
                   1154: # but we must check long long (if it exists) and double.
                   1155: 
                   1156: MAX_ALIGNOF=$pgac_cv_alignof_long
                   1157: if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
                   1158:   MAX_ALIGNOF=$pgac_cv_alignof_double
                   1159: fi
                   1160: if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
                   1161:   MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1.1       petere   1162: fi
1.242     petere   1163: AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
1.1       petere   1164: 
1.155     petere   1165: 
1.152     momjian  1166: # Some platforms predefine the types int8, int16, etc.  Only check
1.171     petere   1167: # a (hopefully) representative subset.
                   1168: AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
                   1169: [#include <stdio.h>
1.155     petere   1170: #ifdef HAVE_SUPPORTDEFS_H
                   1171: #include <SupportDefs.h>
1.171     petere   1172: #endif])
1.155     petere   1173: 
1.171     petere   1174: # We also check for sig_atomic_t, which *should* be defined per ANSI
                   1175: # C, but is missing on some old platforms.
1.223     momjian  1176: AC_CHECK_TYPES(sig_atomic_t, [], [], [#include <signal.h>])
1.155     petere   1177: 
1.152     momjian  1178: 
1.6       petere   1179: PGAC_FUNC_POSIX_SIGNALS
1.195     petere   1180: if test $ac_cv_func_fseeko = yes; then
                   1181: AC_SYS_LARGEFILE
                   1182: fi
1.172     petere   1183: 
                   1184: 
1.184     tgl      1185: # Select semaphore implementation type.
                   1186: if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
1.242     petere   1187:   AC_DEFINE(USE_NAMED_POSIX_SEMAPHORES, 1, [Define to select named POSIX semaphores.])
1.184     tgl      1188:   SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
                   1189: else
                   1190:   if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
1.242     petere   1191:     AC_DEFINE(USE_UNNAMED_POSIX_SEMAPHORES, 1, [Define to select unnamed POSIX semaphores.])
1.184     tgl      1192:     SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
                   1193:   else
1.242     petere   1194:     AC_DEFINE(USE_SYSV_SEMAPHORES, 1, [Define to select SysV-style semaphores.])
1.184     tgl      1195:     SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
                   1196:   fi
                   1197: fi
                   1198: 
                   1199: 
                   1200: # Select shared-memory implementation type.
1.242     petere   1201: AC_DEFINE(USE_SYSV_SHARED_MEMORY, 1, [Define to select SysV-style shared memory.])
1.184     tgl      1202: SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
                   1203: 
                   1204: 
1.172     petere   1205: if test "$enable_nls" = yes ; then
                   1206:   PGAC_CHECK_GETTEXT
                   1207: fi
1.1       petere   1208: 
1.43      petere   1209: # Check for Tcl configuration script tclConfig.sh
                   1210: if test "$with_tcl" = yes; then
                   1211:     PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
1.185     petere   1212:     PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH],
1.235     petere   1213:                           [TCL_INCLUDE_SPEC,TCL_LIB_FILE,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
1.185     petere   1214:     AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one
1.43      petere   1215: fi
1.1       petere   1216: 
1.43      petere   1217: # Check for Tk configuration script tkConfig.sh
                   1218: if test "$with_tk" = yes; then
                   1219:     PGAC_PATH_TKCONFIGSH([$with_tkconfig $with_tclconfig])
1.185     petere   1220:     PGAC_EVAL_TCLCONFIGSH([$TK_CONFIG_SH], [TK_LIBS,TK_LIB_SPEC,TK_XINCLUDES])
1.1       petere   1221: fi
                   1222: 
                   1223: 
1.75      petere   1224: #
                   1225: # Check for DocBook and tools
                   1226: #
                   1227: PGAC_PROG_NSGMLS
1.178     petere   1228: PGAC_PROG_JADE
1.223     momjian  1229: PGAC_CHECK_DOCBOOK(3.1)
1.178     petere   1230: PGAC_PATH_DOCBOOK_STYLESHEETS
                   1231: PGAC_PATH_COLLATEINDEX
                   1232: AC_CHECK_PROGS(SGMLSPL, sgmlspl)
1.75      petere   1233: 
1.61      petere   1234: 
1.104     petere   1235: # prepare build tree if outside source tree
1.138     petere   1236: # Note 1: test -ef might not exist, but it's more reliable than `pwd`.
                   1237: # Note 2: /bin/pwd might be better than shell's built-in at getting
                   1238: #         a symlink-free name.
1.171     petere   1239: if test "$no_create" != yes; then
                   1240:   if ( test "$srcdir" -ef . ) >/dev/null 2>&1 || test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
1.138     petere   1241:     :
1.171     petere   1242:   else
                   1243:     AC_SUBST(vpath_build, yes)
                   1244:     _AS_ECHO_N([preparing build tree... ])
                   1245:     pgac_abs_top_srcdir=`cd "$srcdir" && pwd`
                   1246:     $SHELL "$ac_aux_dir/prep_buildtree" "$pgac_abs_top_srcdir" "." \
1.104     petere   1247:       || AC_MSG_ERROR(failed)
                   1248:     AC_MSG_RESULT(done)
1.171     petere   1249:   fi
1.61      petere   1250: fi
1.1       petere   1251: 
1.171     petere   1252: 
                   1253: AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
                   1254: 
                   1255: AC_CONFIG_LINKS([
                   1256:   src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c
1.184     tgl      1257:   src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}
                   1258:   src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}
1.171     petere   1259:   src/include/dynloader.h:src/backend/port/dynloader/${template}.h
                   1260:   src/include/pg_config_os.h:src/include/port/${template}.h
                   1261:   src/Makefile.port:src/makefiles/Makefile.${template}
                   1262: ])
                   1263: 
                   1264: AC_CONFIG_HEADERS([src/include/pg_config.h],
1.85      tgl      1265: [
1.133     petere   1266: # Update timestamp for pg_config.h (see Makefile.global)
1.171     petere   1267: echo >src/include/stamp-h
1.83      petere   1268: ])
1.171     petere   1269: 
                   1270: AC_OUTPUT

PostgreSQL CVSweb <[email protected]>