Home | History | Annotate | Download | only in curl
      1 #***************************************************************************
      2 #                                  _   _ ____  _
      3 #  Project                     ___| | | |  _ \| |
      4 #                             / __| | | | |_) | |
      5 #                            | (__| |_| |  _ <| |___
      6 #                             \___|\___/|_| \_\_____|
      7 #
      8 # Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel (a] haxx.se>, et al.
      9 #
     10 # This software is licensed as described in the file COPYING, which
     11 # you should have received as part of this distribution. The terms
     12 # are also available at https://curl.haxx.se/docs/copyright.html.
     13 #
     14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
     15 # copies of the Software, and permit persons to whom the Software is
     16 # furnished to do so, under the terms of the COPYING file.
     17 #
     18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     19 # KIND, either express or implied.
     20 #
     21 #***************************************************************************
     22 
     23 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
     24 dnl -------------------------------------------------
     25 dnl Use the C preprocessor to find out if the given object-style symbol
     26 dnl is defined and get its expansion. This macro will not use default
     27 dnl includes even if no INCLUDES argument is given. This macro will run
     28 dnl silently when invoked with three arguments. If the expansion would
     29 dnl result in a set of double-quoted strings the returned expansion will
     30 dnl actually be a single double-quoted string concatenating all them.
     31 
     32 AC_DEFUN([CURL_CHECK_DEF], [
     33   AC_REQUIRE([CURL_CPP_P])dnl
     34   OLDCPPFLAGS=$CPPFLAGS
     35   # CPPPFLAG comes from CURL_CPP_P
     36   CPPFLAGS="$CPPFLAGS $CPPPFLAG"
     37   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
     38   AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
     39   if test -z "$SED"; then
     40     AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
     41   fi
     42   if test -z "$GREP"; then
     43     AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
     44   fi
     45   ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
     46   tmp_exp=""
     47   AC_PREPROC_IFELSE([
     48     AC_LANG_SOURCE(
     49 ifelse($2,,,[$2])[[
     50 #ifdef $1
     51 CURL_DEF_TOKEN $1
     52 #endif
     53     ]])
     54   ],[
     55     tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
     56       "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
     57       "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
     58       "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
     59     if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
     60       tmp_exp=""
     61     fi
     62   ])
     63   if test -z "$tmp_exp"; then
     64     AS_VAR_SET(ac_HaveDef, no)
     65     ifelse($3,,[AC_MSG_RESULT([no])])
     66   else
     67     AS_VAR_SET(ac_HaveDef, yes)
     68     AS_VAR_SET(ac_Def, $tmp_exp)
     69     ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
     70   fi
     71   AS_VAR_POPDEF([ac_Def])dnl
     72   AS_VAR_POPDEF([ac_HaveDef])dnl
     73   CPPFLAGS=$OLDCPPFLAGS
     74 ])
     75 
     76 
     77 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
     78 dnl -------------------------------------------------
     79 dnl Use the C compiler to find out only if the given symbol is defined
     80 dnl or not, this can not find out its expansion. This macro will not use
     81 dnl default includes even if no INCLUDES argument is given. This macro
     82 dnl will run silently when invoked with three arguments.
     83 
     84 AC_DEFUN([CURL_CHECK_DEF_CC], [
     85   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
     86   ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
     87   AC_COMPILE_IFELSE([
     88     AC_LANG_SOURCE(
     89 ifelse($2,,,[$2])[[
     90 int main (void)
     91 {
     92 #ifdef $1
     93   return 0;
     94 #else
     95   force compilation error
     96 #endif
     97 }
     98     ]])
     99   ],[
    100     tst_symbol_defined="yes"
    101   ],[
    102     tst_symbol_defined="no"
    103   ])
    104   if test "$tst_symbol_defined" = "yes"; then
    105     AS_VAR_SET(ac_HaveDef, yes)
    106     ifelse($3,,[AC_MSG_RESULT([yes])])
    107   else
    108     AS_VAR_SET(ac_HaveDef, no)
    109     ifelse($3,,[AC_MSG_RESULT([no])])
    110   fi
    111   AS_VAR_POPDEF([ac_HaveDef])dnl
    112 ])
    113 
    114 
    115 dnl CURL_CHECK_LIB_XNET
    116 dnl -------------------------------------------------
    117 dnl Verify if X/Open network library is required.
    118 
    119 AC_DEFUN([CURL_CHECK_LIB_XNET], [
    120   AC_MSG_CHECKING([if X/Open network library is required])
    121   tst_lib_xnet_required="no"
    122   AC_COMPILE_IFELSE([
    123     AC_LANG_SOURCE([[
    124 int main (void)
    125 {
    126 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
    127   return 0;
    128 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
    129   return 0;
    130 #else
    131   force compilation error
    132 #endif
    133 }
    134     ]])
    135   ],[
    136     tst_lib_xnet_required="yes"
    137     LIBS="-lxnet $LIBS"
    138   ])
    139   AC_MSG_RESULT([$tst_lib_xnet_required])
    140 ])
    141 
    142 
    143 dnl CURL_CHECK_AIX_ALL_SOURCE
    144 dnl -------------------------------------------------
    145 dnl Provides a replacement of traditional AC_AIX with
    146 dnl an uniform behaviour across all autoconf versions,
    147 dnl and with our own placement rules.
    148 
    149 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
    150   AH_VERBATIM([_ALL_SOURCE],
    151     [/* Define to 1 if OS is AIX. */
    152 #ifndef _ALL_SOURCE
    153 #  undef _ALL_SOURCE
    154 #endif])
    155   AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
    156   AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
    157   AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
    158   AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
    159   AC_EGREP_CPP([yes_this_is_aix],[
    160 #ifdef _AIX
    161    yes_this_is_aix
    162 #endif
    163   ],[
    164     AC_MSG_RESULT([yes])
    165     AC_DEFINE(_ALL_SOURCE)
    166   ],[
    167     AC_MSG_RESULT([no])
    168   ])
    169 ])
    170 
    171 
    172 dnl CURL_CHECK_HEADER_WINDOWS
    173 dnl -------------------------------------------------
    174 dnl Check for compilable and valid windows.h header
    175 
    176 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
    177   AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
    178     AC_COMPILE_IFELSE([
    179       AC_LANG_PROGRAM([[
    180 #undef inline
    181 #ifndef WIN32_LEAN_AND_MEAN
    182 #define WIN32_LEAN_AND_MEAN
    183 #endif
    184 #include <windows.h>
    185       ]],[[
    186 #if defined(__CYGWIN__) || defined(__CEGCC__)
    187         HAVE_WINDOWS_H shall not be defined.
    188 #else
    189         int dummy=2*WINVER;
    190 #endif
    191       ]])
    192     ],[
    193       curl_cv_header_windows_h="yes"
    194     ],[
    195       curl_cv_header_windows_h="no"
    196     ])
    197   ])
    198   case "$curl_cv_header_windows_h" in
    199     yes)
    200       AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
    201         [Define to 1 if you have the windows.h header file.])
    202       ;;
    203   esac
    204 ])
    205 
    206 
    207 dnl CURL_CHECK_NATIVE_WINDOWS
    208 dnl -------------------------------------------------
    209 dnl Check if building a native Windows target
    210 
    211 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
    212   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    213   AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
    214     if test "$curl_cv_header_windows_h" = "no"; then
    215       curl_cv_native_windows="no"
    216     else
    217       AC_COMPILE_IFELSE([
    218         AC_LANG_PROGRAM([[
    219         ]],[[
    220 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
    221    (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
    222           int dummy=1;
    223 #else
    224           Not a native Windows build target.
    225 #endif
    226         ]])
    227       ],[
    228         curl_cv_native_windows="yes"
    229       ],[
    230         curl_cv_native_windows="no"
    231       ])
    232     fi
    233   ])
    234   AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
    235 ])
    236 
    237 
    238 dnl CURL_CHECK_HEADER_WINSOCK
    239 dnl -------------------------------------------------
    240 dnl Check for compilable and valid winsock.h header
    241 
    242 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
    243   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    244   AC_CACHE_CHECK([for winsock.h], [curl_cv_header_winsock_h], [
    245     AC_COMPILE_IFELSE([
    246       AC_LANG_PROGRAM([[
    247 #undef inline
    248 #ifndef WIN32_LEAN_AND_MEAN
    249 #define WIN32_LEAN_AND_MEAN
    250 #endif
    251 #include <windows.h>
    252 #include <winsock.h>
    253       ]],[[
    254 #if defined(__CYGWIN__) || defined(__CEGCC__)
    255         HAVE_WINSOCK_H shall not be defined.
    256 #else
    257         int dummy=WSACleanup();
    258 #endif
    259       ]])
    260     ],[
    261       curl_cv_header_winsock_h="yes"
    262     ],[
    263       curl_cv_header_winsock_h="no"
    264     ])
    265   ])
    266   case "$curl_cv_header_winsock_h" in
    267     yes)
    268       AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
    269         [Define to 1 if you have the winsock.h header file.])
    270       ;;
    271   esac
    272 ])
    273 
    274 
    275 dnl CURL_CHECK_HEADER_WINSOCK2
    276 dnl -------------------------------------------------
    277 dnl Check for compilable and valid winsock2.h header
    278 
    279 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
    280   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    281   AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
    282     AC_COMPILE_IFELSE([
    283       AC_LANG_PROGRAM([[
    284 #undef inline
    285 #ifndef WIN32_LEAN_AND_MEAN
    286 #define WIN32_LEAN_AND_MEAN
    287 #endif
    288 #include <windows.h>
    289 #include <winsock2.h>
    290       ]],[[
    291 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
    292         HAVE_WINSOCK2_H shall not be defined.
    293 #else
    294         int dummy=2*IPPROTO_ESP;
    295 #endif
    296       ]])
    297     ],[
    298       curl_cv_header_winsock2_h="yes"
    299     ],[
    300       curl_cv_header_winsock2_h="no"
    301     ])
    302   ])
    303   case "$curl_cv_header_winsock2_h" in
    304     yes)
    305       AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
    306         [Define to 1 if you have the winsock2.h header file.])
    307       ;;
    308   esac
    309 ])
    310 
    311 
    312 dnl CURL_CHECK_HEADER_WS2TCPIP
    313 dnl -------------------------------------------------
    314 dnl Check for compilable and valid ws2tcpip.h header
    315 
    316 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
    317   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
    318   AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
    319     AC_COMPILE_IFELSE([
    320       AC_LANG_PROGRAM([[
    321 #undef inline
    322 #ifndef WIN32_LEAN_AND_MEAN
    323 #define WIN32_LEAN_AND_MEAN
    324 #endif
    325 #include <windows.h>
    326 #include <winsock2.h>
    327 #include <ws2tcpip.h>
    328       ]],[[
    329 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
    330         HAVE_WS2TCPIP_H shall not be defined.
    331 #else
    332         int dummy=2*IP_PKTINFO;
    333 #endif
    334       ]])
    335     ],[
    336       curl_cv_header_ws2tcpip_h="yes"
    337     ],[
    338       curl_cv_header_ws2tcpip_h="no"
    339     ])
    340   ])
    341   case "$curl_cv_header_ws2tcpip_h" in
    342     yes)
    343       AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
    344         [Define to 1 if you have the ws2tcpip.h header file.])
    345       ;;
    346   esac
    347 ])
    348 
    349 
    350 dnl CURL_CHECK_HEADER_WINLDAP
    351 dnl -------------------------------------------------
    352 dnl Check for compilable and valid winldap.h header
    353 
    354 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
    355   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    356   AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
    357     AC_COMPILE_IFELSE([
    358       AC_LANG_PROGRAM([[
    359 #undef inline
    360 #ifdef HAVE_WINDOWS_H
    361 #ifndef WIN32_LEAN_AND_MEAN
    362 #define WIN32_LEAN_AND_MEAN
    363 #endif
    364 #include <windows.h>
    365 #endif
    366 #include <winldap.h>
    367       ]],[[
    368 #if defined(__CYGWIN__) || defined(__CEGCC__)
    369         HAVE_WINLDAP_H shall not be defined.
    370 #else
    371         LDAP *ldp = ldap_init("dummy", LDAP_PORT);
    372         ULONG res = ldap_unbind(ldp);
    373 #endif
    374       ]])
    375     ],[
    376       curl_cv_header_winldap_h="yes"
    377     ],[
    378       curl_cv_header_winldap_h="no"
    379     ])
    380   ])
    381   case "$curl_cv_header_winldap_h" in
    382     yes)
    383       AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
    384         [Define to 1 if you have the winldap.h header file.])
    385       ;;
    386   esac
    387 ])
    388 
    389 
    390 dnl CURL_CHECK_HEADER_WINBER
    391 dnl -------------------------------------------------
    392 dnl Check for compilable and valid winber.h header
    393 
    394 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
    395   AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
    396   AC_CACHE_CHECK([for winber.h], [curl_cv_header_winber_h], [
    397     AC_COMPILE_IFELSE([
    398       AC_LANG_PROGRAM([[
    399 #undef inline
    400 #ifdef HAVE_WINDOWS_H
    401 #ifndef WIN32_LEAN_AND_MEAN
    402 #define WIN32_LEAN_AND_MEAN
    403 #endif
    404 #include <windows.h>
    405 #endif
    406 #include <winldap.h>
    407 #include <winber.h>
    408       ]],[[
    409 #if defined(__CYGWIN__) || defined(__CEGCC__)
    410         HAVE_WINBER_H shall not be defined.
    411 #else
    412         BERVAL *bvp = NULL;
    413         BerElement *bep = ber_init(bvp);
    414         ber_free(bep, 1);
    415 #endif
    416       ]])
    417     ],[
    418       curl_cv_header_winber_h="yes"
    419     ],[
    420       curl_cv_header_winber_h="no"
    421     ])
    422   ])
    423   case "$curl_cv_header_winber_h" in
    424     yes)
    425       AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
    426         [Define to 1 if you have the winber.h header file.])
    427       ;;
    428   esac
    429 ])
    430 
    431 
    432 dnl CURL_CHECK_HEADER_LBER
    433 dnl -------------------------------------------------
    434 dnl Check for compilable and valid lber.h header,
    435 dnl and check if it is needed even with ldap.h
    436 
    437 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
    438   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
    439   AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
    440     AC_COMPILE_IFELSE([
    441       AC_LANG_PROGRAM([[
    442 #undef inline
    443 #ifdef HAVE_WINDOWS_H
    444 #ifndef WIN32_LEAN_AND_MEAN
    445 #define WIN32_LEAN_AND_MEAN
    446 #endif
    447 #include <windows.h>
    448 #else
    449 #ifdef HAVE_SYS_TYPES_H
    450 #include <sys/types.h>
    451 #endif
    452 #endif
    453 #ifndef NULL
    454 #define NULL (void *)0
    455 #endif
    456 #include <lber.h>
    457       ]],[[
    458         BerValue *bvp = NULL;
    459         BerElement *bep = ber_init(bvp);
    460         ber_free(bep, 1);
    461       ]])
    462     ],[
    463       curl_cv_header_lber_h="yes"
    464     ],[
    465       curl_cv_header_lber_h="no"
    466     ])
    467   ])
    468   if test "$curl_cv_header_lber_h" = "yes"; then
    469     AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
    470       [Define to 1 if you have the lber.h header file.])
    471     #
    472     AC_COMPILE_IFELSE([
    473       AC_LANG_PROGRAM([[
    474 #undef inline
    475 #ifdef HAVE_WINDOWS_H
    476 #ifndef WIN32_LEAN_AND_MEAN
    477 #define WIN32_LEAN_AND_MEAN
    478 #endif
    479 #include <windows.h>
    480 #else
    481 #ifdef HAVE_SYS_TYPES_H
    482 #include <sys/types.h>
    483 #endif
    484 #endif
    485 #ifndef NULL
    486 #define NULL (void *)0
    487 #endif
    488 #ifndef LDAP_DEPRECATED
    489 #define LDAP_DEPRECATED 1
    490 #endif
    491 #include <ldap.h>
    492       ]],[[
    493         BerValue *bvp = NULL;
    494         BerElement *bep = ber_init(bvp);
    495         ber_free(bep, 1);
    496       ]])
    497     ],[
    498       curl_cv_need_header_lber_h="no"
    499     ],[
    500       curl_cv_need_header_lber_h="yes"
    501     ])
    502     #
    503     case "$curl_cv_need_header_lber_h" in
    504       yes)
    505         AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
    506           [Define to 1 if you need the lber.h header file even with ldap.h])
    507         ;;
    508     esac
    509   fi
    510 ])
    511 
    512 
    513 dnl CURL_CHECK_HEADER_LDAP
    514 dnl -------------------------------------------------
    515 dnl Check for compilable and valid ldap.h header
    516 
    517 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
    518   AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
    519   AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
    520     AC_COMPILE_IFELSE([
    521       AC_LANG_PROGRAM([[
    522 #undef inline
    523 #ifdef HAVE_WINDOWS_H
    524 #ifndef WIN32_LEAN_AND_MEAN
    525 #define WIN32_LEAN_AND_MEAN
    526 #endif
    527 #include <windows.h>
    528 #else
    529 #ifdef HAVE_SYS_TYPES_H
    530 #include <sys/types.h>
    531 #endif
    532 #endif
    533 #ifndef LDAP_DEPRECATED
    534 #define LDAP_DEPRECATED 1
    535 #endif
    536 #ifdef NEED_LBER_H
    537 #include <lber.h>
    538 #endif
    539 #include <ldap.h>
    540       ]],[[
    541         LDAP *ldp = ldap_init("dummy", LDAP_PORT);
    542         int res = ldap_unbind(ldp);
    543       ]])
    544     ],[
    545       curl_cv_header_ldap_h="yes"
    546     ],[
    547       curl_cv_header_ldap_h="no"
    548     ])
    549   ])
    550   case "$curl_cv_header_ldap_h" in
    551     yes)
    552       AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
    553         [Define to 1 if you have the ldap.h header file.])
    554       ;;
    555   esac
    556 ])
    557 
    558 
    559 dnl CURL_CHECK_HEADER_LDAP_SSL
    560 dnl -------------------------------------------------
    561 dnl Check for compilable and valid ldap_ssl.h header
    562 
    563 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
    564   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
    565   AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
    566     AC_COMPILE_IFELSE([
    567       AC_LANG_PROGRAM([[
    568 #undef inline
    569 #ifdef HAVE_WINDOWS_H
    570 #ifndef WIN32_LEAN_AND_MEAN
    571 #define WIN32_LEAN_AND_MEAN
    572 #endif
    573 #include <windows.h>
    574 #else
    575 #ifdef HAVE_SYS_TYPES_H
    576 #include <sys/types.h>
    577 #endif
    578 #endif
    579 #ifndef LDAP_DEPRECATED
    580 #define LDAP_DEPRECATED 1
    581 #endif
    582 #ifdef NEED_LBER_H
    583 #include <lber.h>
    584 #endif
    585 #ifdef HAVE_LDAP_H
    586 #include <ldap.h>
    587 #endif
    588 #include <ldap_ssl.h>
    589       ]],[[
    590         LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
    591       ]])
    592     ],[
    593       curl_cv_header_ldap_ssl_h="yes"
    594     ],[
    595       curl_cv_header_ldap_ssl_h="no"
    596     ])
    597   ])
    598   case "$curl_cv_header_ldap_ssl_h" in
    599     yes)
    600       AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
    601         [Define to 1 if you have the ldap_ssl.h header file.])
    602       ;;
    603   esac
    604 ])
    605 
    606 
    607 dnl CURL_CHECK_HEADER_LDAPSSL
    608 dnl -------------------------------------------------
    609 dnl Check for compilable and valid ldapssl.h header
    610 
    611 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
    612   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
    613   AC_CACHE_CHECK([for ldapssl.h], [curl_cv_header_ldapssl_h], [
    614     AC_COMPILE_IFELSE([
    615       AC_LANG_PROGRAM([[
    616 #undef inline
    617 #ifdef HAVE_WINDOWS_H
    618 #ifndef WIN32_LEAN_AND_MEAN
    619 #define WIN32_LEAN_AND_MEAN
    620 #endif
    621 #include <windows.h>
    622 #else
    623 #ifdef HAVE_SYS_TYPES_H
    624 #include <sys/types.h>
    625 #endif
    626 #endif
    627 #ifndef NULL
    628 #define NULL (void *)0
    629 #endif
    630 #ifndef LDAP_DEPRECATED
    631 #define LDAP_DEPRECATED 1
    632 #endif
    633 #ifdef NEED_LBER_H
    634 #include <lber.h>
    635 #endif
    636 #ifdef HAVE_LDAP_H
    637 #include <ldap.h>
    638 #endif
    639 #include <ldapssl.h>
    640       ]],[[
    641         char *cert_label = NULL;
    642         LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
    643       ]])
    644     ],[
    645       curl_cv_header_ldapssl_h="yes"
    646     ],[
    647       curl_cv_header_ldapssl_h="no"
    648     ])
    649   ])
    650   case "$curl_cv_header_ldapssl_h" in
    651     yes)
    652       AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
    653         [Define to 1 if you have the ldapssl.h header file.])
    654       ;;
    655   esac
    656 ])
    657 
    658 
    659 dnl CURL_CHECK_LIBS_WINLDAP
    660 dnl -------------------------------------------------
    661 dnl Check for libraries needed for WINLDAP support,
    662 dnl and prepended to LIBS any needed libraries.
    663 dnl This macro can take an optional parameter with a
    664 dnl white space separated list of libraries to check
    665 dnl before the WINLDAP default ones.
    666 
    667 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
    668   AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
    669   #
    670   AC_MSG_CHECKING([for WINLDAP libraries])
    671   #
    672   u_libs=""
    673   #
    674   ifelse($1,,,[
    675     for x_lib in $1; do
    676       case "$x_lib" in
    677         -l*)
    678           l_lib="$x_lib"
    679           ;;
    680         *)
    681           l_lib="-l$x_lib"
    682           ;;
    683       esac
    684       if test -z "$u_libs"; then
    685         u_libs="$l_lib"
    686       else
    687         u_libs="$u_libs $l_lib"
    688       fi
    689     done
    690   ])
    691   #
    692   curl_cv_save_LIBS="$LIBS"
    693   curl_cv_ldap_LIBS="unknown"
    694   #
    695   for x_nlibs in '' "$u_libs" \
    696     '-lwldap32' ; do
    697     if test "$curl_cv_ldap_LIBS" = "unknown"; then
    698       if test -z "$x_nlibs"; then
    699         LIBS="$curl_cv_save_LIBS"
    700       else
    701         LIBS="$x_nlibs $curl_cv_save_LIBS"
    702       fi
    703       AC_LINK_IFELSE([
    704         AC_LANG_PROGRAM([[
    705 #undef inline
    706 #ifdef HAVE_WINDOWS_H
    707 #ifndef WIN32_LEAN_AND_MEAN
    708 #define WIN32_LEAN_AND_MEAN
    709 #endif
    710 #include <windows.h>
    711 #ifdef HAVE_WINLDAP_H
    712 #include <winldap.h>
    713 #endif
    714 #ifdef HAVE_WINBER_H
    715 #include <winber.h>
    716 #endif
    717 #endif
    718         ]],[[
    719           BERVAL *bvp = NULL;
    720           BerElement *bep = ber_init(bvp);
    721           LDAP *ldp = ldap_init("dummy", LDAP_PORT);
    722           ULONG res = ldap_unbind(ldp);
    723           ber_free(bep, 1);
    724         ]])
    725       ],[
    726         curl_cv_ldap_LIBS="$x_nlibs"
    727       ])
    728     fi
    729   done
    730   #
    731   LIBS="$curl_cv_save_LIBS"
    732   #
    733   case X-"$curl_cv_ldap_LIBS" in
    734     X-unknown)
    735       AC_MSG_RESULT([cannot find WINLDAP libraries])
    736       ;;
    737     X-)
    738       AC_MSG_RESULT([no additional lib required])
    739       ;;
    740     *)
    741       if test -z "$curl_cv_save_LIBS"; then
    742         LIBS="$curl_cv_ldap_LIBS"
    743       else
    744         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
    745       fi
    746       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
    747       ;;
    748   esac
    749   #
    750 ])
    751 
    752 
    753 dnl CURL_CHECK_LIBS_LDAP
    754 dnl -------------------------------------------------
    755 dnl Check for libraries needed for LDAP support,
    756 dnl and prepended to LIBS any needed libraries.
    757 dnl This macro can take an optional parameter with a
    758 dnl white space separated list of libraries to check
    759 dnl before the default ones.
    760 
    761 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
    762   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
    763   #
    764   AC_MSG_CHECKING([for LDAP libraries])
    765   #
    766   u_libs=""
    767   #
    768   ifelse($1,,,[
    769     for x_lib in $1; do
    770       case "$x_lib" in
    771         -l*)
    772           l_lib="$x_lib"
    773           ;;
    774         *)
    775           l_lib="-l$x_lib"
    776           ;;
    777       esac
    778       if test -z "$u_libs"; then
    779         u_libs="$l_lib"
    780       else
    781         u_libs="$u_libs $l_lib"
    782       fi
    783     done
    784   ])
    785   #
    786   curl_cv_save_LIBS="$LIBS"
    787   curl_cv_ldap_LIBS="unknown"
    788   #
    789   for x_nlibs in '' "$u_libs" \
    790     '-lldap' \
    791     '-lldap -llber' \
    792     '-llber -lldap' \
    793     '-lldapssl -lldapx -lldapsdk' \
    794     '-lldapsdk -lldapx -lldapssl' ; do
    795     if test "$curl_cv_ldap_LIBS" = "unknown"; then
    796       if test -z "$x_nlibs"; then
    797         LIBS="$curl_cv_save_LIBS"
    798       else
    799         LIBS="$x_nlibs $curl_cv_save_LIBS"
    800       fi
    801       AC_LINK_IFELSE([
    802         AC_LANG_PROGRAM([[
    803 #undef inline
    804 #ifdef HAVE_WINDOWS_H
    805 #ifndef WIN32_LEAN_AND_MEAN
    806 #define WIN32_LEAN_AND_MEAN
    807 #endif
    808 #include <windows.h>
    809 #else
    810 #ifdef HAVE_SYS_TYPES_H
    811 #include <sys/types.h>
    812 #endif
    813 #endif
    814 #ifndef NULL
    815 #define NULL (void *)0
    816 #endif
    817 #ifndef LDAP_DEPRECATED
    818 #define LDAP_DEPRECATED 1
    819 #endif
    820 #ifdef NEED_LBER_H
    821 #include <lber.h>
    822 #endif
    823 #ifdef HAVE_LDAP_H
    824 #include <ldap.h>
    825 #endif
    826         ]],[[
    827           BerValue *bvp = NULL;
    828           BerElement *bep = ber_init(bvp);
    829           LDAP *ldp = ldap_init("dummy", LDAP_PORT);
    830           int res = ldap_unbind(ldp);
    831           ber_free(bep, 1);
    832         ]])
    833       ],[
    834         curl_cv_ldap_LIBS="$x_nlibs"
    835       ])
    836     fi
    837   done
    838   #
    839   LIBS="$curl_cv_save_LIBS"
    840   #
    841   case X-"$curl_cv_ldap_LIBS" in
    842     X-unknown)
    843       AC_MSG_RESULT([cannot find LDAP libraries])
    844       ;;
    845     X-)
    846       AC_MSG_RESULT([no additional lib required])
    847       ;;
    848     *)
    849       if test -z "$curl_cv_save_LIBS"; then
    850         LIBS="$curl_cv_ldap_LIBS"
    851       else
    852         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
    853       fi
    854       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
    855       ;;
    856   esac
    857   #
    858 ])
    859 
    860 
    861 dnl CURL_CHECK_HEADER_MALLOC
    862 dnl -------------------------------------------------
    863 dnl Check for compilable and valid malloc.h header,
    864 dnl and check if it is needed even with stdlib.h
    865 
    866 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
    867   AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
    868     AC_COMPILE_IFELSE([
    869       AC_LANG_PROGRAM([[
    870 #include <malloc.h>
    871       ]],[[
    872         void *p = malloc(10);
    873         void *q = calloc(10,10);
    874         free(p);
    875         free(q);
    876       ]])
    877     ],[
    878       curl_cv_header_malloc_h="yes"
    879     ],[
    880       curl_cv_header_malloc_h="no"
    881     ])
    882   ])
    883   if test "$curl_cv_header_malloc_h" = "yes"; then
    884     AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
    885       [Define to 1 if you have the malloc.h header file.])
    886     #
    887     AC_COMPILE_IFELSE([
    888       AC_LANG_PROGRAM([[
    889 #include <stdlib.h>
    890       ]],[[
    891         void *p = malloc(10);
    892         void *q = calloc(10,10);
    893         free(p);
    894         free(q);
    895       ]])
    896     ],[
    897       curl_cv_need_header_malloc_h="no"
    898     ],[
    899       curl_cv_need_header_malloc_h="yes"
    900     ])
    901     #
    902     case "$curl_cv_need_header_malloc_h" in
    903       yes)
    904         AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
    905           [Define to 1 if you need the malloc.h header file even with stdlib.h])
    906         ;;
    907     esac
    908   fi
    909 ])
    910 
    911 
    912 dnl CURL_CHECK_HEADER_MEMORY
    913 dnl -------------------------------------------------
    914 dnl Check for compilable and valid memory.h header,
    915 dnl and check if it is needed even with stdlib.h for
    916 dnl memory related functions.
    917 
    918 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
    919   AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
    920     AC_COMPILE_IFELSE([
    921       AC_LANG_PROGRAM([[
    922 #include <memory.h>
    923       ]],[[
    924         void *p = malloc(10);
    925         void *q = calloc(10,10);
    926         free(p);
    927         free(q);
    928       ]])
    929     ],[
    930       curl_cv_header_memory_h="yes"
    931     ],[
    932       curl_cv_header_memory_h="no"
    933     ])
    934   ])
    935   if test "$curl_cv_header_memory_h" = "yes"; then
    936     AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
    937       [Define to 1 if you have the memory.h header file.])
    938     #
    939     AC_COMPILE_IFELSE([
    940       AC_LANG_PROGRAM([[
    941 #include <stdlib.h>
    942       ]],[[
    943         void *p = malloc(10);
    944         void *q = calloc(10,10);
    945         free(p);
    946         free(q);
    947       ]])
    948     ],[
    949       curl_cv_need_header_memory_h="no"
    950     ],[
    951       curl_cv_need_header_memory_h="yes"
    952     ])
    953     #
    954     case "$curl_cv_need_header_memory_h" in
    955       yes)
    956         AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
    957           [Define to 1 if you need the memory.h header file even with stdlib.h])
    958         ;;
    959     esac
    960   fi
    961 ])
    962 
    963 
    964 dnl CURL_CHECK_FUNC_GETNAMEINFO
    965 dnl -------------------------------------------------
    966 dnl Test if the getnameinfo function is available,
    967 dnl and check the types of five of its arguments.
    968 dnl If the function succeeds HAVE_GETNAMEINFO will be
    969 dnl defined, defining the types of the arguments in
    970 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
    971 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
    972 dnl and also defining the type qualifier of first
    973 dnl argument in GETNAMEINFO_QUAL_ARG1.
    974 
    975 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
    976   AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
    977   AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
    978   #
    979   AC_MSG_CHECKING([for getnameinfo])
    980   AC_LINK_IFELSE([
    981     AC_LANG_FUNC_LINK_TRY([getnameinfo])
    982   ],[
    983     AC_MSG_RESULT([yes])
    984     curl_cv_getnameinfo="yes"
    985   ],[
    986     AC_MSG_RESULT([no])
    987     curl_cv_getnameinfo="no"
    988   ])
    989   #
    990   if test "$curl_cv_getnameinfo" != "yes"; then
    991     AC_MSG_CHECKING([deeper for getnameinfo])
    992     AC_LINK_IFELSE([
    993       AC_LANG_PROGRAM([[
    994       ]],[[
    995         getnameinfo();
    996       ]])
    997     ],[
    998       AC_MSG_RESULT([yes])
    999       curl_cv_getnameinfo="yes"
   1000     ],[
   1001       AC_MSG_RESULT([but still no])
   1002       curl_cv_getnameinfo="no"
   1003     ])
   1004   fi
   1005   #
   1006   if test "$curl_cv_getnameinfo" != "yes"; then
   1007     AC_MSG_CHECKING([deeper and deeper for getnameinfo])
   1008     AC_LINK_IFELSE([
   1009       AC_LANG_PROGRAM([[
   1010 #undef inline
   1011 #ifdef HAVE_WINDOWS_H
   1012 #ifndef WIN32_LEAN_AND_MEAN
   1013 #define WIN32_LEAN_AND_MEAN
   1014 #endif
   1015 #include <windows.h>
   1016 #ifdef HAVE_WINSOCK2_H
   1017 #include <winsock2.h>
   1018 #ifdef HAVE_WS2TCPIP_H
   1019 #include <ws2tcpip.h>
   1020 #endif
   1021 #endif
   1022 #else
   1023 #ifdef HAVE_SYS_TYPES_H
   1024 #include <sys/types.h>
   1025 #endif
   1026 #ifdef HAVE_SYS_SOCKET_H
   1027 #include <sys/socket.h>
   1028 #endif
   1029 #ifdef HAVE_NETDB_H
   1030 #include <netdb.h>
   1031 #endif
   1032 #endif
   1033       ]],[[
   1034         getnameinfo(0, 0, 0, 0, 0, 0, 0);
   1035       ]])
   1036     ],[
   1037       AC_MSG_RESULT([yes])
   1038       curl_cv_getnameinfo="yes"
   1039     ],[
   1040       AC_MSG_RESULT([but still no])
   1041       curl_cv_getnameinfo="no"
   1042     ])
   1043   fi
   1044   #
   1045   if test "$curl_cv_getnameinfo" = "yes"; then
   1046     AC_CACHE_CHECK([types of arguments for getnameinfo],
   1047       [curl_cv_func_getnameinfo_args], [
   1048       curl_cv_func_getnameinfo_args="unknown"
   1049       for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
   1050         for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
   1051           for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
   1052             for gni_arg7 in 'int' 'unsigned int'; do
   1053               if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
   1054                 AC_COMPILE_IFELSE([
   1055                   AC_LANG_PROGRAM([[
   1056 #undef inline
   1057 #ifdef HAVE_WINDOWS_H
   1058 #ifndef WIN32_LEAN_AND_MEAN
   1059 #define WIN32_LEAN_AND_MEAN
   1060 #endif
   1061 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
   1062 #undef _WIN32_WINNT
   1063 #define _WIN32_WINNT 0x0501
   1064 #endif
   1065 #include <windows.h>
   1066 #ifdef HAVE_WINSOCK2_H
   1067 #include <winsock2.h>
   1068 #ifdef HAVE_WS2TCPIP_H
   1069 #include <ws2tcpip.h>
   1070 #endif
   1071 #endif
   1072 #define GNICALLCONV WSAAPI
   1073 #else
   1074 #ifdef HAVE_SYS_TYPES_H
   1075 #include <sys/types.h>
   1076 #endif
   1077 #ifdef HAVE_SYS_SOCKET_H
   1078 #include <sys/socket.h>
   1079 #endif
   1080 #ifdef HAVE_NETDB_H
   1081 #include <netdb.h>
   1082 #endif
   1083 #define GNICALLCONV
   1084 #endif
   1085                     extern int GNICALLCONV
   1086 #ifdef __ANDROID__
   1087 __attribute__((overloadable))
   1088 #endif
   1089 				getnameinfo($gni_arg1, $gni_arg2,
   1090                                            char *, $gni_arg46,
   1091                                            char *, $gni_arg46,
   1092                                            $gni_arg7);
   1093                   ]],[[
   1094                     $gni_arg2 salen=0;
   1095                     $gni_arg46 hostlen=0;
   1096                     $gni_arg46 servlen=0;
   1097                     $gni_arg7 flags=0;
   1098                     int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
   1099                   ]])
   1100                 ],[
   1101                   curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
   1102                 ])
   1103               fi
   1104             done
   1105           done
   1106         done
   1107       done
   1108     ]) # AC-CACHE-CHECK
   1109     if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
   1110       AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
   1111       AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
   1112     else
   1113       gni_prev_IFS=$IFS; IFS=','
   1114       set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
   1115       IFS=$gni_prev_IFS
   1116       shift
   1117       #
   1118       gni_qual_type_arg1=$[1]
   1119       #
   1120       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
   1121         [Define to the type of arg 2 for getnameinfo.])
   1122       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
   1123         [Define to the type of args 4 and 6 for getnameinfo.])
   1124       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
   1125         [Define to the type of arg 7 for getnameinfo.])
   1126       #
   1127       prev_sh_opts=$-
   1128       #
   1129       case $prev_sh_opts in
   1130         *f*)
   1131           ;;
   1132         *)
   1133           set -f
   1134           ;;
   1135       esac
   1136       #
   1137       case "$gni_qual_type_arg1" in
   1138         const*)
   1139           gni_qual_arg1=const
   1140           gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
   1141         ;;
   1142         *)
   1143           gni_qual_arg1=
   1144           gni_type_arg1=$gni_qual_type_arg1
   1145         ;;
   1146       esac
   1147       #
   1148       AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
   1149         [Define to the type qualifier of arg 1 for getnameinfo.])
   1150       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
   1151         [Define to the type of arg 1 for getnameinfo.])
   1152       #
   1153       case $prev_sh_opts in
   1154         *f*)
   1155           ;;
   1156         *)
   1157           set +f
   1158           ;;
   1159       esac
   1160       #
   1161       AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
   1162         [Define to 1 if you have the getnameinfo function.])
   1163       curl_cv_func_getnameinfo="yes"
   1164     fi
   1165   fi
   1166 ])
   1167 
   1168 
   1169 dnl TYPE_SOCKADDR_STORAGE
   1170 dnl -------------------------------------------------
   1171 dnl Check for struct sockaddr_storage. Most IPv6-enabled
   1172 dnl hosts have it, but AIX 4.3 is one known exception.
   1173 
   1174 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
   1175 [
   1176    AC_CHECK_TYPE([struct sockaddr_storage],
   1177         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
   1178                   [if struct sockaddr_storage is defined]), ,
   1179    [
   1180 #undef inline
   1181 #ifdef HAVE_WINDOWS_H
   1182 #ifndef WIN32_LEAN_AND_MEAN
   1183 #define WIN32_LEAN_AND_MEAN
   1184 #endif
   1185 #include <windows.h>
   1186 #ifdef HAVE_WINSOCK2_H
   1187 #include <winsock2.h>
   1188 #endif
   1189 #else
   1190 #ifdef HAVE_SYS_TYPES_H
   1191 #include <sys/types.h>
   1192 #endif
   1193 #ifdef HAVE_SYS_SOCKET_H
   1194 #include <sys/socket.h>
   1195 #endif
   1196 #ifdef HAVE_NETINET_IN_H
   1197 #include <netinet/in.h>
   1198 #endif
   1199 #ifdef HAVE_ARPA_INET_H
   1200 #include <arpa/inet.h>
   1201 #endif
   1202 #endif
   1203    ])
   1204 ])
   1205 
   1206 
   1207 dnl CURL_CHECK_NI_WITHSCOPEID
   1208 dnl -------------------------------------------------
   1209 dnl Check for working NI_WITHSCOPEID in getnameinfo()
   1210 
   1211 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
   1212   AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
   1213   AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
   1214   AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
   1215                    netdb.h netinet/in.h arpa/inet.h)
   1216   #
   1217   AC_CACHE_CHECK([for working NI_WITHSCOPEID],
   1218     [curl_cv_working_ni_withscopeid], [
   1219     AC_RUN_IFELSE([
   1220       AC_LANG_PROGRAM([[
   1221 #ifdef HAVE_STDLIB_H
   1222 #include <stdlib.h>
   1223 #endif
   1224 #ifdef HAVE_STDIO_H
   1225 #include <stdio.h>
   1226 #endif
   1227 #ifdef HAVE_SYS_TYPES_H
   1228 #include <sys/types.h>
   1229 #endif
   1230 #ifdef HAVE_SYS_SOCKET_H
   1231 #include <sys/socket.h>
   1232 #endif
   1233 #ifdef HAVE_NETDB_H
   1234 #include <netdb.h>
   1235 #endif
   1236 #ifdef HAVE_NETINET_IN_H
   1237 #include <netinet/in.h>
   1238 #endif
   1239 #ifdef HAVE_ARPA_INET_H
   1240 #include <arpa/inet.h>
   1241 #endif
   1242       ]],[[
   1243 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
   1244 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
   1245         struct sockaddr_storage sa;
   1246 #else
   1247         unsigned char sa[256];
   1248 #endif
   1249         char hostbuf[NI_MAXHOST];
   1250         int rc;
   1251         GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
   1252         GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
   1253         GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
   1254         int fd = socket(AF_INET6, SOCK_STREAM, 0);
   1255         if(fd < 0) {
   1256           perror("socket()");
   1257           return 1; /* Error creating socket */
   1258         }
   1259         rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
   1260         if(rc) {
   1261           perror("getsockname()");
   1262           return 2; /* Error retrieving socket name */
   1263         }
   1264         rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
   1265         if(rc) {
   1266           printf("rc = %s\n", gai_strerror(rc));
   1267           return 3; /* Error translating socket address */
   1268         }
   1269         return 0; /* Ok, NI_WITHSCOPEID works */
   1270 #else
   1271         return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
   1272 #endif
   1273       ]]) # AC-LANG-PROGRAM
   1274     ],[
   1275       # Exit code == 0. Program worked.
   1276       curl_cv_working_ni_withscopeid="yes"
   1277     ],[
   1278       # Exit code != 0. Program failed.
   1279       curl_cv_working_ni_withscopeid="no"
   1280     ],[
   1281       # Program is not run when cross-compiling. So we assume
   1282       # NI_WITHSCOPEID will work if we are able to compile it.
   1283       AC_COMPILE_IFELSE([
   1284         AC_LANG_PROGRAM([[
   1285 #include <sys/types.h>
   1286 #include <sys/socket.h>
   1287 #include <netdb.h>
   1288         ]],[[
   1289           unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
   1290         ]])
   1291       ],[
   1292         curl_cv_working_ni_withscopeid="yes"
   1293       ],[
   1294         curl_cv_working_ni_withscopeid="no"
   1295       ]) # AC-COMPILE-IFELSE
   1296     ]) # AC-RUN-IFELSE
   1297   ]) # AC-CACHE-CHECK
   1298   case "$curl_cv_working_ni_withscopeid" in
   1299     yes)
   1300       AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
   1301         [Define to 1 if NI_WITHSCOPEID exists and works.])
   1302       ;;
   1303   esac
   1304 ])
   1305 
   1306 
   1307 dnl CURL_CHECK_FUNC_RECV
   1308 dnl -------------------------------------------------
   1309 dnl Test if the socket recv() function is available,
   1310 dnl and check its return type and the types of its
   1311 dnl arguments. If the function succeeds HAVE_RECV
   1312 dnl will be defined, defining the types of the arguments
   1313 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
   1314 dnl and RECV_TYPE_ARG4, defining the type of the function
   1315 dnl return value in RECV_TYPE_RETV.
   1316 
   1317 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
   1318   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
   1319   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
   1320   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
   1321   #
   1322   AC_MSG_CHECKING([for recv])
   1323   AC_LINK_IFELSE([
   1324     AC_LANG_PROGRAM([[
   1325 #undef inline
   1326 #ifdef HAVE_WINDOWS_H
   1327 #ifndef WIN32_LEAN_AND_MEAN
   1328 #define WIN32_LEAN_AND_MEAN
   1329 #endif
   1330 #include <windows.h>
   1331 #ifdef HAVE_WINSOCK2_H
   1332 #include <winsock2.h>
   1333 #else
   1334 #ifdef HAVE_WINSOCK_H
   1335 #include <winsock.h>
   1336 #endif
   1337 #endif
   1338 #else
   1339 #ifdef HAVE_SYS_TYPES_H
   1340 #include <sys/types.h>
   1341 #endif
   1342 #ifdef HAVE_SYS_SOCKET_H
   1343 #include <sys/socket.h>
   1344 #endif
   1345 #endif
   1346     ]],[[
   1347       recv(0, 0, 0, 0);
   1348     ]])
   1349   ],[
   1350     AC_MSG_RESULT([yes])
   1351     curl_cv_recv="yes"
   1352   ],[
   1353     AC_MSG_RESULT([no])
   1354     curl_cv_recv="no"
   1355   ])
   1356   #
   1357   if test "$curl_cv_recv" = "yes"; then
   1358     AC_CACHE_CHECK([types of args and return type for recv],
   1359       [curl_cv_func_recv_args], [
   1360       curl_cv_func_recv_args="unknown"
   1361       for recv_retv in 'int' 'ssize_t'; do
   1362         for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
   1363           for recv_arg2 in 'char *' 'void *'; do
   1364             for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
   1365               for recv_arg4 in 'int' 'unsigned int'; do
   1366                 if test "$curl_cv_func_recv_args" = "unknown"; then
   1367                   AC_COMPILE_IFELSE([
   1368                     AC_LANG_PROGRAM([[
   1369 #undef inline
   1370 #ifdef HAVE_WINDOWS_H
   1371 #ifndef WIN32_LEAN_AND_MEAN
   1372 #define WIN32_LEAN_AND_MEAN
   1373 #endif
   1374 #include <windows.h>
   1375 #ifdef HAVE_WINSOCK2_H
   1376 #include <winsock2.h>
   1377 #else
   1378 #ifdef HAVE_WINSOCK_H
   1379 #include <winsock.h>
   1380 #endif
   1381 #endif
   1382 #define RECVCALLCONV PASCAL
   1383 #else
   1384 #ifdef HAVE_SYS_TYPES_H
   1385 #include <sys/types.h>
   1386 #endif
   1387 #ifdef HAVE_SYS_SOCKET_H
   1388 #include <sys/socket.h>
   1389 #endif
   1390 #define RECVCALLCONV
   1391 #endif
   1392                       extern $recv_retv RECVCALLCONV
   1393 #ifdef __ANDROID__
   1394 __attribute__((overloadable))
   1395 #endif
   1396                       recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
   1397                     ]],[[
   1398                       $recv_arg1 s=0;
   1399                       $recv_arg2 buf=0;
   1400                       $recv_arg3 len=0;
   1401                       $recv_arg4 flags=0;
   1402                       $recv_retv res = recv(s, buf, len, flags);
   1403                     ]])
   1404                   ],[
   1405                     curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
   1406                   ])
   1407                 fi
   1408               done
   1409             done
   1410           done
   1411         done
   1412       done
   1413     ]) # AC-CACHE-CHECK
   1414     if test "$curl_cv_func_recv_args" = "unknown"; then
   1415       AC_MSG_ERROR([Cannot find proper types to use for recv args])
   1416     else
   1417       recv_prev_IFS=$IFS; IFS=','
   1418       set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
   1419       IFS=$recv_prev_IFS
   1420       shift
   1421       #
   1422       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
   1423         [Define to the type of arg 1 for recv.])
   1424       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
   1425         [Define to the type of arg 2 for recv.])
   1426       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
   1427         [Define to the type of arg 3 for recv.])
   1428       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
   1429         [Define to the type of arg 4 for recv.])
   1430       AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
   1431         [Define to the function return type for recv.])
   1432       #
   1433       AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
   1434         [Define to 1 if you have the recv function.])
   1435       curl_cv_func_recv="yes"
   1436     fi
   1437   else
   1438     AC_MSG_ERROR([Unable to link function recv])
   1439   fi
   1440 ])
   1441 
   1442 
   1443 dnl CURL_CHECK_FUNC_SEND
   1444 dnl -------------------------------------------------
   1445 dnl Test if the socket send() function is available,
   1446 dnl and check its return type and the types of its
   1447 dnl arguments. If the function succeeds HAVE_SEND
   1448 dnl will be defined, defining the types of the arguments
   1449 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
   1450 dnl and SEND_TYPE_ARG4, defining the type of the function
   1451 dnl return value in SEND_TYPE_RETV, and also defining the
   1452 dnl type qualifier of second argument in SEND_QUAL_ARG2.
   1453 
   1454 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
   1455   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
   1456   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
   1457   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
   1458   #
   1459   AC_MSG_CHECKING([for send])
   1460   AC_LINK_IFELSE([
   1461     AC_LANG_PROGRAM([[
   1462 #undef inline
   1463 #ifdef HAVE_WINDOWS_H
   1464 #ifndef WIN32_LEAN_AND_MEAN
   1465 #define WIN32_LEAN_AND_MEAN
   1466 #endif
   1467 #include <windows.h>
   1468 #ifdef HAVE_WINSOCK2_H
   1469 #include <winsock2.h>
   1470 #else
   1471 #ifdef HAVE_WINSOCK_H
   1472 #include <winsock.h>
   1473 #endif
   1474 #endif
   1475 #else
   1476 #ifdef HAVE_SYS_TYPES_H
   1477 #include <sys/types.h>
   1478 #endif
   1479 #ifdef HAVE_SYS_SOCKET_H
   1480 #include <sys/socket.h>
   1481 #endif
   1482 #endif
   1483     ]],[[
   1484       send(0, 0, 0, 0);
   1485     ]])
   1486   ],[
   1487     AC_MSG_RESULT([yes])
   1488     curl_cv_send="yes"
   1489   ],[
   1490     AC_MSG_RESULT([no])
   1491     curl_cv_send="no"
   1492   ])
   1493   #
   1494   if test "$curl_cv_send" = "yes"; then
   1495     AC_CACHE_CHECK([types of args and return type for send],
   1496       [curl_cv_func_send_args], [
   1497       curl_cv_func_send_args="unknown"
   1498       for send_retv in 'int' 'ssize_t'; do
   1499         for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
   1500           for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
   1501             for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
   1502               for send_arg4 in 'int' 'unsigned int'; do
   1503                 if test "$curl_cv_func_send_args" = "unknown"; then
   1504                   AC_COMPILE_IFELSE([
   1505                     AC_LANG_PROGRAM([[
   1506 #undef inline
   1507 #ifdef HAVE_WINDOWS_H
   1508 #ifndef WIN32_LEAN_AND_MEAN
   1509 #define WIN32_LEAN_AND_MEAN
   1510 #endif
   1511 #include <windows.h>
   1512 #ifdef HAVE_WINSOCK2_H
   1513 #include <winsock2.h>
   1514 #else
   1515 #ifdef HAVE_WINSOCK_H
   1516 #include <winsock.h>
   1517 #endif
   1518 #endif
   1519 #define SENDCALLCONV PASCAL
   1520 #else
   1521 #ifdef HAVE_SYS_TYPES_H
   1522 #include <sys/types.h>
   1523 #endif
   1524 #ifdef HAVE_SYS_SOCKET_H
   1525 #include <sys/socket.h>
   1526 #endif
   1527 #define SENDCALLCONV
   1528 #endif
   1529                       extern $send_retv SENDCALLCONV
   1530 #ifdef __ANDROID__
   1531 __attribute__((overloadable))
   1532 #endif
   1533                       send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
   1534                     ]],[[
   1535                       $send_arg1 s=0;
   1536                       $send_arg3 len=0;
   1537                       $send_arg4 flags=0;
   1538                       $send_retv res = send(s, 0, len, flags);
   1539                     ]])
   1540                   ],[
   1541                     curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
   1542                   ])
   1543                 fi
   1544               done
   1545             done
   1546           done
   1547         done
   1548       done
   1549     ]) # AC-CACHE-CHECK
   1550     if test "$curl_cv_func_send_args" = "unknown"; then
   1551       AC_MSG_ERROR([Cannot find proper types to use for send args])
   1552     else
   1553       send_prev_IFS=$IFS; IFS=','
   1554       set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
   1555       IFS=$send_prev_IFS
   1556       shift
   1557       #
   1558       send_qual_type_arg2=$[2]
   1559       #
   1560       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
   1561         [Define to the type of arg 1 for send.])
   1562       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
   1563         [Define to the type of arg 3 for send.])
   1564       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
   1565         [Define to the type of arg 4 for send.])
   1566       AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
   1567         [Define to the function return type for send.])
   1568       #
   1569       prev_sh_opts=$-
   1570       #
   1571       case $prev_sh_opts in
   1572         *f*)
   1573           ;;
   1574         *)
   1575           set -f
   1576           ;;
   1577       esac
   1578       #
   1579       case "$send_qual_type_arg2" in
   1580         const*)
   1581           send_qual_arg2=const
   1582           send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
   1583         ;;
   1584         *)
   1585           send_qual_arg2=
   1586           send_type_arg2=$send_qual_type_arg2
   1587         ;;
   1588       esac
   1589       #
   1590       AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
   1591         [Define to the type qualifier of arg 2 for send.])
   1592       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
   1593         [Define to the type of arg 2 for send.])
   1594       #
   1595       case $prev_sh_opts in
   1596         *f*)
   1597           ;;
   1598         *)
   1599           set +f
   1600           ;;
   1601       esac
   1602       #
   1603       AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
   1604         [Define to 1 if you have the send function.])
   1605       curl_cv_func_send="yes"
   1606     fi
   1607   else
   1608     AC_MSG_ERROR([Unable to link function send])
   1609   fi
   1610 ])
   1611 
   1612 dnl CURL_CHECK_MSG_NOSIGNAL
   1613 dnl -------------------------------------------------
   1614 dnl Check for MSG_NOSIGNAL
   1615 
   1616 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
   1617   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
   1618   AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
   1619     AC_COMPILE_IFELSE([
   1620       AC_LANG_PROGRAM([[
   1621 #undef inline
   1622 #ifdef HAVE_WINDOWS_H
   1623 #ifndef WIN32_LEAN_AND_MEAN
   1624 #define WIN32_LEAN_AND_MEAN
   1625 #endif
   1626 #include <windows.h>
   1627 #ifdef HAVE_WINSOCK2_H
   1628 #include <winsock2.h>
   1629 #else
   1630 #ifdef HAVE_WINSOCK_H
   1631 #include <winsock.h>
   1632 #endif
   1633 #endif
   1634 #else
   1635 #ifdef HAVE_SYS_TYPES_H
   1636 #include <sys/types.h>
   1637 #endif
   1638 #ifdef HAVE_SYS_SOCKET_H
   1639 #include <sys/socket.h>
   1640 #endif
   1641 #endif
   1642       ]],[[
   1643         int flag=MSG_NOSIGNAL;
   1644       ]])
   1645     ],[
   1646       curl_cv_msg_nosignal="yes"
   1647     ],[
   1648       curl_cv_msg_nosignal="no"
   1649     ])
   1650   ])
   1651   case "$curl_cv_msg_nosignal" in
   1652     yes)
   1653       AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
   1654         [Define to 1 if you have the MSG_NOSIGNAL flag.])
   1655       ;;
   1656   esac
   1657 ])
   1658 
   1659 
   1660 dnl CURL_CHECK_STRUCT_TIMEVAL
   1661 dnl -------------------------------------------------
   1662 dnl Check for timeval struct
   1663 
   1664 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
   1665   AC_REQUIRE([AC_HEADER_TIME])dnl
   1666   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
   1667   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
   1668   AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
   1669   AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
   1670     AC_COMPILE_IFELSE([
   1671       AC_LANG_PROGRAM([[
   1672 #undef inline
   1673 #ifdef HAVE_WINDOWS_H
   1674 #ifndef WIN32_LEAN_AND_MEAN
   1675 #define WIN32_LEAN_AND_MEAN
   1676 #endif
   1677 #include <windows.h>
   1678 #ifdef HAVE_WINSOCK2_H
   1679 #include <winsock2.h>
   1680 #else
   1681 #ifdef HAVE_WINSOCK_H
   1682 #include <winsock.h>
   1683 #endif
   1684 #endif
   1685 #endif
   1686 #ifdef HAVE_SYS_TYPES_H
   1687 #include <sys/types.h>
   1688 #endif
   1689 #ifdef HAVE_SYS_TIME_H
   1690 #include <sys/time.h>
   1691 #ifdef TIME_WITH_SYS_TIME
   1692 #include <time.h>
   1693 #endif
   1694 #else
   1695 #ifdef HAVE_TIME_H
   1696 #include <time.h>
   1697 #endif
   1698 #endif
   1699 #ifdef HAVE_SYS_SOCKET_H
   1700 #include <sys/socket.h>
   1701 #endif
   1702       ]],[[
   1703         struct timeval ts;
   1704         ts.tv_sec  = 0;
   1705         ts.tv_usec = 0;
   1706       ]])
   1707     ],[
   1708       curl_cv_struct_timeval="yes"
   1709     ],[
   1710       curl_cv_struct_timeval="no"
   1711     ])
   1712   ])
   1713   case "$curl_cv_struct_timeval" in
   1714     yes)
   1715       AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
   1716         [Define to 1 if you have the timeval struct.])
   1717       ;;
   1718   esac
   1719 ])
   1720 
   1721 
   1722 dnl TYPE_SIG_ATOMIC_T
   1723 dnl -------------------------------------------------
   1724 dnl Check if the sig_atomic_t type is available, and
   1725 dnl verify if it is already defined as volatile.
   1726 
   1727 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
   1728   AC_CHECK_HEADERS(signal.h)
   1729   AC_CHECK_TYPE([sig_atomic_t],[
   1730     AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
   1731       [Define to 1 if sig_atomic_t is an available typedef.])
   1732   ], ,[
   1733 #ifdef HAVE_SIGNAL_H
   1734 #include <signal.h>
   1735 #endif
   1736   ])
   1737   case "$ac_cv_type_sig_atomic_t" in
   1738     yes)
   1739       #
   1740       AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
   1741       AC_LINK_IFELSE([
   1742         AC_LANG_PROGRAM([[
   1743 #ifdef HAVE_SIGNAL_H
   1744 #include <signal.h>
   1745 #endif
   1746         ]],[[
   1747           static volatile sig_atomic_t dummy = 0;
   1748         ]])
   1749       ],[
   1750         AC_MSG_RESULT([no])
   1751         curl_cv_sig_atomic_t_volatile="no"
   1752       ],[
   1753         AC_MSG_RESULT([yes])
   1754         curl_cv_sig_atomic_t_volatile="yes"
   1755       ])
   1756       #
   1757       if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
   1758         AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
   1759           [Define to 1 if sig_atomic_t is already defined as volatile.])
   1760       fi
   1761       ;;
   1762   esac
   1763 ])
   1764 
   1765 
   1766 dnl TYPE_IN_ADDR_T
   1767 dnl -------------------------------------------------
   1768 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
   1769 dnl and a few other things.
   1770 
   1771 AC_DEFUN([TYPE_IN_ADDR_T], [
   1772   AC_CHECK_TYPE([in_addr_t], ,[
   1773     dnl in_addr_t not available
   1774     AC_CACHE_CHECK([for in_addr_t equivalent],
   1775       [curl_cv_in_addr_t_equiv], [
   1776       curl_cv_in_addr_t_equiv="unknown"
   1777       for t in "unsigned long" int size_t unsigned long; do
   1778         if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
   1779           AC_LINK_IFELSE([
   1780             AC_LANG_PROGRAM([[
   1781 #undef inline
   1782 #ifdef HAVE_WINDOWS_H
   1783 #ifndef WIN32_LEAN_AND_MEAN
   1784 #define WIN32_LEAN_AND_MEAN
   1785 #endif
   1786 #include <windows.h>
   1787 #ifdef HAVE_WINSOCK2_H
   1788 #include <winsock2.h>
   1789 #else
   1790 #ifdef HAVE_WINSOCK_H
   1791 #include <winsock.h>
   1792 #endif
   1793 #endif
   1794 #else
   1795 #ifdef HAVE_SYS_TYPES_H
   1796 #include <sys/types.h>
   1797 #endif
   1798 #ifdef HAVE_SYS_SOCKET_H
   1799 #include <sys/socket.h>
   1800 #endif
   1801 #ifdef HAVE_NETINET_IN_H
   1802 #include <netinet/in.h>
   1803 #endif
   1804 #ifdef HAVE_ARPA_INET_H
   1805 #include <arpa/inet.h>
   1806 #endif
   1807 #endif
   1808             ]],[[
   1809               $t data = inet_addr ("1.2.3.4");
   1810             ]])
   1811           ],[
   1812             curl_cv_in_addr_t_equiv="$t"
   1813           ])
   1814         fi
   1815       done
   1816     ])
   1817     case "$curl_cv_in_addr_t_equiv" in
   1818       unknown)
   1819         AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
   1820         ;;
   1821       *)
   1822         AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
   1823           [Type to use in place of in_addr_t when system does not provide it.])
   1824         ;;
   1825     esac
   1826   ],[
   1827 #undef inline
   1828 #ifdef HAVE_WINDOWS_H
   1829 #ifndef WIN32_LEAN_AND_MEAN
   1830 #define WIN32_LEAN_AND_MEAN
   1831 #endif
   1832 #include <windows.h>
   1833 #ifdef HAVE_WINSOCK2_H
   1834 #include <winsock2.h>
   1835 #else
   1836 #ifdef HAVE_WINSOCK_H
   1837 #include <winsock.h>
   1838 #endif
   1839 #endif
   1840 #else
   1841 #ifdef HAVE_SYS_TYPES_H
   1842 #include <sys/types.h>
   1843 #endif
   1844 #ifdef HAVE_SYS_SOCKET_H
   1845 #include <sys/socket.h>
   1846 #endif
   1847 #ifdef HAVE_NETINET_IN_H
   1848 #include <netinet/in.h>
   1849 #endif
   1850 #ifdef HAVE_ARPA_INET_H
   1851 #include <arpa/inet.h>
   1852 #endif
   1853 #endif
   1854   ])
   1855 ])
   1856 
   1857 
   1858 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
   1859 dnl -------------------------------------------------
   1860 dnl Check if monotonic clock_gettime is available.
   1861 
   1862 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
   1863   AC_REQUIRE([AC_HEADER_TIME])dnl
   1864   AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
   1865   AC_MSG_CHECKING([for monotonic clock_gettime])
   1866   #
   1867   if test "x$dontwant_rt" = "xno" ; then
   1868     AC_COMPILE_IFELSE([
   1869       AC_LANG_PROGRAM([[
   1870 #ifdef HAVE_SYS_TYPES_H
   1871 #include <sys/types.h>
   1872 #endif
   1873 #ifdef HAVE_SYS_TIME_H
   1874 #include <sys/time.h>
   1875 #ifdef TIME_WITH_SYS_TIME
   1876 #include <time.h>
   1877 #endif
   1878 #else
   1879 #ifdef HAVE_TIME_H
   1880 #include <time.h>
   1881 #endif
   1882 #endif
   1883       ]],[[
   1884         struct timespec ts;
   1885         (void)clock_gettime(CLOCK_MONOTONIC, &ts);
   1886       ]])
   1887     ],[
   1888       AC_MSG_RESULT([yes])
   1889       curl_func_clock_gettime="yes"
   1890     ],[
   1891       AC_MSG_RESULT([no])
   1892       curl_func_clock_gettime="no"
   1893     ])
   1894   fi
   1895   dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
   1896   dnl until library linking and run-time checks for clock_gettime succeed.
   1897 ])
   1898 
   1899 
   1900 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
   1901 dnl -------------------------------------------------
   1902 dnl If monotonic clock_gettime is available then,
   1903 dnl check and prepended to LIBS any needed libraries.
   1904 
   1905 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
   1906   AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
   1907   #
   1908   if test "$curl_func_clock_gettime" = "yes"; then
   1909     #
   1910     AC_MSG_CHECKING([for clock_gettime in libraries])
   1911     #
   1912     curl_cv_save_LIBS="$LIBS"
   1913     curl_cv_gclk_LIBS="unknown"
   1914     #
   1915     for x_xlibs in '' '-lrt' '-lposix4' ; do
   1916       if test "$curl_cv_gclk_LIBS" = "unknown"; then
   1917         if test -z "$x_xlibs"; then
   1918           LIBS="$curl_cv_save_LIBS"
   1919         else
   1920           LIBS="$x_xlibs $curl_cv_save_LIBS"
   1921         fi
   1922         AC_LINK_IFELSE([
   1923           AC_LANG_PROGRAM([[
   1924 #ifdef HAVE_SYS_TYPES_H
   1925 #include <sys/types.h>
   1926 #endif
   1927 #ifdef HAVE_SYS_TIME_H
   1928 #include <sys/time.h>
   1929 #ifdef TIME_WITH_SYS_TIME
   1930 #include <time.h>
   1931 #endif
   1932 #else
   1933 #ifdef HAVE_TIME_H
   1934 #include <time.h>
   1935 #endif
   1936 #endif
   1937           ]],[[
   1938             struct timespec ts;
   1939             (void)clock_gettime(CLOCK_MONOTONIC, &ts);
   1940           ]])
   1941         ],[
   1942           curl_cv_gclk_LIBS="$x_xlibs"
   1943         ])
   1944       fi
   1945     done
   1946     #
   1947     LIBS="$curl_cv_save_LIBS"
   1948     #
   1949     case X-"$curl_cv_gclk_LIBS" in
   1950       X-unknown)
   1951         AC_MSG_RESULT([cannot find clock_gettime])
   1952         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
   1953         curl_func_clock_gettime="no"
   1954         ;;
   1955       X-)
   1956         AC_MSG_RESULT([no additional lib required])
   1957         curl_func_clock_gettime="yes"
   1958         ;;
   1959       *)
   1960         if test -z "$curl_cv_save_LIBS"; then
   1961           LIBS="$curl_cv_gclk_LIBS"
   1962         else
   1963           LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
   1964         fi
   1965         AC_MSG_RESULT([$curl_cv_gclk_LIBS])
   1966         curl_func_clock_gettime="yes"
   1967         ;;
   1968     esac
   1969     #
   1970     dnl only do runtime verification when not cross-compiling
   1971     if test "x$cross_compiling" != "xyes" &&
   1972       test "$curl_func_clock_gettime" = "yes"; then
   1973       AC_MSG_CHECKING([if monotonic clock_gettime works])
   1974       AC_RUN_IFELSE([
   1975         AC_LANG_PROGRAM([[
   1976 #ifdef HAVE_STDLIB_H
   1977 #include <stdlib.h>
   1978 #endif
   1979 #ifdef HAVE_SYS_TYPES_H
   1980 #include <sys/types.h>
   1981 #endif
   1982 #ifdef HAVE_SYS_TIME_H
   1983 #include <sys/time.h>
   1984 #ifdef TIME_WITH_SYS_TIME
   1985 #include <time.h>
   1986 #endif
   1987 #else
   1988 #ifdef HAVE_TIME_H
   1989 #include <time.h>
   1990 #endif
   1991 #endif
   1992         ]],[[
   1993           struct timespec ts;
   1994           if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
   1995             exit(0);
   1996           else
   1997             exit(1);
   1998         ]])
   1999       ],[
   2000         AC_MSG_RESULT([yes])
   2001       ],[
   2002         AC_MSG_RESULT([no])
   2003         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
   2004         curl_func_clock_gettime="no"
   2005         LIBS="$curl_cv_save_LIBS"
   2006       ])
   2007     fi
   2008     #
   2009     case "$curl_func_clock_gettime" in
   2010       yes)
   2011         AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
   2012           [Define to 1 if you have the clock_gettime function and monotonic timer.])
   2013         ;;
   2014     esac
   2015     #
   2016   fi
   2017   #
   2018 ])
   2019 
   2020 
   2021 dnl CURL_CHECK_LIBS_CONNECT
   2022 dnl -------------------------------------------------
   2023 dnl Verify if network connect function is already available
   2024 dnl using current libraries or if another one is required.
   2025 
   2026 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
   2027   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
   2028   AC_MSG_CHECKING([for connect in libraries])
   2029   tst_connect_save_LIBS="$LIBS"
   2030   tst_connect_need_LIBS="unknown"
   2031   for tst_lib in '' '-lsocket' ; do
   2032     if test "$tst_connect_need_LIBS" = "unknown"; then
   2033       LIBS="$tst_lib $tst_connect_save_LIBS"
   2034       AC_LINK_IFELSE([
   2035         AC_LANG_PROGRAM([[
   2036           $curl_includes_winsock2
   2037           #ifndef HAVE_WINDOWS_H
   2038             int connect(int, void*, int);
   2039           #endif
   2040         ]],[[
   2041           if(0 != connect(0, 0, 0))
   2042             return 1;
   2043         ]])
   2044       ],[
   2045         tst_connect_need_LIBS="$tst_lib"
   2046       ])
   2047     fi
   2048   done
   2049   LIBS="$tst_connect_save_LIBS"
   2050   #
   2051   case X-"$tst_connect_need_LIBS" in
   2052     X-unknown)
   2053       AC_MSG_RESULT([cannot find connect])
   2054       AC_MSG_ERROR([cannot find connect function in libraries.])
   2055       ;;
   2056     X-)
   2057       AC_MSG_RESULT([yes])
   2058       ;;
   2059     *)
   2060       AC_MSG_RESULT([$tst_connect_need_LIBS])
   2061       LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
   2062       ;;
   2063   esac
   2064 ])
   2065 
   2066 
   2067 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
   2068 dnl -------------------------------------------------
   2069 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
   2070 dnl symbol that can be further used in custom template configuration
   2071 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
   2072 dnl argument for the description. Symbol definitions done with this
   2073 dnl macro are intended to be exclusively used in handcrafted *.h.in
   2074 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
   2075 dnl prevents autoheader generation and insertion of symbol template
   2076 dnl stub and definition into the first configuration header file. Do
   2077 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
   2078 dnl one serves different functional needs.
   2079 
   2080 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
   2081 cat >>confdefs.h <<_EOF
   2082 [@%:@define] $1 ifelse($#, 2, [$2], 1)
   2083 _EOF
   2084 ])
   2085 
   2086 
   2087 dnl CURL_CONFIGURE_CURL_SOCKLEN_T
   2088 dnl -------------------------------------------------
   2089 dnl The need for the curl_socklen_t definition arises mainly to properly
   2090 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
   2091 dnl data type which is 32 or 64-Bit wide depending on the data model being
   2092 dnl used, and that on the other hand is only actually used when interfacing
   2093 dnl the X/Open sockets provided in the xnet library.
   2094 
   2095 AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
   2096   AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
   2097   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
   2098   AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
   2099   #
   2100   AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
   2101   #
   2102   AC_MSG_CHECKING([for curl_socklen_t data type])
   2103   curl_typeof_curl_socklen_t="unknown"
   2104   for arg1 in int SOCKET; do
   2105     for arg2 in 'struct sockaddr' void; do
   2106       for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
   2107         if test "$curl_typeof_curl_socklen_t" = "unknown"; then
   2108           AC_COMPILE_IFELSE([
   2109             AC_LANG_PROGRAM([[
   2110               $curl_includes_ws2tcpip
   2111               $curl_includes_sys_socket
   2112               $curl_preprocess_callconv
   2113               extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
   2114             ]],[[
   2115               $t *lenptr = 0;
   2116               if(0 != getpeername(0, 0, lenptr))
   2117                 return 1;
   2118             ]])
   2119           ],[
   2120             curl_typeof_curl_socklen_t="$t"
   2121           ])
   2122         fi
   2123       done
   2124     done
   2125   done
   2126   for t in socklen_t int; do
   2127     if test "$curl_typeof_curl_socklen_t" = "void"; then
   2128       AC_COMPILE_IFELSE([
   2129         AC_LANG_PROGRAM([[
   2130           $curl_includes_sys_socket
   2131           typedef $t curl_socklen_t;
   2132         ]],[[
   2133           curl_socklen_t dummy;
   2134         ]])
   2135       ],[
   2136         curl_typeof_curl_socklen_t="$t"
   2137       ])
   2138     fi
   2139   done
   2140   AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
   2141   if test "$curl_typeof_curl_socklen_t" = "void" ||
   2142     test "$curl_typeof_curl_socklen_t" = "unknown"; then
   2143     AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
   2144   fi
   2145   #
   2146   AC_MSG_CHECKING([size of curl_socklen_t])
   2147   curl_sizeof_curl_socklen_t="unknown"
   2148   curl_pull_headers_socklen_t="unknown"
   2149   if test "$curl_cv_header_ws2tcpip_h" = "yes"; then
   2150     tst_pull_header_checks='none ws2tcpip'
   2151     tst_size_checks='4'
   2152   else
   2153     tst_pull_header_checks='none systypes syssocket'
   2154     tst_size_checks='4 8 2'
   2155   fi
   2156   for tst_size in $tst_size_checks; do
   2157     for tst_pull_headers in $tst_pull_header_checks; do
   2158       if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
   2159         case $tst_pull_headers in
   2160           ws2tcpip)
   2161             tmp_includes="$curl_includes_ws2tcpip"
   2162             ;;
   2163           systypes)
   2164             tmp_includes="$curl_includes_sys_types"
   2165             ;;
   2166           syssocket)
   2167             tmp_includes="$curl_includes_sys_socket"
   2168             ;;
   2169           *)
   2170             tmp_includes=""
   2171             ;;
   2172         esac
   2173         AC_COMPILE_IFELSE([
   2174           AC_LANG_PROGRAM([[
   2175             $tmp_includes
   2176             typedef $curl_typeof_curl_socklen_t curl_socklen_t;
   2177             typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
   2178           ]],[[
   2179             curl_socklen_t dummy;
   2180           ]])
   2181         ],[
   2182           curl_sizeof_curl_socklen_t="$tst_size"
   2183           curl_pull_headers_socklen_t="$tst_pull_headers"
   2184         ])
   2185       fi
   2186     done
   2187   done
   2188   AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
   2189   if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
   2190     AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
   2191   fi
   2192   #
   2193   case $curl_pull_headers_socklen_t in
   2194     ws2tcpip)
   2195       CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
   2196       ;;
   2197     systypes)
   2198       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
   2199       ;;
   2200     syssocket)
   2201       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
   2202       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
   2203       ;;
   2204   esac
   2205   CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
   2206   CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
   2207 ])
   2208 
   2209 
   2210 dnl CURL_CONFIGURE_PULL_SYS_POLL
   2211 dnl -------------------------------------------------
   2212 dnl The need for the sys/poll.h inclusion arises mainly to properly
   2213 dnl interface AIX systems which define macros 'events' and 'revents'.
   2214 
   2215 AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
   2216   AC_REQUIRE([CURL_INCLUDES_POLL])dnl
   2217   #
   2218   tst_poll_events_macro_defined="unknown"
   2219   #
   2220   AC_COMPILE_IFELSE([
   2221     AC_LANG_PROGRAM([[
   2222       $curl_includes_poll
   2223     ]],[[
   2224 #if defined(events) || defined(revents)
   2225       return 0;
   2226 #else
   2227       force compilation error
   2228 #endif
   2229     ]])
   2230   ],[
   2231     tst_poll_events_macro_defined="yes"
   2232   ],[
   2233     tst_poll_events_macro_defined="no"
   2234   ])
   2235   #
   2236   if test "$tst_poll_events_macro_defined" = "yes"; then
   2237     if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
   2238       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
   2239     fi
   2240   fi
   2241   #
   2242 ])
   2243 
   2244 
   2245 dnl CURL_CHECK_FUNC_SELECT
   2246 dnl -------------------------------------------------
   2247 dnl Test if the socket select() function is available,
   2248 dnl and check its return type and the types of its
   2249 dnl arguments. If the function succeeds HAVE_SELECT
   2250 dnl will be defined, defining the types of the
   2251 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
   2252 dnl and SELECT_TYPE_ARG5, defining the type of the
   2253 dnl function return value in SELECT_TYPE_RETV, and
   2254 dnl also defining the type qualifier of fifth argument
   2255 dnl in SELECT_QUAL_ARG5.
   2256 
   2257 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
   2258   AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
   2259   AC_CHECK_HEADERS(sys/select.h sys/socket.h)
   2260   #
   2261   AC_MSG_CHECKING([for select])
   2262   AC_LINK_IFELSE([
   2263     AC_LANG_PROGRAM([[
   2264 #undef inline
   2265 #ifdef HAVE_WINDOWS_H
   2266 #ifndef WIN32_LEAN_AND_MEAN
   2267 #define WIN32_LEAN_AND_MEAN
   2268 #endif
   2269 #include <windows.h>
   2270 #ifdef HAVE_WINSOCK2_H
   2271 #include <winsock2.h>
   2272 #else
   2273 #ifdef HAVE_WINSOCK_H
   2274 #include <winsock.h>
   2275 #endif
   2276 #endif
   2277 #endif
   2278 #ifdef HAVE_SYS_TYPES_H
   2279 #include <sys/types.h>
   2280 #endif
   2281 #ifdef HAVE_SYS_TIME_H
   2282 #include <sys/time.h>
   2283 #ifdef TIME_WITH_SYS_TIME
   2284 #include <time.h>
   2285 #endif
   2286 #else
   2287 #ifdef HAVE_TIME_H
   2288 #include <time.h>
   2289 #endif
   2290 #endif
   2291 #ifndef HAVE_WINDOWS_H
   2292 #ifdef HAVE_SYS_SELECT_H
   2293 #include <sys/select.h>
   2294 #endif
   2295 #ifdef HAVE_SYS_SOCKET_H
   2296 #include <sys/socket.h>
   2297 #endif
   2298 #endif
   2299     ]],[[
   2300       select(0, 0, 0, 0, 0);
   2301     ]])
   2302   ],[
   2303     AC_MSG_RESULT([yes])
   2304     curl_cv_select="yes"
   2305   ],[
   2306     AC_MSG_RESULT([no])
   2307     curl_cv_select="no"
   2308   ])
   2309   #
   2310   if test "$curl_cv_select" = "yes"; then
   2311     AC_CACHE_CHECK([types of args and return type for select],
   2312       [curl_cv_func_select_args], [
   2313       curl_cv_func_select_args="unknown"
   2314       for sel_retv in 'int' 'ssize_t'; do
   2315         for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
   2316           for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
   2317             for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
   2318               if test "$curl_cv_func_select_args" = "unknown"; then
   2319                 AC_COMPILE_IFELSE([
   2320                   AC_LANG_PROGRAM([[
   2321 #undef inline
   2322 #ifdef HAVE_WINDOWS_H
   2323 #ifndef WIN32_LEAN_AND_MEAN
   2324 #define WIN32_LEAN_AND_MEAN
   2325 #endif
   2326 #include <windows.h>
   2327 #ifdef HAVE_WINSOCK2_H
   2328 #include <winsock2.h>
   2329 #else
   2330 #ifdef HAVE_WINSOCK_H
   2331 #include <winsock.h>
   2332 #endif
   2333 #endif
   2334 #define SELECTCALLCONV PASCAL
   2335 #endif
   2336 #ifdef HAVE_SYS_TYPES_H
   2337 #include <sys/types.h>
   2338 #endif
   2339 #ifdef HAVE_SYS_TIME_H
   2340 #include <sys/time.h>
   2341 #ifdef TIME_WITH_SYS_TIME
   2342 #include <time.h>
   2343 #endif
   2344 #else
   2345 #ifdef HAVE_TIME_H
   2346 #include <time.h>
   2347 #endif
   2348 #endif
   2349 #ifndef HAVE_WINDOWS_H
   2350 #ifdef HAVE_SYS_SELECT_H
   2351 #include <sys/select.h>
   2352 #endif
   2353 #ifdef HAVE_SYS_SOCKET_H
   2354 #include <sys/socket.h>
   2355 #endif
   2356 #define SELECTCALLCONV
   2357 #endif
   2358 #ifndef HAVE_STRUCT_TIMEVAL
   2359                     struct timeval {
   2360                       long tv_sec;
   2361                       long tv_usec;
   2362                     };
   2363 #endif
   2364                     extern $sel_retv SELECTCALLCONV
   2365 #ifdef __ANDROID__
   2366 __attribute__((overloadable))
   2367 #endif
   2368 			select($sel_arg1,
   2369 					$sel_arg234,
   2370 					$sel_arg234,
   2371 					$sel_arg234,
   2372 					$sel_arg5);
   2373                   ]],[[
   2374                     $sel_arg1   nfds=0;
   2375                     $sel_arg234 rfds=0;
   2376                     $sel_arg234 wfds=0;
   2377                     $sel_arg234 efds=0;
   2378                     $sel_retv res = select(nfds, rfds, wfds, efds, 0);
   2379                   ]])
   2380                 ],[
   2381                   curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
   2382                 ])
   2383               fi
   2384             done
   2385           done
   2386         done
   2387       done
   2388     ]) # AC-CACHE-CHECK
   2389     if test "$curl_cv_func_select_args" = "unknown"; then
   2390       AC_MSG_WARN([Cannot find proper types to use for select args])
   2391       AC_MSG_WARN([HAVE_SELECT will not be defined])
   2392     else
   2393       select_prev_IFS=$IFS; IFS=','
   2394       set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
   2395       IFS=$select_prev_IFS
   2396       shift
   2397       #
   2398       sel_qual_type_arg5=$[3]
   2399       #
   2400       AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
   2401         [Define to the type of arg 1 for select.])
   2402       AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
   2403         [Define to the type of args 2, 3 and 4 for select.])
   2404       AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
   2405         [Define to the function return type for select.])
   2406       #
   2407       prev_sh_opts=$-
   2408       #
   2409       case $prev_sh_opts in
   2410         *f*)
   2411           ;;
   2412         *)
   2413           set -f
   2414           ;;
   2415       esac
   2416       #
   2417       case "$sel_qual_type_arg5" in
   2418         const*)
   2419           sel_qual_arg5=const
   2420           sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
   2421         ;;
   2422         *)
   2423           sel_qual_arg5=
   2424           sel_type_arg5=$sel_qual_type_arg5
   2425         ;;
   2426       esac
   2427       #
   2428       AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
   2429         [Define to the type qualifier of arg 5 for select.])
   2430       AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
   2431         [Define to the type of arg 5 for select.])
   2432       #
   2433       case $prev_sh_opts in
   2434         *f*)
   2435           ;;
   2436         *)
   2437           set +f
   2438           ;;
   2439       esac
   2440       #
   2441       AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
   2442         [Define to 1 if you have the select function.])
   2443       curl_cv_func_select="yes"
   2444     fi
   2445   fi
   2446 ])
   2447 
   2448 
   2449 dnl CURL_VERIFY_RUNTIMELIBS
   2450 dnl -------------------------------------------------
   2451 dnl Verify that the shared libs found so far can be used when running
   2452 dnl programs, since otherwise the situation will create odd configure errors
   2453 dnl that are misleading people.
   2454 dnl
   2455 dnl Make sure this test is run BEFORE the first test in the script that
   2456 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
   2457 dnl macro. It must also run AFTER all lib-checking macros are complete.
   2458 
   2459 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
   2460 
   2461   dnl this test is of course not sensible if we are cross-compiling!
   2462   if test "x$cross_compiling" != xyes; then
   2463 
   2464     dnl just run a program to verify that the libs checked for previous to this
   2465     dnl point also is available run-time!
   2466     AC_MSG_CHECKING([run-time libs availability])
   2467     AC_TRY_RUN([
   2468 main()
   2469 {
   2470   return 0;
   2471 }
   2472 ],
   2473     AC_MSG_RESULT([fine]),
   2474     AC_MSG_RESULT([failed])
   2475     AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
   2476     )
   2477 
   2478     dnl if this test fails, configure has already stopped
   2479   fi
   2480 ])
   2481 
   2482 
   2483 dnl CURL_CHECK_VARIADIC_MACROS
   2484 dnl -------------------------------------------------
   2485 dnl Check compiler support of variadic macros
   2486 
   2487 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
   2488   AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
   2489     [curl_cv_variadic_macros_c99], [
   2490     AC_COMPILE_IFELSE([
   2491       AC_LANG_PROGRAM([[
   2492 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
   2493 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
   2494         int fun3(int arg1, int arg2, int arg3);
   2495         int fun2(int arg1, int arg2);
   2496         int fun3(int arg1, int arg2, int arg3)
   2497         { return arg1 + arg2 + arg3; }
   2498         int fun2(int arg1, int arg2)
   2499         { return arg1 + arg2; }
   2500       ]],[[
   2501         int res3 = c99_vmacro3(1, 2, 3);
   2502         int res2 = c99_vmacro2(1, 2);
   2503       ]])
   2504     ],[
   2505       curl_cv_variadic_macros_c99="yes"
   2506     ],[
   2507       curl_cv_variadic_macros_c99="no"
   2508     ])
   2509   ])
   2510   case "$curl_cv_variadic_macros_c99" in
   2511     yes)
   2512       AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
   2513         [Define to 1 if compiler supports C99 variadic macro style.])
   2514       ;;
   2515   esac
   2516   AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
   2517     [curl_cv_variadic_macros_gcc], [
   2518     AC_COMPILE_IFELSE([
   2519       AC_LANG_PROGRAM([[
   2520 #define gcc_vmacro3(first, args...) fun3(first, args)
   2521 #define gcc_vmacro2(first, args...) fun2(first, args)
   2522         int fun3(int arg1, int arg2, int arg3);
   2523         int fun2(int arg1, int arg2);
   2524         int fun3(int arg1, int arg2, int arg3)
   2525         { return arg1 + arg2 + arg3; }
   2526         int fun2(int arg1, int arg2)
   2527         { return arg1 + arg2; }
   2528       ]],[[
   2529         int res3 = gcc_vmacro3(1, 2, 3);
   2530         int res2 = gcc_vmacro2(1, 2);
   2531       ]])
   2532     ],[
   2533       curl_cv_variadic_macros_gcc="yes"
   2534     ],[
   2535       curl_cv_variadic_macros_gcc="no"
   2536     ])
   2537   ])
   2538   case "$curl_cv_variadic_macros_gcc" in
   2539     yes)
   2540       AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
   2541         [Define to 1 if compiler supports old gcc variadic macro style.])
   2542       ;;
   2543   esac
   2544 ])
   2545 
   2546 
   2547 dnl CURL_CHECK_CA_BUNDLE
   2548 dnl -------------------------------------------------
   2549 dnl Check if a default ca-bundle should be used
   2550 dnl
   2551 dnl regarding the paths this will scan:
   2552 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
   2553 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
   2554 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
   2555 dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
   2556 dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
   2557 dnl /etc/ssl/certs/ (ca path) SUSE
   2558 
   2559 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
   2560 
   2561   AC_MSG_CHECKING([default CA cert bundle/path])
   2562 
   2563   AC_ARG_WITH(ca-bundle,
   2564 AC_HELP_STRING([--with-ca-bundle=FILE],
   2565 [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
   2566 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
   2567   [
   2568     want_ca="$withval"
   2569     if test "x$want_ca" = "xyes"; then
   2570       AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
   2571     fi
   2572   ],
   2573   [ want_ca="unset" ])
   2574   AC_ARG_WITH(ca-path,
   2575 AC_HELP_STRING([--with-ca-path=DIRECTORY],
   2576 [Path to a directory containing CA certificates stored individually, with \
   2577 their filenames in a hash format. This option can be used with OpenSSL, \
   2578 GnuTLS and PolarSSL backends. Refer to OpenSSL c_rehash for details. \
   2579 (example: /etc/certificates)])
   2580 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
   2581   [
   2582     want_capath="$withval"
   2583     if test "x$want_capath" = "xyes"; then
   2584       AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
   2585     fi
   2586   ],
   2587   [ want_capath="unset"])
   2588 
   2589   ca_warning="   (warning: certs not found)"
   2590   capath_warning="   (warning: certs not found)"
   2591   check_capath=""
   2592 
   2593   if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
   2594           "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
   2595     dnl both given
   2596     ca="$want_ca"
   2597     capath="$want_capath"
   2598   elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
   2599     dnl --with-ca-bundle given
   2600     ca="$want_ca"
   2601     capath="no"
   2602   elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
   2603     dnl --with-ca-path given
   2604     if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
   2605       AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or PolarSSL])
   2606     fi
   2607     capath="$want_capath"
   2608     ca="no"
   2609   else
   2610     dnl first try autodetecting a CA bundle , then a CA path
   2611     dnl both autodetections can be skipped by --without-ca-*
   2612     ca="no"
   2613     capath="no"
   2614     if test "x$cross_compiling" != "xyes"; then
   2615       dnl NOT cross-compiling and...
   2616       dnl neither of the --with-ca-* options are provided
   2617       if test "x$want_ca" = "xunset"; then
   2618         dnl the path we previously would have installed the curl ca bundle
   2619         dnl to, and thus we now check for an already existing cert in that
   2620         dnl place in case we find no other
   2621         if test "x$prefix" != xNONE; then
   2622           cac="${prefix}/share/curl/curl-ca-bundle.crt"
   2623         else
   2624           cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
   2625         fi
   2626 
   2627         for a in /etc/ssl/certs/ca-certificates.crt \
   2628                  /etc/pki/tls/certs/ca-bundle.crt \
   2629                  /usr/share/ssl/certs/ca-bundle.crt \
   2630                  /usr/local/share/certs/ca-root-nss.crt \
   2631                  /etc/ssl/cert.pem \
   2632                  "$cac"; do
   2633           if test -f "$a"; then
   2634             ca="$a"
   2635             break
   2636           fi
   2637         done
   2638       fi
   2639       if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
   2640               "x$OPENSSL_ENABLED" = "x1"; then
   2641         check_capath="/etc/ssl/certs/"
   2642       fi
   2643     else
   2644       dnl no option given and cross-compiling
   2645       AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
   2646     fi
   2647   fi
   2648 
   2649   if test "x$ca" = "xno" || test -f "$ca"; then
   2650     ca_warning=""
   2651   fi
   2652 
   2653   if test "x$capath" != "xno"; then
   2654     check_capath="$capath"
   2655   fi
   2656 
   2657   if test ! -z "$check_capath"; then
   2658     for a in "$check_capath"; do
   2659       if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then
   2660         if test "x$capath" = "xno"; then
   2661           capath="$a"
   2662         fi
   2663         capath_warning=""
   2664         break
   2665       fi
   2666     done
   2667   fi
   2668 
   2669   if test "x$capath" = "xno"; then
   2670     capath_warning=""
   2671   fi
   2672 
   2673   if test "x$ca" != "xno"; then
   2674     CURL_CA_BUNDLE='"'$ca'"'
   2675     AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
   2676     AC_SUBST(CURL_CA_BUNDLE)
   2677     AC_MSG_RESULT([$ca])
   2678   fi
   2679   if test "x$capath" != "xno"; then
   2680     CURL_CA_PATH="\"$capath\""
   2681     AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
   2682     AC_MSG_RESULT([$capath (capath)])
   2683   fi
   2684   if test "x$ca" = "xno" && test "x$capath" = "xno"; then
   2685     AC_MSG_RESULT([no])
   2686   fi
   2687 
   2688   AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
   2689   AC_ARG_WITH(ca-fallback,
   2690 AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
   2691 AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
   2692   [
   2693     if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
   2694       AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
   2695     fi
   2696   ],
   2697   [ with_ca_fallback="no"])
   2698   AC_MSG_RESULT([$with_ca_fallback])
   2699   if test "x$with_ca_fallback" = "xyes"; then
   2700     if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
   2701       AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
   2702     fi
   2703     AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
   2704   fi
   2705 ])
   2706 
   2707 dnl CURL_CHECK_WIN32_LARGEFILE
   2708 dnl -------------------------------------------------
   2709 dnl Check if curl's WIN32 large file will be used
   2710 
   2711 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
   2712   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
   2713   AC_MSG_CHECKING([whether build target supports WIN32 file API])
   2714   curl_win32_file_api="no"
   2715   if test "$curl_cv_header_windows_h" = "yes"; then
   2716     if test x"$enable_largefile" != "xno"; then
   2717       AC_COMPILE_IFELSE([
   2718         AC_LANG_PROGRAM([[
   2719         ]],[[
   2720 #if !defined(_WIN32_WCE) && \
   2721     (defined(__MINGW32__) || \
   2722     (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
   2723           int dummy=1;
   2724 #else
   2725           WIN32 large file API not supported.
   2726 #endif
   2727         ]])
   2728       ],[
   2729         curl_win32_file_api="win32_large_files"
   2730       ])
   2731     fi
   2732     if test "$curl_win32_file_api" = "no"; then
   2733       AC_COMPILE_IFELSE([
   2734         AC_LANG_PROGRAM([[
   2735         ]],[[
   2736 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
   2737           int dummy=1;
   2738 #else
   2739           WIN32 small file API not supported.
   2740 #endif
   2741         ]])
   2742       ],[
   2743         curl_win32_file_api="win32_small_files"
   2744       ])
   2745     fi
   2746   fi
   2747   case "$curl_win32_file_api" in
   2748     win32_large_files)
   2749       AC_MSG_RESULT([yes (large file enabled)])
   2750       AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
   2751         [Define to 1 if you are building a Windows target with large file support.])
   2752       ;;
   2753     win32_small_files)
   2754       AC_MSG_RESULT([yes (large file disabled)])
   2755       AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
   2756         [Define to 1 if you are building a Windows target without large file support.])
   2757       ;;
   2758     *)
   2759       AC_MSG_RESULT([no])
   2760       ;;
   2761   esac
   2762 ])
   2763 
   2764 dnl CURL_EXPORT_PCDIR ($pcdir)
   2765 dnl ------------------------
   2766 dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
   2767 dnl
   2768 dnl we need this macro since pkg-config distinguishes among empty and unset
   2769 dnl variable while checking PKG_CONFIG_LIBDIR
   2770 dnl
   2771 
   2772 AC_DEFUN([CURL_EXPORT_PCDIR], [
   2773     if test -n "$1"; then
   2774       PKG_CONFIG_LIBDIR="$1"
   2775       export PKG_CONFIG_LIBDIR
   2776     fi
   2777 ])
   2778 
   2779 dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
   2780 dnl ------------------------
   2781 dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
   2782 dnl path to it, or 'no' if not found/present.
   2783 dnl
   2784 dnl If pkg-config is present, check that it has info about the $module or
   2785 dnl return "no" anyway!
   2786 dnl
   2787 dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
   2788 dnl
   2789 
   2790 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
   2791     if test -n "$PKG_CONFIG"; then
   2792       PKGCONFIG="$PKG_CONFIG"
   2793     else
   2794       AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
   2795         [$PATH:/usr/bin:/usr/local/bin])
   2796     fi
   2797 
   2798     if test "x$PKGCONFIG" != "xno"; then
   2799       AC_MSG_CHECKING([for $1 options with pkg-config])
   2800       dnl ask pkg-config about $1
   2801       itexists=`CURL_EXPORT_PCDIR([$2]) dnl
   2802         $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
   2803 
   2804       if test -z "$itexists"; then
   2805         dnl pkg-config does not have info about the given module! set the
   2806         dnl variable to 'no'
   2807         PKGCONFIG="no"
   2808         AC_MSG_RESULT([no])
   2809       else
   2810         AC_MSG_RESULT([found])
   2811       fi
   2812     fi
   2813 ])
   2814 
   2815 
   2816 dnl CURL_GENERATE_CONFIGUREHELP_PM
   2817 dnl -------------------------------------------------
   2818 dnl Generate test harness configurehelp.pm module, defining and
   2819 dnl initializing some perl variables with values which are known
   2820 dnl when the configure script runs. For portability reasons, test
   2821 dnl harness needs information on how to run the C preprocessor.
   2822 
   2823 AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
   2824   AC_REQUIRE([AC_PROG_CPP])dnl
   2825   tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
   2826   if test -z "$tmp_cpp"; then
   2827     tmp_cpp='cpp'
   2828   fi
   2829   cat >./tests/configurehelp.pm <<_EOF
   2830 [@%:@] This is a generated file.  Do not edit.
   2831 
   2832 package configurehelp;
   2833 
   2834 use strict;
   2835 use warnings;
   2836 use Exporter;
   2837 
   2838 use vars qw(
   2839     @ISA
   2840     @EXPORT_OK
   2841     \$Cpreprocessor
   2842     );
   2843 
   2844 @ISA = qw(Exporter);
   2845 
   2846 @EXPORT_OK = qw(
   2847     \$Cpreprocessor
   2848     );
   2849 
   2850 \$Cpreprocessor = '$tmp_cpp';
   2851 
   2852 1;
   2853 _EOF
   2854 ])
   2855 
   2856 dnl CURL_CPP_P
   2857 dnl
   2858 dnl Check if $cpp -P should be used for extract define values due to gcc 5
   2859 dnl splitting up strings and defines between line outputs. gcc by default
   2860 dnl (without -P) will show TEST EINVAL TEST as
   2861 dnl
   2862 dnl # 13 "conftest.c"
   2863 dnl TEST
   2864 dnl # 13 "conftest.c" 3 4
   2865 dnl     22
   2866 dnl # 13 "conftest.c"
   2867 dnl            TEST
   2868 
   2869 AC_DEFUN([CURL_CPP_P], [
   2870   AC_MSG_CHECKING([if cpp -P is needed])
   2871   AC_EGREP_CPP([TEST.*TEST], [
   2872  #include <errno.h>
   2873 TEST EINVAL TEST
   2874   ], [cpp=no], [cpp=yes])
   2875   AC_MSG_RESULT([$cpp])
   2876 
   2877   dnl we need cpp -P so check if it works then
   2878   if test "x$cpp" = "xyes"; then
   2879     AC_MSG_CHECKING([if cpp -P works])
   2880     OLDCPPFLAGS=$CPPFLAGS
   2881     CPPFLAGS="$CPPFLAGS -P"
   2882     AC_EGREP_CPP([TEST.*TEST], [
   2883  #include <errno.h>
   2884 TEST EINVAL TEST
   2885     ], [cpp_p=yes], [cpp_p=no])
   2886     AC_MSG_RESULT([$cpp_p])
   2887 
   2888     if test "x$cpp_p" = "xno"; then
   2889       AC_MSG_WARN([failed to figure out cpp -P alternative])
   2890       # without -P
   2891       CPPPFLAG=""
   2892     else
   2893       # with -P
   2894       CPPPFLAG="-P"
   2895     fi
   2896     dnl restore CPPFLAGS
   2897     CPPFLAGS=$OLDCPPFLAGS
   2898   else
   2899     # without -P
   2900     CPPPFLAG=""
   2901   fi
   2902 ])
   2903 
   2904 
   2905 dnl CURL_MAC_CFLAGS
   2906 dnl
   2907 dnl Check if -mmacosx-version-min, -miphoneos-version-min or any
   2908 dnl similar are set manually, otherwise do. And set
   2909 dnl -Werror=partial-availability.
   2910 dnl
   2911 
   2912 AC_DEFUN([CURL_MAC_CFLAGS], [
   2913 
   2914   tst_cflags="no"
   2915   case $host_os in
   2916     darwin*)
   2917       tst_cflags="yes"
   2918       ;;
   2919   esac
   2920 
   2921   AC_MSG_CHECKING([for good-to-use Mac CFLAGS])
   2922   AC_MSG_RESULT([$tst_cflags]);
   2923 
   2924   if test "$tst_cflags" = "yes"; then
   2925     AC_MSG_CHECKING([for *version-min in CFLAGS])
   2926     min=""
   2927     if test -z "$(echo $CFLAGS | grep m.*os.*-version-min)"; then
   2928       min="-mmacosx-version-min=10.8"
   2929       CFLAGS="$CFLAGS $min"
   2930     fi
   2931     if test -z "$min"; then
   2932       AC_MSG_RESULT([set by user])
   2933     else
   2934       AC_MSG_RESULT([$min set])
   2935     fi
   2936 
   2937     old_CFLAGS=$CFLAGS
   2938     CFLAGS="$CFLAGS -Werror=partial-availability"
   2939     AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
   2940     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
   2941       [AC_MSG_RESULT([yes])],
   2942       [AC_MSG_RESULT([no])
   2943       CFLAGS=$old_CFLAGS])
   2944   fi
   2945 
   2946 ])
   2947 
   2948 
   2949 dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
   2950 dnl
   2951 dnl Check to see if the compiler supports __builtin_available. This built-in
   2952 dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
   2953 dnl the time this macro was written, the function was not yet documented. Its
   2954 dnl purpose is to return true if the code is running under a certain OS version
   2955 dnl or later.
   2956 
   2957 AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
   2958   AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
   2959   AC_COMPILE_IFELSE([
   2960     AC_LANG_PROGRAM([[
   2961 #include <stdlib.h>
   2962     ]],[[
   2963       if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
   2964     ]])
   2965   ],[
   2966     AC_MSG_RESULT([yes])
   2967     AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
   2968         [Define to 1 if you have the __builtin_available function.])
   2969   ],[
   2970     AC_MSG_RESULT([no])
   2971   ])
   2972 ])
   2973