Annotation of pgsql/configure.in, revision 1.32

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.28      petere    480: fi
1.13      petere    481: 
                    482: 
1.28      petere    483: #
                    484: # Kerberos 5
                    485: #
1.13      petere    486: AC_ARG_WITH(krb5, [  --with-krb5[=DIR]       use Kerberos 5 [/usr/athena]],
                    487: [if test x"$withval" != x"no"; then
1.28      petere    488:   if test x"$withval" != x"yes"; then
                    489:     krb5_prefix=$withval
1.13      petere    490:   else
1.28      petere    491:     krb5_prefix=/usr/athena
1.13      petere    492:   fi
                    493:   with_krb5=yes
1.28      petere    494: else
                    495:   with_krb5=no
                    496: fi],
                    497: [with_krb5=no])
                    498: 
                    499: AC_SUBST(with_krb5)
                    500: if test "$with_krb5" = yes ; then
                    501:   AC_MSG_RESULT([building with Kerberos 5 support])
                    502:   AC_DEFINE(KRB5,, [Define if you are building with Kerberos 5 support.])
                    503: 
                    504:   if test -d $krb5_prefix; then
                    505:     if test -d "$krb5_prefix/include"; then
                    506:       INCLUDES="$INCLUDES -I$krb5_prefix/include"
1.13      petere    507:     fi
1.28      petere    508:     if test -d "$krb5_prefix/lib"; then
                    509:       krb_libdir="-L$krb5_prefix/lib"
1.13      petere    510:       LIBS="$krb_libdir $LIBS"
                    511:     fi
                    512:   fi
1.28      petere    513: 
                    514:   dnl Test for these libraries is below
1.13      petere    515:   KRB_LIBS="$krb_libdir -lkrb5 -lcrypto -lcom_err"
1.28      petere    516: fi
                    517: 
                    518: 
                    519: # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
                    520: if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
                    521:   AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
                    522: fi
1.13      petere    523: 
                    524: dnl Necessary for special libpq link
                    525: AC_SUBST(KRB_LIBS)
                    526: 
                    527: 
1.28      petere    528: #
                    529: # Kerberos configuration parameters
                    530: #
1.13      petere    531: AC_ARG_WITH(krb-srvnam, [  --with-krb-srvnam=NAME  name of the Postgres service principal in Kerberos],
                    532: [if test x"$withval" = x"yes"; then
                    533:   AC_MSG_ERROR([argument required for --with-krb-srvnam])
                    534: else
                    535:   krb_srvnam=$withval
                    536: fi],
                    537: [krb_srvnam="postgres"])
                    538: AC_DEFINE_UNQUOTED(PG_KRB_SRVNAM, ["$krb_srvnam"], [The name of the Postgres service principal])
                    539: 
                    540: AC_ARG_WITH(krb-srvtab, [  --with-krb-srvtab=FILE  location of Kerberos server's keytab file],
                    541: [if test x"$withval" = x"yes"; then
                    542:   AC_MSG_ERROR([argument required for --with-krb-srvtab])
                    543: else
                    544:   krb_srvtab=$withval
                    545: fi],
1.28      petere    546: [if test "$with_krb5" = yes ; then
                    547:   krb_srvtab='FILE:${sysconfdir}/krb5.keytab'
                    548: elif test "$with_krb4" = yes ; then
                    549:   krb_srvtab='/etc/srvtab'
1.13      petere    550: else
1.28      petere    551:   krb_srvtab=
1.13      petere    552: fi])
1.28      petere    553: AC_SUBST(krb_srvtab)
                    554: 
                    555: 
                    556: #
                    557: # OpenSSL
                    558: #
                    559: AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]],
                    560: [if test x"$withval" != x"no" ; then
                    561:   if test x"$withval" != x"yes" ; then
                    562:     openssl_prefix=$withval
                    563:   else
                    564:     openssl_prefix=/usr/local/ssl
                    565:   fi
                    566:   with_openssl=yes
                    567: else
                    568:   with_openssl=no
                    569: fi],
                    570: [with_openssl=no])
                    571: 
                    572: AC_SUBST(with_openssl)
                    573: if test "$with_openssl" = yes ; then
                    574:   AC_MSG_RESULT([building with OpenSSL support])
                    575:   AC_DEFINE([USE_SSL], [], [Define to build with (Open)SSL support])
                    576: 
                    577:   if test -d "${openssl_prefix}/include" ; then
                    578:     INCLUDES="$INCLUDES -I${openssl_prefix}/include"
                    579:   fi
                    580:   if test -d "${openssl_prefix}/lib" ; then
                    581:     openssl_libdir="${openssl_prefix}/lib"
                    582:     LIBS="$LIBS -L${openssl_prefix}/lib"
                    583:   fi
                    584: fi
                    585: 
