~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to acinclude.m4

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-04-02 23:35:45 UTC
  • mto: (1.2.1 upstream) (3.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090402233545-geixkwhe3izccjt7
Tags: upstream-7.19.4
ImportĀ upstreamĀ versionĀ 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#                            | (__| |_| |  _ <| |___
6
6
#                             \___|\___/|_| \_\_____|
7
7
#
8
 
# Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
# Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
#
10
10
# This software is licensed as described in the file COPYING, which
11
11
# you should have received as part of this distribution. The terms
18
18
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
# KIND, either express or implied.
20
20
#
21
 
# $Id: acinclude.m4,v 1.154 2008-05-21 18:24:09 yangtse Exp $
22
 
###########################################################################
 
21
# $Id: acinclude.m4,v 1.217 2009-01-11 23:41:50 bagder Exp $
 
22
#***************************************************************************
 
23
 
 
24
 
 
25
dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
 
26
dnl -------------------------------------------------
 
27
dnl Verifies if the compiler actually halts after the
 
28
dnl compilation phase without generating any object
 
29
dnl code file, when the source compiles with errors.
 
30
 
 
31
AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
 
32
  AC_MSG_CHECKING([if compiler halts on compilation errors])
 
33
  AC_COMPILE_IFELSE([
 
34
    AC_LANG_PROGRAM([[
 
35
    ]],[[
 
36
      force compilation error
 
37
    ]])
 
38
  ],[
 
39
    AC_MSG_RESULT([no])
 
40
    AC_MSG_ERROR([compiler does not halt on compilation errors.])
 
41
  ],[
 
42
    AC_MSG_RESULT([yes])
 
43
  ])
 
44
])
 
45
 
 
46
 
 
47
dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
 
48
dnl -------------------------------------------------
 
49
dnl Verifies if the compiler actually halts after the
 
50
dnl compilation phase without generating any object
 
51
dnl code file, when the source code tries to define a
 
52
dnl type for a constant array with negative dimension.
 
53
 
 
54
AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
 
55
  AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
 
56
  AC_MSG_CHECKING([if compiler halts on negative sized arrays])
 
57
  AC_COMPILE_IFELSE([
 
58
    AC_LANG_PROGRAM([[
 
59
      typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
 
60
    ]],[[
 
61
      bad_t dummy;
 
62
    ]])
 
63
  ],[
 
64
    AC_MSG_RESULT([no])
 
65
    AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
 
66
  ],[
 
67
    AC_MSG_RESULT([yes])
 
68
  ])
 
69
])
 
70
 
 
71
 
 
72
dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
 
73
dnl -------------------------------------------------
 
74
dnl Use the C preprocessor to find out if the given object-style symbol
 
75
dnl is defined and get its expansion. This macro will not use default
 
76
dnl includes even if no INCLUDES argument is given. This macro will run
 
77
dnl silently when invoked with three arguments. If the expansion would
 
78
dnl result in a set of double-quoted strings the returned expansion will
 
79
dnl actually be a single double-quoted string concatenating all them.
 
80
 
 
81
AC_DEFUN([CURL_CHECK_DEF], [
 
82
  AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
 
83
  AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
 
84
  if test -z "$SED"; then
 
85
    AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
 
86
  fi
 
87
  if test -z "$GREP"; then
 
88
    AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
 
89
  fi
 
90
  ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
 
91
  tmp_exp=""
 
92
  AC_PREPROC_IFELSE([
 
93
    AC_LANG_SOURCE(
 
94
ifelse($2,,,[$2])[[
 
95
#ifdef $1
 
96
CURL_DEF_TOKEN $1
 
97
#endif
 
98
    ]])
 
99
  ],[
 
100
    tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
 
101
      "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
 
102
      "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
 
103
      "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
 
104
    if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
 
105
      tmp_exp=""
 
106
    fi
 
107
  ])
 
108
  if test -z "$tmp_exp"; then
 
109
    AS_VAR_SET(ac_HaveDef, no)
 
110
    ifelse($3,,[AC_MSG_RESULT([no])])
 
111
  else
 
112
    AS_VAR_SET(ac_HaveDef, yes)
 
113
    AS_VAR_SET(ac_Def, $tmp_exp)
 
114
    ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
 
115
  fi
 
116
  AS_VAR_POPDEF([ac_Def])dnl
 
117
  AS_VAR_POPDEF([ac_HaveDef])dnl
 
118
])
 
119
 
 
120
 
 
121
dnl CURL_CHECK_AIX_ALL_SOURCE
 
122
dnl -------------------------------------------------
 
123
dnl Provides a replacement of traditional AC_AIX with
 
124
dnl an uniform behaviour across all autoconf versions,
 
125
dnl and with our own placement rules.
 
126
 
 
127
AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
 
128
  AH_VERBATIM([_ALL_SOURCE],
 
129
    [/* Define to 1 if OS is AIX. */
 
130
#ifndef _ALL_SOURCE
 
131
#  undef _ALL_SOURCE
 
132
#endif])
 
133
  AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
 
134
  AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
 
135
  AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
 
136
  AC_EGREP_CPP([yes_this_is_aix],[
 
137
#ifdef _AIX
 
138
   yes_this_is_aix
 
139
#endif
 
140
  ],[
 
141
    AC_MSG_RESULT([yes])
 
142
    AC_DEFINE(_ALL_SOURCE)
 
143
  ],[
 
144
    AC_MSG_RESULT([no])
 
145
  ])
 
146
])
23
147
 
24
148
 
25
149
dnl CURL_CHECK_HEADER_WINDOWS
72
196
      AC_COMPILE_IFELSE([
73
197
        AC_LANG_PROGRAM([[
74
198
        ]],[[
75
 
#if defined(__MINGW32__) || defined(__MINGW32CE__)
 
199
#if defined(__MINGW32__) || defined(__MINGW32CE__) || \
 
200
   (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
76
201
          int dummy=1;
77
202
#else
78
203
          Not a native Windows build target.
553
678
  #
554
679
  for x_nlibs in '' "$u_libs" \
555
680
    '-lwldap32' ; do
556
 
    if test -z "$x_nlibs"; then
557
 
      LIBS="$curl_cv_save_LIBS"
558
 
    else
559
 
      LIBS="$x_nlibs $curl_cv_save_LIBS"
560
 
    fi
561
 
    AC_LINK_IFELSE([
562
 
      AC_LANG_PROGRAM([[
 
681
    if test "$curl_cv_ldap_LIBS" = "unknown"; then
 
682
      if test -z "$x_nlibs"; then
 
683
        LIBS="$curl_cv_save_LIBS"
 
684
      else
 
685
        LIBS="$x_nlibs $curl_cv_save_LIBS"
 
686
      fi
 
687
      AC_LINK_IFELSE([
 
688
        AC_LANG_PROGRAM([[
563
689
#undef inline
564
690
#ifdef HAVE_WINDOWS_H
565
691
#ifndef WIN32_LEAN_AND_MEAN
573
699
#include <winber.h>
574
700
#endif
575
701
#endif
576
 
      ]],[[
577
 
        BERVAL *bvp = NULL;
578
 
        BerElement *bep = ber_init(bvp);
579
 
        LDAP *ldp = ldap_init("dummy", LDAP_PORT);
580
 
        ULONG res = ldap_unbind(ldp);
581
 
        ber_free(bep, 1);
582
 
      ]])
583
 
    ],[
584
 
      curl_cv_ldap_LIBS="$x_nlibs"
585
 
      break
586
 
    ])
 
702
        ]],[[
 
703
          BERVAL *bvp = NULL;
 
704
          BerElement *bep = ber_init(bvp);
 
705
          LDAP *ldp = ldap_init("dummy", LDAP_PORT);
 
706
          ULONG res = ldap_unbind(ldp);
 
707
          ber_free(bep, 1);
 
708
        ]])
 
709
      ],[
 
710
        curl_cv_ldap_LIBS="$x_nlibs"
 
711
      ])
 
712
    fi
587
713
  done
588
714
  #
589
715
  LIBS="$curl_cv_save_LIBS"
650
776
    '-lldap -llber' \
651
777
    '-lldapssl -lldapx -lldapsdk' \
652
778
    '-lldapsdk -lldapx -lldapssl' ; do
653
 
    if test -z "$x_nlibs"; then
654
 
      LIBS="$curl_cv_save_LIBS"
655
 
    else
656
 
      LIBS="$x_nlibs $curl_cv_save_LIBS"
657
 
    fi
658
 
    AC_LINK_IFELSE([
659
 
      AC_LANG_PROGRAM([[
 
779
    if test "$curl_cv_ldap_LIBS" = "unknown"; then
 
780
      if test -z "$x_nlibs"; then
 
781
        LIBS="$curl_cv_save_LIBS"
 
782
      else
 
783
        LIBS="$x_nlibs $curl_cv_save_LIBS"
 
784
      fi
 
785
      AC_LINK_IFELSE([
 
786
        AC_LANG_PROGRAM([[
660
787
#undef inline
661
788
#ifdef HAVE_WINDOWS_H
662
789
#ifndef WIN32_LEAN_AND_MEAN
680
807
#ifdef HAVE_LDAP_H
681
808
#include <ldap.h>
682
809
#endif
683
 
      ]],[[
684
 
        BerValue *bvp = NULL;
685
 
        BerElement *bep = ber_init(bvp);
686
 
        LDAP *ldp = ldap_init("dummy", LDAP_PORT);
687
 
        int res = ldap_unbind(ldp);
688
 
        ber_free(bep, 1);
689
 
      ]])
690
 
    ],[
691
 
      curl_cv_ldap_LIBS="$x_nlibs"
692
 
      break
693
 
    ])
 
810
        ]],[[
 
811
          BerValue *bvp = NULL;
 
812
          BerElement *bep = ber_init(bvp);
 
813
          LDAP *ldp = ldap_init("dummy", LDAP_PORT);
 
814
          int res = ldap_unbind(ldp);
 
815
          ber_free(bep, 1);
 
816
        ]])
 
817
      ],[
 
818
        curl_cv_ldap_LIBS="$x_nlibs"
 
819
      ])
 
820
    fi
694
821
  done
695
822
  #
696
823
  LIBS="$curl_cv_save_LIBS"
781
908
      for arg1 in 'int' 'SOCKET'; do
782
909
        for arg2 in "struct sockaddr" void; do
783
910
          for t in int size_t unsigned long "unsigned long"; do
784
 
            AC_COMPILE_IFELSE([
785
 
              AC_LANG_PROGRAM([[
 
911
            if test "$curl_cv_socklen_t_equiv" = "unknown"; then
 
912
              AC_COMPILE_IFELSE([
 
913
                AC_LANG_PROGRAM([[
786
914
#undef inline
787
915
#ifdef HAVE_WINDOWS_H
788
916
#ifndef WIN32_LEAN_AND_MEAN
806
934
#endif
807
935
#define GETPEERNCALLCONV
808
936
#endif
809
 
                extern int GETPEERNCALLCONV getpeername ($arg1, $arg2 *, $t *);
810
 
              ]],[[
811
 
                $t len=0;
812
 
                getpeername(0,0,&len);
813
 
              ]])
814
 
            ],[
815
 
               curl_cv_socklen_t_equiv="$t"
816
 
               break 3
817
 
            ])
 
937
                  extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
 
938
                ]],[[
 
939
                  $t len=0;
 
940
                  getpeername(0,0,&len);
 
941
                ]])
 
942
              ],[
 
943
                curl_cv_socklen_t_equiv="$t"
 
944
              ])
 
945
            fi
818
946
          done
819
947
        done
820
948
      done
943
1071
        for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
944
1072
          for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
945
1073
            for gni_arg7 in 'int' 'unsigned int'; do
946
 
              AC_COMPILE_IFELSE([
947
 
                AC_LANG_PROGRAM([[
 
1074
              if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
 
1075
                AC_COMPILE_IFELSE([
 
1076
                  AC_LANG_PROGRAM([[
948
1077
#undef inline 
949
1078
#ifdef HAVE_WINDOWS_H
950
1079
#ifndef WIN32_LEAN_AND_MEAN
974
1103
#endif
975
1104
#define GNICALLCONV
976
1105
#endif
977
 
                  extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
978
 
                                         char *, $gni_arg46,
979
 
                                         char *, $gni_arg46,
980
 
                                         $gni_arg7);
981
 
                ]],[[
982
 
                  $gni_arg2 salen=0;
983
 
                  $gni_arg46 hostlen=0;
984
 
                  $gni_arg46 servlen=0;
985
 
                  $gni_arg7 flags=0;
986
 
                  int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
987
 
                ]])
988
 
              ],[
989
 
                 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
990
 
                 break 4
991
 
              ])
 
1106
                    extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
 
1107
                                           char *, $gni_arg46,
 
1108
                                           char *, $gni_arg46,
 
1109
                                           $gni_arg7);
 
1110
                  ]],[[
 
1111
                    $gni_arg2 salen=0;
 
1112
                    $gni_arg46 hostlen=0;
 
1113
                    $gni_arg46 servlen=0;
 
1114
                    $gni_arg7 flags=0;
 
1115
                    int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
 
1116
                  ]])
 
1117
                ],[
 
1118
                  curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
 
1119
                ])
 
1120
              fi
992
1121
            done
993
1122
          done
994
1123
        done
995
1124
      done
996
 
    ]) # AC_CACHE_CHECK
 
1125
    ]) # AC-CACHE-CHECK
