Annotation of pgsql/configure.in, revision 1.37

1.1       petere      1: dnl Process this file with autoconf to produce a configure script.
1.28      petere      2: 
                      3: dnl Developers, please strive to achieve this order:
                      4: dnl
                      5: dnl 0. Initialization and options processing
                      6: dnl 1. Programs
                      7: dnl 2. Libraries
                      8: dnl 3. Header files
                      9: dnl 4. Types
                     10: dnl 5. Structures
                     11: dnl 6. Compiler characteristics
                     12: dnl 7. Functions, global variables
                     13: dnl 8. System services
                     14: dnl
                     15: dnl Read the Autoconf manual for details.
                     16: 
1.32      petere     17: dnl The GNU folks apparently haven't heard that some people don't use
                     18: dnl Texinfo. Use this sorcery to use "docdir" instead of "infodir".
                     19: define([info], [doc])
                     20: define([infodir], [docdir])
1.1       petere     21: AC_INIT(src/backend/access/common/heaptuple.c)
1.32      petere     22: undefine([infodir])
                     23: undefine([info])
                     24: 
1.1       petere     25: AC_PREFIX_DEFAULT(/usr/local/pgsql)
                     26: AC_CONFIG_HEADER(src/include/config.h)
                     27: 
                     28: AC_PREREQ(2.13)
1.28      petere     29: AC_CONFIG_AUX_DIR(config)
1.5       petere     30: 
1.24      petere     31: VERSION='7.1devel'
                     32: AC_SUBST(VERSION)
                     33: AC_DEFINE_UNQUOTED(PG_VERSION, "$VERSION")
                     34: 
1.1       petere     35: AC_CANONICAL_HOST
                     36: 
