quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

acinclude.m4 (44132B)


      1 #***************************************************************************
      2 #                                  _   _ ____  _
      3 #  Project                     ___| | | |  _ \| |
      4 #                             / __| | | | |_) | |
      5 #                            | (__| |_| |  _ <| |___
      6 #                             \___|\___/|_| \_\_____|
      7 #
      8 # Copyright (C) Daniel Stenberg, <daniel@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.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 # SPDX-License-Identifier: curl
     22 #
     23 #***************************************************************************
     24 
     25 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
     26 dnl -------------------------------------------------
     27 dnl Use the C preprocessor to find out if the given object-style symbol
     28 dnl is defined and get its expansion. This macro will not use default
     29 dnl includes even if no INCLUDES argument is given. This macro will run
     30 dnl silently when invoked with three arguments. If the expansion would
     31 dnl result in a set of double-quoted strings the returned expansion will
     32 dnl actually be a single double-quoted string concatenating all them.
     33 
     34 AC_DEFUN([CURL_CHECK_DEF], [
     35   AC_REQUIRE([CURL_CPP_P])dnl
     36   OLDCPPFLAGS=$CPPFLAGS
     37   # CPPPFLAG comes from CURL_CPP_P
     38   CPPFLAGS="$CPPFLAGS $CPPPFLAG"
     39   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
     40   AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
     41   if test -z "$SED"; then
     42     AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
     43   fi
     44   if test -z "$GREP"; then
     45     AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
     46   fi
     47   ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
     48   tmp_exp=""
     49   AC_PREPROC_IFELSE([
     50     AC_LANG_SOURCE(
     51     ifelse($2,,,[$2])[[
     52       #ifdef $1
     53       CURL_DEF_TOKEN $1
     54       #endif
     55     ]])
     56   ],[
     57     tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
     58       "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
     59       "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
     60       "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
     61     if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
     62       tmp_exp=""
     63     fi
     64   ])
     65   if test -z "$tmp_exp"; then
     66     AS_VAR_SET(ac_HaveDef, no)
     67     ifelse($3,,[AC_MSG_RESULT([no])])
     68   else
     69     AS_VAR_SET(ac_HaveDef, yes)
     70     AS_VAR_SET(ac_Def, $tmp_exp)
     71     ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
     72   fi
     73   AS_VAR_POPDEF([ac_Def])dnl
     74   AS_VAR_POPDEF([ac_HaveDef])dnl
     75   CPPFLAGS=$OLDCPPFLAGS
     76 ])
     77 
     78 
     79 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
     80 dnl -------------------------------------------------
     81 dnl Use the C compiler to find out only if the given symbol is defined
     82 dnl or not, this can not find out its expansion. This macro will not use
     83 dnl default includes even if no INCLUDES argument is given. This macro
     84 dnl will run silently when invoked with three arguments.
     85 
     86 AC_DEFUN([CURL_CHECK_DEF_CC], [
     87   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
     88   ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
     89   AC_COMPILE_IFELSE([
     90     AC_LANG_SOURCE(
     91     ifelse($2,,,[$2])[[
     92       int main(void)
     93       {
     94       #ifndef $1
     95         #error force compilation error
     96       #endif
     97         return 0;
     98       }
     99     ]])
    100   ],[
    101     tst_symbol_defined="yes"
    102   ],[
    103     tst_symbol_defined="no"
    104   ])
    105   if test "$tst_symbol_defined" = "yes"; then
    106     AS_VAR_SET(ac_HaveDef, yes)
    107     ifelse($3,,[AC_MSG_RESULT([yes])])
    108   else
    109     AS_VAR_SET(ac_HaveDef, no)
    110     ifelse($3,,[AC_MSG_RESULT([no])])
    111   fi
    112   AS_VAR_POPDEF([ac_HaveDef])dnl
    113 ])
    114 
    115 
    116 dnl CURL_CHECK_LIB_XNET
    117 dnl -------------------------------------------------
    118 dnl Verify if X/Open network library is required.
    119 
    120 AC_DEFUN([CURL_CHECK_LIB_XNET], [
    121   AC_MSG_CHECKING([if X/Open network library is required])
    122   tst_lib_xnet_required="no"
    123   AC_COMPILE_IFELSE([
    124     AC_LANG_SOURCE([[
    125       int main(void)
    126       {
    127       #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
    128       #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
    129       #else
    130         #error force compilation error
    131       #endif
    132         return 0;
    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 behavior 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_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
    158   AC_EGREP_CPP([yes_this_is_aix],[
    159 #ifdef _AIX
    160    yes_this_is_aix
    161 #endif
    162   ],[
    163     AC_MSG_RESULT([yes])
    164     AC_DEFINE(_ALL_SOURCE)
    165   ],[
    166     AC_MSG_RESULT([no])
    167   ])
    168 ])
    169 
    170 
    171 dnl CURL_CHECK_NATIVE_WINDOWS
    172 dnl -------------------------------------------------
    173 dnl Check if building a native Windows target
    174 
    175 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
    176   AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
    177     AC_COMPILE_IFELSE([
    178       AC_LANG_PROGRAM([[
    179       ]],[[
    180         #ifdef _WIN32
    181           int dummy = 1;
    182           (void)dummy;
    183         #else
    184           #error Not a native Windows build target.
    185         #endif
    186       ]])
    187     ],[
    188       curl_cv_native_windows="yes"
    189     ],[
    190       curl_cv_native_windows="no"
    191     ])
    192   ])
    193   AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
    194 ])
    195 
    196 
    197 dnl CURL_CHECK_HEADER_LBER
    198 dnl -------------------------------------------------
    199 dnl Check for compilable and valid lber.h header,
    200 dnl and check if it is needed even with ldap.h
    201 
    202 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
    203   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
    204   AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
    205     AC_COMPILE_IFELSE([
    206       AC_LANG_PROGRAM([[
    207         #undef inline
    208         #ifdef _WIN32
    209         #ifndef WIN32_LEAN_AND_MEAN
    210         #define WIN32_LEAN_AND_MEAN
    211         #endif
    212         #include <windows.h>
    213         #else
    214         #ifdef HAVE_SYS_TYPES_H
    215         #include <sys/types.h>
    216         #endif
    217         #endif
    218         #ifndef NULL
    219         #define NULL (void *)0
    220         #endif
    221         #include <lber.h>
    222       ]],[[
    223         BerValue *bvp = NULL;
    224         BerElement *bep = ber_init(bvp);
    225         ber_free(bep, 1);
    226       ]])
    227     ],[
    228       curl_cv_header_lber_h="yes"
    229     ],[
    230       curl_cv_header_lber_h="no"
    231     ])
    232   ])
    233   if test "$curl_cv_header_lber_h" = "yes"; then
    234     AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
    235       [Define to 1 if you have the lber.h header file.])
    236     #
    237     AC_COMPILE_IFELSE([
    238       AC_LANG_PROGRAM([[
    239         #undef inline
    240         #ifdef _WIN32
    241         #ifndef WIN32_LEAN_AND_MEAN
    242         #define WIN32_LEAN_AND_MEAN
    243         #endif
    244         #include <windows.h>
    245         #else
    246         #ifdef HAVE_SYS_TYPES_H
    247         #include <sys/types.h>
    248         #endif
    249         #endif
    250         #ifndef NULL
    251         #define NULL (void *)0
    252         #endif
    253         #ifndef LDAP_DEPRECATED
    254         #define LDAP_DEPRECATED 1
    255         #endif
    256         #include <ldap.h>
    257       ]],[[
    258         BerValue *bvp = NULL;
    259         BerElement *bep = ber_init(bvp);
    260         ber_free(bep, 1);
    261       ]])
    262     ],[
    263       curl_cv_need_header_lber_h="no"
    264     ],[
    265       curl_cv_need_header_lber_h="yes"
    266     ])
    267     #
    268     case "$curl_cv_need_header_lber_h" in
    269       yes)
    270         AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
    271           [Define to 1 if you need the lber.h header file even with ldap.h])
    272         ;;
    273     esac
    274   fi
    275 ])
    276 
    277 
    278 dnl CURL_CHECK_HEADER_LDAP
    279 dnl -------------------------------------------------
    280 dnl Check for compilable and valid ldap.h header
    281 
    282 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
    283   AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
    284   AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
    285     AC_COMPILE_IFELSE([
    286       AC_LANG_PROGRAM([[
    287         #undef inline
    288         #ifdef _WIN32
    289         #ifndef WIN32_LEAN_AND_MEAN
    290         #define WIN32_LEAN_AND_MEAN
    291         #endif
    292         #include <windows.h>
    293         #else
    294         #ifdef HAVE_SYS_TYPES_H
    295         #include <sys/types.h>
    296         #endif
    297         #endif
    298         #ifndef LDAP_DEPRECATED
    299         #define LDAP_DEPRECATED 1
    300         #endif
    301         #ifdef NEED_LBER_H
    302         #include <lber.h>
    303         #endif
    304         #include <ldap.h>
    305       ]],[[
    306         LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
    307         int res = ldap_unbind(ldp);
    308         (void)res;
    309       ]])
    310     ],[
    311       curl_cv_header_ldap_h="yes"
    312     ],[
    313       curl_cv_header_ldap_h="no"
    314     ])
    315   ])
    316   case "$curl_cv_header_ldap_h" in
    317     yes)
    318       AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
    319         [Define to 1 if you have the ldap.h header file.])
    320       ;;
    321   esac
    322 ])
    323 
    324 
    325 dnl CURL_CHECK_HEADER_LDAP_SSL
    326 dnl -------------------------------------------------
    327 dnl Check for compilable and valid ldap_ssl.h header
    328 
    329 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
    330   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
    331   AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
    332     AC_COMPILE_IFELSE([
    333       AC_LANG_PROGRAM([[
    334         #undef inline
    335         #ifdef _WIN32
    336         #ifndef WIN32_LEAN_AND_MEAN
    337         #define WIN32_LEAN_AND_MEAN
    338         #endif
    339         #include <windows.h>
    340         #else
    341         #ifdef HAVE_SYS_TYPES_H
    342         #include <sys/types.h>
    343         #endif
    344         #endif
    345         #ifndef LDAP_DEPRECATED
    346         #define LDAP_DEPRECATED 1
    347         #endif
    348         #ifdef NEED_LBER_H
    349         #include <lber.h>
    350         #endif
    351         #ifdef HAVE_LDAP_H
    352         #include <ldap.h>
    353         #endif
    354         #include <ldap_ssl.h>
    355       ]],[[
    356         LDAP *ldp = ldapssl_init("0.0.0.0", LDAPS_PORT, 1);
    357         (void)ldp;
    358       ]])
    359     ],[
    360       curl_cv_header_ldap_ssl_h="yes"
    361     ],[
    362       curl_cv_header_ldap_ssl_h="no"
    363     ])
    364   ])
    365   case "$curl_cv_header_ldap_ssl_h" in
    366     yes)
    367       AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
    368         [Define to 1 if you have the ldap_ssl.h header file.])
    369       ;;
    370   esac
    371 ])
    372 
    373 
    374 dnl CURL_CHECK_LIBS_WINLDAP
    375 dnl -------------------------------------------------
    376 dnl Check for libraries needed for WINLDAP support,
    377 dnl and prepended to LIBS any needed libraries.
    378 dnl This macro can take an optional parameter with a
    379 dnl whitespace separated list of libraries to check
    380 dnl before the WINLDAP default ones.
    381 
    382 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
    383   AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
    384   #
    385   AC_MSG_CHECKING([for WINLDAP libraries])
    386   #
    387   u_libs=""
    388   #
    389   ifelse($1,,,[
    390     for x_lib in $1; do
    391       case "$x_lib" in
    392         -l*)
    393           l_lib="$x_lib"
    394           ;;
    395         *)
    396           l_lib="-l$x_lib"
    397           ;;
    398       esac
    399       if test -z "$u_libs"; then
    400         u_libs="$l_lib"
    401       else
    402         u_libs="$u_libs $l_lib"
    403       fi
    404     done
    405   ])
    406   #
    407   curl_cv_save_LIBS="$LIBS"
    408   curl_cv_ldap_LIBS="unknown"
    409   #
    410   for x_nlibs in '' "$u_libs" \
    411     '-lwldap32' ; do
    412     if test "$curl_cv_ldap_LIBS" = "unknown"; then
    413       if test -z "$x_nlibs"; then
    414         LIBS="$curl_cv_save_LIBS"
    415       else
    416         LIBS="$x_nlibs $curl_cv_save_LIBS"
    417       fi
    418       AC_LINK_IFELSE([
    419         AC_LANG_PROGRAM([[
    420           #undef inline
    421           #ifdef _WIN32
    422           #ifndef WIN32_LEAN_AND_MEAN
    423           #define WIN32_LEAN_AND_MEAN
    424           #endif
    425           #include <windows.h>
    426           #include <winldap.h>
    427           #ifdef HAVE_WINBER_H
    428           #include <winber.h>
    429           #endif
    430           #endif
    431         ]],[[
    432           BERVAL *bvp = NULL;
    433           BerElement *bep = ber_init(bvp);
    434           LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
    435           ULONG res = ldap_unbind(ldp);
    436           ber_free(bep, 1);
    437           (void)res;
    438         ]])
    439       ],[
    440         curl_cv_ldap_LIBS="$x_nlibs"
    441       ])
    442     fi
    443   done
    444   #
    445   LIBS="$curl_cv_save_LIBS"
    446   #
    447   case X-"$curl_cv_ldap_LIBS" in
    448     X-unknown)
    449       AC_MSG_RESULT([cannot find WINLDAP libraries])
    450       ;;
    451     X-)
    452       AC_MSG_RESULT([no additional lib required])
    453       ;;
    454     *)
    455       if test -z "$curl_cv_save_LIBS"; then
    456         LIBS="$curl_cv_ldap_LIBS"
    457       else
    458         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
    459       fi
    460       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
    461       ;;
    462   esac
    463   #
    464 ])
    465 
    466 
    467 dnl CURL_CHECK_LIBS_LDAP
    468 dnl -------------------------------------------------
    469 dnl Check for libraries needed for LDAP support,
    470 dnl and prepended to LIBS any needed libraries.
    471 dnl This macro can take an optional parameter with a
    472 dnl whitespace separated list of libraries to check
    473 dnl before the default ones.
    474 
    475 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
    476   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
    477   #
    478   AC_MSG_CHECKING([for LDAP libraries])
    479   #
    480   u_libs=""
    481   #
    482   ifelse($1,,,[
    483     for x_lib in $1; do
    484       case "$x_lib" in
    485         -l*)
    486           l_lib="$x_lib"
    487           ;;
    488         *)
    489           l_lib="-l$x_lib"
    490           ;;
    491       esac
    492       if test -z "$u_libs"; then
    493         u_libs="$l_lib"
    494       else
    495         u_libs="$u_libs $l_lib"
    496       fi
    497     done
    498   ])
    499   #
    500   curl_cv_save_LIBS="$LIBS"
    501   curl_cv_ldap_LIBS="unknown"
    502   #
    503   for x_nlibs in '' "$u_libs" \
    504     '-lldap' \
    505     '-lldap -llber' \
    506     '-llber -lldap' \
    507     '-lldapssl -lldapx -lldapsdk' \
    508     '-lldapsdk -lldapx -lldapssl' \
    509     '-lldap -llber -lssl -lcrypto'; do
    510 
    511     if test "$curl_cv_ldap_LIBS" = "unknown"; then
    512       if test -z "$x_nlibs"; then
    513         LIBS="$curl_cv_save_LIBS"
    514       else
    515         LIBS="$x_nlibs $curl_cv_save_LIBS"
    516       fi
    517       AC_LINK_IFELSE([
    518         AC_LANG_PROGRAM([[
    519           #undef inline
    520           #ifdef _WIN32
    521           #ifndef WIN32_LEAN_AND_MEAN
    522           #define WIN32_LEAN_AND_MEAN
    523           #endif
    524           #include <windows.h>
    525           #else
    526           #ifdef HAVE_SYS_TYPES_H
    527           #include <sys/types.h>
    528           #endif
    529           #endif
    530           #ifndef NULL
    531           #define NULL (void *)0
    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           #ifdef HAVE_LDAP_H
    540           #include <ldap.h>
    541           #endif
    542         ]],[[
    543           BerValue *bvp = NULL;
    544           BerElement *bep = ber_init(bvp);
    545           LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
    546           int res = ldap_unbind(ldp);
    547           ber_free(bep, 1);
    548           (void)res;
    549         ]])
    550       ],[
    551         curl_cv_ldap_LIBS="$x_nlibs"
    552       ])
    553     fi
    554   done
    555   #
    556   LIBS="$curl_cv_save_LIBS"
    557   #
    558   case X-"$curl_cv_ldap_LIBS" in
    559     X-unknown)
    560       AC_MSG_RESULT([cannot find LDAP libraries])
    561       ;;
    562     X-)
    563       AC_MSG_RESULT([no additional lib required])
    564       ;;
    565     *)
    566       if test -z "$curl_cv_save_LIBS"; then
    567         LIBS="$curl_cv_ldap_LIBS"
    568       else
    569         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
    570       fi
    571       # FIXME: Enable when ldap was detected via pkg-config
    572       if false; then
    573         LIBCURL_PC_REQUIRES_PRIVATE="ldap $LIBCURL_PC_REQUIRES_PRIVATE"
    574       fi
    575       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
    576       ;;
    577   esac
    578   #
    579 ])
    580 
    581 
    582 dnl TYPE_SOCKADDR_STORAGE
    583 dnl -------------------------------------------------
    584 dnl Check for struct sockaddr_storage. Most IPv6-enabled
    585 dnl hosts have it, but AIX 4.3 is one known exception.
    586 
    587 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
    588 [
    589    AC_CHECK_TYPE([struct sockaddr_storage],
    590      AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
    591        [if struct sockaddr_storage is defined]), ,
    592    [
    593      #undef inline
    594      #ifdef _WIN32
    595      #ifndef WIN32_LEAN_AND_MEAN
    596      #define WIN32_LEAN_AND_MEAN
    597      #endif
    598      #include <winsock2.h>
    599      #else
    600      #ifdef HAVE_SYS_TYPES_H
    601      #include <sys/types.h>
    602      #endif
    603      #include <sys/socket.h>
    604      #ifdef HAVE_NETINET_IN_H
    605      #include <netinet/in.h>
    606      #endif
    607      #ifdef HAVE_ARPA_INET_H
    608      #include <arpa/inet.h>
    609      #endif
    610      #endif
    611    ])
    612 ])
    613 
    614 dnl CURL_CHECK_FUNC_RECV
    615 dnl -------------------------------------------------
    616 dnl Test if the socket recv() function is available,
    617 
    618 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
    619   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
    620   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
    621   AC_CHECK_HEADERS(sys/types.h)
    622   #
    623   AC_MSG_CHECKING([for recv])
    624   AC_LINK_IFELSE([
    625     AC_LANG_PROGRAM([[
    626       #undef inline
    627       #ifdef _WIN32
    628       #ifndef WIN32_LEAN_AND_MEAN
    629       #define WIN32_LEAN_AND_MEAN
    630       #endif
    631       #include <winsock2.h>
    632       #else
    633       $curl_includes_bsdsocket
    634       #ifdef HAVE_SYS_TYPES_H
    635       #include <sys/types.h>
    636       #endif
    637       #include <sys/socket.h>
    638       #endif
    639     ]],[[
    640       recv(0, 0, 0, 0);
    641     ]])
    642   ],[
    643     AC_MSG_RESULT([yes])
    644     curl_cv_recv="yes"
    645   ],[
    646     AC_MSG_RESULT([no])
    647     curl_cv_recv="no"
    648   ])
    649   #
    650   if test "$curl_cv_recv" = "yes"; then
    651     AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
    652       [Define to 1 if you have the recv function.])
    653     curl_cv_func_recv="yes"
    654   else
    655     AC_MSG_ERROR([Unable to link function recv])
    656   fi
    657 ])
    658 
    659 
    660 dnl CURL_CHECK_FUNC_SEND
    661 dnl -------------------------------------------------
    662 dnl Test if the socket send() function is available,
    663 
    664 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
    665   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
    666   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
    667   AC_CHECK_HEADERS(sys/types.h)
    668   #
    669   AC_MSG_CHECKING([for send])
    670   AC_LINK_IFELSE([
    671     AC_LANG_PROGRAM([[
    672       #undef inline
    673       #ifdef _WIN32
    674       #ifndef WIN32_LEAN_AND_MEAN
    675       #define WIN32_LEAN_AND_MEAN
    676       #endif
    677       #include <winsock2.h>
    678       #else
    679       $curl_includes_bsdsocket
    680       #ifdef HAVE_SYS_TYPES_H
    681       #include <sys/types.h>
    682       #endif
    683       #include <sys/socket.h>
    684       #endif
    685     ]],[[
    686       char s[] = "";
    687       send(0, (void *)s, 0, 0);
    688     ]])
    689   ],[
    690     AC_MSG_RESULT([yes])
    691     curl_cv_send="yes"
    692   ],[
    693     AC_MSG_RESULT([no])
    694     curl_cv_send="no"
    695   ])
    696   #
    697   if test "$curl_cv_send" = "yes"; then
    698     AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
    699       [Define to 1 if you have the send function.])
    700     curl_cv_func_send="yes"
    701   else
    702     AC_MSG_ERROR([Unable to link function send])
    703   fi
    704 ])
    705 
    706 dnl CURL_CHECK_MSG_NOSIGNAL
    707 dnl -------------------------------------------------
    708 dnl Check for MSG_NOSIGNAL
    709 
    710 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
    711   AC_CHECK_HEADERS(sys/types.h)
    712   AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
    713     AC_COMPILE_IFELSE([
    714       AC_LANG_PROGRAM([[
    715         #undef inline
    716         #ifdef _WIN32
    717         #ifndef WIN32_LEAN_AND_MEAN
    718         #define WIN32_LEAN_AND_MEAN
    719         #endif
    720         #include <winsock2.h>
    721         #else
    722         #ifdef HAVE_SYS_TYPES_H
    723         #include <sys/types.h>
    724         #endif
    725         #include <sys/socket.h>
    726         #endif
    727       ]],[[
    728         int flag = MSG_NOSIGNAL;
    729         (void)flag;
    730       ]])
    731     ],[
    732       curl_cv_msg_nosignal="yes"
    733     ],[
    734       curl_cv_msg_nosignal="no"
    735     ])
    736   ])
    737   case "$curl_cv_msg_nosignal" in
    738     yes)
    739       AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
    740         [Define to 1 if you have the MSG_NOSIGNAL flag.])
    741       ;;
    742   esac
    743 ])
    744 
    745 
    746 dnl CURL_CHECK_STRUCT_TIMEVAL
    747 dnl -------------------------------------------------
    748 dnl Check for timeval struct
    749 
    750 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
    751   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
    752   AC_CHECK_HEADERS(sys/types.h)
    753   AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
    754     AC_COMPILE_IFELSE([
    755       AC_LANG_PROGRAM([[
    756         #undef inline
    757         #ifdef _WIN32
    758         #ifndef WIN32_LEAN_AND_MEAN
    759         #define WIN32_LEAN_AND_MEAN
    760         #endif
    761         #include <winsock2.h>
    762         #else
    763         #include <sys/socket.h>
    764         #include <sys/time.h>
    765         #endif
    766         #ifdef HAVE_SYS_TYPES_H
    767         #include <sys/types.h>
    768         #endif
    769         #include <time.h>
    770       ]],[[
    771         struct timeval ts;
    772         ts.tv_sec  = 0;
    773         ts.tv_usec = 0;
    774         (void)ts;
    775       ]])
    776     ],[
    777       curl_cv_struct_timeval="yes"
    778     ],[
    779       curl_cv_struct_timeval="no"
    780     ])
    781   ])
    782   case "$curl_cv_struct_timeval" in
    783     yes)
    784       AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
    785         [Define to 1 if you have the timeval struct.])
    786       ;;
    787   esac
    788 ])
    789 
    790 
    791 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
    792 dnl -------------------------------------------------
    793 dnl Check if monotonic clock_gettime is available.
    794 
    795 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
    796   AC_CHECK_HEADERS(sys/types.h)
    797   AC_MSG_CHECKING([for monotonic clock_gettime])
    798   #
    799 
    800   AC_COMPILE_IFELSE([
    801     AC_LANG_PROGRAM([[
    802       #ifdef HAVE_SYS_TYPES_H
    803       #include <sys/types.h>
    804       #endif
    805       #ifndef _WIN32
    806       #include <sys/time.h>
    807       #endif
    808       #include <time.h>
    809     ]],[[
    810       struct timespec ts;
    811       (void)clock_gettime(CLOCK_MONOTONIC, &ts);
    812       (void)ts;
    813     ]])
    814   ],[
    815     AC_MSG_RESULT([yes])
    816     curl_func_clock_gettime="yes"
    817   ],[
    818     AC_MSG_RESULT([no])
    819     curl_func_clock_gettime="no"
    820   ])
    821 
    822   dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
    823   dnl until library linking and run-time checks for clock_gettime succeed.
    824 ])
    825 
    826 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW
    827 dnl -------------------------------------------------
    828 dnl Check if monotonic clock_gettime is available.
    829 
    830 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [
    831   AC_CHECK_HEADERS(sys/types.h)
    832   AC_MSG_CHECKING([for raw monotonic clock_gettime])
    833   #
    834   AC_COMPILE_IFELSE([
    835     AC_LANG_PROGRAM([[
    836       #ifdef HAVE_SYS_TYPES_H
    837       #include <sys/types.h>
    838       #endif
    839       #ifndef _WIN32
    840       #include <sys/time.h>
    841       #endif
    842       #include <time.h>
    843     ]],[[
    844       struct timespec ts;
    845       (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
    846       (void)ts;
    847     ]])
    848   ],[
    849     AC_MSG_RESULT([yes])
    850     AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1,
    851       [Define to 1 if you have the clock_gettime function and raw monotonic timer.])
    852   ],[
    853     AC_MSG_RESULT([no])
    854   ])
    855 ])
    856 
    857 
    858 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
    859 dnl -------------------------------------------------
    860 dnl If monotonic clock_gettime is available then,
    861 dnl check and prepended to LIBS any needed libraries.
    862 
    863 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
    864   AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
    865   #
    866   if test "$curl_func_clock_gettime" = "yes"; then
    867     #
    868     AC_MSG_CHECKING([for clock_gettime in libraries])
    869     #
    870     curl_cv_save_LIBS="$LIBS"
    871     curl_cv_gclk_LIBS="unknown"
    872     #
    873     for x_xlibs in '' '-lrt' '-lposix4' ; do
    874       if test "$curl_cv_gclk_LIBS" = "unknown"; then
    875         if test -z "$x_xlibs"; then
    876           LIBS="$curl_cv_save_LIBS"
    877         else
    878           LIBS="$x_xlibs $curl_cv_save_LIBS"
    879         fi
    880         AC_LINK_IFELSE([
    881           AC_LANG_PROGRAM([[
    882             #ifdef HAVE_SYS_TYPES_H
    883             #include <sys/types.h>
    884             #endif
    885             #ifndef _WIN32
    886             #include <sys/time.h>
    887             #endif
    888             #include <time.h>
    889           ]],[[
    890             struct timespec ts;
    891             (void)clock_gettime(CLOCK_MONOTONIC, &ts);
    892             (void)ts;
    893           ]])
    894         ],[
    895           curl_cv_gclk_LIBS="$x_xlibs"
    896         ])
    897       fi
    898     done
    899     #
    900     LIBS="$curl_cv_save_LIBS"
    901     #
    902     case X-"$curl_cv_gclk_LIBS" in
    903       X-unknown)
    904         AC_MSG_RESULT([cannot find clock_gettime])
    905         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
    906         curl_func_clock_gettime="no"
    907         ;;
    908       X-)
    909         AC_MSG_RESULT([no additional lib required])
    910         curl_func_clock_gettime="yes"
    911         ;;
    912       *)
    913         if test "x$dontwant_rt" = "xyes" ; then
    914           AC_MSG_WARN([needs -lrt but asked not to use it, HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
    915           curl_func_clock_gettime="no"
    916         else
    917           if test -z "$curl_cv_save_LIBS"; then
    918             LIBS="$curl_cv_gclk_LIBS"
    919           else
    920             LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
    921           fi
    922           AC_MSG_RESULT([$curl_cv_gclk_LIBS])
    923           curl_func_clock_gettime="yes"
    924         fi
    925         ;;
    926     esac
    927     #
    928     dnl only do runtime verification when not cross-compiling
    929     if test "x$cross_compiling" != "xyes" &&
    930       test "$curl_func_clock_gettime" = "yes"; then
    931       AC_MSG_CHECKING([if monotonic clock_gettime works])
    932       CURL_RUN_IFELSE([
    933         AC_LANG_PROGRAM([[
    934           #include <stdlib.h>
    935           #ifdef HAVE_SYS_TYPES_H
    936           #include <sys/types.h>
    937           #endif
    938           #ifndef _WIN32
    939           #include <sys/time.h>
    940           #endif
    941           #include <time.h>
    942         ]],[[
    943           struct timespec ts;
    944           if(0 == clock_gettime(CLOCK_MONOTONIC, &ts))
    945             return 0;
    946           (void)ts;
    947           return 1;
    948         ]])
    949       ],[
    950         AC_MSG_RESULT([yes])
    951       ],[
    952         AC_MSG_RESULT([no])
    953         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
    954         curl_func_clock_gettime="no"
    955         LIBS="$curl_cv_save_LIBS"
    956       ])
    957     fi
    958     #
    959     case "$curl_func_clock_gettime" in
    960       yes)
    961         AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
    962           [Define to 1 if you have the clock_gettime function and monotonic timer.])
    963         ;;
    964     esac
    965     #
    966   fi
    967   #
    968 ])
    969 
    970 
    971 dnl CURL_CHECK_LIBS_CONNECT
    972 dnl -------------------------------------------------
    973 dnl Verify if network connect function is already available
    974 dnl using current libraries or if another one is required.
    975 
    976 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
    977   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
    978   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
    979   AC_MSG_CHECKING([for connect in libraries])
    980   tst_connect_save_LIBS="$LIBS"
    981   tst_connect_need_LIBS="unknown"
    982   for tst_lib in '' '-lsocket' ; do
    983     if test "$tst_connect_need_LIBS" = "unknown"; then
    984       LIBS="$tst_lib $tst_connect_save_LIBS"
    985       AC_LINK_IFELSE([
    986         AC_LANG_PROGRAM([[
    987           $curl_includes_winsock2
    988           $curl_includes_bsdsocket
    989           #if !defined(_WIN32) && !defined(HAVE_PROTO_BSDSOCKET_H)
    990             int connect(int, void*, int);
    991           #endif
    992         ]],[[
    993           if(0 != connect(0, 0, 0))
    994             return 1;
    995         ]])
    996       ],[
    997         tst_connect_need_LIBS="$tst_lib"
    998       ])
    999     fi
   1000   done
   1001   LIBS="$tst_connect_save_LIBS"
   1002   #
   1003   case X-"$tst_connect_need_LIBS" in
   1004     X-unknown)
   1005       AC_MSG_RESULT([cannot find connect])
   1006       AC_MSG_ERROR([cannot find connect function in libraries.])
   1007       ;;
   1008     X-)
   1009       AC_MSG_RESULT([yes])
   1010       ;;
   1011     *)
   1012       AC_MSG_RESULT([$tst_connect_need_LIBS])
   1013       LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
   1014       ;;
   1015   esac
   1016 ])
   1017 
   1018 
   1019 dnl CURL_CHECK_FUNC_SELECT
   1020 dnl -------------------------------------------------
   1021 dnl Test if the socket select() function is available.
   1022 
   1023 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
   1024   AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
   1025   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
   1026   AC_CHECK_HEADERS(sys/select.h)
   1027   #
   1028   AC_MSG_CHECKING([for select])
   1029   AC_LINK_IFELSE([
   1030     AC_LANG_PROGRAM([[
   1031       #undef inline
   1032       #ifdef _WIN32
   1033       #ifndef WIN32_LEAN_AND_MEAN
   1034       #define WIN32_LEAN_AND_MEAN
   1035       #endif
   1036       #include <winsock2.h>
   1037       #else
   1038       #include <sys/socket.h>
   1039       #include <sys/time.h>
   1040       #endif
   1041       #ifdef HAVE_SYS_TYPES_H
   1042       #include <sys/types.h>
   1043       #endif
   1044       #include <time.h>
   1045       #ifndef _WIN32
   1046       #ifdef HAVE_SYS_SELECT_H
   1047       #include <sys/select.h>
   1048       #elif defined(HAVE_UNISTD_H)
   1049       #include <unistd.h>
   1050       #endif
   1051       $curl_includes_bsdsocket
   1052       #endif
   1053     ]],[[
   1054       select(0, 0, 0, 0, 0);
   1055     ]])
   1056   ],[
   1057     AC_MSG_RESULT([yes])
   1058     curl_cv_select="yes"
   1059   ],[
   1060     AC_MSG_RESULT([no])
   1061     curl_cv_select="no"
   1062   ])
   1063   #
   1064   if test "$curl_cv_select" = "yes"; then
   1065     AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
   1066       [Define to 1 if you have the select function.])
   1067     curl_cv_func_select="yes"
   1068   fi
   1069 ])
   1070 
   1071 
   1072 dnl CURL_VERIFY_RUNTIMELIBS
   1073 dnl -------------------------------------------------
   1074 dnl Verify that the shared libs found so far can be used when running
   1075 dnl programs, since otherwise the situation will create odd configure errors
   1076 dnl that are misleading people.
   1077 dnl
   1078 dnl Make sure this test is run BEFORE the first test in the script that
   1079 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
   1080 dnl macro. It must also run AFTER all lib-checking macros are complete.
   1081 
   1082 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
   1083 
   1084   dnl this test is of course not sensible if we are cross-compiling!
   1085   if test "x$cross_compiling" != xyes; then
   1086 
   1087     dnl just run a program to verify that the libs checked for previous to this
   1088     dnl point also is available run-time!
   1089     AC_MSG_CHECKING([run-time libs availability])
   1090     CURL_RUN_IFELSE([
   1091       int main(void)
   1092       {
   1093         return 0;
   1094       }
   1095     ],
   1096     AC_MSG_RESULT([fine]),
   1097     AC_MSG_RESULT([failed])
   1098     AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
   1099     )
   1100 
   1101     dnl if this test fails, configure has already stopped
   1102   fi
   1103 ])
   1104 
   1105 
   1106 dnl CURL_CHECK_CA_BUNDLE
   1107 dnl -------------------------------------------------
   1108 dnl Check if a default ca-bundle should be used
   1109 dnl
   1110 dnl regarding the paths this will scan:
   1111 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
   1112 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
   1113 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
   1114 dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD
   1115 dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink)
   1116 dnl /etc/ssl/certs (CA path) SUSE, FreeBSD
   1117 
   1118 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
   1119 
   1120   AC_MSG_CHECKING([default CA cert bundle/path])
   1121 
   1122   AC_ARG_WITH(ca-bundle,
   1123 AS_HELP_STRING([--with-ca-bundle=FILE],
   1124   [Absolute path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
   1125 AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
   1126   [
   1127     want_ca="$withval"
   1128     if test "x$want_ca" = "xyes"; then
   1129       AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
   1130     fi
   1131   ],
   1132   [ want_ca="unset" ])
   1133   AC_ARG_WITH(ca-path,
   1134 AS_HELP_STRING([--with-ca-path=DIRECTORY],
   1135   [Absolute path to a directory containing CA certificates stored individually, with \
   1136 their filenames in a hash format. This option can be used with the OpenSSL, \
   1137 GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \
   1138 (example: /etc/certificates)])
   1139 AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
   1140   [
   1141     want_capath="$withval"
   1142     if test "x$want_capath" = "xyes"; then
   1143       AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
   1144     fi
   1145   ],
   1146   [ want_capath="unset"])
   1147 
   1148   ca_warning="   (warning: certs not found)"
   1149   capath_warning="   (warning: certs not found)"
   1150   check_capath=""
   1151 
   1152   if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
   1153           "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
   1154     dnl both given
   1155     ca="$want_ca"
   1156     capath="$want_capath"
   1157   elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
   1158     dnl --with-ca-bundle given
   1159     ca="$want_ca"
   1160     capath="no"
   1161   elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
   1162     dnl --with-ca-path given
   1163     capath="$want_capath"
   1164     ca="no"
   1165   else
   1166     dnl First try auto-detecting a CA bundle, then a CA path.
   1167     dnl Both auto-detections can be skipped by --without-ca-*
   1168     ca="no"
   1169     capath="no"
   1170     if test "x$cross_compiling" != "xyes" -a \
   1171             "x$curl_cv_native_windows" != "xyes"; then
   1172       dnl NOT cross-compiling and...
   1173       dnl neither of the --with-ca-* options are provided
   1174       if test "x$want_ca" = "xunset"; then
   1175         dnl the path we previously would have installed the curl CA bundle
   1176         dnl to, and thus we now check for an already existing cert in that
   1177         dnl place in case we find no other
   1178         if test "x$prefix" != xNONE; then
   1179           cac="${prefix}/share/curl/curl-ca-bundle.crt"
   1180         else
   1181           cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
   1182         fi
   1183 
   1184         for a in /etc/ssl/certs/ca-certificates.crt \
   1185                  /etc/pki/tls/certs/ca-bundle.crt \
   1186                  /usr/share/ssl/certs/ca-bundle.crt \
   1187                  /usr/local/share/certs/ca-root-nss.crt \
   1188                  /etc/ssl/cert.pem \
   1189                  "$cac"; do
   1190           if test -f "$a"; then
   1191             ca="$a"
   1192             break
   1193           fi
   1194         done
   1195       fi
   1196       AC_MSG_NOTICE([want $want_capath ca $ca])
   1197       if test "x$want_capath" = "xunset"; then
   1198         check_capath="/etc/ssl/certs"
   1199       fi
   1200     else
   1201       dnl no option given and cross-compiling
   1202       AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
   1203     fi
   1204   fi
   1205 
   1206   if test "x$ca" = "xno" || test -f "$ca"; then
   1207     ca_warning=""
   1208   fi
   1209 
   1210   if test "x$capath" != "xno"; then
   1211     check_capath="$capath"
   1212   fi
   1213 
   1214   if test ! -z "$check_capath"; then
   1215     for a in "$check_capath"; do
   1216       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
   1217         if test "x$capath" = "xno"; then
   1218           capath="$a"
   1219         fi
   1220         capath_warning=""
   1221         break
   1222       fi
   1223     done
   1224   fi
   1225 
   1226   if test "x$capath" = "xno"; then
   1227     capath_warning=""
   1228   fi
   1229 
   1230   if test "x$ca" != "xno"; then
   1231     CURL_CA_BUNDLE="$ca"
   1232     AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
   1233     AC_SUBST(CURL_CA_BUNDLE)
   1234     AC_MSG_RESULT([$ca])
   1235   fi
   1236   if test "x$capath" != "xno"; then
   1237     CURL_CA_PATH="\"$capath\""
   1238     AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
   1239     AC_MSG_RESULT([$capath (capath)])
   1240   fi
   1241   if test "x$ca" = "xno" && test "x$capath" = "xno"; then
   1242     AC_MSG_RESULT([no])
   1243   fi
   1244 
   1245   AC_MSG_CHECKING([whether to use built-in CA store of SSL library])
   1246   AC_ARG_WITH(ca-fallback,
   1247 AS_HELP_STRING([--with-ca-fallback], [Use the built-in CA store of the SSL library])
   1248 AS_HELP_STRING([--without-ca-fallback], [Don't use the built-in CA store of the SSL library]),
   1249   [
   1250     if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
   1251       AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
   1252     fi
   1253   ],
   1254   [ with_ca_fallback="no"])
   1255   AC_MSG_RESULT([$with_ca_fallback])
   1256   if test "x$with_ca_fallback" = "xyes"; then
   1257     if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
   1258       AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
   1259     fi
   1260     AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built-in CA store of SSL library])
   1261   fi
   1262 ])
   1263 
   1264 
   1265 dnl CURL_CHECK_CA_EMBED
   1266 dnl -------------------------------------------------
   1267 dnl Check if a ca-bundle should be embedded
   1268 
   1269 AC_DEFUN([CURL_CHECK_CA_EMBED], [
   1270 
   1271   AC_MSG_CHECKING([CA cert bundle path to embed in the curl tool])
   1272 
   1273   AC_ARG_WITH(ca-embed,
   1274 AS_HELP_STRING([--with-ca-embed=FILE],
   1275   [Absolute path to a file containing CA certificates to embed in the curl tool (example: /etc/ca-bundle.crt)])
   1276 AS_HELP_STRING([--without-ca-embed], [Don't embed a default CA bundle in the curl tool]),
   1277   [
   1278     want_ca_embed="$withval"
   1279     if test "x$want_ca_embed" = "xyes"; then
   1280       AC_MSG_ERROR([--with-ca-embed=FILE requires a path to the CA bundle])
   1281     fi
   1282   ],
   1283   [ want_ca_embed="unset" ])
   1284 
   1285   CURL_CA_EMBED=''
   1286   if test "x$want_ca_embed" != "xno" -a "x$want_ca_embed" != "xunset" -a -f "$want_ca_embed"; then
   1287     CURL_CA_EMBED="$want_ca_embed"
   1288     AC_SUBST(CURL_CA_EMBED)
   1289     AC_MSG_RESULT([$want_ca_embed])
   1290   else
   1291     AC_MSG_RESULT([no])
   1292   fi
   1293 ])
   1294 
   1295 dnl CURL_CHECK_WIN32_LARGEFILE
   1296 dnl -------------------------------------------------
   1297 dnl Check if curl's Win32 large file will be used
   1298 
   1299 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
   1300   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
   1301   if test "$curl_cv_native_windows" = 'yes'; then
   1302     AC_MSG_CHECKING([whether build target supports Win32 large files])
   1303     if test "$curl_cv_wince" = 'yes'; then
   1304       dnl Windows CE does not support large files
   1305       curl_win32_has_largefile='no'
   1306     else
   1307       dnl All mingw-w64 versions support large files
   1308       curl_win32_has_largefile='yes'
   1309     fi
   1310     case "$curl_win32_has_largefile" in
   1311       yes)
   1312         if test x"$enable_largefile" = 'xno'; then
   1313           AC_MSG_RESULT([yes (large file disabled)])
   1314         else
   1315           AC_MSG_RESULT([yes (large file enabled)])
   1316           AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
   1317             [Define to 1 if you are building a Windows target with large file support.])
   1318         fi
   1319         ;;
   1320       *)
   1321         AC_MSG_RESULT([no])
   1322         ;;
   1323     esac
   1324   fi
   1325 ])
   1326 
   1327 dnl CURL_CHECK_WIN32_CRYPTO
   1328 dnl -------------------------------------------------
   1329 dnl Check if curl's Win32 crypto lib can be used
   1330 
   1331 AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
   1332   AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
   1333   AC_MSG_CHECKING([whether build target supports Win32 crypto API])
   1334   curl_win32_crypto_api="no"
   1335   if test "$curl_cv_native_windows" = "yes" -a "$curl_cv_winuwp" != "yes"; then
   1336     AC_COMPILE_IFELSE([
   1337       AC_LANG_PROGRAM([[
   1338         #undef inline
   1339         #ifndef WIN32_LEAN_AND_MEAN
   1340         #define WIN32_LEAN_AND_MEAN
   1341         #endif
   1342         #include <windows.h>
   1343         #include <wincrypt.h>
   1344       ]],[[
   1345         HCRYPTPROV hCryptProv;
   1346         if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
   1347                                CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
   1348           CryptReleaseContext(hCryptProv, 0);
   1349         }
   1350       ]])
   1351     ],[
   1352       curl_win32_crypto_api="yes"
   1353     ])
   1354   fi
   1355   case "$curl_win32_crypto_api" in
   1356     yes)
   1357       AC_MSG_RESULT([yes])
   1358       AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
   1359         [Define to 1 if you are building a Windows target with crypto API support.])
   1360       USE_WIN32_CRYPTO=1
   1361       ;;
   1362     *)
   1363       AC_MSG_RESULT([no])
   1364       ;;
   1365   esac
   1366 ])
   1367 
   1368 dnl CURL_EXPORT_PCDIR ($pcdir)
   1369 dnl ------------------------
   1370 dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
   1371 dnl
   1372 dnl we need this macro since pkg-config distinguishes among empty and unset
   1373 dnl variable while checking PKG_CONFIG_LIBDIR
   1374 dnl
   1375 
   1376 AC_DEFUN([CURL_EXPORT_PCDIR], [
   1377   if test -n "$1"; then
   1378     PKG_CONFIG_LIBDIR="$1"
   1379     export PKG_CONFIG_LIBDIR
   1380   fi
   1381 ])
   1382 
   1383 dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
   1384 dnl ------------------------
   1385 dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
   1386 dnl path to it, or 'no' if not found/present.
   1387 dnl
   1388 dnl If pkg-config is present, check that it has info about the $module or
   1389 dnl return "no" anyway!
   1390 dnl
   1391 dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
   1392 dnl
   1393 
   1394 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
   1395   if test -n "$PKG_CONFIG"; then
   1396     PKGCONFIG="$PKG_CONFIG"
   1397   else
   1398     AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
   1399       [$PATH:/usr/bin:/usr/local/bin])
   1400   fi
   1401 
   1402   if test "x$PKGCONFIG" != "xno"; then
   1403     AC_MSG_CHECKING([for $1 options with pkg-config])
   1404     dnl ask pkg-config about $1
   1405     itexists=`CURL_EXPORT_PCDIR([$2]) dnl
   1406       $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
   1407 
   1408     if test -z "$itexists"; then
   1409       dnl pkg-config does not have info about the given module! set the
   1410       dnl variable to 'no'
   1411       PKGCONFIG="no"
   1412       AC_MSG_RESULT([no])
   1413     else
   1414       AC_MSG_RESULT([found])
   1415     fi
   1416   fi
   1417 ])
   1418 
   1419 
   1420 dnl CURL_PREPARE_CONFIGUREHELP_PM
   1421 dnl -------------------------------------------------
   1422 dnl Prepare test harness configurehelp.pm module, defining and
   1423 dnl initializing some perl variables with values which are known
   1424 dnl when the configure script runs. For portability reasons, test
   1425 dnl harness needs information on how to run the C preprocessor.
   1426 
   1427 AC_DEFUN([CURL_PREPARE_CONFIGUREHELP_PM], [
   1428   AC_REQUIRE([AC_PROG_CPP])dnl
   1429   tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
   1430   if test -z "$tmp_cpp"; then
   1431     tmp_cpp='cpp'
   1432   fi
   1433   AC_SUBST(CURL_CPP, $tmp_cpp)
   1434 ])
   1435 
   1436 
   1437 dnl CURL_PREPARE_BUILDINFO
   1438 dnl -------------------------------------------------
   1439 dnl Save build info for test runner to pick up and log
   1440 
   1441 AC_DEFUN([CURL_PREPARE_BUILDINFO], [
   1442   curl_pflags=""
   1443   if test "$curl_cv_apple" = 'yes'; then
   1444     curl_pflags="${curl_pflags} APPLE"
   1445   fi
   1446   case $host in
   1447     *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*)
   1448       curl_pflags="${curl_pflags} UNIX";;
   1449   esac
   1450   case $host in
   1451     *-*-*bsd*)
   1452       curl_pflags="${curl_pflags} BSD";;
   1453   esac
   1454   case $host in
   1455     *-*-android*)
   1456       curl_pflags="${curl_pflags} ANDROID"
   1457       ANDROID_PLATFORM_LEVEL=`echo "$host_os" | $SED -ne 's/.*android\(@<:@0-9@:>@*\).*/\1/p'`
   1458       if test -n "${ANDROID_PLATFORM_LEVEL}"; then
   1459         curl_pflags="${curl_pflags}-${ANDROID_PLATFORM_LEVEL}"
   1460       fi
   1461       ;;
   1462   esac
   1463   if test "$curl_cv_native_windows" = 'yes'; then
   1464     curl_pflags="${curl_pflags} WIN32"
   1465   fi
   1466   if test "$curl_cv_wince" = 'yes'; then
   1467     curl_pflags="${curl_pflags} WINCE"
   1468   fi
   1469   if test "$curl_cv_winuwp" = 'yes'; then
   1470     curl_pflags="${curl_pflags} UWP"
   1471   fi
   1472   case $host in
   1473     *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*)
   1474       curl_pflags="${curl_pflags} UNIX";;
   1475   esac
   1476   case $host in
   1477     *-*-*bsd*)
   1478       curl_pflags="${curl_pflags} BSD";;
   1479   esac
   1480   if test "$curl_cv_cygwin" = 'yes'; then
   1481     curl_pflags="${curl_pflags} CYGWIN"
   1482   fi
   1483   case $host_os in
   1484     msdos*) curl_pflags="${curl_pflags} DOS";;
   1485     amiga*) curl_pflags="${curl_pflags} AMIGA";;
   1486   esac
   1487   if test "x$compiler_id" = 'xGNU_C'; then
   1488     curl_pflags="${curl_pflags} GCC"
   1489   fi
   1490   case $host_os in
   1491     mingw*) curl_pflags="${curl_pflags} MINGW";;
   1492   esac
   1493   if test "x$cross_compiling" = 'xyes'; then
   1494     curl_pflags="${curl_pflags} CROSS"
   1495   fi
   1496   squeeze curl_pflags
   1497   curl_buildinfo="
   1498 buildinfo.configure.tool: configure
   1499 buildinfo.configure.args: $ac_configure_args
   1500 buildinfo.host: $build
   1501 buildinfo.host.cpu: $build_cpu
   1502 buildinfo.host.os: $build_os
   1503 buildinfo.target: $host
   1504 buildinfo.target.cpu: $host_cpu
   1505 buildinfo.target.os: $host_os
   1506 buildinfo.target.flags: $curl_pflags
   1507 buildinfo.compiler: $compiler_id
   1508 buildinfo.compiler.version: $compiler_ver
   1509 buildinfo.sysroot: $lt_sysroot"
   1510 ])
   1511 
   1512 
   1513 dnl CURL_CPP_P
   1514 dnl
   1515 dnl Check if $cpp -P should be used for extract define values due to gcc 5
   1516 dnl splitting up strings and defines between line outputs. gcc by default
   1517 dnl (without -P) will show TEST EINVAL TEST as
   1518 dnl
   1519 dnl # 13 "conftest.c"
   1520 dnl TEST
   1521 dnl # 13 "conftest.c" 3 4
   1522 dnl     22
   1523 dnl # 13 "conftest.c"
   1524 dnl            TEST
   1525 
   1526 AC_DEFUN([CURL_CPP_P], [
   1527   AC_MSG_CHECKING([if cpp -P is needed])
   1528   AC_EGREP_CPP([TEST.*TEST], [
   1529  #include <errno.h>
   1530 TEST EINVAL TEST
   1531   ], [cpp=no], [cpp=yes])
   1532   AC_MSG_RESULT([$cpp])
   1533 
   1534   dnl we need cpp -P so check if it works then
   1535   if test "x$cpp" = "xyes"; then
   1536     AC_MSG_CHECKING([if cpp -P works])
   1537     OLDCPPFLAGS=$CPPFLAGS
   1538     CPPFLAGS="$CPPFLAGS -P"
   1539     AC_EGREP_CPP([TEST.*TEST], [
   1540  #include <errno.h>
   1541 TEST EINVAL TEST
   1542     ], [cpp_p=yes], [cpp_p=no])
   1543     AC_MSG_RESULT([$cpp_p])
   1544 
   1545     if test "x$cpp_p" = "xno"; then
   1546       AC_MSG_WARN([failed to figure out cpp -P alternative])
   1547       # without -P
   1548       CPPPFLAG=""
   1549     else
   1550       # with -P
   1551       CPPPFLAG="-P"
   1552     fi
   1553     dnl restore CPPFLAGS
   1554     CPPFLAGS=$OLDCPPFLAGS
   1555   else
   1556     # without -P
   1557     CPPPFLAG=""
   1558   fi
   1559 ])
   1560 
   1561 
   1562 dnl CURL_DARWIN_CFLAGS
   1563 dnl
   1564 dnl Set -Werror=partial-availability to detect possible breaking code
   1565 dnl with very low deployment targets.
   1566 dnl
   1567 
   1568 AC_DEFUN([CURL_DARWIN_CFLAGS], [
   1569   old_CFLAGS=$CFLAGS
   1570   CFLAGS="$CFLAGS -Werror=partial-availability"
   1571   AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
   1572   AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
   1573     [AC_MSG_RESULT([yes])],
   1574     [AC_MSG_RESULT([no])
   1575     CFLAGS=$old_CFLAGS])
   1576 ])
   1577 
   1578 
   1579 dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
   1580 dnl
   1581 dnl Check to see if the compiler supports __builtin_available. This built-in
   1582 dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
   1583 dnl the time this macro was written, the function was not yet documented. Its
   1584 dnl purpose is to return true if the code is running under a certain OS version
   1585 dnl or later.
   1586 
   1587 AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
   1588   AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
   1589   AC_COMPILE_IFELSE([
   1590     AC_LANG_PROGRAM([[
   1591     ]],[[
   1592       if(__builtin_available(macOS 10.12, iOS 5.0, *)) {}
   1593     ]])
   1594   ],[
   1595     AC_MSG_RESULT([yes])
   1596     AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
   1597       [Define to 1 if you have the __builtin_available function.])
   1598   ],[
   1599     AC_MSG_RESULT([no])
   1600   ])
   1601 ])