997
1126
    if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
998
1127
      AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
999
1128
      AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1051
1180
      ac_cv_func_getnameinfo="yes"
1052
1181
    fi
1053
1182
  fi
1054
 
]) # AC_DEFUN
 
1183
])
1055
1184
 
1056
1185
 
1057
1186
dnl TYPE_SOCKADDR_STORAGE
1106
1235
    [ac_cv_working_ni_withscopeid], [
1107
1236
    AC_RUN_IFELSE([
1108
1237
      AC_LANG_PROGRAM([[
 
1238
#ifdef HAVE_STDLIB_H
 
1239
#include <stdlib.h>
 
1240
#endif
1109
1241
#ifdef HAVE_STDIO_H
1110
1242
#include <stdio.h>
1111
1243
#endif
1155
1287
#else
1156
1288
        return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1157
1289
#endif
1158
 
      ]]) # AC_LANG_PROGRAM
 
1290
      ]]) # AC-LANG-PROGRAM
1159
1291
    ],[
1160
1292
      # Exit code == 0. Program worked.
1161
1293
      ac_cv_working_ni_withscopeid="yes"
1177
1309
        ac_cv_working_ni_withscopeid="yes"
1178
1310
      ],[
1179
1311
        ac_cv_working_ni_withscopeid="no"
1180
 
      ]) # AC_COMPILE_IFELSE
1181
 
    ]) # AC_RUN_IFELSE
1182
 
  ]) # AC_CACHE_CHECK
 
1312
      ]) # AC-COMPILE-IFELSE
 
1313
    ]) # AC-RUN-IFELSE
 
1314
  ]) # AC-CACHE-CHECK
1183
1315
  case "$ac_cv_working_ni_withscopeid" in
1184
1316
    yes)
1185
1317
      AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1186
1318
        [Define to 1 if NI_WITHSCOPEID exists and works.])
1187
1319
      ;;
1188
1320
  esac
1189
 
]) # AC_DEFUN
 
1321
])
1190
1322
 
1191
1323
 
1192
1324
dnl CURL_CHECK_FUNC_RECV
1248
1380
          for recv_arg2 in 'char *' 'void *'; do
1249
1381
            for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1250
1382
              for recv_arg4 in 'int' 'unsigned int'; do
1251
 
                AC_COMPILE_IFELSE([
1252
 
                  AC_LANG_PROGRAM([[
 
1383
                if test "$curl_cv_func_recv_args" = "unknown"; then
 
1384
                  AC_COMPILE_IFELSE([
 
1385
                    AC_LANG_PROGRAM([[
1253
1386
#undef inline 
1254
1387
#ifdef HAVE_WINDOWS_H
1255
1388
#ifndef WIN32_LEAN_AND_MEAN
1273
1406
#endif
1274
1407
#define RECVCALLCONV
1275
1408
#endif
1276
 
                    extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1277
 
                  ]],[[
1278
 
                    $recv_arg1 s=0;
1279
 
                    $recv_arg2 buf=0;
1280
 
                    $recv_arg3 len=0;
1281
 
                    $recv_arg4 flags=0;
1282
 
                    $recv_retv res = recv(s, buf, len, flags);
1283
 
                  ]])
1284
 
                ],[
1285
 
                   curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1286
 
                   break 5
1287
 
                ])
 
1409
                      extern $recv_retv RECVCALLCONV
 
1410
                      recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
 
1411
                    ]],[[
 
1412
                      $recv_arg1 s=0;
 
1413
                      $recv_arg2 buf=0;
 
1414
                      $recv_arg3 len=0;
 
1415
                      $recv_arg4 flags=0;
 
1416
                      $recv_retv res = recv(s, buf, len, flags);
 
1417
                    ]])
 
1418
                  ],[
 
1419
                    curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
 
1420
                  ])
 
1421
                fi
1288
1422
              done
1289
1423
            done
1290
1424
          done
1291
1425
        done
1292
1426
      done
1293
 
    ]) # AC_CACHE_CHECK
 
1427
    ]) # AC-CACHE-CHECK
1294
1428
    if test "$curl_cv_func_recv_args" = "unknown"; then
1295
1429
      AC_MSG_ERROR([Cannot find proper types to use for recv args])
1296
1430
    else
1317
1451
  else
1318
1452
    AC_MSG_ERROR([Unable to link function recv])
1319
1453
  fi
1320
 
]) # AC_DEFUN
 
1454
])
1321
1455
 
1322
1456
 
1323
1457
dnl CURL_CHECK_FUNC_SEND
1380
1514
          for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1381
1515
            for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1382
1516
              for send_arg4 in 'int' 'unsigned int'; do
1383
 
                AC_COMPILE_IFELSE([
1384
 
                  AC_LANG_PROGRAM([[
 
1517
                if test "$curl_cv_func_send_args" = "unknown"; then
 
1518
                  AC_COMPILE_IFELSE([
 
1519
                    AC_LANG_PROGRAM([[
1385
1520
#undef inline 
1386
1521
#ifdef HAVE_WINDOWS_H
1387
1522
#ifndef WIN32_LEAN_AND_MEAN
1405
1540
#endif
1406
1541
#define SENDCALLCONV
1407
1542
#endif
1408
 
                    extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1409
 
                  ]],[[
1410
 
                    $send_arg1 s=0;
1411
 
                    $send_arg3 len=0;
1412
 
                    $send_arg4 flags=0;
1413
 
                    $send_retv res = send(s, 0, len, flags);
1414
 
                  ]])
1415
 
                ],[
1416
 
                   curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1417
 
                   break 5
1418
 
                ])
 
1543
                      extern $send_retv SENDCALLCONV
 
1544
                      send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
 
1545
                    ]],[[
 
1546
                      $send_arg1 s=0;
 
1547
                      $send_arg3 len=0;
 
1548
                      $send_arg4 flags=0;
 
1549
                      $send_retv res = send(s, 0, len, flags);
 
1550
                    ]])
 
1551
                  ],[
 
1552
                    curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
 
1553
                  ])
 
1554
                fi
1419
1555
              done
1420
1556
            done
1421
1557
          done
1422
1558
        done
1423
1559
      done
1424
 
    ]) # AC_CACHE_CHECK
 
1560
    ]) # AC-CACHE-CHECK
1425
1561
    if test "$curl_cv_func_send_args" = "unknown"; then
1426
1562
      AC_MSG_ERROR([Cannot find proper types to use for send args])
1427
1563
    else
1482
1618
  else
1483
1619
    AC_MSG_ERROR([Unable to link function send])
1484
1620
  fi
1485
 
]) # AC_DEFUN
 
1621
])
 
1622
 
 
1623
 
 
1624
dnl CURL_CHECK_FUNC_RECVFROM
 
1625
dnl -------------------------------------------------
 
1626
dnl Test if the socket recvfrom() function is available,
 
1627
dnl and check its return type and the types of its
 
1628
dnl arguments. If the function succeeds HAVE_RECVFROM
 
1629
dnl will be defined, defining the types of the arguments
 
1630
dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
 
1631
dnl to RECVFROM_TYPE_ARG6, defining also the type of the
 
1632
dnl function return value in RECVFROM_TYPE_RETV.
 
1633
dnl Notice that the types returned for pointer arguments
 
1634
dnl will actually be the type pointed by the pointer.
 
1635
 
 
1636
AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
 
1637
  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
 
1638
  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
 
1639
  AC_CHECK_HEADERS(sys/types.h sys/socket.h)
 
1640
  #
 
1641
  AC_MSG_CHECKING([for recvfrom])
 
1642
  AC_LINK_IFELSE([
 
1643
    AC_LANG_PROGRAM([[
 
1644
#undef inline 
 
1645
#ifdef HAVE_WINDOWS_H
 
1646
#ifndef WIN32_LEAN_AND_MEAN
 
1647
#define WIN32_LEAN_AND_MEAN
 
1648
#endif
 
1649
#include <windows.h>
 
1650
#ifdef HAVE_WINSOCK2_H
 
1651
#include <winsock2.h>
 
1652
#else
 
1653
#ifdef HAVE_WINSOCK_H
 
1654
#include <winsock.h>
 
1655
#endif
 
1656
#endif
 
1657
#else
 
1658
#ifdef HAVE_SYS_TYPES_H
 
1659
#include <sys/types.h>
 
1660
#endif
 
1661
#ifdef HAVE_SYS_SOCKET_H
 
1662
#include <sys/socket.h>
 
1663
#endif
 
1664
#endif
 
1665
    ]],[[
 
1666
      recvfrom(0, 0, 0, 0, 0, 0);
 
1667
    ]])
 
1668
  ],[
 
1669
    AC_MSG_RESULT([yes])
 
1670
    curl_cv_recvfrom="yes"
 
1671
  ],[
 
1672
    AC_MSG_RESULT([no])
 
1673
    curl_cv_recvfrom="no"
 
1674
  ])
 
1675
  #
 
1676
  if test "$curl_cv_recvfrom" = "yes"; then
 
1677
    AC_CACHE_CHECK([types of args and return type for recvfrom],
 
1678
      [curl_cv_func_recvfrom_args], [
 
1679
      curl_cv_func_recvfrom_args="unknown"
 
1680
      for recvfrom_retv in 'int' 'ssize_t'; do
 
1681
        for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
 
1682
          for recvfrom_arg2 in 'char *' 'void *'; do
 
1683
            for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
 
1684
              for recvfrom_arg4 in 'int' 'unsigned int'; do
 
1685
                for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
 
1686
                  for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
 
1687
                    if test "$curl_cv_func_recvfrom_args" = "unknown"; then
 
1688
                      AC_COMPILE_IFELSE([
 
1689
                        AC_LANG_PROGRAM([[
 
1690
#undef inline 
 
1691
#ifdef HAVE_WINDOWS_H
 
1692
#ifndef WIN32_LEAN_AND_MEAN
 
1693
#define WIN32_LEAN_AND_MEAN
 
1694
#endif
 
1695
#include <windows.h>
 
1696
#ifdef HAVE_WINSOCK2_H
 
1697
#include <winsock2.h>
 
1698
#else
 
1699
#ifdef HAVE_WINSOCK_H
 
1700
#include <winsock.h>
 
1701
#endif
 
1702
#endif
 
1703
#define RECVFROMCALLCONV PASCAL
 
1704
#else
 
1705
#ifdef HAVE_SYS_TYPES_H
 
1706
#include <sys/types.h>
 
1707
#endif
 
1708
#ifdef HAVE_SYS_SOCKET_H
 
1709
#include <sys/socket.h>
 
1710
#endif
 
1711
#define RECVFROMCALLCONV
 
1712
#endif
 
1713
                          extern $recvfrom_retv RECVFROMCALLCONV
 
1714
                          recvfrom($recvfrom_arg1, $recvfrom_arg2,
 
1715
                                   $recvfrom_arg3, $recvfrom_arg4,
 
1716
                                   $recvfrom_arg5, $recvfrom_arg6);
 
1717
                        ]],[[
 
1718
                          $recvfrom_arg1 s=0;
 
1719
                          $recvfrom_arg2 buf=0;
 
1720
                          $recvfrom_arg3 len=0;
 
1721
                          $recvfrom_arg4 flags=0;
 
1722
                          $recvfrom_arg5 addr=0;
 
1723
                          $recvfrom_arg6 addrlen=0;
 
1724
                          $recvfrom_retv res=0;
 
1725
                          res = recvfrom(s, buf, len, flags, addr, addrlen);
 
1726
                        ]])
 
1727
                      ],[
 
1728
                        curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
 
1729
                      ])
 
1730
                    fi
 
1731
                  done
 
1732
                done
 
1733
              done
 
1734
            done
 
1735
          done
 
1736
        done
 
1737
      done
 
1738
    ]) # AC-CACHE-CHECK
 