1.30      petere     37: template=
                     38: AC_MSG_CHECKING([which template to use])
                     39: 
                     40: # check if --with-template was given
                     41: if test x"${with_template+set}" = xset ; then
                     42:   case $with_template in
                     43:     yes|no) AC_MSG_ERROR([You must supply an argument to the --with-template option.]);;
                     44:     list)   echo; ls "$srcdir/src/template"; exit;;
                     45:     *)      if test -f "$srcdir/src/template/$with_template" ; then
                     46:               template=$with_template
                     47:             else
                     48:               AC_MSG_ERROR([\`$with_template' is not a valid template name. Use \`list' for a list.])
                     49:             fi;;
                     50:   esac
                     51: 
                     52: else # --with-template not given
                     53: 
                     54: case $host_os in
                     55:      aix*) template=aix ;;
                     56:     bsdi*) template=bsdi ;;
                     57:   cygwin*) template=win ;;
                     58:     dgux*) template=dgux ;;
                     59:  freebsd*) template=freebsd ;;
                     60:     hpux*) template=hpux ;;
                     61:     irix*) template=irix5 ;;
                     62:    linux*) template=linux ;;
                     63:   netbsd*) template=netbsd ;;
                     64: nextstep*) template=nextstep ;;
                     65:  openbsd*) template=openbsd ;;
                     66:      osf*) template=osf ;;
                     67:      qnx*) template=qnx4 ;;
                     68:      sco*) template=sco ;;
1.1       petere     69:  solaris*)
1.30      petere     70:        case $host_cpu in
                     71:          sparc) template=solaris_sparc ;;
                     72:           i?86) template=solaris_i386 ;;
1.1       petere     73:        esac ;;
1.30      petere     74:    sunos*) template=sunos4 ;;
1.1       petere     75:  sysv4.2*)
1.30      petere     76:         case $host_vendor in
                     77:           univel) template=univel ;;
                     78:         esac ;;
                     79:    sysv4*) template=svr4 ;;
                     80:  sysv5uw*) template=unixware ;;
                     81:   ultrix*) template=ultrix4 ;;
1.1       petere     82: esac
                     83: 
1.30      petere     84:   if test x"$template" = x"" ; then
                     85:     AC_MSG_ERROR([
                     86: *******************************************************************
                     87: PostgreSQL has apparently not been ported to your platform yet.
1.32      petere     88: To try a manual configuration, look into the src/template directory
1.30      petere     89: for a similar platform and use the \`--with-template=' option.
                     90: 
                     91: Please also contact <[email protected]> to see about
                     92: rectifying this.  Include the above \`checking host system type...'
                     93: line.
                     94: *******************************************************************
                     95: ])
                     96:   fi
                     97: 
                     98: fi # --with-template not given
1.1       petere     99: 
1.30      petere    100: AC_MSG_RESULT([$template])
1.1       petere    101: 
1.30      petere    102: PORTNAME=$template
                    103: CPU=$host_cpu
                    104: AC_SUBST(PORTNAME)
                    105: AC_SUBST(CPU)
1.1       petere    106: 
1.30      petere    107: AC_LINK_FILES([src/backend/port/dynloader/${template}.c], [src/backend/port/dynloader.c])
                    108: AC_LINK_FILES([src/backend/port/dynloader/${template}.h], [src/include/dynloader.h])
                    109: AC_LINK_FILES([src/include/port/${template}.h], [src/include/os.h])
                    110: AC_LINK_FILES([src/makefiles/Makefile.${template}], [src/Makefile.port])
                    111: 
                    112: # Pick right test-and-set (TAS) code. Most platforms have inline
                    113: # assembler code in their port include file, so we just use a dummy
                    114: # file here.
                    115: tas_file=dummy.s
                    116: need_tas=no
                    117: case $template in
                    118:   hpux)           need_tas=yes; tas_file=hpux.s ;;
                    119:   solaris_sparc)  need_tas=yes; tas_file=solaris_sparc.s ;;
                    120:   solaris_i386)   need_tas=yes; tas_file=solaris_i386.s ;;
                    121: esac
1.1       petere    122: 
1.30      petere    123: if test "$need_tas" = yes ; then
                    124:   AC_LINK_FILES([src/backend/port/tas/${tas_file}], [src/backend/port/tas.s])
                    125:   TAS=tas.o
1.1       petere    126: fi
1.30      petere    127: AC_SUBST(TAS)
1.1       petere    128: 
                    129: 
                    130: 
1.30      petere    131: ##
                    132: ## Command line options
                    133: ##
1.13      petere    134: 
1.1       petere    135: 
1.30      petere    136: #
                    137: # Add non-standard directories to the include path
                    138: #
                    139: AC_ARG_WITH(includes, [  --with-includes=DIRS    look for additional header files in DIRS],
                    140: [
                    141:   case $withval in
                    142:     yes | no) AC_MSG_ERROR([You must supply an argument to the --with-includes option.]);;
                    143:   esac
                    144: ])
1.1       petere    145: 
                    146: 
1.30      petere    147: #
                    148: # Add non-standard directories to the library search path
                    149: #
                    150: AC_ARG_WITH(libraries, [  --with-libraries=DIRS   look for additional libraries in DIRS],
                    151: [
                    152:   case $withval in
                    153:     yes | no) AC_MSG_ERROR([You must supply an argument to the --with-libraries option.]);;
                    154:   esac
                    155:   LIBRARY_DIRS=$withval
                    156: ])
1.1       petere    157: 
1.30      petere    158: AC_ARG_WITH(libs,      [  --with-libs=DIRS        alternative spelling of --with-libraries],
                    159: [
                    160:   case $withval in
                    161:     yes | no) AC_MSG_ERROR([You must supply an argument to the --with-libs option.]);;
                    162:   esac
                    163:   LIBRARY_DIRS=$withval
                    164: ])
1.29      petere    165: 
                    166: 
                    167: #
                    168: # Locale (--enable-locale)
                    169: #
                    170: AC_MSG_CHECKING([whether to build with locale support])
                    171: AC_ARG_ENABLE(locale, [  --enable-locale         enable locale support],
                    172: [if test x"$enable_locale" != x"no" ; then
                    173:   enable_locale=yes
1.30      petere    174:   AC_DEFINE(USE_LOCALE, 1, [Set to 1 if you want LOCALE support (--enable-locale)])
1.29      petere    175: fi],
                    176: [enable_locale=no])
                    177: AC_MSG_RESULT([$enable_locale])
1.2       petere    178: 
1.1       petere    179: 
1.29      petere    180: #
                    181: # Cyrillic recode (--enable-recode)
                    182: #
                    183: AC_MSG_CHECKING([whether to build with Cyrillic recode support])
                    184: AC_ARG_ENABLE(recode, [  --enable-recode         enable cyrillic recode support],
                    185: [if test x"$enable_recode" != x"no" ; then
                    186:   enable_recode=yes
1.30      petere    187:   AC_DEFINE(CYR_RECODE, 1, [Set to 1 if you want cyrillic recode support (--enable-recode)])
1.29      petere    188: fi],
                    189: [enable_recode=no])
                    190: AC_MSG_RESULT([$enable_recode])
1.1       petere    191: 
                    192: 
1.29      petere    193: #
                    194: # Multibyte support
                    195: #
                    196: MULTIBYTE=
                    197: AC_MSG_CHECKING([whether to build with multibyte character support])
                    198: AC_ARG_ENABLE(multibyte, [  --enable-multibyte      enable multibyte character support],
                    199: [
                    200:   case $enableval in
                    201:     no)         enable_multibyte=no;;
                    202:     yes)        enable_multibyte=yes; MULTIBYTE=SQL_ASCII;;
                    203:     SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
                    204:                 enable_multibyte=yes; MULTIBYTE=$enableval;;
                    205:     *)          AC_MSG_ERROR(
                    206: [argument to --enable-multibyte must be one of:
1.1       petere    207:   SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW,
                    208:   UNICODE, MULE_INTERNAL,
                    209:   LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
                    210:   KOI8, WIN, ALT
1.29      petere    211: Or do not specify an argument to the option to use the default.]) ;;
                    212:   esac
                    213: ],
                    214: [enable_multibyte=no])
                    215: 
                    216: AC_SUBST(MULTIBYTE)
1.1       petere    217: 
1.29      petere    218: if test "$enable_multibyte" = yes ; then
1.30      petere    219:   AC_DEFINE(MULTIBYTE, 1, [Set to 1 if you want to use multibyte characters (--enable-multibyte)])
1.29      petere    220:   AC_MSG_RESULT([yes, default $MULTIBYTE])
                    221: else
                    222:   AC_MSG_RESULT(no)
1.4       tgl       223: fi
1.1       petere    224: 
                    225: 
1.29      petere    226: #
                    227: # Default port number (--with-pgport), default 5432
                    228: #
                    229: AC_MSG_CHECKING([for default port number])
                    230: AC_ARG_WITH(pgport, [  --with-pgport=PORTNUM   change default port number [5432]],
                    231: [case $withval in
                    232:   yes|no)       AC_MSG_ERROR([You must supply an argument to the --with-pgport option]);;
                    233:   *)            default_port=$withval;;
                    234: esac
                    235: ],
                    236: [default_port=5432])
                    237: # Need both of these because backend wants an integer and frontend a string
1.1       petere    238: AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
                    239: AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
1.29      petere    240: AC_MSG_RESULT([$default_port])
1.1       petere    241: 
                    242: 
1.29      petere    243: #
                    244: # Maximum number of allowed connections (--with-maxbackends), default 32
                    245: #
                    246: AC_MSG_CHECKING([for default soft limit on number of connections])
                    247: AC_ARG_WITH(maxbackends, [  --with-maxbackends=N    set default maximum number of connections [32]],
                    248: [case $withval in
                    249:   yes|no)       AC_MSG_ERROR([You must supply an argument to the --with-maxbackends option]);;
                    250: esac],
                    251: [with_maxbackends=32])
                    252: AC_MSG_RESULT([$with_maxbackends])
                    253: AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, [$with_maxbackends], [The default soft limit on the number of concurrent connections, i.e., the default for the postmaster -N switch (--with-maxbackends)])
                    254: 
1.1       petere    255: 
1.29      petere    256: #
1.30      petere    257: # C compiler
                    258: #
                    259: 
1.29      petere    260: # For historical reasons you can also use --with-CC to specify the C compiler
                    261: # to use, although the standard way to do this is to set the CC environment
                    262: # variable.
                    263: if test "${with_CC+set}" = set; then
                    264:   case $with_CC in
                    265:     yes | no)   AC_MSG_ERROR([You must supply an argument to the --with-CC option.]);;
                    266:     *)          CC=$with_CC;;
                    267:   esac
                    268: fi
1.4       tgl       269: 
1.30      petere    270: # On AIX, default compiler to xlc.
                    271: if test "$template" = aix && test -z "$CC" ; then CC=xlc; fi
1.4       tgl       272: 
                    273: AC_PROG_CC
1.30      petere    274: # Read the template
                    275: . "$srcdir/src/template/$template" || exit
                    276: echo "using CFLAGS=$CFLAGS"
                    277: # Check if the compiler still works with the template settings
                    278: AC_PROG_CC_WORKS
1.4       tgl       279: AC_PROG_CPP
                    280: AC_PROG_GCC_TRADITIONAL
1.30      petere    281: 
1.6       petere    282: AC_SUBST(GCC)
1.30      petere    283: AC_SUBST(AROPT)
                    284: AC_SUBST(SHARED_LIB)
                    285: AC_SUBST(DLSUFFIX)
                    286: AC_SUBST(DL_LIB)
1.4       tgl       287: 
1.29      petere    288: # Create compiler version string
1.24      petere    289: if test x"$GCC" = x"yes" ; then
                    290:   cc_string="GCC `${CC} --version`"
1.4       tgl       291: else
1.24      petere    292:   cc_string=$CC
1.4       tgl       293: fi
1.24      petere    294: AC_DEFINE_UNQUOTED(PG_VERSION_STR, ["PostgreSQL $VERSION on $host, compiled by $cc_string"], [A canonical string containing the version number, platform, and C compiler])
                    295: 
1.4       tgl       296: 
1.31      petere    297: #
                    298: # Automatic dependency tracking
                    299: #
                    300: AC_ARG_ENABLE(depend, [  --enable-depend         turn on automatic dependency tracking],
                    301: [
                    302:   if test x"$enableval" = x"yes" ; then
                    303:     autodepend=yes
                    304:   fi
                    305: ])
                    306: AC_SUBST(autodepend)
                    307: 
                    308: 
1.30      petere    309: # --enable-debug adds -g to compiler flags
                    310: # --disable-debug will forcefully remove it
                    311: AC_MSG_CHECKING(setting debug compiler flag)
                    312: AC_ARG_ENABLE(debug, [  --enable-debug          build with debugging symbols (-g)],
                    313: [
                    314:   case $enableval in
                    315:     yes)  CFLAGS="$CFLAGS -g"
                    316:           AC_MSG_RESULT(yes)
                    317:           ;;
                    318:     *)    CFLAGS=`echo "$CFLAGS" | sed -e 's/ -g/ /g' -e 's/^-g//'`
                    319:           AC_MSG_RESULT(no)
                    320:           ;;
                    321:   esac
                    322: ],
                    323: [AC_MSG_RESULT(using default)])
                    324: 
                    325: 
                    326: #
                    327: # Include directories
                    328: #
                    329: ac_save_IFS=$IFS
                    330: IFS=':'
                    331: # SRCH_INC comes from the template file
                    332: for dir in $with_includes $SRCH_INC; do
                    333:   if test -d "$dir"; then
                    334:     INCLUDES="$INCLUDES -I$dir"
                    335:   else
                    336:     AC_MSG_WARN([*** Include directory $dir does not exist.])
                    337:   fi
                    338: done
                    339: IFS=$ac_save_IFS
                    340: AC_SUBST(INCLUDES)
                    341: 
                    342: 
                    343: #
                    344: # Library directories
                    345: #
                    346: ac_save_IFS=$IFS
                    347: IFS=':'
                    348: # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
                    349: for dir in $LIBRARY_DIRS $SRCH_LIB; do
                    350:   if test -d "$dir"; then
                    351:     PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
                    352:   else
                    353:     AC_MSG_WARN([*** Library directory $dir does not exist.])
                    354:   fi
                    355: done
                    356: IFS=$ac_save_IFS
                    357: 
                    358: 
1.4       tgl       359: 
1.1       petere    360: dnl We exclude tcl support unless user says --with-tcl
                    361: AC_MSG_CHECKING(setting USE_TCL)
                    362: AC_ARG_WITH(
                    363:    tcl,
                    364:    [  --with-tcl              build Tcl interfaces and pgtclsh ],
                    365:    [
                    366:        case "$withval" in
                    367:        y | ye | yes)           USE_TCL=true; USE_TK=true; AC_MSG_RESULT(enabled) ;;
                    368:        *)                      USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ;;
                    369:        esac
                    370:    ],
                    371:    [ USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ]
                    372: )
1.30      petere    373: AC_SUBST(USE_TCL)
                    374: AC_SUBST(USE_TK)
1.1       petere    375: 
                    376: 
                    377: dnl We see if the path to the TCL/TK configuration scripts is specified.
                    378: dnl This will override the use of tclsh to find the paths to search.
                    379: 
                    380: AC_ARG_WITH(tclconfig,
                    381:     [  --with-tclconfig=DIR    tclConfig.sh and tkConfig.sh are in DIR],
                    382:     [
                    383:        case "$withval" in
                    384:        "" | y | ye | yes | n | no)
                    385:            AC_MSG_ERROR([*** You must supply an argument to the --with-tclconfig option.])
                    386:          ;;
                    387:        esac
                    388:        TCL_DIRS="$withval"
                    389:     ]
                    390: )
                    391: 
                    392: dnl We see if the path to the TK configuration scripts is specified.
                    393: dnl This will override the use of tclsh to find the paths to search.
                    394: 
                    395: AC_ARG_WITH(tkconfig,
                    396:     [  --with-tkconfig=DIR     tkConfig.sh is in DIR],
                    397:     [
                    398:        case "$withval" in
                    399:        "" | y | ye | yes | n | no)
                    400:            AC_MSG_ERROR([*** You must supply an argument to the --with-tkconfig option.])
                    401:          ;;
                    402:        esac
                    403:        TK_DIRS="$withval"
                    404:     ]
                    405: )
                    406: 
1.5       petere    407: 
                    408: dnl
                    409: dnl Optionally build Perl modules (Pg.pm and PL/Perl)
                    410: dnl
                    411: AC_MSG_CHECKING(whether to build Perl modules)
                    412: AC_ARG_WITH(perl, [  --with-perl             build Perl interface and plperl],
                    413: [if test x"${withval}" = x"yes" ; then
                    414:   AC_MSG_RESULT(yes)
                    415: else
                    416:   AC_MSG_RESULT(no)
                    417: fi],
                    418: [AC_MSG_RESULT(no)])
                    419: AC_SUBST(with_perl)
                    420: 
                    421: 
                    422: dnl
                    423: dnl Optionally build Python interface module
                    424: dnl
                    425: AC_MSG_CHECKING(whether to build Python modules)
                    426: AC_ARG_WITH(python, [  --with-python           build Python interface module],
                    427: [if test x"${withval}" = x"yes" ; then
                    428:   AC_MSG_RESULT(yes)
                    429:   PGAC_PROG_PYTHON
                    430:   PGAC_PATH_PYTHONDIR
                    431: else
                    432:   AC_MSG_RESULT(no)
                    433: fi],
                    434: [AC_MSG_RESULT(no)])
                    435: AC_SUBST(with_python)
1.1       petere    436: 
1.13      petere    437: 
1.28      petere    438: dnl A note on the Kerberos and OpenSSL options:
1.13      petere    439: dnl
1.28      petere    440: dnl The user can give an argument to the option in order the specify
                    441: dnl the base path of the respective installation (what he specified
                    442: dnl perhaps as --prefix). If no argument is given ($withval is "yes")
                    443: dnl then we take the path where the package installs by default. This
                    444: dnl way the user doesn't have to use redundant --with-includes and
                    445: dnl --with-libraries options, but he can still use them if the layout
                    446: dnl is non-standard.
                    447: 
                    448: #
                    449: # Kerberos 4
                    450: #
1.13      petere    451: AC_ARG_WITH(krb4, [  --with-krb4[=DIR]       use Kerberos 4 [/usr/athena]],
                    452: [if test x"$withval" != x"no"; then
1.28      petere    453:   if test x"$withval" != x"yes"; then
                    454:     krb4_prefix=$withval
1.13      petere    455:   else
1.28      petere    456:     krb4_prefix=/usr/athena
1.13      petere    457:   fi
                    458:   with_krb4=yes
1.28      petere    459: else
                    460:   with_krb4=no
                    461: fi],
                    462: [with_krb4=no])
                    463: 
                    464: AC_SUBST(with_krb4)
                    465: if test "$with_krb4" = yes ; then
                    466:   AC_MSG_RESULT([building with Kerberos 4 support])
                    467:   AC_DEFINE(KRB4, [], [Define if you are building with Kerberos 4 support.])
                    468: 
                    469:   if test -d "$krb4_prefix"; then
                    470:     if test -d "$krb4_prefix/include"; then
                    471:       INCLUDES="$INCLUDES -I$krb4_prefix/include"
1.13      petere    472:     fi
1.28      petere    473:     if test -d "$krb4_prefix/lib"; then
                    474:       krb_libdir="-L$krb4_prefix/lib"
1.13      petere    475:       LIBS="$krb_libdir $LIBS"
                    476:     fi
                    477:   fi
1.28      petere    478:   dnl Test for these libraries is below
1.13      petere    479:   KRB_LIBS="$krb_libdir -lkrb -ldes"
1.37    ! petere    480: 
        !           481:   krb_srvtab='/etc/srvtab'
1.28      petere    482: fi
1.13      petere    483: 
                    484: 
1.28      petere    485: #
                    486: # Kerberos 5
                    487: #
1.13      petere    488: AC_ARG_WITH(krb5, [  --with-krb5[=DIR]       use Kerberos 5 [/usr/athena]],
                    489: [if test x"$withval" != x"no"; then
1.28      petere    490:   if test x"$withval" != x"yes"; then
                    491:     krb5_prefix=$withval
1.13      petere    492:   else
1.28      petere    493:     krb5_prefix=/usr/athena
1.13      petere    494:   fi
                    495:   with_krb5=yes
1.28      petere    496: else
                    497:   with_krb5=no
                    498: fi],
                    499: [with_krb5=no])
                    500: 
                    501: AC_SUBST(with_krb5)
                    502: if test "$with_krb5" = yes ; then
                    503:   AC_MSG_RESULT([building with Kerberos 5 support])
                    504:   AC_DEFINE(KRB5,, [Define if you are building with Kerberos 5 support.])
                    505: 
                    506:   if test -d $krb5_prefix; then
                    507:     if test -d "$krb5_prefix/include"; then
                    508:       INCLUDES="$INCLUDES -I$krb5_prefix/include"
1.13      petere    509:     fi
1.28      petere    510:     if test -d "$krb5_prefix/lib"; then
                    511:       krb_libdir="-L$krb5_prefix/lib"
1.13      petere    512:       LIBS="$krb_libdir $LIBS"
                    513:     fi
                    514:   fi
1.28      petere    515: 
                    516:   dnl Test for these libraries is below
1.13      petere    517:   KRB_LIBS="$krb_libdir -lkrb5 -lcrypto -lcom_err"
1.37    ! petere    518: 
        !           519:   krb_srvtab='FILE:$(sysconfdir)/krb5.keytab'
1.28      petere    520: fi
                    521: 
                    522: 
                    523: # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
                    524: if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
                    525:   AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
                    526: fi
1.13      petere    527: 
1.37    ! petere    528: 
        !           529: AC_SUBST(krb_srvtab)
1.13      petere    530: dnl Necessary for special libpq link
                    531: AC_SUBST(KRB_LIBS)
                    532: 
                    533: 
1.28      petere    534: #
                    535: # Kerberos configuration parameters
                    536: #
1.13      petere    537: AC_ARG_WITH(krb-srvnam, [  --with-krb-srvnam=NAME  name of the Postgres service principal in Kerberos],
                    538: [if test x"$withval" = x"yes"; then
                    539:   AC_MSG_ERROR([argument required for --with-krb-srvnam])
                    540: else
                    541:   krb_srvnam=$withval
                    542: fi],
                    543: [krb_srvnam="postgres"])
                    544: AC_DEFINE_UNQUOTED(PG_KRB_SRVNAM, ["$krb_srvnam"], [The name of the Postgres service principal])
                    545: 
1.28      petere    546: 
                    547: 
                    548: #
                    549: # OpenSSL
                    550: #
                    551: AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]],
                    552: [if test x"$withval" != x"no" ; then
                    553:   if test x"$withval" != x"yes" ; then
                    554:     openssl_prefix=$withval
                    555:   else
                    556:     openssl_prefix=/usr/local/ssl
                    557:   fi
                    558:   with_openssl=yes
                    559: else
                    560:   with_openssl=no
                    561: fi],
                    562: [with_openssl=no])
                    563: 
                    564: AC_SUBST(with_openssl)
                    565: if test "$with_openssl" = yes ; then
                    566:   AC_MSG_RESULT([building with OpenSSL support])
                    567:   AC_DEFINE([USE_SSL], [], [Define to build with (Open)SSL support])
                    568: 
                    569:   if test -d "${openssl_prefix}/include" ; then
                    570:     INCLUDES="$INCLUDES -I${openssl_prefix}/include"
                    571:   fi
                    572:   if test -d "${openssl_prefix}/lib" ; then
                    573:     openssl_libdir="${openssl_prefix}/lib"
                    574:     LIBS="$LIBS -L${openssl_prefix}/lib"
                    575:   fi
                    576: fi
                    577: 
1.13      petere    578: 
1.28      petere    579: # OpenSSL and Kerberos 5 both have a `crypto' library, so if you want to
                    580: # use both of them you'll have to figure it out yourself.
                    581: if test "$with_openssl" = yes && test "$with_krb5" = yes ; then
                    582:   AC_MSG_ERROR([OpenSSL and Kerberos 5 support cannot be combined])
                    583: fi
1.13      petere    584: 
                    585: 
1.15      petere    586: dnl
                    587: dnl Optionally enable the building of the ODBC driver
                    588: dnl
                    589:  
                    590: dnl Old option name
                    591: if test "x${with_odbc+set}" = xset && test "x${enable_odbc+set}" != xset; then
                    592:   enable_odbc=$with_odbc
                    593: fi
                    594:  
                    595: AC_MSG_CHECKING(whether to build the ODBC driver)
                    596: AC_ARG_ENABLE(odbc, [  --enable-odbc           build the ODBC driver package],
                    597: [if test x"$enableval" = x"yes" ; then
                    598:   AC_MSG_RESULT(yes)
                    599: else
                    600:   AC_MSG_RESULT(no)
                    601: fi],
                    602: [AC_MSG_RESULT(no)])
                    603: AC_SUBST(enable_odbc)
1.8       momjian   604: 
1.1       petere    605: 
                    606: dnl Allow for overriding the default location of the odbcinst.ini
1.15      petere    607: dnl file which is normally ${datadir} (i.e., ${prefix}/share).
                    608: if test x"$enable_odbc" = x"yes" ; then
1.28      petere    609: AC_ARG_WITH(odbcinst, [  --with-odbcinst=DIR     default directory for odbcinst.ini [sysconfdir]],
1.15      petere    610: [if test x"$with_odbcinst" = x"yes" || test x"$with_odbcinst" = x"no" ; then
                    611:   AC_MSG_ERROR([You must supply an argument to the --with-odbcinst option.])
1.1       petere    612: fi
1.15      petere    613: odbcinst_ini_dir=$withval],
1.28      petere    614: [odbcinst_ini_dir='${sysconfdir}'])
1.15      petere    615: else
1.28      petere    616:   odbcinst_ini_dir='${sysconfdir}'
1.1       petere    617: fi
1.15      petere    618: AC_SUBST(odbcinst_ini_dir)
1.3       momjian   619: 
                    620: 
                    621: 
1.1       petere    622: dnl Unless we specify the command line options
                    623: dnl    --enable cassert        to explicitly enable it
                    624: dnl If you do not explicitly do it, it defaults to disabled
                    625: AC_MSG_CHECKING(setting ASSERT CHECKING)
                    626: AC_ARG_ENABLE(
                    627:    cassert,
                    628:    [  --enable-cassert        enable assertion checks (for debugging) ],
                    629:    AC_DEFINE(USE_ASSERT_CHECKING) AC_MSG_RESULT(enabled),
                    630:    AC_MSG_RESULT(disabled)
                    631: )
                    632: 
                    633: 
1.30      petere    634: # Assume system is ELF if it predefines __ELF__ as 1,
                    635: # otherwise believe host_os based default.
                    636: case $host_os in
                    637:   freebsd1*|freebsd2*) elf=yes;;
                    638: esac
1.1       petere    639: 
                    640: AC_EGREP_CPP(yes,
                    641: [#if __ELF__
                    642:   yes
                    643: #endif
                    644: ],
1.30      petere    645: [ELF_SYS=true],
                    646: [if test "X$elf" = "Xyes" ; then
                    647:   ELF_SYS=true
1.1       petere    648: else
1.30      petere    649:   ELF_SYS=
                    650: fi])
                    651: AC_SUBST(ELF_SYS)
1.1       petere    652: 
                    653: 
                    654: 
1.6       petere    655: dnl
                    656: dnl Optionally build C++ code (i.e., libpq++)
                    657: dnl
1.36      petere    658: AC_MSG_CHECKING([whether to build C++ modules])
1.6       petere    659: AC_ARG_WITH(CXX, [  --with-CXX              build C++ modules (libpq++)],
1.36      petere    660: [if test x"$withval" != x"no"; then
                    661:   if test x"$withval" != x"yes" ; then
1.6       petere    662:     CXX=$withval
                    663:   fi
1.36      petere    664:   with_CXX=yes
                    665: fi],
                    666: [with_CXX=no])
                    667: 
                    668: AC_MSG_RESULT([$with_CXX])
                    669: AC_SUBST(with_CXX)
                    670: 
                    671: if test $with_CXX = yes; then
1.6       petere    672:   AC_PROG_CXX
                    673:   AC_PROG_CXXCPP
                    674:   PGAC_CLASS_STRING
                    675:   PGAC_CXX_NAMESPACE_STD
1.36      petere    676: fi
1.1       petere    677: 
                    678: 
1.30      petere    679: CPPFLAGS="$CPPFLAGS $INCLUDES"
                    680: LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
                    681: 
                    682: echo "using CPPFLAGS=$CPPFLAGS"
                    683: echo "using LDFLAGS=$LDFLAGS"
                    684: 
                    685: 
1.28      petere    686: # Figure out how to invoke "install" and what install options to use.
1.1       petere    687: 
                    688: AC_PROG_INSTALL
1.28      petere    689: # When Autoconf chooses install-sh as install program it tries to generate
                    690: # a relative path to it in each makefile where it subsitutes it. This clashes
                    691: # with our Makefile.global concept. This workaround helps.
                    692: case $INSTALL in
                    693:   *install-sh*) INSTALL='\${SHELL} \${top_srcdir}/config/install-sh -c';;
                    694: esac