1.13      petere    586: 
1.28      petere    587: # OpenSSL and Kerberos 5 both have a `crypto' library, so if you want to
                    588: # use both of them you'll have to figure it out yourself.
                    589: if test "$with_openssl" = yes && test "$with_krb5" = yes ; then
                    590:   AC_MSG_ERROR([OpenSSL and Kerberos 5 support cannot be combined])
                    591: fi
1.13      petere    592: 
                    593: 
1.15      petere    594: dnl
                    595: dnl Optionally enable the building of the ODBC driver
                    596: dnl
                    597:  
                    598: dnl Old option name
                    599: if test "x${with_odbc+set}" = xset && test "x${enable_odbc+set}" != xset; then
                    600:   enable_odbc=$with_odbc
                    601: fi
                    602:  
                    603: AC_MSG_CHECKING(whether to build the ODBC driver)
                    604: AC_ARG_ENABLE(odbc, [  --enable-odbc           build the ODBC driver package],
                    605: [if test x"$enableval" = x"yes" ; then
                    606:   AC_MSG_RESULT(yes)
                    607: else
                    608:   AC_MSG_RESULT(no)
                    609: fi],
                    610: [AC_MSG_RESULT(no)])
                    611: AC_SUBST(enable_odbc)
1.8       momjian   612: 
1.1       petere    613: 
                    614: dnl Allow for overriding the default location of the odbcinst.ini
1.15      petere    615: dnl file which is normally ${datadir} (i.e., ${prefix}/share).
                    616: if test x"$enable_odbc" = x"yes" ; then
1.28      petere    617: AC_ARG_WITH(odbcinst, [  --with-odbcinst=DIR     default directory for odbcinst.ini [sysconfdir]],
1.15      petere    618: [if test x"$with_odbcinst" = x"yes" || test x"$with_odbcinst" = x"no" ; then
                    619:   AC_MSG_ERROR([You must supply an argument to the --with-odbcinst option.])
1.1       petere    620: fi
1.15      petere    621: odbcinst_ini_dir=$withval],
1.28      petere    622: [odbcinst_ini_dir='${sysconfdir}'])
1.15      petere    623: else
1.28      petere    624:   odbcinst_ini_dir='${sysconfdir}'
1.1       petere    625: fi
1.15      petere    626: AC_SUBST(odbcinst_ini_dir)
1.3       momjian   627: 
                    628: 
                    629: 
1.1       petere    630: dnl Unless we specify the command line options
                    631: dnl    --enable cassert        to explicitly enable it
                    632: dnl If you do not explicitly do it, it defaults to disabled
                    633: AC_MSG_CHECKING(setting ASSERT CHECKING)
                    634: AC_ARG_ENABLE(
                    635:    cassert,
                    636:    [  --enable-cassert        enable assertion checks (for debugging) ],
                    637:    AC_DEFINE(USE_ASSERT_CHECKING) AC_MSG_RESULT(enabled),
                    638:    AC_MSG_RESULT(disabled)
                    639: )
                    640: 
                    641: 
1.30      petere    642: # Assume system is ELF if it predefines __ELF__ as 1,
                    643: # otherwise believe host_os based default.
                    644: case $host_os in
                    645:   freebsd1*|freebsd2*) elf=yes;;
                    646: esac
1.1       petere    647: 
                    648: AC_EGREP_CPP(yes,
                    649: [#if __ELF__
                    650:   yes
                    651: #endif
                    652: ],
1.30      petere    653: [ELF_SYS=true],
                    654: [if test "X$elf" = "Xyes" ; then
                    655:   ELF_SYS=true
1.1       petere    656: else
1.30      petere    657:   ELF_SYS=
                    658: fi])
                    659: AC_SUBST(ELF_SYS)
1.1       petere    660: 
                    661: 
                    662: 
1.6       petere    663: dnl
                    664: dnl Optionally build C++ code (i.e., libpq++)
                    665: dnl
                    666: AC_MSG_CHECKING(whether to build C++ modules)
                    667: AC_ARG_WITH(CXX, [  --with-CXX              build C++ modules (libpq++)],
                    668: [if test "x${withval+set}" = xset; then
                    669:   AC_MSG_RESULT(yes)
                    670:   if test x"$withval" != xyes ; then
                    671:     CXX=$withval
                    672:   fi
                    673:   AC_PROG_CXX
                    674:   AC_PROG_CXXCPP
                    675:   PGAC_CLASS_STRING
                    676:   PGAC_CXX_NAMESPACE_STD
                    677: else
                    678:   AC_MSG_RESULT(no)
                    679: fi],
                    680: [AC_MSG_RESULT(no)])
                    681: AC_SUBST(with_CXX)