1739
    # Nearly last minute change for this release starts here
 
1740
    AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
 
1741
      [Define to 1 if you have the recvfrom function.])
 
1742
    ac_cv_func_recvfrom="yes"
 
1743
    # Nearly last minute change for this release ends here
 
1744
    if test "$curl_cv_func_recvfrom_args" = "unknown"; then
 
1745
      AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
 
1746
    else
 
1747
      recvfrom_prev_IFS=$IFS; IFS=','
 
1748
      set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
 
1749
      IFS=$recvfrom_prev_IFS
 
1750
      shift
 
1751
      #
 
1752
      recvfrom_ptrt_arg2=$[2]
 
1753
      recvfrom_ptrt_arg5=$[5]
 
1754
      recvfrom_ptrt_arg6=$[6]
 
1755
      #
 
1756
      AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
 
1757
        [Define to the type of arg 1 for recvfrom.])
 
1758
      AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
 
1759
        [Define to the type of arg 3 for recvfrom.])
 
1760
      AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
 
1761
        [Define to the type of arg 4 for recvfrom.])
 
1762
      AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
 
1763
        [Define to the function return type for recvfrom.])
 
1764
      #
 
1765
      prev_sh_opts=$-
 
1766
      #
 
1767
      case $prev_sh_opts in
 
1768
        *f*)
 
1769
          ;;
 
1770
        *)
 
1771
          set -f
 
1772
          ;;
 
1773
      esac
 
1774
      #
 
1775
      recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
 
1776
      recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
 
1777
      recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
 
1778
      #
 
1779
      AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
 
1780
        [Define to the type pointed by arg 2 for recvfrom.])
 
1781
      AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
 
1782
        [Define to the type pointed by arg 5 for recvfrom.])
 
1783
      AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
 
1784
        [Define to the type pointed by arg 6 for recvfrom.])
 
1785
      #
 
1786
      if test "$recvfrom_type_arg2" = "void"; then
 
1787
        AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
 
1788
          [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
 
1789
      fi
 
1790
      if test "$recvfrom_type_arg5" = "void"; then
 
1791
        AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
 
1792
          [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
 
1793
      fi
 
1794
      if test "$recvfrom_type_arg6" = "void"; then
 
1795
        AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
 
1796
          [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
 
1797
      fi
 
1798
      #
 
1799
      case $prev_sh_opts in
 
1800
        *f*)
 
1801
          ;;
 
1802
        *)
 
1803
          set +f
 
1804
          ;;
 
1805
      esac
 
1806
      #
 
1807
      AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
 
1808
        [Define to 1 if you have the recvfrom function.])
 
1809
      ac_cv_func_recvfrom="yes"
 
1810
    fi
 
1811
  else
 
1812
    AC_MSG_WARN([Unable to link function recvfrom])
 
1813
  fi
 
1814
])
1486
1815
 
1487
1816
 
1488
1817
dnl CURL_CHECK_MSG_NOSIGNAL
1530
1859
        [Define to 1 if you have the MSG_NOSIGNAL flag.])
1531
1860
      ;;
1532
1861
  esac
1533
 
]) # AC_DEFUN
 
1862
])
1534
1863
 
1535
1864
 
1536
1865
dnl CURL_CHECK_STRUCT_TIMEVAL
1589
1918
        [Define to 1 if you have the timeval struct.])
1590
1919
      ;;
1591
1920
  esac
1592
 
]) # AC_DEFUN
 
1921
])
1593
1922
 
1594
1923
 
1595
1924
dnl TYPE_SIG_ATOMIC_T
1633
1962
      fi
1634
1963
      ;;
1635
1964
  esac
1636
 
]) # AC_DEFUN
1637
 
 
1638
 
 
1639
 
dnl CURL_CHECK_NONBLOCKING_SOCKET
1640
 
dnl -------------------------------------------------
1641
 
dnl Check for how to set a socket to non-blocking state. There seems to exist
1642
 
dnl four known different ways, with the one used almost everywhere being POSIX
1643
 
dnl and XPG3, while the other different ways for different systems (old BSD,
1644
 
dnl Windows and Amiga).
1645
 
dnl
1646
 
dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1647
 
dnl O_NONBLOCK define is found but does not work. This condition is attempted
1648
 
dnl to get caught in this script by using an excessive number of #ifdefs...
1649
 
 
1650
 
AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1651
 
  AC_MSG_CHECKING([non-blocking sockets style])
1652
 
  nonblock="unknown"
1653
 
  #
1654
 
  AC_COMPILE_IFELSE([
1655
 
    AC_LANG_PROGRAM([[
1656
 
/* headers for O_NONBLOCK test */
1657
 
#include <sys/types.h>
1658
 
#include <unistd.h>
1659
 
#include <fcntl.h>
1660
 
/* */
1661
 
#if defined(sun) || defined(__sun__) || \
1662
 
    defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1663
 
# if defined(__SVR4) || defined(__srv4__)
1664
 
#  define PLATFORM_SOLARIS
1665
 
# else
1666
 
#  define PLATFORM_SUNOS4
1667
 
# endif
1668
 
#endif
1669
 
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1670
 
# define PLATFORM_AIX_V3
1671
 
#endif
1672
 
/* */
1673
 
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1674
 
#error "O_NONBLOCK does not work on this platform"
1675
 
#endif
1676
 
    ]],[[
1677
 
      /* O_NONBLOCK source test */
1678
 
      int socket;
1679
 
      int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1680
 
    ]])
1681
 
  ],[
1682
 
    dnl the O_NONBLOCK test was fine
1683
 
    nonblock="O_NONBLOCK"
1684
 
    AC_DEFINE(HAVE_O_NONBLOCK, 1,
1685
 
      [use O_NONBLOCK for non-blocking sockets])
1686
 
  ])
1687
 
  #
1688
 
  if test "$nonblock" = "unknown"; then
1689
 
    AC_COMPILE_IFELSE([
1690
 
      AC_LANG_PROGRAM([[
1691
 
/* headers for FIONBIO test */
1692
 
#include <unistd.h>
1693
 
#include <stropts.h>
1694
 
      ]],[[
1695
 
        /* FIONBIO source test (old-style unix) */
1696
 
        int socket;
1697
 
        int flags = ioctl(socket, FIONBIO, &flags);
1698
 
      ]])
1699
 
    ],[
1700
 
      dnl FIONBIO test was good
1701
 
      nonblock="FIONBIO"
1702
 
      AC_DEFINE(HAVE_FIONBIO, 1,
1703
 
        [use FIONBIO for non-blocking sockets])
1704
 
    ])
1705
 
  fi
1706
 
  #
1707
 
  if test "$nonblock" = "unknown"; then
1708
 
    AC_COMPILE_IFELSE([
1709
 
      AC_LANG_PROGRAM([[
1710
 
/* headers for ioctlsocket test (Windows) */
1711
 
#undef inline
1712
 
#ifdef HAVE_WINDOWS_H
1713
 
#ifndef WIN32_LEAN_AND_MEAN
1714
 
#define WIN32_LEAN_AND_MEAN
1715
 
#endif
1716
 
#include <windows.h>
1717
 
#ifdef HAVE_WINSOCK2_H
1718
 
#include <winsock2.h>
1719
 
#else
1720
 
#ifdef HAVE_WINSOCK_H
1721
 
#include <winsock.h>
1722
 
#endif
1723
 
#endif
1724
 
#endif
1725
 
      ]],[[
1726
 
        /* ioctlsocket source code (Windows) */
1727
 
        SOCKET sd;
1728
 
        unsigned long flags = 0;
1729
 
        sd = socket(0, 0, 0);
1730
 
        ioctlsocket(sd, FIONBIO, &flags);
1731
 
      ]])
1732
 
    ],[
1733
 
      dnl ioctlsocket test was good
1734
 
      nonblock="ioctlsocket"
1735
 
      AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1736
 
        [use ioctlsocket() for non-blocking sockets])
1737
 
    ])
1738
 
  fi
1739
 
  #
1740
 
  if test "$nonblock" = "unknown"; then
1741
 
    AC_LINK_IFELSE([
1742
 
      AC_LANG_PROGRAM([[
1743
 
/* headers for IoctlSocket test (Amiga?) */
1744
 
#include <sys/ioctl.h>
1745
 
      ]],[[
1746
 
        /* IoctlSocket source code (Amiga?) */
1747
 
        int socket;
1748
 
        int flags = IoctlSocket(socket, FIONBIO, (long)1);
1749
 
      ]])
1750
 
    ],[
1751
 
      dnl Ioctlsocket test was good
1752
 
      nonblock="IoctlSocket"
1753
 
      AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1754
 
        [use Ioctlsocket() for non-blocking sockets])
1755
 
    ])
1756
 
  fi
1757
 
  #
1758
 
  if test "$nonblock" = "unknown"; then
1759
 
    AC_COMPILE_IFELSE([
1760
 
      AC_LANG_PROGRAM([[
1761
 
/* headers for SO_NONBLOCK test (BeOS) */
1762
 
#include <socket.h>
1763
 
      ]],[[
1764
 
        /* SO_NONBLOCK source code (BeOS) */
1765
 
        long b = 1;
1766
 
        int socket;
1767
 
        int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1768
 
      ]])
1769
 
    ],[
1770
 
      dnl the SO_NONBLOCK test was good
1771
 
      nonblock="SO_NONBLOCK"
1772
 
      AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1773
 
        [use SO_NONBLOCK for non-blocking sockets])
1774
 
    ])
1775
 
  fi
1776
 
  #
1777
 
  AC_MSG_RESULT($nonblock)
1778
 
  #
1779
 
  if test "$nonblock" = "unknown"; then
1780
 
    AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1781
 
      [disabled non-blocking sockets])
1782
 
    AC_MSG_WARN([non-block sockets disabled])
1783
 
  fi
1784
1965
])
1785
1966
 
1786
1967
 
1788
1969
dnl -------------------------------------------------
1789
1970
dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1790
1971
dnl and a few other things.
1791
 