1.1       petere    695: 
1.28      petere    696: # Fix Autoconf's brain-dead defaults for script installs.
                    697: INSTALL_SCRIPT="\${INSTALL} -m 755"
1.1       petere    698: 
1.28      petere    699: # HPUX wants shared libs to be mode 555. Add your platform's special
                    700: # needs here if necessary.
                    701: case $host_os in
                    702:     hpux*)      INSTL_SHLIB_OPTS="-m 555" ;;
                    703:     *)          INSTL_SHLIB_OPTS="-m 644" ;;
1.1       petere    704: esac
1.19      tgl       705: 
1.28      petere    706: INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
                    707: AC_SUBST(INSTALL_SHLIB)
1.1       petere    708: 
1.19      tgl       709: 
1.28      petere    710: mkinstalldirs="\$(SHELL) \$(top_srcdir)/config/mkinstalldirs"
                    711: AC_SUBST(mkinstalldirs)
1.15      petere    712: 
                    713: 
1.2       petere    714: AC_PROG_AWK
                    715: 
1.1       petere    716: AC_PROG_LEX
                    717: if test "$LEX" = "flex"; then
                    718:         $LEX --version 2> /dev/null | grep -s '2\.5\.3' > /dev/null 2>&1
                    719:         if test $? -eq 0 ; then
                    720:                 AC_MSG_WARN([
                    721: ***
                    722: You have flex version 2.5.3, which is broken. Get version 2.5.4 or
                    723: a different lex.
                    724: (If you are using the official distribution of PostgreSQL then you
                    725: do not need to worry about this because the lexer files are
                    726: pre-generated. However, other software using flex is likely to be
                    727: broken as well.)
                    728: ***])
                    729:         fi
                    730: fi
                    731: AC_PROG_LN_S
                    732: AC_PROG_RANLIB
                    733: AC_PATH_PROG(tar, tar)
                    734: AC_CHECK_PROGS(PERL, perl,)