1.1       petere    682: 
                    683: 
1.30      petere    684: CPPFLAGS="$CPPFLAGS $INCLUDES"
                    685: LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
                    686: 
                    687: echo "using CPPFLAGS=$CPPFLAGS"
                    688: echo "using LDFLAGS=$LDFLAGS"
                    689: 
                    690: 
1.28      petere    691: # Figure out how to invoke "install" and what install options to use.
1.1       petere    692: 
                    693: AC_PROG_INSTALL
1.28      petere    694: # When Autoconf chooses install-sh as install program it tries to generate
                    695: # a relative path to it in each makefile where it subsitutes it. This clashes
                    696: # with our Makefile.global concept. This workaround helps.
                    697: case $INSTALL in
                    698:   *install-sh*) INSTALL='\${SHELL} \${top_srcdir}/config/install-sh -c';;
                    699: esac
1.1       petere    700: 
1.28      petere    701: # Fix Autoconf's brain-dead defaults for script installs.
                    702: INSTALL_SCRIPT="\${INSTALL} -m 755"
1.1       petere    703: 
1.28      petere    704: # HPUX wants shared libs to be mode 555. Add your platform's special
                    705: # needs here if necessary.
                    706: case $host_os in
                    707:     hpux*)      INSTL_SHLIB_OPTS="-m 555" ;;
                    708:     *)          INSTL_SHLIB_OPTS="-m 644" ;;
1.1       petere    709: esac
1.19      tgl       710: 
1.28      petere    711: INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
                    712: AC_SUBST(INSTALL_SHLIB)
1.1       petere    713: 
1.19      tgl       714: 
1.28      petere    715: mkinstalldirs="\$(SHELL) \$(top_srcdir)/config/mkinstalldirs"
                    716: AC_SUBST(mkinstalldirs)
1.15      petere    717: 
                    718: 
1.2       petere    719: AC_PROG_AWK
                    720: 
1.1       petere    721: AC_PROG_LEX
                    722: if test "$LEX" = "flex"; then
                    723:         $LEX --version 2> /dev/null | grep -s '2\.5\.3' > /dev/null 2>&1
                    724:         if test $? -eq 0 ; then
                    725:                 AC_MSG_WARN([
                    726: ***
                    727: You have flex version 2.5.3, which is broken. Get version 2.5.4 or
                    728: a different lex.
                    729: (If you are using the official distribution of PostgreSQL then you
                    730: do not need to worry about this because the lexer files are
                    731: pre-generated. However, other software using flex is likely to be
                    732: broken as well.)
                    733: ***])
                    734:         fi
                    735: fi
                    736: AC_PROG_LN_S
                    737: AC_PROG_RANLIB
                    738: AC_PATH_PROG(tar, tar)
                    739: AC_CHECK_PROGS(PERL, perl,)
1.2       petere    740: AC_PROG_YACC
1.6       petere    741: AC_SUBST(YFLAGS)
1.1       petere    742: 
                    743: 
1.29      petere    744: ##
                    745: ## Libraries
                    746: ##
                    747: 
1.1       petere    748: AC_CHECK_LIB(sfio,     main)
1.13      petere    749: AC_CHECK_LIB(ncurses,  main, [], [AC_CHECK_LIB(curses, main)])
1.1       petere    750: AC_CHECK_LIB(termcap,  main)
                    751: AC_CHECK_LIB(readline, main)
                    752: AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
                    753:     AC_CHECK_LIB(history,  main) )
                    754: 
                    755: if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
                    756: then
                    757:        AC_CHECK_LIB(bsd,      main)
                    758: fi
1.21      petere    759: AC_CHECK_LIB(util,     setproctitle)
1.1       petere    760: AC_CHECK_LIB(m,        main)
                    761: AC_CHECK_LIB(dl,       main)
                    762: AC_CHECK_LIB(socket,   main)
                    763: AC_CHECK_LIB(nsl,      main)
                    764: AC_CHECK_LIB(ipc,      main)
                    765: AC_CHECK_LIB(IPC,      main)
                    766: AC_CHECK_LIB(lc,       main)
                    767: AC_CHECK_LIB(dld,      main)
                    768: AC_CHECK_LIB(ln,       main)
                    769: AC_CHECK_LIB(ld,       main)
                    770: AC_CHECK_LIB(compat,   main)
                    771: AC_CHECK_LIB(BSD,      main)
                    772: AC_CHECK_LIB(gen,      main)
                    773: AC_CHECK_LIB(PW,       main)