AC_DEFUN([TYPE_IN_ADDR_T],
1792
 
[
1793
 
   AC_CHECK_TYPE([in_addr_t], ,[
1794
 
      AC_MSG_CHECKING([for in_addr_t equivalent])
1795
 
      AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1796
 
      [
1797
 
         curl_cv_in_addr_t_equiv=
1798
 
         for t in "unsigned long" int size_t unsigned long; do
1799
 
            AC_LINK_IFELSE([
1800
 
              AC_LANG_PROGRAM([[
1801
 
#undef inline
1802
 
#ifdef HAVE_WINDOWS_H
1803
 
#ifndef WIN32_LEAN_AND_MEAN
1804
 
#define WIN32_LEAN_AND_MEAN
1805
 
#endif
1806
 
#include <windows.h>
1807
 
#ifdef HAVE_WINSOCK2_H
1808
 
#include <winsock2.h>
1809
 
#else
1810
 
#ifdef HAVE_WINSOCK_H
1811
 
#include <winsock.h>
1812
 
#endif
1813
 
#endif
1814
 
#else
1815
 
#ifdef HAVE_SYS_TYPES_H
1816
 
#include <sys/types.h>
1817
 
#endif
1818
 
#ifdef HAVE_SYS_SOCKET_H
1819
 
#include <sys/socket.h>
1820
 
#endif
1821
 
#ifdef HAVE_NETINET_IN_H
1822
 
#include <netinet/in.h>
1823
 
#endif
1824
 
#ifdef HAVE_ARPA_INET_H
1825
 
#include <arpa/inet.h>
1826
 
#endif
1827
 
#endif
1828
 
              ]],[[
1829
 
                $t data = inet_addr ("1.2.3.4");
1830
 
              ]])
1831
 
            ],[
1832
 
              curl_cv_in_addr_t_equiv="$t"
1833
 
              break
1834
 
            ])
1835
 
         done
1836
 
 
1837
 
         if test "x$curl_cv_in_addr_t_equiv" = x; then
1838
 
            AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1839
 
         fi
1840
 
      ])
1841
 
      AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1842
 
      AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1843
 
                        [type to use in place of in_addr_t if not defined])],
1844
 
      [
1845
 
#undef inline
1846
 
#ifdef HAVE_WINDOWS_H
1847
 
#ifndef WIN32_LEAN_AND_MEAN
1848
 
#define WIN32_LEAN_AND_MEAN
1849
 
#endif
1850
 
#include <windows.h>
1851
 
#ifdef HAVE_WINSOCK2_H
1852
 
#include <winsock2.h>
1853
 
#else
1854
 
#ifdef HAVE_WINSOCK_H
1855
 
#include <winsock.h>
1856
 
#endif
1857
 
#endif
1858
 
#else
1859
 
#ifdef HAVE_SYS_TYPES_H
1860
 
#include <sys/types.h>
1861
 
#endif
1862
 
#ifdef HAVE_SYS_SOCKET_H
1863
 
#include <sys/socket.h>
1864
 
#endif
1865
 
#ifdef HAVE_NETINET_IN_H
1866
 
#include <netinet/in.h>
1867
 
#endif
1868
 
#ifdef HAVE_ARPA_INET_H
1869
 
#include <arpa/inet.h>
1870
 
#endif
1871
 
#endif
1872
 
  ]) dnl AC_CHECK_TYPE
1873
 
]) dnl AC_DEFUN
 
1972
 
 
1973
AC_DEFUN([TYPE_IN_ADDR_T], [
 
1974
  AC_CHECK_TYPE([in_addr_t], ,[
 
1975
    dnl in_addr_t not available
 
1976
    AC_CACHE_CHECK([for in_addr_t equivalent],
 
1977
      [curl_cv_in_addr_t_equiv], [
 
1978
      curl_cv_in_addr_t_equiv="unknown"
 
1979
      for t in "unsigned long" int size_t unsigned long; do
 
1980
        if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
 
1981
          AC_LINK_IFELSE([
 
1982
            AC_LANG_PROGRAM([[
 
1983
#undef inline
 
1984
#ifdef HAVE_WINDOWS_H
 
1985
#ifndef WIN32_LEAN_AND_MEAN
 
1986
#define WIN32_LEAN_AND_MEAN
 
1987
#endif
 
1988
#include <windows.h>
 
1989
#ifdef HAVE_WINSOCK2_H
 
1990
#include <winsock2.h>
 
1991
#else
 
1992
#ifdef HAVE_WINSOCK_H
 
1993
#include <winsock.h>
 
1994
#endif
 
1995
#endif
 
1996
#else
 
1997
#ifdef HAVE_SYS_TYPES_H
 
1998
#include <sys/types.h>
 
1999
#endif
 
2000
#ifdef HAVE_SYS_SOCKET_H
 
2001
#include <sys/socket.h>
 
2002
#endif
 
2003
#ifdef HAVE_NETINET_IN_H
 
2004
#include <netinet/in.h>
 
2005
#endif
 
2006
#ifdef HAVE_ARPA_INET_H
 
2007
#include <arpa/inet.h>
 
2008
#endif
 
2009
#endif
 
2010
            ]],[[
 
2011
              $t data = inet_addr ("1.2.3.4");
 
2012
            ]])
 
2013
          ],[
 
2014
            curl_cv_in_addr_t_equiv="$t"
 
2015
          ])
 
2016
        fi
 
2017
      done
 
2018
    ])
 
2019
    case "$curl_cv_in_addr_t_equiv" in
 
2020
      unknown)
 
2021
        AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
 
2022
        ;;
 
2023
      *)
 
2024
        AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
 
2025
          [Type to use in place of in_addr_t when system does not provide it.])
 
2026
        ;;
 
2027
    esac
 
2028
  ],[
 
2029
#undef inline
 
2030
#ifdef HAVE_WINDOWS_H
 
2031
#ifndef WIN32_LEAN_AND_MEAN
 
2032
#define WIN32_LEAN_AND_MEAN
 
2033
#endif
 
2034
#include <windows.h>
 
2035
#ifdef HAVE_WINSOCK2_H
 
2036
#include <winsock2.h>
 
2037
#else
 
2038
#ifdef HAVE_WINSOCK_H
 
2039
#include <winsock.h>
 
2040
#endif
 
2041
#endif
 
2042
#else
 
2043
#ifdef HAVE_SYS_TYPES_H
 
2044
#include <sys/types.h>
 
2045
#endif
 
2046
#ifdef HAVE_SYS_SOCKET_H
 
2047
#include <sys/socket.h>
 
2048
#endif
 
2049
#ifdef HAVE_NETINET_IN_H
 
2050
#include <netinet/in.h>
 
2051
#endif
 
2052
#ifdef HAVE_ARPA_INET_H
 
2053
#include <arpa/inet.h>
 
2054
#endif
 
2055
#endif
 
2056
  ])
 
2057
])
 
2058
 
1874
2059
 
1875
2060
dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1876
2061
dnl -------------------------------------------------
1906
2091
    AC_MSG_RESULT([no])
1907
2092
    ac_cv_func_clock_gettime="no"
1908
2093
  ])
1909
 
  dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
1910
 
  dnl postponed until library linking checks for clock_gettime pass.
1911
 
]) dnl AC_DEFUN
 
2094
  dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
 
2095
  dnl until library linking and run-time checks for clock_gettime succeed.
 
2096
])
 
2097
 
1912
2098
 
1913
2099
dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1914
2100
dnl -------------------------------------------------
1926
2112
    curl_cv_gclk_LIBS="unknown"
1927
2113
    #
1928
2114
    for x_xlibs in '' '-lrt' '-lposix4' ; do
1929
 
      if test -z "$x_xlibs"; then
1930
 
        LIBS="$curl_cv_save_LIBS"
1931
 
      else
1932
 
        LIBS="$x_xlibs $curl_cv_save_LIBS"
1933
 
      fi
1934
 
      AC_LINK_IFELSE([
1935
 
        AC_LANG_PROGRAM([[
 
2115
      if test "$curl_cv_gclk_LIBS" = "unknown"; then
 
2116
        if test -z "$x_xlibs"; then
 
2117
          LIBS="$curl_cv_save_LIBS"
 
2118
        else
 
2119
          LIBS="$x_xlibs $curl_cv_save_LIBS"
 
2120
        fi
 
2121
        AC_LINK_IFELSE([
 
2122
          AC_LANG_PROGRAM([[
1936
2123
#ifdef HAVE_SYS_TYPES_H
1937
2124
#include <sys/types.h>
1938
2125
#endif
1946
2133
#include <time.h>
1947
2134
#endif
1948
2135
#endif
1949
 
        ]],[[
1950
 
          struct timespec ts;
1951
 
          (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1952
 
        ]])
1953
 
      ],[
1954
 
        curl_cv_gclk_LIBS="$x_xlibs"
1955
 
        break
1956
 
      ])
 
2136
          ]],[[
 
2137
            struct timespec ts;
 
2138
            (void)clock_gettime(CLOCK_MONOTONIC, &ts);
 
2139
          ]])
 
2140
        ],[
 
2141
          curl_cv_gclk_LIBS="$x_xlibs"
 
2142
        ])
 
2143
      fi
1957
2144
    done
1958
2145
    #
1959
2146
    LIBS="$curl_cv_save_LIBS"
1979
2166
        ;;
1980
2167
    esac
1981
2168
    #
 
2169
    dnl only do runtime verification when not cross-compiling
 
2170
    if test "x$cross_compiling" != "xyes" &&
 
2171
      test "$ac_cv_func_clock_gettime" = "yes"; then
 
2172
      AC_MSG_CHECKING([if monotonic clock_gettime works])
 
2173
      AC_RUN_IFELSE([
 
2174
        AC_LANG_PROGRAM([[
 
2175
#ifdef HAVE_STDLIB_H
 
2176
#include <stdlib.h>
 
2177
#endif
 
2178
#ifdef HAVE_SYS_TYPES_H
 
2179
#include <sys/types.h>
 
2180
#endif
 
2181
#ifdef HAVE_SYS_TIME_H
 
2182
#include <sys/time.h>
 
2183
#ifdef TIME_WITH_SYS_TIME
 
2184
#include <time.h>
 
2185
#endif
 
2186
#else
 
2187
#ifdef HAVE_TIME_H
 
2188
#include <time.h>
 
2189
#endif
 
2190
#endif
 
2191
        ]],[[
 
2192
          struct timespec ts;
 
2193
          if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
 
2194
            exit(0);
 
2195
          else
 
2196
            exit(1);
 
2197
        ]])
 
2198
      ],[
 
2199
        AC_MSG_RESULT([yes])
 
2200
      ],[
 
2201
        AC_MSG_RESULT([no])
 
2202
        AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
 
2203
        ac_cv_func_clock_gettime="no"
 
2204
        LIBS="$curl_cv_save_LIBS"
 
2205
      ])
 
2206
    fi
 
2207
    #
1982
2208
    case "$ac_cv_func_clock_gettime" in
1983
2209
      yes)
1984
2210
        AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1988
2214
    #
1989
2215
  fi
1990
2216
  #
1991
 
]) dnl AC_DEFUN
 
2217
])
1992
2218
 
1993
2219
 
1994
2220
dnl CURL_CHECK_FUNC_SELECT
2064
2290
        for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2065
2291
          for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2066
2292
            for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2067
 
              AC_COMPILE_IFELSE([
2068
 
                AC_LANG_PROGRAM([[
 
2293
              if test "$curl_cv_func_select_args" = "unknown"; then
 
2294
                AC_COMPILE_IFELSE([
 
2295
                  AC_LANG_PROGRAM([[
2069
2296
#undef inline
2070
2297
#ifdef HAVE_WINDOWS_H
2071
2298
#ifndef WIN32_LEAN_AND_MEAN
2104
2331
#define SELECTCALLCONV
2105
2332
#endif
2106
2333
#ifndef HAVE_STRUCT_TIMEVAL
2107
 
                  struct timeval {
2108
 
                    long tv_sec;
2109
 
                    long tv_usec;
2110
 
                  };
 
2334
                    struct timeval {
 
2335
                      long tv_sec;
 
2336
                      long tv_usec;
 
2337
                    };
2111
2338
#endif
2112
 
                  extern $sel_retv SELECTCALLCONV select($sel_arg1,
2113
 
                                                         $sel_arg234,
2114
 
                                                         $sel_arg234,
2115
 
                                                         $sel_arg234,
2116
 
                                                         $sel_arg5);
2117
 
                ]],[[
2118
 
                  $sel_arg1   nfds=0;
2119
 
                  $sel_arg234 rfds=0;
2120
 
                  $sel_arg234 wfds=0;
2121
 
                  $sel_arg234 efds=0;
2122
 
                  $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2123
 
                ]])
2124
 
              ],[
2125
 
                 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2126
 
                 break 4
2127
 
              ])
 
2339
                    extern $sel_retv SELECTCALLCONV select($sel_arg1,
 
2340
                                                           $sel_arg234,
 
2341
                                                           $sel_arg234,
 
2342
                                                           $sel_arg234,
 
2343
                                                           $sel_arg5);
 
2344
                  ]],[[
 
2345
                    $sel_arg1   nfds=0;
 
2346
                    $sel_arg234 rfds=0;
 
2347
                    $sel_arg234 wfds=0;
 
2348
                    $sel_arg234 efds=0;
 
2349
                    $sel_retv res = select(nfds, rfds, wfds, efds, 0);
 
2350
                  ]])
 
2351
                ],[
 
2352
                  curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
 
2353
                ])
 