1.2       petere    735: AC_PROG_YACC
1.6       petere    736: AC_SUBST(YFLAGS)
1.1       petere    737: 
                    738: 
1.29      petere    739: ##
                    740: ## Libraries
                    741: ##
                    742: 
1.1       petere    743: AC_CHECK_LIB(sfio,     main)
1.13      petere    744: AC_CHECK_LIB(ncurses,  main, [], [AC_CHECK_LIB(curses, main)])
1.1       petere    745: AC_CHECK_LIB(termcap,  main)
                    746: AC_CHECK_LIB(readline, main)
                    747: AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
                    748:     AC_CHECK_LIB(history,  main) )
                    749: 
                    750: if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
                    751: then
                    752:        AC_CHECK_LIB(bsd,      main)
                    753: fi
1.21      petere    754: AC_CHECK_LIB(util,     setproctitle)
1.1       petere    755: AC_CHECK_LIB(m,        main)
                    756: AC_CHECK_LIB(dl,       main)
                    757: AC_CHECK_LIB(socket,   main)
                    758: AC_CHECK_LIB(nsl,      main)
                    759: AC_CHECK_LIB(ipc,      main)
                    760: AC_CHECK_LIB(IPC,      main)
                    761: AC_CHECK_LIB(lc,       main)
                    762: AC_CHECK_LIB(dld,      main)
                    763: AC_CHECK_LIB(ln,       main)
                    764: AC_CHECK_LIB(ld,       main)
                    765: AC_CHECK_LIB(compat,   main)
                    766: AC_CHECK_LIB(BSD,      main)
                    767: AC_CHECK_LIB(gen,      main)
                    768: AC_CHECK_LIB(PW,       main)