1.21      petere    774: AC_SEARCH_LIBS(crypt,  crypt)
1.28      petere    775: AC_CHECK_LIB(z,        inflate)
                    776: 
                    777: if test "$with_krb4" = yes ; then
                    778:   AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library \`des' is required for Kerberos 4])])
                    779:   AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library \`krb' is required for Kerberos 4])])
                    780: fi
                    781: 
                    782: if test "$with_krb5" = yes ; then
                    783:   AC_CHECK_LIB(com_err, main, [], [AC_MSG_ERROR([library \`com_err' is required for Kerberos 5])])
                    784:   AC_CHECK_LIB(crypto,  main, [], [AC_MSG_ERROR([library \`crypto' is required for Kerberos 5])])
                    785:   AC_CHECK_LIB(krb5,    main, [], [AC_MSG_ERROR([library \`krb5' is required for Kerberos 5])])
                    786: fi
                    787: 
                    788: if test "$with_openssl" = yes ; then
                    789:   dnl Order matters!
                    790:   AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
                    791:   AC_CHECK_LIB(ssl,    [SSL_library_init], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
                    792: fi
1.1       petere    793: 
1.28      petere    794: 
1.29      petere    795: ##
                    796: ## Header files
                    797: ##
                    798: dnl sys/socket.h and sys/types.h are required by AC_FUNC_ACCEPT_ARGTYPES
                    799: 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 values.h])
                    800: 
1.28      petere    801: AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
                    802: AC_CHECK_HEADERS([readline/history.h history.h], [break])
1.15      petere    803: 
1.28      petere    804: if test "$with_krb4" = yes ; then
                    805:   AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
                    806: fi
                    807: 
                    808: if test "$with_krb5" = yes ; then
                    809:   AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
                    810:   AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
                    811: fi
                    812: 
                    813: if test "$with_openssl" = yes ; then
                    814:   AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
                    815:   AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
                    816: fi
                    817: 
1.1       petere    818: 
1.29      petere    819: ##
                    820: ## Types, structures, compiler characteristics
                    821: ##
1.1       petere    822: AC_C_CONST
                    823: AC_C_INLINE
                    824: AC_C_STRINGIZE
1.6       petere    825: PGAC_C_SIGNED
                    826: PGAC_C_VOLATILE
1.29      petere    827: AC_STRUCT_TIMEZONE
                    828: PGAC_UNION_SEMUN
1.1       petere    829: 
                    830: 
1.29      petere    831: ##
                    832: ## Functions, global variables
                    833: ##
1.6       petere    834: PGAC_VAR_INT_TIMEZONE
1.29      petere    835: AC_FUNC_ACCEPT_ARGTYPES
1.6       petere    836: PGAC_FUNC_GETTIMEOFDAY_1ARG
1.1       petere    837: 
1.30      petere    838: AC_MSG_CHECKING([for fcntl(F_SETLK)])
                    839: case $host_os in
                    840:   linux*)       AC_MSG_RESULT([broken on Linux]) ;;
                    841:   *)
                    842: AC_TRY_LINK(
                    843: [#include <stdio.h>
                    844: #include <fcntl.h>
                    845: ],
                    846: [struct flock lck;
                    847: lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
                    848: lck.l_type = F_WRLCK;
                    849: fcntl(0, F_SETLK, &lck);],
                    850: [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
                    851: [AC_MSG_RESULT(no)])
                    852:         ;;
                    853: esac
1.1       petere    854: 
1.29      petere    855: AC_CHECK_FUNCS([fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid])
1.1       petere    856: 
1.28      petere    857: AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
                    858: [AC_TRY_LINK(
                    859: [#include <machine/vmparam.h>
                    860: #include <sys/exec.h>
                    861: ],
1.1       petere    862: [PS_STRINGS->ps_nargvstr = 1;
                    863: PS_STRINGS->ps_argvstr = "foo";],
1.28      petere    864: [pgac_cv_var_PS_STRINGS=yes],
                    865: [pgac_cv_var_PS_STRINGS=no])])
                    866: if test "$pgac_cv_var_PS_STRINGS" = yes ; then
                    867:   AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
                    868: fi
1.1       petere    869: 
                    870: dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
                    871: dnl is missing.  Yes, there are machines that have only one.
                    872: dnl We may also decide to use snprintf.c if snprintf() is present but does
                    873: dnl not have working "long long int" support -- see below.
                    874: SNPRINTF=''
                    875: AC_CHECK_FUNC(snprintf,
                    876:              AC_DEFINE(HAVE_SNPRINTF),
                    877:              SNPRINTF='snprintf.o')
                    878: AC_CHECK_FUNC(vsnprintf,
                    879:              AC_DEFINE(HAVE_VSNPRINTF),
                    880:              SNPRINTF='snprintf.o')
                    881: AC_SUBST(SNPRINTF)
                    882: dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
                    883: dnl include/c.h will provide declarations.  Note this is a separate test
                    884: dnl from whether the functions exist in the C library --- there are systems
                    885: dnl that have the functions but don't bother to declare them :-(
                    886: dnl Note: simple-minded pattern here will do wrong thing if stdio.h
                    887: dnl declares vsnprintf() but not snprintf().  Hopefully there are no
                    888: dnl systems that are *that* brain-damaged...
                    889: AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
                    890: AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
1.29      petere    891: 
                    892: # do this one the hard way in case isinf() is a macro
                    893: AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
1.1       petere    894: [AC_TRY_LINK(
1.29      petere    895: [#include <math.h>
                    896: ],
1.1       petere    897: [double x = 0.0; int res = isinf(x);],
1.29      petere    898: [ac_cv_func_isinf=yes],
                    899: [ac_cv_func_isinf=no])])
                    900: 
                    901: if test $ac_cv_func_isinf = yes ; then
1.1       petere    902:   AC_DEFINE(HAVE_ISINF)
1.29      petere    903:   ISINF=
1.1       petere    904: else
                    905:   ISINF='isinf.o'
1.29      petere    906:   # Look for a way to implement a substitute for isinf()
                    907:   AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
1.1       petere    908: fi
                    909: AC_SUBST(ISINF)
1.29      petere    910: 
1.1       petere    911: AC_CHECK_FUNC(getrusage,
                    912:              AC_DEFINE(HAVE_GETRUSAGE),
                    913:              GETRUSAGE='getrusage.o')
                    914: AC_SUBST(GETRUSAGE)
                    915: AC_CHECK_FUNC(srandom,
                    916:              AC_DEFINE(HAVE_SRANDOM),
                    917:              SRANDOM='srandom.o')
                    918: AC_SUBST(SRANDOM)
                    919: AC_CHECK_FUNC(gethostname,
                    920:              AC_DEFINE(HAVE_GETHOSTNAME),
                    921:              GETHOSTNAME='gethostname.o')
                    922: AC_SUBST(GETHOSTNAME)
                    923: AC_CHECK_FUNC(random,
                    924:              AC_DEFINE(HAVE_RANDOM),
                    925:              MISSING_RANDOM='random.o')
                    926: AC_SUBST(MISSING_RANDOM)
                    927: AC_CHECK_FUNC(inet_aton,
                    928:              AC_DEFINE(HAVE_INET_ATON),
                    929:              INET_ATON='inet_aton.o')
                    930: AC_SUBST(INET_ATON)
                    931: AC_CHECK_FUNC(strerror,
                    932:              AC_DEFINE(HAVE_STRERROR),
                    933:              [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
                    934: AC_SUBST(STRERROR)
                    935: AC_SUBST(STRERROR2)
                    936: AC_CHECK_FUNC(strdup,
                    937:              AC_DEFINE(HAVE_STRDUP),
                    938:              STRDUP='../../utils/strdup.o')
                    939: AC_SUBST(STRDUP)
                    940: AC_CHECK_FUNC(strtol,
                    941:              AC_DEFINE(HAVE_STRTOL),
                    942:              STRTOL='strtol.o')
                    943: AC_SUBST(STRTOL)
                    944: AC_CHECK_FUNC(strtoul,
                    945:              AC_DEFINE(HAVE_STRTOUL),
                    946:              STRTOL='strtoul.o')
                    947: AC_SUBST(STRTOUL)
                    948: AC_CHECK_FUNC(strcasecmp,
                    949:              AC_DEFINE(HAVE_STRCASECMP),
                    950:              STRCASECMP='strcasecmp.o')
                    951: AC_SUBST(STRCASECMP)
                    952: AC_CHECK_FUNC(cbrt,
                    953:              AC_DEFINE(HAVE_CBRT),
                    954:              AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
                    955: 
                    956: # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
                    957: # this hackery with HPUXMATHLIB allows us to cope.
                    958: HPUXMATHLIB=""
1.30      petere    959: case $host_cpu in
1.1       petere    960:   hppa1.1) 
                    961:        if [[ -r /lib/pa1.1/libm.a ]] ; then
                    962:            HPUXMATHLIB="-L /lib/pa1.1 -lm"
                    963:        fi ;;
                    964: esac
                    965: AC_SUBST(HPUXMATHLIB)
                    966: 
                    967: AC_CHECK_FUNC(rint,
                    968:              AC_DEFINE(HAVE_RINT),
                    969:              AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
                    970: 
                    971: dnl Some old versions of libreadline don't have rl_completion_append_character
                    972: AC_EGREP_HEADER(rl_completion_append_character, readline.h,
                    973:        AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER),
                    974:        [AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h,
                    975:                AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
                    976: AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
                    977: 
                    978: dnl Check for readline's filename_completion_function.
                    979: dnl Some versions have it but it's not in the headers, so we have to take
                    980: dnl care of that, too.
                    981: AC_CHECK_FUNCS(filename_completion_function,
                    982:     AC_EGREP_HEADER(filename_completion_function, readline.h,
                    983:         AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
                    984:         [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
                    985:             AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
                    986: )
                    987: AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
                    988: AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
                    989: 
                    990: 
                    991: dnl Cannot use AC_CHECK_FUNC because finite may be a macro
                    992: AC_MSG_CHECKING(for finite)
                    993: AC_TRY_LINK([#include <math.h>],
                    994:        [int dummy=finite(1.0);],
                    995:        [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
                    996:        AC_MSG_RESULT(no))
                    997: 
                    998: dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
                    999: dnl (especially on GNU libc)
                   1000: dnl See also comments in config.h.
                   1001: AC_MSG_CHECKING(for sigsetjmp)
                   1002: AC_TRY_LINK([#include <setjmp.h>],
                   1003:        [sigjmp_buf x; sigsetjmp(x, 1);],
                   1004:        [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
                   1005:        AC_MSG_RESULT(no))
                   1006: 
                   1007: AC_ARG_ENABLE(syslog, [  --enable-syslog         enable logging to syslog],
                   1008:     [case $enableval in y|ye|yes)
                   1009:        AC_CHECK_FUNC(syslog, [AC_DEFINE(ENABLE_SYSLOG)], [AC_MSG_ERROR([no syslog interface found])])
                   1010:         ;;
                   1011:      esac]
                   1012: )
                   1013: 
                   1014: dnl Check to see if we have a working 64-bit integer type.
                   1015: dnl This breaks down into two steps:
                   1016: dnl (1) figure out if the compiler has a 64-bit int type with working
                   1017: dnl arithmetic, and if so
                   1018: dnl (2) see whether snprintf() can format the type correctly.  (Currently,
                   1019: dnl snprintf is the only library routine we really need for int8 support.)
                   1020: dnl It's entirely possible to have a compiler that handles a 64-bit type
                   1021: dnl when the C library doesn't; this is fairly likely when using gcc on
                   1022: dnl an older platform, for example.
                   1023: dnl If there is no native snprintf() or it does not handle the 64-bit type,
                   1024: dnl we force our own version of snprintf() to be used instead.
                   1025: dnl Note this test must be run after our initial check for snprintf/vsnprintf.
                   1026: 
1.6       petere   1027: PGAC_TYPE_64BIT_INT([long int])
1.1       petere   1028: 
1.6       petere   1029: if test x"$HAVE_LONG_INT_64" = x"no" ; then
                   1030:   PGAC_TYPE_64BIT_INT([long long int])
                   1031: fi
1.1       petere   1032: 
                   1033: 
                   1034: dnl If we found "long int" is 64 bits, assume snprintf handles it.
                   1035: dnl If we found we need to use "long long int", better check.
                   1036: dnl We cope with snprintfs that use either %lld or %qd as the format.
                   1037: dnl If neither works, fall back to our own snprintf emulation (which we
                   1038: dnl know uses %lld).
                   1039: 
1.7       petere   1040: if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1.1       petere   1041:   if [[ x$SNPRINTF = x ]] ; then
                   1042:     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
                   1043:     AC_TRY_RUN([#include <stdio.h>
                   1044: typedef long long int int64;
                   1045: #define INT64_FORMAT "%lld"
                   1046: 
                   1047: int64 a = 20000001;
                   1048: int64 b = 40000005;
                   1049: 
                   1050: int does_int64_snprintf_work()
                   1051: {
                   1052:   int64 c;
                   1053:   char buf[100];
                   1054: 
                   1055:   if (sizeof(int64) != 8)
                   1056:     return 0;                  /* doesn't look like the right size */
                   1057: 
                   1058:   c = a * b;
                   1059:   snprintf(buf, 100, INT64_FORMAT, c);
                   1060:   if (strcmp(buf, "800000140000005") != 0)
                   1061:     return 0;                  /* either multiply or snprintf is busted */
                   1062:   return 1;
                   1063: }
                   1064: main() {
                   1065:   exit(! does_int64_snprintf_work());
                   1066: }],
                   1067:        [ AC_MSG_RESULT(yes)
                   1068:          INT64_FORMAT='"%lld"'
                   1069:        ],
                   1070:   [ AC_MSG_RESULT(no)
                   1071:     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd) 
                   1072:     AC_TRY_RUN([#include <stdio.h>
                   1073: typedef long long int int64;
                   1074: #define INT64_FORMAT "%qd"
                   1075:    
                   1076: int64 a = 20000001;
                   1077: int64 b = 40000005;
                   1078:    
                   1079: int does_int64_snprintf_work()
                   1080: {  
                   1081:   int64 c;
                   1082:   char buf[100];
                   1083: 
                   1084:   if (sizeof(int64) != 8)
                   1085:     return 0;     /* doesn't look like the right size */
                   1086: 
                   1087:   c = a * b;
                   1088:   snprintf(buf, 100, INT64_FORMAT, c);
                   1089:   if (strcmp(buf, "800000140000005") != 0)
                   1090:     return 0;     /* either multiply or snprintf is busted */
                   1091:   return 1;
                   1092: }
                   1093: main() {
                   1094:   exit(! does_int64_snprintf_work());
                   1095: }],
                   1096:   [ AC_MSG_RESULT(yes)
                   1097:     INT64_FORMAT='"%qd"'
                   1098:   ],
                   1099:   [ AC_MSG_RESULT(no)
                   1100:        # Force usage of our own snprintf, since system snprintf is broken
                   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:   [ AC_MSG_RESULT(assuming not on target machine)
                   1110:        # Force usage of our own snprintf, since we cannot test foreign snprintf
                   1111:        SNPRINTF='snprintf.o'
                   1112:        INT64_FORMAT='"%lld"'
                   1113:   ])
                   1114:   else
                   1115:     # here if we previously decided we needed to use our own snprintf
                   1116:     INT64_FORMAT='"%lld"'
                   1117:   fi
                   1118: else
                   1119:   # Here if we are not using 'long long int' at all
                   1120:   INT64_FORMAT='"%ld"'
                   1121: fi
                   1122: 
                   1123: AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
                   1124: 
                   1125: 
                   1126: dnl Determine memory alignment requirements for the basic C datatypes.
                   1127: 
1.6       petere   1128: PGAC_CHECK_ALIGNOF(short)
                   1129: PGAC_CHECK_ALIGNOF(int)
                   1130: PGAC_CHECK_ALIGNOF(long)
1.7       petere   1131: if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1.6       petere   1132:   PGAC_CHECK_ALIGNOF(long long int)
1.1       petere   1133: fi
1.6       petere   1134: PGAC_CHECK_ALIGNOF(double)
1.1       petere   1135: 
                   1136: dnl Compute maximum alignment of any basic type.
                   1137: dnl We assume long's alignment is at least as strong as char, short, or int;
                   1138: dnl but we must check long long (if it exists) and double.
                   1139: 
1.6       petere   1140: if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
                   1141:   MAX_ALIGNOF=$pgac_cv_alignof_long
                   1142:   if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
                   1143:     MAX_ALIGNOF=$pgac_cv_alignof_double
1.1       petere   1144:   fi
1.7       petere   1145:   if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1.6       petere   1146:     MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1.1       petere   1147:   fi
                   1148: else
                   1149:   dnl cross-compiling: assume that double's alignment is worst case
1.6       petere   1150:   MAX_ALIGNOF="$pgac_cv_alignof_double"
1.1       petere   1151: fi
1.6       petere   1152: AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1.1       petere   1153: 
1.6       petere   1154: PGAC_FUNC_POSIX_SIGNALS
1.1       petere   1155: 
                   1156: 
                   1157: dnl Check for Tcl configuration script tclConfig.sh
                   1158: 
                   1159: dnl If --with-tclconfig was given, don't check for tclsh, tcl
                   1160: if test -z "$TCL_DIRS"
                   1161: then
                   1162:        AC_PATH_PROG(TCLSH, tclsh)
                   1163:        if test -z "$TCLSH"
                   1164:        then
                   1165:                AC_PATH_PROG(TCLSH, tcl)
                   1166:                if test -z "$TCLSH"
                   1167:                then
                   1168:                        AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
                   1169:                        USE_TCL=
                   1170:                fi
                   1171:        fi
                   1172: fi
                   1173:        
                   1174: if test "$USE_TCL" = true
                   1175: then
                   1176:        AC_MSG_CHECKING(for tclConfig.sh)
                   1177:        TCL_CONFIG_SH=
                   1178:        library_dirs=
                   1179:        if test -z "$TCL_DIRS"
                   1180:        then
                   1181:                library_dirs=`echo 'puts $auto_path' | $TCLSH`
                   1182:        fi
                   1183:        library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
                   1184:        for dir in $library_dirs; do
                   1185:                if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
                   1186:                        TCL_CONFIG_SH=$dir/tclConfig.sh
                   1187:                        break
                   1188:                fi
                   1189:        done
                   1190:        if test -z "$TCL_CONFIG_SH"; then
                   1191:                AC_MSG_RESULT(no)
                   1192:                AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
                   1193:                USE_TCL=
                   1194:        else
                   1195:                AC_MSG_RESULT($TCL_CONFIG_SH)
                   1196:                AC_SUBST(TCL_CONFIG_SH)
                   1197:        fi
                   1198: fi
                   1199: 
                   1200: USE_TK=$USE_TCL                # If TCL is disabled, disable TK
                   1201: 
                   1202: dnl Check for Tk configuration script tkConfig.sh
                   1203: if test "$USE_TK" = true
                   1204: then
                   1205:        AC_MSG_CHECKING(for tkConfig.sh)
                   1206:        TK_CONFIG_SH=
                   1207:        # library_dirs are set in the check for TCL
                   1208:        for dir in $library_dirs
                   1209:        do
                   1210:                if test -d "$dir" -a -r "$dir/tkConfig.sh"
                   1211:                then
                   1212:                        TK_CONFIG_SH=$dir/tkConfig.sh
                   1213:                        break
                   1214:                fi
                   1215:        done
                   1216:        if test -z "$TK_CONFIG_SH"
                   1217:        then
                   1218:                AC_MSG_RESULT(no)
                   1219:                AC_MSG_WARN(TK support disabled; Tk configuration script missing)
                   1220:                USE_TK=
                   1221:        else
                   1222:                AC_MSG_RESULT($TK_CONFIG_SH)
                   1223:                AC_SUBST(TK_CONFIG_SH)
                   1224:                AC_PATH_PROG(WISH, wish)
                   1225:        fi
                   1226: fi
1.30      petere   1227: AC_SUBST(WISH)
1.1       petere   1228: 
                   1229: USE_X=$USE_TK
                   1230: 
                   1231: dnl Check for X libraries
                   1232: 
                   1233: if test "$USE_X" = true; then
                   1234: 
                   1235:        ice_save_LIBS="$LIBS"
                   1236:        ice_save_CFLAGS="$CFLAGS"
                   1237:        ice_save_CPPFLAGS="$CPPFLAGS"
                   1238:        ice_save_LDFLAGS="$LDFLAGS"
                   1239: 
                   1240:        AC_PATH_XTRA
                   1241: 
                   1242:        LIBS="$LIBS $X_EXTRA_LIBS"
                   1243:        CFLAGS="$CFLAGS $X_CFLAGS"
                   1244:        CPPFLAGS="$CPPFLAGS $X_CFLAGS"
                   1245:        LDFLAGS="$LDFLAGS $X_LIBS"
                   1246: 
                   1247:        dnl Check for X library
                   1248: 
                   1249:        X11_LIBS=""
                   1250:        AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
                   1251:        if test "$X11_LIBS" = ""; then
                   1252:                dnl Not having X is bad news for pgtksh. Let the user fix this.
                   1253:                AC_MSG_WARN([The X11 library '-lX11' could not be found,
                   1254: so TK support will be disabled.  To enable TK support,
                   1255: please use the configure options '--x-includes=DIR'
                   1256: and '--x-libraries=DIR' to specify the X location.
                   1257: See the file 'config.log' for further diagnostics.])
                   1258:                USE_TK=
                   1259:        fi
                   1260:        AC_SUBST(X_LIBS)
                   1261:        AC_SUBST(X11_LIBS)
                   1262:        AC_SUBST(X_PRE_LIBS)
                   1263: 
                   1264:        LIBS="$ice_save_LIBS"
                   1265:        CFLAGS="$ice_save_CFLAGS"
                   1266:        CPPFLAGS="$ice_save_CPPFLAGS"
                   1267:        LDFLAGS="$ice_save_LDFLAGS"
                   1268: fi
                   1269: 
1.28      petere   1270: 
                   1271: # Wait with these until we're done so no tests fail because of too
                   1272: # many warnings.
                   1273: if test x"$GCC" = x"yes" ; then
                   1274:   CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations"
                   1275: fi
1.1       petere   1276: 
                   1277: dnl Finally ready to produce output files ...
                   1278: 
                   1279: AC_OUTPUT(
                   1280:        GNUmakefile
                   1281:        src/GNUmakefile
                   1282:        src/Makefile.global
                   1283:        src/backend/port/Makefile
                   1284:        src/test/regress/GNUmakefile
                   1285: )

PostgreSQL CVSweb <[email protected]>