2354
              fi
2128
2355
            done
2129
2356
          done
2130
2357
        done
2131
2358
      done
2132
 
    ]) # AC_CACHE_CHECK
 
2359
    ]) # AC-CACHE-CHECK
2133
2360
    if test "$curl_cv_func_select_args" = "unknown"; then
2134
2361
      AC_MSG_WARN([Cannot find proper types to use for select args])
2135
2362
      AC_MSG_WARN([HAVE_SELECT will not be defined])
2187
2414
      ac_cv_func_select="yes"
2188
2415
    fi
2189
2416
  fi
2190
 
]) # AC_DEFUN
2191
 
 
2192
 
 
2193
 
dnl ************************************************************
2194
 
dnl check for "localhost", if it doesn't exist, we can't do the
2195
 
dnl gethostbyname_r tests!
2196
 
dnl 
2197
 
 
2198
 
AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
2199
 
AC_MSG_CHECKING([if "localhost" resolves])
2200
 
AC_TRY_RUN([
2201
 
#include <string.h>
2202
 
#include <sys/types.h>
2203
 
#include <netdb.h>
2204
 
#ifndef NULL
2205
 
#define NULL (void *)0
2206
 
#endif
2207
 
 
2208
 
int
2209
 
main () {
2210
 
struct hostent *h;
2211
 
h = gethostbyname("localhost");
2212
 
exit (h == NULL ? 1 : 0); }],[
2213
 
      AC_MSG_RESULT(yes)],[
2214
 
      AC_MSG_RESULT(no)
2215
 
      AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
2216
 
 
2217
 
      ]
2218
 
)
2219
 
])
2220
 
 
2221
 
dnl ************************************************************
2222
 
dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2223
 
dnl
2224
 
AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2225
 
  AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2226
 
  AC_TRY_RUN( [
2227
 
#include <netdb.h>
2228
 
#include <sys/types.h>
2229
 
#include <sys/socket.h>
2230
 
 
2231
 
int main(void)
2232
 
{
2233
 
    struct addrinfo hints, *ai;
2234
 
    int error;
2235
 
 
2236
 
    memset(&hints, 0, sizeof(hints));
2237
 
    hints.ai_flags = AI_NUMERICHOST;
2238
 
    hints.ai_family = AF_UNSPEC;
2239
 
    hints.ai_socktype = SOCK_STREAM;
2240
 
    error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2241
 
    if (error) {
2242
 
        return 1;
2243
 
    }
2244
 
    return 0;
2245
 
}
2246
 
],[
2247
 
  ac_cv_working_getaddrinfo="yes"
2248
 
],[
2249
 
  ac_cv_working_getaddrinfo="no"
2250
 
],[
2251
 
  ac_cv_working_getaddrinfo="yes"
2252
 
])])
2253
 
if test "$ac_cv_working_getaddrinfo" = "yes"; then
2254
 
  AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2255
 
  AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2256
 
 
2257
 
  IPV6_ENABLED=1
2258
 
  AC_SUBST(IPV6_ENABLED)
2259
 
fi
2260
 
])
2261
 
 
2262
 
 
2263
 
AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2264
 
[
2265
 
  dnl check for localtime_r
2266
 
  AC_CHECK_FUNCS(localtime_r,[
2267
 
    AC_MSG_CHECKING(whether localtime_r is declared)
2268
 
    AC_EGREP_CPP(localtime_r,[
2269
 
#include <time.h>],[
2270
 
      AC_MSG_RESULT(yes)],[
2271
 
      AC_MSG_RESULT(no)
2272
 
      AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2273
 
      AC_EGREP_CPP(localtime_r,[
2274
 
#define _REENTRANT
2275
 
#include <time.h>],[
2276
 
        AC_DEFINE(NEED_REENTRANT)
2277
 
        AC_MSG_RESULT(yes)],
2278
 
        AC_MSG_RESULT(no))])])
2279
 
])
2280
 
 
2281
 
dnl
2282
 
dnl This function checks for strerror_r(). If it isn't found at first, it
2283
 
dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2284
 
dnl in order to find this function.
2285
 
dnl
2286
 
dnl If the function is found, it will then proceed to check how the function
2287
 
dnl actually works: glibc-style or POSIX-style.
2288
 
dnl
2289
 
dnl glibc:
2290
 
dnl      char *strerror_r(int errnum, char *buf, size_t n);
2291
 
dnl  
2292
 
dnl  What this one does is to return the error string (no surprises there),
2293
 
dnl  but it doesn't usually copy anything into buf!  The 'buf' and 'n'
2294
 
dnl  parameters are only meant as an optional working area, in case strerror_r
2295
 
dnl  needs it.  A quick test on a few systems shows that it's generally not
2296
 
dnl  touched at all.
2297
 
dnl
2298
 
dnl POSIX:
2299
 
dnl      int strerror_r(int errnum, char *buf, size_t n);
2300
 
dnl
2301
 
AC_DEFUN([CURL_CHECK_STRERROR_R],
2302
 
[
2303
 
  AC_CHECK_FUNCS(strerror_r)
2304
 
 
2305
 
  if test "x$ac_cv_func_strerror_r" = "xyes"; then
2306
 
 
2307
 
    AC_MSG_CHECKING(whether strerror_r is declared)
2308
 
    AC_EGREP_CPP(strerror_r,[
2309
 
#include <string.h>],[
2310
 
      AC_MSG_RESULT(yes)],[
2311
 
      AC_MSG_RESULT(no)
2312
 
      AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2313
 
      AC_EGREP_CPP(strerror_r,[
2314
 
#define _REENTRANT
2315
 
#include <string.h>],[
2316
 
        CPPFLAGS="-D_REENTRANT $CPPFLAGS"
2317
 
        AC_MSG_RESULT(yes)],
2318
 
        AC_MSG_RESULT(no)
2319
 
        AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2320
 
       ) dnl with _THREAD_SAFE
2321
 
    ]) dnl plain cpp for it
2322
 
 
2323
 
    dnl determine if this strerror_r() is glibc or POSIX
2324
 
    AC_MSG_CHECKING([for a glibc strerror_r API])
2325
 
    AC_TRY_RUN([
2326
 
#include <string.h>
2327
 
#include <errno.h>
2328
 
int
2329
 
main () {
2330
 
  char buffer[1024]; /* big enough to play with */
2331
 
  char *string =
2332
 
    strerror_r(EACCES, buffer, sizeof(buffer));
2333
 
    /* this should've returned a string */
2334
 
    if(!string || !string[0])
2335
 
      return 99;
2336
 
    return 0;
2337
 
}
2338
 
],
2339
 
    GLIBC_STRERROR_R="1"
2340
 
    AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2341
 
    AC_MSG_RESULT([yes]),
2342
 
    AC_MSG_RESULT([no]),
2343
 
 
2344
 
    dnl Use an inferior method of strerror_r detection while cross-compiling
2345
 
    AC_EGREP_CPP(yes, [
2346
 
#include <features.h>
2347
 
#ifdef __GLIBC__
2348
 
yes
2349
 
#endif
2350
 
], 
2351
 
      dnl looks like glibc, so assume a glibc-style strerror_r()
2352
 
      GLIBC_STRERROR_R="1"
2353
 
      AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2354
 
      AC_MSG_RESULT([yes]),
2355
 
      AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2356
 
    ) dnl while cross-compiling
2357
 
    )
2358
 
 
2359
 
    if test -z "$GLIBC_STRERROR_R"; then
2360
 
 
2361
 
      AC_MSG_CHECKING([for a POSIX strerror_r API])
2362
 
      AC_TRY_RUN([
2363
 
#include <string.h>
2364
 
#include <errno.h>
2365
 
int
2366
 
main () {
2367
 
  char buffer[1024]; /* big enough to play with */
2368
 
  int error =
2369
 
    strerror_r(EACCES, buffer, sizeof(buffer));
2370
 
    /* This should've returned zero, and written an error string in the
2371
 
       buffer.*/
2372
 
    if(!buffer[0] || error)
2373
 
      return 99;
2374
 
    return 0;
2375
 
}
2376
 
],
2377
 
      AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2378
 
      AC_MSG_RESULT([yes]),
2379
 
      AC_MSG_RESULT([no]) ,
2380
 
      dnl cross-compiling!
2381
 
      AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2382
 
    )
2383
 
 
2384
 
    fi dnl if not using glibc API
2385
 
 
2386
 
  fi dnl we have a strerror_r
2387
 
 
2388
 
])
2389
 
 
2390
 
AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2391
 
[
2392
 
  dnl determine if function definition for inet_ntoa_r exists.
2393
 
  AC_CHECK_FUNCS(inet_ntoa_r,[
2394
 
    AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2395
 
    AC_EGREP_CPP(inet_ntoa_r,[
2396
 
#include <arpa/inet.h>],[
2397
 
      AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2398
 
      AC_MSG_RESULT(yes)],[
2399
 
      AC_MSG_RESULT(no)
2400
 
      AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2401
 
      AC_EGREP_CPP(inet_ntoa_r,[
2402
 
#define _REENTRANT
2403
 
#include <arpa/inet.h>],[
2404
 
        AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2405
 
        AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
2406
 
        AC_MSG_RESULT(yes)],
2407
 
        AC_MSG_RESULT(no))])])
2408
 
])
2409
 
 
2410
 
 
2411
 
dnl CURL_CHECK_GETHOSTBYADDR_R
2412
 
dnl -------------------------------------------------
2413
 
dnl check number of arguments for gethostbyaddr_r, it
2414
 
dnl might take either 5, 7, or 8 arguments.
2415
 
 
2416
 
AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
2417
 
  #
2418
 
  AC_MSG_CHECKING([for gethostbyaddr_r])
2419
 
  AC_LINK_IFELSE([
2420
 
    AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2421
 
  ],[
2422
 
    AC_MSG_RESULT([yes])
2423
 
    tmp_cv_gethostbyaddr_r="yes"
2424
 
  ],[
2425
 
    AC_MSG_RESULT([no])
2426
 
    tmp_cv_gethostbyaddr_r="no"
2427
 
  ])
2428
 
  #
2429
 
  if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
2430
 
    AC_MSG_CHECKING([deeper for gethostbyaddr_r])
2431
 
    AC_LINK_IFELSE([
2432
 
      AC_LANG_PROGRAM([[
2433
 
      ]],[[
2434
 
        gethostbyaddr_r();
2435
 
      ]])
2436
 
    ],[
2437
 
      AC_MSG_RESULT([yes])
2438
 
      tmp_cv_gethostbyaddr_r="yes"
2439
 
    ],[
2440
 
      AC_MSG_RESULT([but still no])
2441
 
      tmp_cv_gethostbyaddr_r="no"
2442
 
    ])
2443
 
  fi
2444
 
  #
2445
 
  if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
2446
 
 
2447
 
    ac_cv_gethostbyaddr_r_args="unknown"
2448
 
 
2449
 
    AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
2450
 
    AC_COMPILE_IFELSE([
2451
 
      AC_LANG_PROGRAM([[
2452
 
#include <sys/types.h>
2453
 
#include <netdb.h>
2454
 
      ]],[[
2455
 
        char * address;
2456
 
        int length;
2457
 
        int type;
2458
 
        struct hostent h;
2459
 
        struct hostent_data hdata;
2460
 
        int rc;
2461
 
        rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2462
 
      ]])
2463
 
    ],[
2464
 
      AC_MSG_RESULT([yes])
2465
 
      AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2466
 
      ac_cv_gethostbyaddr_r_args="5"
2467
 
    ],[
2468
 
      AC_MSG_RESULT([no])
2469
 
    ])