1.21      petere    769: AC_SEARCH_LIBS(crypt,  crypt)
1.28      petere    770: AC_CHECK_LIB(z,        inflate)
                    771: 
                    772: if test "$with_krb4" = yes ; then
                    773:   AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library \`des' is required for Kerberos 4])])
                    774:   AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library \`krb' is required for Kerberos 4])])
                    775: fi
                    776: 
                    777: if test "$with_krb5" = yes ; then
                    778:   AC_CHECK_LIB(com_err, main, [], [AC_MSG_ERROR([library \`com_err' is required for Kerberos 5])])
                    779:   AC_CHECK_LIB(crypto,  main, [], [AC_MSG_ERROR([library \`crypto' is required for Kerberos 5])])
                    780:   AC_CHECK_LIB(krb5,    main, [], [AC_MSG_ERROR([library \`krb5' is required for Kerberos 5])])
                    781: fi
                    782: 
                    783: if test "$with_openssl" = yes ; then
                    784:   dnl Order matters!
                    785:   AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
                    786:   AC_CHECK_LIB(ssl,    [SSL_library_init], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
                    787: fi
1.1       petere    788: 
1.28      petere    789: 
1.29      petere    790: ##
                    791: ## Header files
                    792: ##
                    793: dnl sys/socket.h and sys/types.h are required by AC_FUNC_ACCEPT_ARGTYPES
1.35      tgl       794: AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h pwd.h sys/pstat.h sys/select.h sys/socket.h sys/types.h termios.h])
1.29      petere    795: 
1.28      petere    796: AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
                    797: AC_CHECK_HEADERS([readline/history.h history.h], [break])
1.15      petere    798: 
1.28      petere    799: if test "$with_krb4" = yes ; then
                    800:   AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
                    801: fi
                    802: 
                    803: if test "$with_krb5" = yes ; then
                    804:   AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
                    805:   AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
                    806: fi
                    807: 
                    808: if test "$with_openssl" = yes ; then
                    809:   AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
                    810:   AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
                    811: fi
                    812: 
1.1       petere    813: 
1.29      petere    814: ##
                    815: ## Types, structures, compiler characteristics
                    816: ##
1.1       petere    817: AC_C_CONST
                    818: AC_C_INLINE
                    819: AC_C_STRINGIZE
1.6       petere    820: PGAC_C_SIGNED
                    821: PGAC_C_VOLATILE
1.29      petere    822: AC_STRUCT_TIMEZONE
                    823: PGAC_UNION_SEMUN
1.1       petere    824: 
                    825: 
1.29      petere    826: ##
                    827: ## Functions, global variables
                    828: ##
1.6       petere    829: PGAC_VAR_INT_TIMEZONE
1.29      petere    830: AC_FUNC_ACCEPT_ARGTYPES
1.6       petere    831: PGAC_FUNC_GETTIMEOFDAY_1ARG
1.1       petere    832: 
1.30      petere    833: AC_MSG_CHECKING([for fcntl(F_SETLK)])
                    834: case $host_os in
                    835:   linux*)       AC_MSG_RESULT([broken on Linux]) ;;
                    836:   *)
                    837: AC_TRY_LINK(
                    838: [#include <stdio.h>
                    839: #include <fcntl.h>
                    840: ],
                    841: [struct flock lck;
                    842: lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
                    843: lck.l_type = F_WRLCK;
                    844: fcntl(0, F_SETLK, &lck);],
                    845: [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
                    846: [AC_MSG_RESULT(no)])
                    847:         ;;
                    848: esac
1.1       petere    849: 
1.29      petere    850: AC_CHECK_FUNCS([fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid])
1.1       petere    851: 
1.28      petere    852: AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
                    853: [AC_TRY_LINK(
                    854: [#include <machine/vmparam.h>
                    855: #include <sys/exec.h>
                    856: ],
1.1       petere    857: [PS_STRINGS->ps_nargvstr = 1;
                    858: PS_STRINGS->ps_argvstr = "foo";],
1.28      petere    859: [pgac_cv_var_PS_STRINGS=yes],
                    860: [pgac_cv_var_PS_STRINGS=no])])
                    861: if test "$pgac_cv_var_PS_STRINGS" = yes ; then
                    862:   AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
                    863: fi
1.1       petere    864: 
                    865: dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
                    866: dnl is missing.  Yes, there are machines that have only one.
                    867: dnl We may also decide to use snprintf.c if snprintf() is present but does
                    868: dnl not have working "long long int" support -- see below.
                    869: SNPRINTF=''
                    870: AC_CHECK_FUNC(snprintf,
                    871:              AC_DEFINE(HAVE_SNPRINTF),
                    872:              SNPRINTF='snprintf.o')
                    873: AC_CHECK_FUNC(vsnprintf,
                    874:              AC_DEFINE(HAVE_VSNPRINTF),
                    875:              SNPRINTF='snprintf.o')
                    876: AC_SUBST(SNPRINTF)
                    877: dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
                    878: dnl include/c.h will provide declarations.  Note this is a separate test
                    879: dnl from whether the functions exist in the C library --- there are systems
                    880: dnl that have the functions but don't bother to declare them :-(
                    881: dnl Note: simple-minded pattern here will do wrong thing if stdio.h
                    882: dnl declares vsnprintf() but not snprintf().  Hopefully there are no
                    883: dnl systems that are *that* brain-damaged...
                    884: AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
                    885: AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
1.29      petere    886: 
                    887: # do this one the hard way in case isinf() is a macro
                    888: AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
1.1       petere    889: [AC_TRY_LINK(
1.29      petere    890: [#include <math.h>
                    891: ],
1.1       petere    892: [double x = 0.0; int res = isinf(x);],
1.29      petere    893: [ac_cv_func_isinf=yes],
                    894: [ac_cv_func_isinf=no])])
                    895: 
                    896: if test $ac_cv_func_isinf = yes ; then
1.1       petere    897:   AC_DEFINE(HAVE_ISINF)
1.29      petere    898:   ISINF=
1.1       petere    899: else
                    900:   ISINF='isinf.o'
1.29      petere    901:   # Look for a way to implement a substitute for isinf()
                    902:   AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
1.1       petere    903: fi
                    904: AC_SUBST(ISINF)
1.29      petere    905: 
1.1       petere    906: AC_CHECK_FUNC(getrusage,
                    907:              AC_DEFINE(HAVE_GETRUSAGE),
                    908:              GETRUSAGE='getrusage.o')
                    909: AC_SUBST(GETRUSAGE)
                    910: AC_CHECK_FUNC(srandom,
                    911:              AC_DEFINE(HAVE_SRANDOM),
                    912:              SRANDOM='srandom.o')
                    913: AC_SUBST(SRANDOM)
                    914: AC_CHECK_FUNC(gethostname,
                    915:              AC_DEFINE(HAVE_GETHOSTNAME),
                    916:              GETHOSTNAME='gethostname.o')
                    917: AC_SUBST(GETHOSTNAME)
                    918: AC_CHECK_FUNC(random,
                    919:              AC_DEFINE(HAVE_RANDOM),
                    920:              MISSING_RANDOM='random.o')
                    921: AC_SUBST(MISSING_RANDOM)
                    922: AC_CHECK_FUNC(inet_aton,
                    923:              AC_DEFINE(HAVE_INET_ATON),
                    924:              INET_ATON='inet_aton.o')
                    925: AC_SUBST(INET_ATON)
                    926: AC_CHECK_FUNC(strerror,
                    927:              AC_DEFINE(HAVE_STRERROR),
                    928:              [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
                    929: AC_SUBST(STRERROR)
                    930: AC_SUBST(STRERROR2)
                    931: AC_CHECK_FUNC(strdup,
                    932:              AC_DEFINE(HAVE_STRDUP),
                    933:              STRDUP='../../utils/strdup.o')
                    934: AC_SUBST(STRDUP)
                    935: AC_CHECK_FUNC(strtol,
                    936:              AC_DEFINE(HAVE_STRTOL),
                    937:              STRTOL='strtol.o')
                    938: AC_SUBST(STRTOL)
                    939: AC_CHECK_FUNC(strtoul,
                    940:              AC_DEFINE(HAVE_STRTOUL),
                    941:              STRTOL='strtoul.o')
                    942: AC_SUBST(STRTOUL)
                    943: AC_CHECK_FUNC(strcasecmp,
                    944:              AC_DEFINE(HAVE_STRCASECMP),
                    945:              STRCASECMP='strcasecmp.o')
                    946: AC_SUBST(STRCASECMP)
                    947: AC_CHECK_FUNC(cbrt,
                    948:              AC_DEFINE(HAVE_CBRT),
                    949:              AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
                    950: 
                    951: # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
                    952: # this hackery with HPUXMATHLIB allows us to cope.
                    953: HPUXMATHLIB=""
1.30      petere    954: case $host_cpu in
1.1       petere    955:   hppa1.1) 
                    956:        if [[ -r /lib/pa1.1/libm.a ]] ; then
                    957:            HPUXMATHLIB="-L /lib/pa1.1 -lm"
                    958:        fi ;;
                    959: esac
                    960: AC_SUBST(HPUXMATHLIB)
                    961: 
                    962: AC_CHECK_FUNC(rint,
                    963:              AC_DEFINE(HAVE_RINT),
                    964:              AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
                    965: 
                    966: dnl Some old versions of libreadline don't have rl_completion_append_character
                    967: AC_EGREP_HEADER(rl_completion_append_character, readline.h,
                    968:        AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER),
                    969:        [AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h,
                    970:                AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
                    971: AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
                    972: 
                    973: dnl Check for readline's filename_completion_function.
                    974: dnl Some versions have it but it's not in the headers, so we have to take
                    975: dnl care of that, too.
                    976: AC_CHECK_FUNCS(filename_completion_function,
                    977:     AC_EGREP_HEADER(filename_completion_function, readline.h,
                    978:         AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
                    979:         [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
                    980:             AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
                    981: )
                    982: AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
                    983: AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
                    984: 
                    985: 
                    986: dnl Cannot use AC_CHECK_FUNC because finite may be a macro
                    987: AC_MSG_CHECKING(for finite)
                    988: AC_TRY_LINK([#include <math.h>],
                    989:        [int dummy=finite(1.0);],
                    990:        [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
                    991:        AC_MSG_RESULT(no))
                    992: 
                    993: dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
                    994: dnl (especially on GNU libc)
                    995: dnl See also comments in config.h.
                    996: AC_MSG_CHECKING(for sigsetjmp)
                    997: AC_TRY_LINK([#include <setjmp.h>],
                    998:        [sigjmp_buf x; sigsetjmp(x, 1);],
                    999:        [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
                   1000:        AC_MSG_RESULT(no))
                   1001: 
                   1002: AC_ARG_ENABLE(syslog, [  --enable-syslog         enable logging to syslog],
                   1003:     [case $enableval in y|ye|yes)
                   1004:        AC_CHECK_FUNC(syslog, [AC_DEFINE(ENABLE_SYSLOG)], [AC_MSG_ERROR([no syslog interface found])])
                   1005:         ;;
                   1006:      esac]
                   1007: )
                   1008: 
                   1009: dnl Check to see if we have a working 64-bit integer type.
                   1010: dnl This breaks down into two steps:
                   1011: dnl (1) figure out if the compiler has a 64-bit int type with working
                   1012: dnl arithmetic, and if so
                   1013: dnl (2) see whether snprintf() can format the type correctly.  (Currently,
                   1014: dnl snprintf is the only library routine we really need for int8 support.)
                   1015: dnl It's entirely possible to have a compiler that handles a 64-bit type
                   1016: dnl when the C library doesn't; this is fairly likely when using gcc on
                   1017: dnl an older platform, for example.
                   1018: dnl If there is no native snprintf() or it does not handle the 64-bit type,
                   1019: dnl we force our own version of snprintf() to be used instead.
                   1020: dnl Note this test must be run after our initial check for snprintf/vsnprintf.
                   1021: 
1.6       petere   1022: PGAC_TYPE_64BIT_INT([long int])
1.1       petere   1023: 
1.6       petere   1024: if test x"$HAVE_LONG_INT_64" = x"no" ; then
                   1025:   PGAC_TYPE_64BIT_INT([long long int])
                   1026: fi
1.1       petere   1027: 
                   1028: 
                   1029: dnl If we found "long int" is 64 bits, assume snprintf handles it.
                   1030: dnl If we found we need to use "long long int", better check.
                   1031: dnl We cope with snprintfs that use either %lld or %qd as the format.
                   1032: dnl If neither works, fall back to our own snprintf emulation (which we
                   1033: dnl know uses %lld).
                   1034: 
1.7       petere   1035: if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1.1       petere   1036:   if [[ x$SNPRINTF = x ]] ; then
                   1037:     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
                   1038:     AC_TRY_RUN([#include <stdio.h>
                   1039: typedef long long int int64;
                   1040: #define INT64_FORMAT "%lld"
                   1041: 
                   1042: int64 a = 20000001;
                   1043: int64 b = 40000005;
                   1044: 
                   1045: int does_int64_snprintf_work()
                   1046: {
                   1047:   int64 c;
                   1048:   char buf[100];
                   1049: 
                   1050:   if (sizeof(int64) != 8)
                   1051:     return 0;                  /* doesn't look like the right size */
                   1052: 
                   1053:   c = a * b;
                   1054:   snprintf(buf, 100, INT64_FORMAT, c);
                   1055:   if (strcmp(buf, "800000140000005") != 0)
                   1056:     return 0;                  /* either multiply or snprintf is busted */
                   1057:   return 1;
                   1058: }
                   1059: main() {
                   1060:   exit(! does_int64_snprintf_work());
                   1061: }],
                   1062:        [ AC_MSG_RESULT(yes)
                   1063:          INT64_FORMAT='"%lld"'
                   1064:        ],
                   1065:   [ AC_MSG_RESULT(no)
                   1066:     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd) 
                   1067:     AC_TRY_RUN([#include <stdio.h>
                   1068: typedef long long int int64;
                   1069: #define INT64_FORMAT "%qd"
                   1070:    
                   1071: int64 a = 20000001;
                   1072: int64 b = 40000005;
                   1073:    
                   1074: int does_int64_snprintf_work()
                   1075: {  
                   1076:   int64 c;
                   1077:   char buf[100];
                   1078: 
                   1079:   if (sizeof(int64) != 8)
                   1080:     return 0;     /* doesn't look like the right size */
                   1081: 
                   1082:   c = a * b;
                   1083:   snprintf(buf, 100, INT64_FORMAT, c);
                   1084:   if (strcmp(buf, "800000140000005") != 0)
                   1085:     return 0;     /* either multiply or snprintf is busted */
                   1086:   return 1;
                   1087: }
                   1088: main() {
                   1089:   exit(! does_int64_snprintf_work());
                   1090: }],
                   1091:   [ AC_MSG_RESULT(yes)
                   1092:     INT64_FORMAT='"%qd"'
                   1093:   ],
                   1094:   [ AC_MSG_RESULT(no)
                   1095:        # Force usage of our own snprintf, since system snprintf is broken
                   1096:        SNPRINTF='snprintf.o'
                   1097:        INT64_FORMAT='"%lld"'
                   1098:   ],
                   1099:   [ AC_MSG_RESULT(assuming not on target machine)
                   1100:        # Force usage of our own snprintf, since we cannot test foreign snprintf
                   1101:        SNPRINTF='snprintf.o'
                   1102:        INT64_FORMAT='"%lld"'
                   1103:   ]) ],
                   1104:   [ AC_MSG_RESULT(assuming not on target machine)
                   1105:        # Force usage of our own snprintf, since we cannot test foreign snprintf
                   1106:        SNPRINTF='snprintf.o'
                   1107:        INT64_FORMAT='"%lld"'
                   1108:   ])
                   1109:   else
                   1110:     # here if we previously decided we needed to use our own snprintf
                   1111:     INT64_FORMAT='"%lld"'
                   1112:   fi
                   1113: else
                   1114:   # Here if we are not using 'long long int' at all
                   1115:   INT64_FORMAT='"%ld"'
                   1116: fi
                   1117: 
                   1118: AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
                   1119: 
                   1120: 
                   1121: dnl Determine memory alignment requirements for the basic C datatypes.
                   1122: 
1.6       petere   1123: PGAC_CHECK_ALIGNOF(short)
                   1124: PGAC_CHECK_ALIGNOF(int)
                   1125: PGAC_CHECK_ALIGNOF(long)
1.7       petere   1126: if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1.6       petere   1127:   PGAC_CHECK_ALIGNOF(long long int)
1.1       petere   1128: fi
1.6       petere   1129: PGAC_CHECK_ALIGNOF(double)
1.1       petere   1130: 
                   1131: dnl Compute maximum alignment of any basic type.
                   1132: dnl We assume long's alignment is at least as strong as char, short, or int;
                   1133: dnl but we must check long long (if it exists) and double.
                   1134: 
1.6       petere   1135: if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
                   1136:   MAX_ALIGNOF=$pgac_cv_alignof_long
                   1137:   if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
                   1138:     MAX_ALIGNOF=$pgac_cv_alignof_double
1.1       petere   1139:   fi
1.7       petere   1140:   if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1.6       petere   1141:     MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1.1       petere   1142:   fi
                   1143: else
                   1144:   dnl cross-compiling: assume that double's alignment is worst case
1.6       petere   1145:   MAX_ALIGNOF="$pgac_cv_alignof_double"
1.1       petere   1146: fi
1.6       petere   1147: AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1.1       petere   1148: 
1.6       petere   1149: PGAC_FUNC_POSIX_SIGNALS
1.1       petere   1150: 
                   1151: 
                   1152: dnl Check for Tcl configuration script tclConfig.sh
                   1153: 
                   1154: dnl If --with-tclconfig was given, don't check for tclsh, tcl
                   1155: if test -z "$TCL_DIRS"
                   1156: then
                   1157:        AC_PATH_PROG(TCLSH, tclsh)
                   1158:        if test -z "$TCLSH"
                   1159:        then
                   1160:                AC_PATH_PROG(TCLSH, tcl)
                   1161:                if test -z "$TCLSH"
                   1162:                then
                   1163:                        AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
                   1164:                        USE_TCL=
                   1165:                fi
                   1166:        fi
                   1167: fi
                   1168:        
                   1169: if test "$USE_TCL" = true
                   1170: then
                   1171:        AC_MSG_CHECKING(for tclConfig.sh)
                   1172:        TCL_CONFIG_SH=
                   1173:        library_dirs=
                   1174:        if test -z "$TCL_DIRS"
                   1175:        then
                   1176:                library_dirs=`echo 'puts $auto_path' | $TCLSH`
                   1177:        fi
                   1178:        library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
                   1179:        for dir in $library_dirs; do
                   1180:                if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
                   1181:                        TCL_CONFIG_SH=$dir/tclConfig.sh
                   1182:                        break
                   1183:                fi
                   1184:        done
                   1185:        if test -z "$TCL_CONFIG_SH"; then
                   1186:                AC_MSG_RESULT(no)
                   1187:                AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
                   1188:                USE_TCL=
                   1189:        else
                   1190:                AC_MSG_RESULT($TCL_CONFIG_SH)
                   1191:                AC_SUBST(TCL_CONFIG_SH)
                   1192:        fi
                   1193: fi
                   1194: 
                   1195: USE_TK=$USE_TCL                # If TCL is disabled, disable TK
                   1196: 
                   1197: dnl Check for Tk configuration script tkConfig.sh
                   1198: if test "$USE_TK" = true
                   1199: then
                   1200:        AC_MSG_CHECKING(for tkConfig.sh)
                   1201:        TK_CONFIG_SH=
                   1202:        # library_dirs are set in the check for TCL
                   1203:        for dir in $library_dirs
                   1204:        do
                   1205:                if test -d "$dir" -a -r "$dir/tkConfig.sh"
                   1206:                then
                   1207:                        TK_CONFIG_SH=$dir/tkConfig.sh
                   1208:                        break
                   1209:                fi
                   1210:        done
                   1211:        if test -z "$TK_CONFIG_SH"
                   1212:        then
                   1213:                AC_MSG_RESULT(no)
                   1214:                AC_MSG_WARN(TK support disabled; Tk configuration script missing)
                   1215:                USE_TK=
                   1216:        else
                   1217:                AC_MSG_RESULT($TK_CONFIG_SH)
                   1218:                AC_SUBST(TK_CONFIG_SH)
                   1219:                AC_PATH_PROG(WISH, wish)
                   1220:        fi
                   1221: fi
1.30      petere   1222: AC_SUBST(WISH)
1.1       petere   1223: 
                   1224: USE_X=$USE_TK
                   1225: 
                   1226: dnl Check for X libraries
                   1227: 
                   1228: if test "$USE_X" = true; then
                   1229: 
                   1230:        ice_save_LIBS="$LIBS"
                   1231:        ice_save_CFLAGS="$CFLAGS"
                   1232:        ice_save_CPPFLAGS="$CPPFLAGS"
                   1233:        ice_save_LDFLAGS="$LDFLAGS"
                   1234: 
                   1235:        AC_PATH_XTRA
                   1236: 
                   1237:        LIBS="$LIBS $X_EXTRA_LIBS"
                   1238:        CFLAGS="$CFLAGS $X_CFLAGS"
                   1239:        CPPFLAGS="$CPPFLAGS $X_CFLAGS"
                   1240:        LDFLAGS="$LDFLAGS $X_LIBS"
                   1241: 
                   1242:        dnl Check for X library
                   1243: 
                   1244:        X11_LIBS=""
                   1245:        AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
                   1246:        if test "$X11_LIBS" = ""; then
                   1247:                dnl Not having X is bad news for pgtksh. Let the user fix this.
                   1248:                AC_MSG_WARN([The X11 library '-lX11' could not be found,
                   1249: so TK support will be disabled.  To enable TK support,
                   1250: please use the configure options '--x-includes=DIR'
                   1251: and '--x-libraries=DIR' to specify the X location.
                   1252: See the file 'config.log' for further diagnostics.])
                   1253:                USE_TK=
                   1254:        fi
                   1255:        AC_SUBST(X_LIBS)
                   1256:        AC_SUBST(X11_LIBS)
                   1257:        AC_SUBST(X_PRE_LIBS)
                   1258: 
                   1259:        LIBS="$ice_save_LIBS"
                   1260:        CFLAGS="$ice_save_CFLAGS"
                   1261:        CPPFLAGS="$ice_save_CPPFLAGS"
                   1262:        LDFLAGS="$ice_save_LDFLAGS"
                   1263: fi
                   1264: 
1.28      petere   1265: 
                   1266: # Wait with these until we're done so no tests fail because of too
                   1267: # many warnings.
                   1268: if test x"$GCC" = x"yes" ; then
                   1269:   CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations"
                   1270: fi
1.1       petere   1271: 
                   1272: dnl Finally ready to produce output files ...
                   1273: 
                   1274: AC_OUTPUT(
1.33      petere   1275: [
                   1276:   GNUmakefile
                   1277:   src/GNUmakefile
                   1278:   src/Makefile.global
                   1279:   src/backend/port/Makefile
                   1280: ],
                   1281: [echo timestamp > src/include/stamp-h]
1.1       petere   1282: )

PostgreSQL CVSweb <[email protected]>