2470
 
 
2471
 
    if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2472
 
      AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
2473
 
      AC_COMPILE_IFELSE([
2474
 
        AC_LANG_PROGRAM([[
2475
 
#define _REENTRANT
2476
 
#include <sys/types.h>
2477
 
#include <netdb.h>
2478
 
        ]],[[
2479
 
          char * address;
2480
 
          int length;
2481
 
          int type;
2482
 
          struct hostent h;
2483
 
          struct hostent_data hdata;
2484
 
          int rc;
2485
 
          rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2486
 
        ]])
2487
 
      ],[
2488
 
        AC_MSG_RESULT([yes])
2489
 
        AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2490
 
        AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2491
 
        ac_cv_gethostbyaddr_r_args="5"
2492
 
      ],[
2493
 
        AC_MSG_RESULT([no])
2494
 
      ])
2495
 
    fi
2496
 
 
2497
 
    if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2498
 
      AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
2499
 
      AC_COMPILE_IFELSE([
2500
 
        AC_LANG_PROGRAM([[
2501
 
#include <sys/types.h>
2502
 
#include <netdb.h>
2503
 
        ]],[[
2504
 
          char * address;
2505
 
          int length;
2506
 
          int type;
2507
 
          struct hostent h;
2508
 
          char buffer[8192];
2509
 
          int h_errnop;
2510
 
          struct hostent * hp;
2511
 
          hp = gethostbyaddr_r(address, length, type, &h,
2512
 
                               buffer, 8192, &h_errnop);
2513
 
        ]])
2514
 
      ],[
2515
 
        AC_MSG_RESULT([yes])
2516
 
        AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2517
 
        ac_cv_gethostbyaddr_r_args="7"
2518
 
      ],[
2519
 
        AC_MSG_RESULT([no])
2520
 
      ])
2521
 
    fi
2522
 
 
2523
 
    if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2524
 
      AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
2525
 
      AC_COMPILE_IFELSE([
2526
 
        AC_LANG_PROGRAM([[
2527
 
#include <sys/types.h>
2528
 
#include <netdb.h>
2529
 
        ]],[[
2530
 
          char * address;
2531
 
          int length;
2532
 
          int type;
2533
 
          struct hostent h;
2534
 
          char buffer[8192];
2535
 
          int h_errnop;
2536
 
          struct hostent * hp;
2537
 
          int rc;
2538
 
          rc = gethostbyaddr_r(address, length, type, &h,
2539
 
                               buffer, 8192, &hp, &h_errnop);
2540
 
        ]])
2541
 
      ],[
2542
 
        AC_MSG_RESULT([yes])
2543
 
        AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2544
 
        ac_cv_gethostbyaddr_r_args="8"
2545
 
      ],[
2546
 
        AC_MSG_RESULT([no])
2547
 
      ])
2548
 
    fi
2549
 
 
2550
 
    if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2551
 
      AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
2552
 
      AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
2553
 
      ac_cv_func_gethostbyaddr_r="no"
2554
 
    else
2555
 
      AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2556
 
        [Define to 1 if you have the gethostbyaddr_r function.])
2557
 
      ac_cv_func_gethostbyaddr_r="yes"
2558
 
    fi
2559
 
 
2560
 
  else
2561
 
    ac_cv_func_gethostbyaddr_r="no"
2562
 
  fi
2563
 
])
2564
 
 
2565
 
 
2566
 
dnl CURL_CHECK_GETHOSTBYNAME_R
2567
 
dnl -------------------------------------------------
2568
 
dnl check number of arguments for gethostbyname_r, it
2569
 
dnl might take either 3, 5, or 6 arguments.
2570
 
 
2571
 
AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
2572
 
  #
2573
 
  AC_MSG_CHECKING([for gethostbyname_r])
2574
 
  AC_LINK_IFELSE([
2575
 
    AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
2576
 
  ],[
2577
 
    AC_MSG_RESULT([yes])
2578
 
    tmp_cv_gethostbyname_r="yes"
2579
 
  ],[
2580
 
    AC_MSG_RESULT([no])
2581
 
    tmp_cv_gethostbyname_r="no"
2582
 
  ])
2583
 
  #
2584
 
  if test "$tmp_cv_gethostbyname_r" != "yes"; then
2585
 
    AC_MSG_CHECKING([deeper for gethostbyname_r])
2586
 
    AC_LINK_IFELSE([
2587
 
      AC_LANG_PROGRAM([[
2588
 
      ]],[[
2589
 
        gethostbyname_r();
2590
 
      ]])
2591
 
    ],[
2592
 
      AC_MSG_RESULT([yes])
2593
 
      tmp_cv_gethostbyname_r="yes"
2594
 
    ],[
2595
 
      AC_MSG_RESULT([but still no])
2596
 
      tmp_cv_gethostbyname_r="no"
2597
 
    ])
2598
 
  fi
2599
 
  #
2600
 
  if test "$tmp_cv_gethostbyname_r" = "yes"; then
2601
 
 
2602
 
    ac_cv_gethostbyname_r_args="unknown"
2603
 
 
2604
 
    AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
2605
 
    AC_COMPILE_IFELSE([
2606
 
      AC_LANG_PROGRAM([[
2607
 
#include <string.h>
2608
 
#include <sys/types.h>
2609
 
#include <netdb.h>
2610
 
#undef NULL
2611
 
#define NULL (void *)0
2612
 
        int
2613
 
        gethostbyname_r(const char *, struct hostent *,
2614
 
                        struct hostent_data *);
2615
 
      ]],[[
2616
 
        struct hostent_data data;
2617
 
        gethostbyname_r(NULL, NULL, NULL);
2618
 
      ]])
2619
 
    ],[
2620
 
      AC_MSG_RESULT([yes])
2621
 
      AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2622
 
      ac_cv_gethostbyname_r_args="3"
2623
 
    ],[
2624
 
      AC_MSG_RESULT([no])
2625
 
    ])
2626
 
 
2627
 
    if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2628
 
      AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
2629
 
      AC_COMPILE_IFELSE([
2630
 
        AC_LANG_PROGRAM([[
2631
 
#define _REENTRANT
2632
 
#include <string.h>
2633
 
#include <sys/types.h>
2634
 
#include <netdb.h>
2635
 
#undef NULL
2636
 
#define NULL (void *)0
2637
 
          int
2638
 
          gethostbyname_r(const char *, struct hostent *,
2639
 
                          struct hostent_data *);
2640
 
        ]],[[
2641
 
          struct hostent_data data;
2642
 
          gethostbyname_r(NULL, NULL, NULL);
2643
 
        ]])
2644
 
      ],[
2645
 
        AC_MSG_RESULT([yes])
2646
 
        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2647
 
        AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2648
 
        ac_cv_gethostbyname_r_args="3"
2649
 
      ],[
2650
 
        AC_MSG_RESULT([no])
2651
 
      ])
2652
 
    fi
2653
 
 
2654
 
    if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2655
 
      AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
2656
 
      AC_COMPILE_IFELSE([
2657
 
        AC_LANG_PROGRAM([[
2658
 
#include <sys/types.h>
2659
 
#include <netdb.h>
2660
 
#undef NULL
2661
 
#define NULL (void *)0
2662
 
          struct hostent *
2663
 
          gethostbyname_r(const char *, struct hostent *,
2664
 
                          char *, int, int *);
2665
 
        ]],[[
2666
 
          gethostbyname_r(NULL, NULL, NULL, 0, NULL);
2667
 
        ]])
2668
 
      ],[
2669
 
        AC_MSG_RESULT([yes])
2670
 
        AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2671
 
        ac_cv_gethostbyname_r_args="5"
2672
 
      ],[
2673
 
        AC_MSG_RESULT([no])
2674
 
      ])
2675
 
    fi
2676
 
 
2677
 
    if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2678
 
      AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
2679
 
      AC_COMPILE_IFELSE([
2680
 
        AC_LANG_PROGRAM([[
2681
 
#include <sys/types.h>
2682
 
#include <netdb.h>
2683
 
#undef NULL
2684
 
#define NULL (void *)0
2685
 
          int
2686
 
          gethostbyname_r(const char *, struct hostent *,
2687
 
                          char *, size_t, struct hostent **, int *);
2688
 
        ]],[[
2689
 
          gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
2690
 
        ]])
2691
 
      ],[
2692
 
        AC_MSG_RESULT([yes])
2693
 
        AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2694
 
        ac_cv_gethostbyname_r_args="6"
2695
 
      ],[
2696
 
        AC_MSG_RESULT([no])
2697
 
      ])
2698
 
    fi
2699
 
 
2700
 
    if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2701
 
      AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
2702
 
      AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
2703
 
      ac_cv_func_gethostbyname_r="no"
2704
 
    else
2705
 
      AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
2706
 
        [Define to 1 if you have the gethostbyname_r function.])
2707
 
      ac_cv_func_gethostbyname_r="yes"
2708
 
    fi
2709
 
 
2710
 
  else
2711
 
    ac_cv_func_gethostbyname_r="no"
2712
 
  fi
2713
 
])
2714
 
 
2715
 
 
2716
 
dnl **********************************************************************
2717
 
dnl CURL_DETECT_ICC ([ACTION-IF-YES])
2718
 
dnl
2719
 
dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
2720
 
dnl sets the $ICC variable to "yes" or "no"
2721
 
dnl **********************************************************************
2722
 
AC_DEFUN([CURL_DETECT_ICC],
2723
 
[
2724
 
    ICC="no"
2725
 
    AC_MSG_CHECKING([for icc in use])
2726
 
    if test "$GCC" = "yes"; then
2727
 
       dnl check if this is icc acting as gcc in disguise
2728
 
       AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2729
 
         dnl action if the text is found, this it has not been replaced by the
2730
 
         dnl cpp
2731
 
         ICC="no",
2732
 
         dnl the text was not found, it was replaced by the cpp
2733
 
         ICC="yes"
2734
 
         AC_MSG_RESULT([yes])
2735
 
         [$1]
2736
 
       )
2737
 
    fi
2738
 
    if test "$ICC" = "no"; then
2739
 
        # this is not ICC
2740
 
        AC_MSG_RESULT([no])
2741
 
    fi
2742
 
])
2743
 
 
2744
 
dnl We create a function for detecting which compiler we use and then set as
2745
 
dnl pendantic compiler options as possible for that particular compiler. The
2746
 
dnl options are only used for debug-builds.
2747
 
 
2748
 
AC_DEFUN([CURL_CC_DEBUG_OPTS],
2749
 
[
2750
 
    if test "z$ICC" = "z"; then
2751
 
      CURL_DETECT_ICC
2752
 
    fi
2753
 
 
2754
 
    if test "$GCC" = "yes"; then
2755
 
 
2756
 
       dnl figure out gcc version!
2757
 
       AC_MSG_CHECKING([gcc version])
2758
 
       gccver=`$CC -dumpversion`
2759
 
       num1=`echo $gccver | cut -d . -f1`
2760
 
       num2=`echo $gccver | cut -d . -f2`
2761
 
       gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
2762
 
       AC_MSG_RESULT($gccver)
2763
 
 
2764
 
       if test "$ICC" = "yes"; then
2765
 
         dnl this is icc, not gcc.
2766
 
 
2767
 
         dnl ICC warnings we ignore:
2768
 
         dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
2769
 
         dnl   "invalid format string conversion"
2770
 
         dnl * 279 warns on static conditions in while expressions
2771
 
         dnl * 981 warns on "operands are evaluated in unspecified order"
2772
 
         dnl * 1418 "external definition with no prior declaration"
2773
 
         dnl * 1419 warns on "external declaration in primary source file"
2774
 
         dnl   which we know and do on purpose.
2775
 
 
2776
 
         WARN="-wd279,269,981,1418,1419"
2777
 
 
2778
 
         if test "$gccnum" -gt "600"; then
2779
 
            dnl icc 6.0 and older doesn't have the -Wall flag
2780
 
            WARN="-Wall $WARN"
2781
 
         fi
2782
 
       else dnl $ICC = yes
2783
 
         dnl this is a set of options we believe *ALL* gcc versions support:
2784
 
         WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
2785
 
 
2786
 
         dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
2787
 
 
2788
 
         if test "$gccnum" -ge "207"; then
2789
 
           dnl gcc 2.7 or later
2790
 
           WARN="$WARN -Wmissing-declarations"
2791
 
         fi
2792
 
 
2793
 
         if test "$gccnum" -gt "295"; then
2794
 
           dnl only if the compiler is newer than 2.95 since we got lots of
2795
 
           dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
2796
 
           dnl gcc 2.95.4 on FreeBSD 4.9!
2797
 
           WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
2798
 
         fi
2799
 
 
2800
 
         if test "$gccnum" -ge "296"; then
2801
 
           dnl gcc 2.96 or later
2802
 
           WARN="$WARN -Wfloat-equal"
2803
 
         fi
2804
 
 
2805
 
         if test "$gccnum" -gt "296"; then
2806
 
           dnl this option does not exist in 2.96
2807
 
           WARN="$WARN -Wno-format-nonliteral"
2808
 
         fi
2809
 
 
2810
 
         dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
2811
 
         dnl on i686-Linux as it gives us heaps with false positives.
2812
 
         dnl Also, on gcc 4.0.X it is totally unbearable and complains all
2813
 
         dnl over making it unusable for generic purposes. Let's not use it.
2814
 
 
2815
 
         if test "$gccnum" -ge "303"; then
2816
 
           dnl gcc 3.3 and later
2817
 
           WARN="$WARN -Wendif-labels -Wstrict-prototypes"
2818
 
         fi
2819
 
 
2820
 
         if test "$gccnum" -ge "304"; then
2821
 
           # try these on gcc 3.4
2822
 
           WARN="$WARN -Wdeclaration-after-statement"
2823
 
         fi
2824
 
 
2825
 
         for flag in $CPPFLAGS; do
2826
 
           case "$flag" in
2827
 
            -I*)
2828
 
              dnl Include path, provide a -isystem option for the same dir
2829
 
              dnl to prevent warnings in those dirs. The -isystem was not very
2830
 
              dnl reliable on earlier gcc versions.
2831
 
              add=`echo $flag | sed 's/^-I/-isystem /g'`
2832
 
              WARN="$WARN $add"
2833
 
              ;;
2834
 
           esac
2835
 
         done
2836
 
 
2837
 
       fi dnl $ICC = no
2838
 
 
2839
 
       CFLAGS="$CFLAGS $WARN"
2840
 
 
2841
 
      AC_MSG_NOTICE([Added this set of compiler options: $WARN])
2842
 
 
2843
 
    else dnl $GCC = yes
2844
 
 
2845
 
      AC_MSG_NOTICE([Added no extra compiler options])
2846
 
 
2847
 
    fi dnl $GCC = yes
2848
 
 
2849
 
    dnl strip off optimizer flags
2850
 
    NEWFLAGS=""
2851
 
    for flag in $CFLAGS; do
2852
 
      case "$flag" in
2853
 
      -O*)
2854
 
        dnl echo "cut off $flag"
2855
 
        ;;
2856
 
      *)
2857
 
        NEWFLAGS="$NEWFLAGS $flag"
2858
 
        ;;
2859
 
      esac
2860
 
    done
2861
 
    CFLAGS=$NEWFLAGS
2862
 
 
2863
 
]) dnl end of AC_DEFUN()
 
2417
])
 
2418
 
2864
2419
 
2865
2420
# This is only a temporary fix. This macro is here to replace the broken one
2866
2421
# delivered by the automake project (including the 1.9.6 release). As soon as
2985
2540
dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2986
2541
dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2987
2542
dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
 
2543
dnl /usr/local/share/certs/ca-root.crt FreeBSD
 
2544
dnl /etc/ssl/cert.pem OpenBSD
2988
2545
dnl /etc/ssl/certs/ (ca path) SUSE
2989
2546
 
2990
2547
AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
3046
2603
      for a in /etc/ssl/certs/ca-certificates.crt \
3047
2604
               /etc/pki/tls/certs/ca-bundle.crt \
3048
2605
               /usr/share/ssl/certs/ca-bundle.crt \
 
2606
               /usr/local/share/certs/ca-root.crt \
 
2607
               /etc/ssl/cert.pem \
3049
2608
               "$cac"; do
3050
2609
        if test -f "$a"; then
3051
2610
          ca="$a"
3069
2628
  if test "x$ca" != "xno"; then
3070
2629
    CURL_CA_BUNDLE='"'$ca'"'
3071
2630
    AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
 
2631
    AC_SUBST(CURL_CA_BUNDLE)
3072
2632
    AC_MSG_RESULT([$ca])
3073
2633
  elif test "x$capath" != "xno"; then
3074
2634
    CURL_CA_PATH="\"$capath\""
3079
2639
  fi
3080
2640
])
3081
2641
 
 
2642
 
 
2643
dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
 
2644
dnl -------------------------------------------------
 
2645
dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
 
2646
dnl symbol that can be further used in custom template configuration
 
2647
dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
 
2648
dnl argument for the description. Symbol definitions done with this
 
2649
dnl macro are intended to be exclusively used in handcrafted *.h.in
 
2650
dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
 
2651
dnl prevents autoheader generation and insertion of symbol template
 
2652
dnl stub and definition into the first configuration header file. Do
 
2653
dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
 
2654
dnl one serves different functional needs.
 
2655
 
 
2656
AC_DEFUN([CURL_DEFINE_UNQUOTED], [
 
2657
cat >>confdefs.h <<_EOF
 
2658
[@%:@define] $1 ifelse($#, 2, [$2], 1)
 
2659
_EOF
 
2660
])
 
2661
 
 
2662
 
 
2663
dnl CURL_INCLUDES_INTTYPES
 
2664
dnl -------------------------------------------------
 
2665
dnl Set up variable with list of headers that must be
 
2666
dnl included when inttypes.h is to be included.
 
2667
 
 
2668
AC_DEFUN([CURL_INCLUDES_INTTYPES], [
 
2669
curl_includes_inttypes="\
 
2670
/* includes start */
 
2671
#ifdef HAVE_SYS_TYPES_H
 
2672
# include <sys/types.h>
 
2673
#endif
 
2674
#ifdef HAVE_STDINT_H
 
2675
# include <stdint.h>
 
2676
#endif
 
2677
#ifdef HAVE_INTTYPES_H
 
2678
# include <inttypes.h>
 
2679
#endif
 
2680
/* includes end */"
 
2681
  AC_CHECK_HEADERS(
 
2682
    sys/types.h stdint.h inttypes.h,
 
2683
    [], [], [$curl_includes_inttypes])
 
2684
])
 
2685
 
 
2686
 
 
2687
dnl CURL_CONFIGURE_LONG
 
2688
dnl -------------------------------------------------
 
2689
dnl Find out the size of long as reported by sizeof() and define
 
2690
dnl CURL_SIZEOF_LONG as appropriate to be used in template file
 
2691
dnl include/curl/curlbuild.h.in to properly configure the library.
 
2692
dnl The size of long is a build time characteristic and as such
 
2693
dnl must be recorded in curlbuild.h
 
2694
 
 
2695
AC_DEFUN([CURL_CONFIGURE_LONG], [
 
2696
  if test -z "$ac_cv_sizeof_long" ||
 
2697
    test "$ac_cv_sizeof_long" -eq "0"; then
 
2698
    AC_MSG_ERROR([cannot find out size of long.])
 
2699
  fi
 
2700
  CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
 
2701
])
 
2702
 
 
2703
 
 
2704
dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
 
2705
dnl -------------------------------------------------
 
2706
dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
 
2707
 
 
2708
AC_DEFUN([DO_CURL_OFF_T_CHECK], [
 
2709
  AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
 
2710
  if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
 
2711
    tmp_includes=""
 
2712
    tmp_source=""
 
2713
    tmp_fmt=""
 
2714
    case AS_TR_SH([$1]) in
 
2715
      int64_t)
 
2716
        tmp_includes="$curl_includes_inttypes"
 
2717
        tmp_source="char f@<:@@:>@ = PRId64;"
 
2718
        tmp_fmt="PRId64"
 
2719
        ;;
 
2720
      int32_t)
 
2721
        tmp_includes="$curl_includes_inttypes"
 
2722
        tmp_source="char f@<:@@:>@ = PRId32;"
 
2723
        tmp_fmt="PRId32"
 
2724
        ;;
 
2725
      int16_t)
 
2726
        tmp_includes="$curl_includes_inttypes"
 
2727
        tmp_source="char f@<:@@:>@ = PRId16;"
 
2728
        tmp_fmt="PRId16"
 
2729
        ;;
 
2730
    esac
 
2731
    AC_COMPILE_IFELSE([
 
2732
      AC_LANG_PROGRAM([[
 
2733
        $tmp_includes
 
2734
        typedef $1 curl_off_t;
 
2735
        typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
 
2736
      ]],[[
 
2737
        $tmp_source
 
2738
        curl_off_t dummy;
 
2739
      ]])
 
2740
    ],[
 
2741
      if test -z "$tmp_fmt"; then
 
2742
        curl_typeof_curl_off_t="$1"
 
2743
        curl_sizeof_curl_off_t="$2"
 
2744
      else
 
2745
        CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
 
2746
        AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
 
2747
        AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
 
2748
        if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
 
2749
          curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
 
2750
          curl_typeof_curl_off_t="$1"
 
2751
          curl_sizeof_curl_off_t="$2"
 
2752
        fi
 
2753
        AS_VAR_POPDEF([tmp_FmtDef])dnl
 
2754
        AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
 
2755
      fi
 
2756
    ])
 
2757
  fi
 
2758
])
 
2759
 
 
2760
 
 
2761
dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
 
2762
dnl -------------------------------------------------
 
2763
dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
 
2764
 
 
2765
AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
 
2766
  AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
 
2767
  AC_MSG_CHECKING([constant suffix string for curl_off_t])
 
2768
  #
 
2769
  curl_suffix_curl_off_t="unknown"
 
2770
  curl_suffix_curl_off_tu="unknown"
 
2771
  #
 
2772
  case AS_TR_SH([$1]) in
 
2773
    long_long | __longlong | __longlong_t)
 
2774
      tst_suffixes="LL::"
 
2775
      ;;
 
2776
    long)
 
2777
      tst_suffixes="L::"
 
2778
      ;;
 
2779
    int)
 
2780
      tst_suffixes="::"
 
2781
      ;;
 
2782
    __int64 | int64_t)
 
2783
      tst_suffixes="LL:i64::"
 
2784
      ;;
 
2785
    __int32 | int32_t)
 
2786
      tst_suffixes="L:i32::"
 
2787
      ;;
 
2788
    __int16 | int16_t)
 
2789
      tst_suffixes="L:i16::"
 
2790
      ;;
 
2791
    *)
 
2792
      AC_MSG_ERROR([unexpected data type $1])
 
2793
      ;;
 
2794
  esac
 
2795
  #
 
2796
  old_IFS=$IFS; IFS=':'
 
2797
  for tmp_ssuf in $tst_suffixes ; do
 
2798
    IFS=$old_IFS
 
2799
    if test "x$curl_suffix_curl_off_t" = "xunknown"; then
 
2800
      case $tmp_ssuf in
 
2801
        i64 | i32 | i16)
 
2802
          tmp_usuf="u$tmp_ssuf"
 
2803
          ;;
 
2804
        LL | L)
 
2805
          tmp_usuf="U$tmp_ssuf"
 
2806
          ;;
 
2807
        *)
 
2808
          tmp_usuf=""
 
2809
          ;;
 
2810
      esac
 
2811
      AC_COMPILE_IFELSE([
 
2812
        AC_LANG_PROGRAM([[
 
2813
          $curl_includes_inttypes
 
2814
          typedef $1 new_t;
 
2815
        ]],[[
 
2816
          new_t s1;
 
2817
          new_t s2;
 
2818
          s1 = -10$tmp_ssuf ;
 
2819
          s2 =  20$tmp_ssuf ;
 
2820
          if(s1 > s2)
 
2821
            return 1;
 
2822
        ]])
 
2823
      ],[
 
2824
        curl_suffix_curl_off_t="$tmp_ssuf"
 
2825
        curl_suffix_curl_off_tu="$tmp_usuf"
 
2826
      ])
 
2827
    fi
 
2828
  done
 
2829
  IFS=$old_IFS
 
2830
  #
 
2831
  if test "x$curl_suffix_curl_off_t" = "xunknown"; then
 
2832
    AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
 
2833
  else
 
2834
    AC_MSG_RESULT([$curl_suffix_curl_off_t])
 
2835
    AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
 
2836
    AC_MSG_RESULT([$curl_suffix_curl_off_tu])
 
2837
  fi
 
2838
  #
 
2839
])
 
2840
 
 
2841
 
 
2842
dnl CURL_CONFIGURE_CURL_OFF_T
 
2843
dnl -------------------------------------------------
 
2844
dnl Find out suitable curl_off_t data type definition and associated
 
2845
dnl items, and make the appropriate definitions used in template file
 
2846
dnl include/curl/curlbuild.h.in to properly configure the library.
 
2847
 
 
2848
AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
 
2849
  AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
 
2850
  #
 
2851
  AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
 
2852
  AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
 
2853
  AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
 
2854
  #
 
2855
  if test -z "$SED"; then
 
2856
    AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
 
2857
  fi
 
2858
  #
 
2859
  AC_CHECK_SIZEOF(long)
 
2860
  AC_CHECK_SIZEOF(void*)
 
2861
  #
 
2862
  if test -z "$ac_cv_sizeof_long" ||
 
2863
    test "$ac_cv_sizeof_long" -eq "0"; then
 
2864
    AC_MSG_ERROR([cannot find out size of long.])
 
2865
  fi
 
2866
  if test -z "$ac_cv_sizeof_voidp" ||
 
2867
     test "$ac_cv_sizeof_voidp" -eq "0"; then
 
2868
    AC_MSG_ERROR([cannot find out size of void*.])
 
2869
  fi
 
2870
  #
 
2871
  x_LP64_long=""
 
2872
  x_LP32_long=""
 
2873
  x_LP16_long=""
 
2874
  #
 
2875
  if test "$ac_cv_sizeof_long" -eq "8" &&
 
2876
     test "$ac_cv_sizeof_voidp" -ge "8"; then
 
2877
    x_LP64_long="long"
 
2878
  elif test "$ac_cv_sizeof_long" -eq "4" &&
 
2879
       test "$ac_cv_sizeof_voidp" -ge "4"; then
 
2880
    x_LP32_long="long"
 
2881
  elif test "$ac_cv_sizeof_long" -eq "2" &&
 
2882
       test "$ac_cv_sizeof_voidp" -ge "2"; then
 
2883
    x_LP16_long="long"
 
2884
  fi
 
2885
  #
 
2886
  dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
 
2887
  #
 
2888
  curl_typeof_curl_off_t="unknown"
 
2889
  curl_sizeof_curl_off_t="unknown"
 
2890
  curl_format_curl_off_t="unknown"
 
2891
  curl_format_curl_off_tu="unknown"
 
2892
  #
 
2893
  if test "$curl_typeof_curl_off_t" = "unknown"; then
 
2894
    AC_MSG_CHECKING([for 64-bit curl_off_t data type])
 
2895
    for t8 in          \
 
2896
      "$x_LP64_long"   \
 
2897
      'int64_t'        \
 
2898
      '__int64'        \
 
2899
      'long long'      \
 
2900
      '__longlong'     \
 
2901
      '__longlong_t'   ; do
 
2902
      DO_CURL_OFF_T_CHECK([$t8], [8])
 
2903
    done
 
2904
    AC_MSG_RESULT([$curl_typeof_curl_off_t])
 
2905
  fi
 
2906
  if test "$curl_typeof_curl_off_t" = "unknown"; then
 
2907
    AC_MSG_CHECKING([for 32-bit curl_off_t data type])
 
2908
    for t4 in          \
 
2909
      "$x_LP32_long"   \
 
2910
      'int32_t'        \
 
2911
      '__int32'        \
 
2912
      'int'            ; do
 
2913
      DO_CURL_OFF_T_CHECK([$t4], [4])
 
2914
    done 
 
2915
    AC_MSG_RESULT([$curl_typeof_curl_off_t])
 
2916
  fi
 
2917
  if test "$curl_typeof_curl_off_t" = "unknown"; then
 
2918
    AC_MSG_CHECKING([for 16-bit curl_off_t data type])
 
2919
    for t2 in          \
 
2920
      "$x_LP16_long"   \
 
2921
      'int16_t'        \
 
2922
      '__int16'        \
 
2923
      'int'            ; do
 
2924
      DO_CURL_OFF_T_CHECK([$t2], [2])
 
2925
    done
 
2926
    AC_MSG_RESULT([$curl_typeof_curl_off_t])
 
2927
  fi
 
2928
  if test "$curl_typeof_curl_off_t" = "unknown"; then
 
2929
    AC_MSG_ERROR([cannot find data type for curl_off_t.])
 
2930
  fi
 
2931
  #
 
2932
  AC_MSG_CHECKING([size of curl_off_t])
 
2933
  AC_MSG_RESULT([$curl_sizeof_curl_off_t])
 
2934
  #
 
2935
  AC_MSG_CHECKING([formatting string directive for curl_off_t])
 
2936
  if test "$curl_format_curl_off_t" != "unknown"; then
 
2937
    x_pull_headers="yes"
 
2938
    curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
 
2939
    curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
 
2940
    curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
 
2941
    curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
 
2942
  else
 
2943
    x_pull_headers="no"
 
2944
    case AS_TR_SH([$curl_typeof_curl_off_t]) in
 
2945
      long_long | __longlong | __longlong_t)
 
2946
        curl_format_curl_off_t="lld"
 
2947
        curl_format_curl_off_tu="llu"
 
2948
        ;;
 
2949
      long)
 
2950
        curl_format_curl_off_t="ld"
 
2951
        curl_format_curl_off_tu="lu"
 
2952
        ;;
 
2953
      int)
 
2954
        curl_format_curl_off_t="d"
 
2955
        curl_format_curl_off_tu="u"
 
2956
        ;;
 
2957
      __int64)
 
2958
        curl_format_curl_off_t="I64d"
 
2959
        curl_format_curl_off_tu="I64u"
 
2960
        ;;
 
2961
      __int32)
 
2962
        curl_format_curl_off_t="I32d"
 
2963
        curl_format_curl_off_tu="I32u"
 
2964
        ;;
 
2965
      __int16)
 
2966
        curl_format_curl_off_t="I16d"
 
2967
        curl_format_curl_off_tu="I16u"
 
2968
        ;;
 
2969
      *)
 
2970
        AC_MSG_ERROR([cannot find print format string for curl_off_t.])
 
2971
        ;;
 
2972
    esac
 
2973
  fi
 
2974
  AC_MSG_RESULT(["$curl_format_curl_off_t"])
 
2975
  #
 
2976
  AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
 
2977
  AC_MSG_RESULT(["$curl_format_curl_off_tu"])
 
2978
  #
 
2979
  DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
 
2980
  #
 
2981
  if test "$x_pull_headers" = "yes"; then
 
2982
    if test "x$ac_cv_header_sys_types_h" = "xyes"; then
 
2983
      CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
 
2984
    fi
 
2985
    if test "x$ac_cv_header_stdint_h" = "xyes"; then
 
2986
      CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
 
2987
    fi
 
2988
    if test "x$ac_cv_header_inttypes_h" = "xyes"; then
 
2989
      CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
 
2990
    fi
 
2991
  fi
 
2992
  #
 
2993
  CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
 
2994
  CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
 
2995
  CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
 
2996
  CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
 
2997
  CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
 
2998
  CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
 
2999
  CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
 
3000
  #
 
3001
])
 
3002
 
 
3003
 
 
3004
dnl CURL_CHECK_WIN32_LARGEFILE
 
3005
dnl -------------------------------------------------
 
3006
dnl Check if curl's WIN32 large file will be used
 
3007
 
 
3008
AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
 
3009
  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
 
3010
  AC_MSG_CHECKING([whether build target supports WIN32 file API])
 
3011
  curl_win32_file_api="no"
 
3012
  if test "$ac_cv_header_windows_h" = "yes"; then
 
3013
    if test x"$enable_largefile" != "xno"; then
 
3014
      AC_COMPILE_IFELSE([
 
3015
        AC_LANG_PROGRAM([[
 
3016
        ]],[[
 
3017
#if !defined(_WIN32_WCE) && \
 
3018
    (defined(__MINGW32__) || \
 
3019
    (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
 
3020
          int dummy=1;
 
3021
#else
 
3022
          WIN32 large file API not supported.
 
3023
#endif
 
3024
        ]])
 
3025
      ],[
 
3026
        curl_win32_file_api="win32_large_files"
 
3027
      ])
 
3028
    fi
 
3029
    if test "$curl_win32_file_api" = "no"; then
 
3030
      AC_COMPILE_IFELSE([
 
3031
        AC_LANG_PROGRAM([[
 
3032
        ]],[[
 
3033
#if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
 
3034
          int dummy=1;
 
3035
#else
 
3036
          WIN32 small file API not supported.
 
3037
#endif
 
3038
        ]])
 
3039
      ],[
 
3040
        curl_win32_file_api="win32_small_files"
 
3041
      ])
 
3042
    fi
 
3043
  fi
 
3044
  case "$curl_win32_file_api" in
 
3045
    win32_large_files)
 
3046
      AC_MSG_RESULT([yes (large file enabled)])
 
3047
      AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
 
3048
        [Define to 1 if you are building a Windows target with large file support.])
 
3049
      ;;
 
3050
    win32_small_files)
 
3051
      AC_MSG_RESULT([yes (large file disabled)])
 
3052
      AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
 
3053
        [Define to 1 if you are building a Windows target without large file support.])
 
3054
      ;;
 
3055
    *)
 
3056
      AC_MSG_RESULT([no])
 
3057
      ;;
 
3058
  esac
 
3059
])
 
3060
 
 
3061
dnl CURL_CHECK_PKGCONFIG ($module)
 
3062
dnl ------------------------
 
3063
dnl search for the pkg-config tool (if not cross-compiling). Set the PKGCONFIG
 
3064
dnl variable to hold the path to it, or 'no' if not found/present.
 
3065
dnl
 
3066
dnl If pkg-config is present, check that it has info about the $module or return
 
3067
dnl "no" anyway!
 
3068
dnl
 
3069
 
 
3070
AC_DEFUN([CURL_CHECK_PKGCONFIG], [
 
3071
  if test x$cross_compiling != xyes; then
 
3072
    dnl only do pkg-config magic when not cross-compiling
 
3073
    AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
 
3074
 
 
3075
    if test x$PKGCONFIG != xno; then
 
3076
      AC_MSG_CHECKING([for $1 options with pkg-config])
 
3077
      dnl ask pkg-config about $1
 
3078
      $PKGCONFIG --exists $1
 
3079
      if test "$?" -ne "0"; then
 
3080
        dnl pkg-config does not have info about the given module! set the
 
3081
        dnl variable to 'no'
 
3082
        PKGCONFIG="no"
 
3083
        AC_MSG_RESULT([no])
 
3084
      else
 
3085
        AC_MSG_RESULT([found])
 
3086
      fi
 
3087
    fi
 
3088
 
 
3089
  else
 
3090
    PKGCONFIG="no"
 
3091
  fi
 
3092
])