improve detection of:
[platform/upstream/curl.git] / m4 / curl-functions.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2008, 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 http://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 # $Id$
22 #***************************************************************************
23
24 # File version for 'aclocal' use. Keep it a single number.
25 # serial 8
26
27
28 dnl CURL_INCLUDES_SIGNAL
29 dnl -------------------------------------------------
30 dnl Set up variable with list of headers that must be
31 dnl included when signal.h is to be included.
32
33 AC_DEFUN([CURL_INCLUDES_SIGNAL], [
34 curl_includes_signal="\
35 /* includes start */
36 #ifdef HAVE_SYS_TYPES_H
37 #  include <sys/types.h>
38 #endif
39 #ifdef HAVE_SIGNAL_H
40 #  include <signal.h>
41 #endif
42 /* includes end */"
43   AC_CHECK_HEADERS(
44     sys/types.h signal.h,
45     [], [], [$curl_includes_signal])
46 ])
47
48
49 dnl CURL_INCLUDES_STDIO
50 dnl -------------------------------------------------
51 dnl Set up variable with list of headers that must be
52 dnl included when stdio.h is to be included.
53
54 AC_DEFUN([CURL_INCLUDES_STDIO], [
55 curl_includes_stdio="\
56 /* includes start */
57 #ifdef HAVE_SYS_TYPES_H
58 #  include <sys/types.h>
59 #endif
60 #ifdef HAVE_STDIO_H
61 #  include <stdio.h>
62 #endif
63 /* includes end */"
64   AC_CHECK_HEADERS(
65     sys/types.h stdio.h,
66     [], [], [$curl_includes_stdio])
67 ])
68
69
70 dnl CURL_INCLUDES_STDLIB
71 dnl -------------------------------------------------
72 dnl Set up variable with list of headers that must be
73 dnl included when stdlib.h is to be included.
74
75 AC_DEFUN([CURL_INCLUDES_STDLIB], [
76 curl_includes_stdlib="\
77 /* includes start */
78 #ifdef HAVE_SYS_TYPES_H
79 #  include <sys/types.h>
80 #endif
81 #ifdef HAVE_STDLIB_H
82 #  include <stdlib.h>
83 #endif
84 /* includes end */"
85   AC_CHECK_HEADERS(
86     sys/types.h stdlib.h,
87     [], [], [$curl_includes_stdlib])
88 ])
89
90
91 dnl CURL_INCLUDES_STRING
92 dnl -------------------------------------------------
93 dnl Set up variable with list of headers that must be
94 dnl included when string(s).h is to be included.
95
96 AC_DEFUN([CURL_INCLUDES_STRING], [
97 curl_includes_string="\
98 /* includes start */
99 #ifdef HAVE_SYS_TYPES_H
100 #  include <sys/types.h>
101 #endif
102 #ifdef HAVE_STRING_H
103 #  include <string.h>
104 #endif
105 #ifdef HAVE_STRINGS_H
106 #  include <strings.h>
107 #endif
108 /* includes end */"
109   AC_CHECK_HEADERS(
110     sys/types.h string.h strings.h,
111     [], [], [$curl_includes_string])
112 ])
113
114
115 dnl CURL_INCLUDES_TIME
116 dnl -------------------------------------------------
117 dnl Set up variable with list of headers that must be
118 dnl included when time.h is to be included.
119
120 AC_DEFUN([CURL_INCLUDES_TIME], [
121 AC_REQUIRE([AC_HEADER_TIME])dnl
122 curl_includes_time="\
123 /* includes start */
124 #ifdef HAVE_SYS_TYPES_H
125 #  include <sys/types.h>
126 #endif
127 #ifdef HAVE_SYS_TIME_H
128 #  include <sys/time.h>
129 #  ifdef TIME_WITH_SYS_TIME
130 #    include <time.h>
131 #  endif
132 #else
133 #  ifdef HAVE_TIME_H
134 #    include <time.h>
135 #  endif
136 #endif
137 /* includes end */"
138   AC_CHECK_HEADERS(
139     sys/types.h sys/time.h time.h,
140     [], [], [$curl_includes_time])
141 ])
142
143
144 dnl CURL_INCLUDES_UNISTD
145 dnl -------------------------------------------------
146 dnl Set up variable with list of headers that must be
147 dnl included when unistd.h is to be included.
148
149 AC_DEFUN([CURL_INCLUDES_UNISTD], [
150 curl_includes_unistd="\
151 /* includes start */
152 #ifdef HAVE_SYS_TYPES_H
153 #  include <sys/types.h>
154 #endif
155 #ifdef HAVE_UNISTD_H
156 #  include <unistd.h>
157 #endif
158 /* includes end */"
159   AC_CHECK_HEADERS(
160     sys/types.h unistd.h,
161     [], [], [$curl_includes_unistd])
162 ])
163
164
165 dnl CURL_CHECK_FUNC_FDOPEN
166 dnl -------------------------------------------------
167 dnl Verify if fdopen is available, prototyped, and
168 dnl can be compiled. If all of these are true, and
169 dnl usage has not been previously disallowed with
170 dnl shell variable curl_disallow_fdopen, then
171 dnl HAVE_FDOPEN will be defined.
172
173 AC_DEFUN([CURL_CHECK_FUNC_FDOPEN], [
174   AC_REQUIRE([CURL_INCLUDES_STDIO])dnl
175   #
176   tst_links_fdopen="unknown"
177   tst_proto_fdopen="unknown"
178   tst_compi_fdopen="unknown"
179   tst_allow_fdopen="unknown"
180   #
181   AC_MSG_CHECKING([if fdopen can be linked])
182   AC_LINK_IFELSE([
183     AC_LANG_FUNC_LINK_TRY([fdopen])
184   ],[
185     AC_MSG_RESULT([yes])
186     tst_links_fdopen="yes"
187   ],[
188     AC_MSG_RESULT([no])
189     tst_links_fdopen="no"
190   ])
191   #
192   if test "$tst_links_fdopen" = "yes"; then
193     AC_MSG_CHECKING([if fdopen is prototyped])
194     AC_EGREP_CPP([fdopen],[
195       $curl_includes_stdio
196     ],[
197       AC_MSG_RESULT([yes])
198       tst_proto_fdopen="yes"
199     ],[
200       AC_MSG_RESULT([no])
201       tst_proto_fdopen="no"
202     ])
203   fi
204   #
205   if test "$tst_proto_fdopen" = "yes"; then
206     AC_MSG_CHECKING([if fdopen is compilable])
207     AC_COMPILE_IFELSE([
208       AC_LANG_PROGRAM([[
209         $curl_includes_stdio
210       ]],[[
211         if(0 != fdopen(0, 0))
212           return 1;
213       ]])
214     ],[
215       AC_MSG_RESULT([yes])
216       tst_compi_fdopen="yes"
217     ],[
218       AC_MSG_RESULT([no])
219       tst_compi_fdopen="no"
220       dnl temporary debug tracing follows
221       echo " " >&6
222       sed 's/^/cc-fail> /' conftest.err >&6
223       echo " " >&6
224     ])
225   fi
226   #
227   if test "$tst_compi_fdopen" = "yes"; then
228     AC_MSG_CHECKING([if fdopen usage allowed])
229     if test "x$curl_disallow_fdopen" != "xyes"; then
230       AC_MSG_RESULT([yes])
231       tst_allow_fdopen="yes"
232     else
233       AC_MSG_RESULT([no])
234       tst_allow_fdopen="no"
235     fi
236   fi
237   #
238   AC_MSG_CHECKING([if fdopen might be used])
239   if test "$tst_links_fdopen" = "yes" &&
240      test "$tst_proto_fdopen" = "yes" &&
241      test "$tst_compi_fdopen" = "yes" &&
242      test "$tst_allow_fdopen" = "yes"; then
243     AC_MSG_RESULT([yes])
244     AC_DEFINE_UNQUOTED(HAVE_FDOPEN, 1,
245       [Define to 1 if you have the fdopen function.])
246     ac_cv_func_fdopen="yes"
247   else
248     AC_MSG_RESULT([no])
249     ac_cv_func_fdopen="no"
250   fi
251 ])
252
253
254 dnl CURL_CHECK_FUNC_FTRUNCATE
255 dnl -------------------------------------------------
256 dnl Verify if ftruncate is available, prototyped, and
257 dnl can be compiled. If all of these are true, and
258 dnl usage has not been previously disallowed with
259 dnl shell variable curl_disallow_ftruncate, then
260 dnl HAVE_FTRUNCATE will be defined.
261
262 AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [
263   AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
264   #
265   tst_links_ftruncate="unknown"
266   tst_proto_ftruncate="unknown"
267   tst_compi_ftruncate="unknown"
268   tst_allow_ftruncate="unknown"
269   #
270   AC_MSG_CHECKING([if ftruncate can be linked])
271   AC_LINK_IFELSE([
272     AC_LANG_FUNC_LINK_TRY([ftruncate])
273   ],[
274     AC_MSG_RESULT([yes])
275     tst_links_ftruncate="yes"
276   ],[
277     AC_MSG_RESULT([no])
278     tst_links_ftruncate="no"
279   ])
280   #
281   if test "$tst_links_ftruncate" = "yes"; then
282     AC_MSG_CHECKING([if ftruncate is prototyped])
283     AC_EGREP_CPP([ftruncate],[
284       $curl_includes_unistd
285     ],[
286       AC_MSG_RESULT([yes])
287       tst_proto_ftruncate="yes"
288     ],[
289       AC_MSG_RESULT([no])
290       tst_proto_ftruncate="no"
291     ])
292   fi
293   #
294   if test "$tst_proto_ftruncate" = "yes"; then
295     AC_MSG_CHECKING([if ftruncate is compilable])
296     AC_COMPILE_IFELSE([
297       AC_LANG_PROGRAM([[
298         $curl_includes_unistd
299       ]],[[
300         if(0 != ftruncate(0, 0))
301           return 1;
302       ]])
303     ],[
304       AC_MSG_RESULT([yes])
305       tst_compi_ftruncate="yes"
306     ],[
307       AC_MSG_RESULT([no])
308       tst_compi_ftruncate="no"
309     ])
310   fi
311   #
312   if test "$tst_compi_ftruncate" = "yes"; then
313     AC_MSG_CHECKING([if ftruncate usage allowed])
314     if test "x$curl_disallow_ftruncate" != "xyes"; then
315       AC_MSG_RESULT([yes])
316       tst_allow_ftruncate="yes"
317     else
318       AC_MSG_RESULT([no])
319       tst_allow_ftruncate="no"
320     fi
321   fi
322   #
323   AC_MSG_CHECKING([if ftruncate might be used])
324   if test "$tst_links_ftruncate" = "yes" &&
325      test "$tst_proto_ftruncate" = "yes" &&
326      test "$tst_compi_ftruncate" = "yes" &&
327      test "$tst_allow_ftruncate" = "yes"; then
328     AC_MSG_RESULT([yes])
329     AC_DEFINE_UNQUOTED(HAVE_FTRUNCATE, 1,
330       [Define to 1 if you have the ftruncate function.])
331     ac_cv_func_ftruncate="yes"
332   else
333     AC_MSG_RESULT([no])
334     ac_cv_func_ftruncate="no"
335   fi
336 ])
337
338
339 dnl CURL_CHECK_FUNC_GMTIME_R
340 dnl -------------------------------------------------
341 dnl Verify if gmtime_r is available, prototyped, can
342 dnl be compiled and seems to work. If all of these are
343 dnl true, and usage has not been previously disallowed
344 dnl with shell variable curl_disallow_gmtime_r, then
345 dnl HAVE_GMTIME_R will be defined.
346
347 AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [
348   AC_REQUIRE([CURL_INCLUDES_TIME])dnl
349   #
350   tst_links_gmtime_r="unknown"
351   tst_proto_gmtime_r="unknown"
352   tst_compi_gmtime_r="unknown"
353   tst_works_gmtime_r="unknown"
354   tst_allow_gmtime_r="unknown"
355   #
356   AC_MSG_CHECKING([if gmtime_r can be linked])
357   AC_LINK_IFELSE([
358     AC_LANG_FUNC_LINK_TRY([gmtime_r])
359   ],[
360     AC_MSG_RESULT([yes])
361     tst_links_gmtime_r="yes"
362   ],[
363     AC_MSG_RESULT([no])
364     tst_links_gmtime_r="no"
365   ])
366   #
367   if test "$tst_links_gmtime_r" = "yes"; then
368     AC_MSG_CHECKING([if gmtime_r is prototyped])
369     AC_EGREP_CPP([gmtime_r],[
370       $curl_includes_time
371     ],[
372       AC_MSG_RESULT([yes])
373       tst_proto_gmtime_r="yes"
374     ],[
375       AC_MSG_RESULT([no])
376       tst_proto_gmtime_r="no"
377     ])
378   fi
379   #
380   if test "$tst_proto_gmtime_r" = "yes"; then
381     AC_MSG_CHECKING([if gmtime_r is compilable])
382     AC_COMPILE_IFELSE([
383       AC_LANG_PROGRAM([[
384         $curl_includes_time
385       ]],[[
386         if(0 != gmtime_r(0, 0))
387           return 1;
388       ]])
389     ],[
390       AC_MSG_RESULT([yes])
391       tst_compi_gmtime_r="yes"
392     ],[
393       AC_MSG_RESULT([no])
394       tst_compi_gmtime_r="no"
395     ])
396   fi
397   #
398   dnl only do runtime verification when not cross-compiling
399   if test "x$cross_compiling" != "xyes" &&
400     test "$tst_compi_gmtime_r" = "yes"; then
401     AC_MSG_CHECKING([if gmtime_r seems to work])
402     AC_RUN_IFELSE([
403       AC_LANG_PROGRAM([[
404         $curl_includes_time
405       ]],[[
406         time_t local = 1170352587;
407         struct tm *gmt = 0;
408         struct tm result;
409         gmt = gmtime_r(&local, &result);
410         if(gmt)
411           exit(0);
412         else
413           exit(1);
414       ]])
415     ],[
416       AC_MSG_RESULT([yes])
417       tst_works_gmtime_r="yes"
418     ],[
419       AC_MSG_RESULT([no])
420       tst_works_gmtime_r="no"
421     ])
422   fi
423   #
424   if test "$tst_compi_gmtime_r" = "yes" &&
425     test "$tst_works_gmtime_r" != "no"; then
426     AC_MSG_CHECKING([if gmtime_r usage allowed])
427     if test "x$curl_disallow_gmtime_r" != "xyes"; then
428       AC_MSG_RESULT([yes])
429       tst_allow_gmtime_r="yes"
430     else
431       AC_MSG_RESULT([no])
432       tst_allow_gmtime_r="no"
433     fi
434   fi
435   #
436   AC_MSG_CHECKING([if gmtime_r might be used])
437   if test "$tst_links_gmtime_r" = "yes" &&
438      test "$tst_proto_gmtime_r" = "yes" &&
439      test "$tst_compi_gmtime_r" = "yes" &&
440      test "$tst_allow_gmtime_r" = "yes" &&
441      test "$tst_works_gmtime_r" != "no"; then
442     AC_MSG_RESULT([yes])
443     AC_DEFINE_UNQUOTED(HAVE_GMTIME_R, 1,
444       [Define to 1 if you have a working gmtime_r function.])
445     ac_cv_func_gmtime_r="yes"
446   else
447     AC_MSG_RESULT([no])
448     ac_cv_func_gmtime_r="no"
449   fi
450 ])
451
452
453 dnl CURL_CHECK_FUNC_SIGACTION
454 dnl -------------------------------------------------
455 dnl Verify if sigaction is available, prototyped, and
456 dnl can be compiled. If all of these are true, and
457 dnl usage has not been previously disallowed with
458 dnl shell variable curl_disallow_sigaction, then
459 dnl HAVE_SIGACTION will be defined.
460
461 AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [
462   AC_REQUIRE([CURL_INCLUDES_SIGNAL])dnl
463   #
464   tst_links_sigaction="unknown"
465   tst_proto_sigaction="unknown"
466   tst_compi_sigaction="unknown"
467   tst_allow_sigaction="unknown"
468   #
469   AC_MSG_CHECKING([if sigaction can be linked])
470   AC_LINK_IFELSE([
471     AC_LANG_FUNC_LINK_TRY([sigaction])
472   ],[
473     AC_MSG_RESULT([yes])
474     tst_links_sigaction="yes"
475   ],[
476     AC_MSG_RESULT([no])
477     tst_links_sigaction="no"
478   ])
479   #
480   if test "$tst_links_sigaction" = "yes"; then
481     AC_MSG_CHECKING([if sigaction is prototyped])
482     AC_EGREP_CPP([sigaction],[
483       $curl_includes_signal
484     ],[
485       AC_MSG_RESULT([yes])
486       tst_proto_sigaction="yes"
487     ],[
488       AC_MSG_RESULT([no])
489       tst_proto_sigaction="no"
490     ])
491   fi
492   #
493   if test "$tst_proto_sigaction" = "yes"; then
494     AC_MSG_CHECKING([if sigaction is compilable])
495     AC_COMPILE_IFELSE([
496       AC_LANG_PROGRAM([[
497         $curl_includes_signal
498       ]],[[
499         if(0 != sigaction(0, 0, 0))
500           return 1;
501       ]])
502     ],[
503       AC_MSG_RESULT([yes])
504       tst_compi_sigaction="yes"
505     ],[
506       AC_MSG_RESULT([no])
507       tst_compi_sigaction="no"
508     ])
509   fi
510   #
511   if test "$tst_compi_sigaction" = "yes"; then
512     AC_MSG_CHECKING([if sigaction usage allowed])
513     if test "x$curl_disallow_sigaction" != "xyes"; then
514       AC_MSG_RESULT([yes])
515       tst_allow_sigaction="yes"
516     else
517       AC_MSG_RESULT([no])
518       tst_allow_sigaction="no"
519     fi
520   fi
521   #
522   AC_MSG_CHECKING([if sigaction might be used])
523   if test "$tst_links_sigaction" = "yes" &&
524      test "$tst_proto_sigaction" = "yes" &&
525      test "$tst_compi_sigaction" = "yes" &&
526      test "$tst_allow_sigaction" = "yes"; then
527     AC_MSG_RESULT([yes])
528     AC_DEFINE_UNQUOTED(HAVE_SIGACTION, 1,
529       [Define to 1 if you have the sigaction function.])
530     ac_cv_func_sigaction="yes"
531   else
532     AC_MSG_RESULT([no])
533     ac_cv_func_sigaction="no"
534   fi
535 ])
536
537
538 dnl CURL_CHECK_FUNC_STRCASECMP
539 dnl -------------------------------------------------
540 dnl Verify if strcasecmp is available, prototyped, and
541 dnl can be compiled. If all of these are true, and
542 dnl usage has not been previously disallowed with
543 dnl shell variable curl_disallow_strcasecmp, then
544 dnl HAVE_STRCASECMP will be defined.
545
546 AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [
547   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
548   #
549   tst_links_strcasecmp="unknown"
550   tst_proto_strcasecmp="unknown"
551   tst_compi_strcasecmp="unknown"
552   tst_allow_strcasecmp="unknown"
553   #
554   AC_MSG_CHECKING([if strcasecmp can be linked])
555   AC_LINK_IFELSE([
556     AC_LANG_FUNC_LINK_TRY([strcasecmp])
557   ],[
558     AC_MSG_RESULT([yes])
559     tst_links_strcasecmp="yes"
560   ],[
561     AC_MSG_RESULT([no])
562     tst_links_strcasecmp="no"
563   ])
564   #
565   if test "$tst_links_strcasecmp" = "yes"; then
566     AC_MSG_CHECKING([if strcasecmp is prototyped])
567     AC_EGREP_CPP([strcasecmp],[
568       $curl_includes_string
569     ],[
570       AC_MSG_RESULT([yes])
571       tst_proto_strcasecmp="yes"
572     ],[
573       AC_MSG_RESULT([no])
574       tst_proto_strcasecmp="no"
575     ])
576   fi
577   #
578   if test "$tst_proto_strcasecmp" = "yes"; then
579     AC_MSG_CHECKING([if strcasecmp is compilable])
580     AC_COMPILE_IFELSE([
581       AC_LANG_PROGRAM([[
582         $curl_includes_string
583       ]],[[
584         if(0 != strcasecmp(0, 0))
585           return 1;
586       ]])
587     ],[
588       AC_MSG_RESULT([yes])
589       tst_compi_strcasecmp="yes"
590     ],[
591       AC_MSG_RESULT([no])
592       tst_compi_strcasecmp="no"
593     ])
594   fi
595   #
596   if test "$tst_compi_strcasecmp" = "yes"; then
597     AC_MSG_CHECKING([if strcasecmp usage allowed])
598     if test "x$curl_disallow_strcasecmp" != "xyes"; then
599       AC_MSG_RESULT([yes])
600       tst_allow_strcasecmp="yes"
601     else
602       AC_MSG_RESULT([no])
603       tst_allow_strcasecmp="no"
604     fi
605   fi
606   #
607   AC_MSG_CHECKING([if strcasecmp might be used])
608   if test "$tst_links_strcasecmp" = "yes" &&
609      test "$tst_proto_strcasecmp" = "yes" &&
610      test "$tst_compi_strcasecmp" = "yes" &&
611      test "$tst_allow_strcasecmp" = "yes"; then
612     AC_MSG_RESULT([yes])
613     AC_DEFINE_UNQUOTED(HAVE_STRCASECMP, 1,
614       [Define to 1 if you have the strcasecmp function.])
615     ac_cv_func_strcasecmp="yes"
616   else
617     AC_MSG_RESULT([no])
618     ac_cv_func_strcasecmp="no"
619   fi
620 ])
621
622
623 dnl CURL_CHECK_FUNC_STRCASESTR
624 dnl -------------------------------------------------
625 dnl Verify if strcasestr is available, prototyped, and
626 dnl can be compiled. If all of these are true, and
627 dnl usage has not been previously disallowed with
628 dnl shell variable curl_disallow_strcasestr, then
629 dnl HAVE_STRCASESTR will be defined.
630
631 AC_DEFUN([CURL_CHECK_FUNC_STRCASESTR], [
632   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
633   #
634   tst_links_strcasestr="unknown"
635   tst_proto_strcasestr="unknown"
636   tst_compi_strcasestr="unknown"
637   tst_allow_strcasestr="unknown"
638   #
639   AC_MSG_CHECKING([if strcasestr can be linked])
640   AC_LINK_IFELSE([
641     AC_LANG_FUNC_LINK_TRY([strcasestr])
642   ],[
643     AC_MSG_RESULT([yes])
644     tst_links_strcasestr="yes"
645   ],[
646     AC_MSG_RESULT([no])
647     tst_links_strcasestr="no"
648   ])
649   #
650   if test "$tst_links_strcasestr" = "yes"; then
651     AC_MSG_CHECKING([if strcasestr is prototyped])
652     AC_EGREP_CPP([strcasestr],[
653       $curl_includes_string
654     ],[
655       AC_MSG_RESULT([yes])
656       tst_proto_strcasestr="yes"
657     ],[
658       AC_MSG_RESULT([no])
659       tst_proto_strcasestr="no"
660     ])
661   fi
662   #
663   if test "$tst_proto_strcasestr" = "yes"; then
664     AC_MSG_CHECKING([if strcasestr is compilable])
665     AC_COMPILE_IFELSE([
666       AC_LANG_PROGRAM([[
667         $curl_includes_string
668       ]],[[
669         if(0 != strcasestr(0, 0))
670           return 1;
671       ]])
672     ],[
673       AC_MSG_RESULT([yes])
674       tst_compi_strcasestr="yes"
675     ],[
676       AC_MSG_RESULT([no])
677       tst_compi_strcasestr="no"
678     ])
679   fi
680   #
681   if test "$tst_compi_strcasestr" = "yes"; then
682     AC_MSG_CHECKING([if strcasestr usage allowed])
683     if test "x$curl_disallow_strcasestr" != "xyes"; then
684       AC_MSG_RESULT([yes])
685       tst_allow_strcasestr="yes"
686     else
687       AC_MSG_RESULT([no])
688       tst_allow_strcasestr="no"
689     fi
690   fi
691   #
692   AC_MSG_CHECKING([if strcasestr might be used])
693   if test "$tst_links_strcasestr" = "yes" &&
694      test "$tst_proto_strcasestr" = "yes" &&
695      test "$tst_compi_strcasestr" = "yes" &&
696      test "$tst_allow_strcasestr" = "yes"; then
697     AC_MSG_RESULT([yes])
698     AC_DEFINE_UNQUOTED(HAVE_STRCASESTR, 1,
699       [Define to 1 if you have the strcasestr function.])
700     ac_cv_func_strcasestr="yes"
701   else
702     AC_MSG_RESULT([no])
703     ac_cv_func_strcasestr="no"
704   fi
705 ])
706
707
708 dnl CURL_CHECK_FUNC_STRCMPI
709 dnl -------------------------------------------------
710 dnl Verify if strcmpi is available, prototyped, and
711 dnl can be compiled. If all of these are true, and
712 dnl usage has not been previously disallowed with
713 dnl shell variable curl_disallow_strcmpi, then
714 dnl HAVE_STRCMPI will be defined.
715
716 AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [
717   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
718   #
719   tst_links_strcmpi="unknown"
720   tst_proto_strcmpi="unknown"
721   tst_compi_strcmpi="unknown"
722   tst_allow_strcmpi="unknown"
723   #
724   AC_MSG_CHECKING([if strcmpi can be linked])
725   AC_LINK_IFELSE([
726     AC_LANG_FUNC_LINK_TRY([strcmpi])
727   ],[
728     AC_MSG_RESULT([yes])
729     tst_links_strcmpi="yes"
730   ],[
731     AC_MSG_RESULT([no])
732     tst_links_strcmpi="no"
733   ])
734   #
735   if test "$tst_links_strcmpi" = "yes"; then
736     AC_MSG_CHECKING([if strcmpi is prototyped])
737     AC_EGREP_CPP([strcmpi],[
738       $curl_includes_string
739     ],[
740       AC_MSG_RESULT([yes])
741       tst_proto_strcmpi="yes"
742     ],[
743       AC_MSG_RESULT([no])
744       tst_proto_strcmpi="no"
745     ])
746   fi
747   #
748   if test "$tst_proto_strcmpi" = "yes"; then
749     AC_MSG_CHECKING([if strcmpi is compilable])
750     AC_COMPILE_IFELSE([
751       AC_LANG_PROGRAM([[
752         $curl_includes_string
753       ]],[[
754         if(0 != strcmpi(0, 0))
755           return 1;
756       ]])
757     ],[
758       AC_MSG_RESULT([yes])
759       tst_compi_strcmpi="yes"
760     ],[
761       AC_MSG_RESULT([no])
762       tst_compi_strcmpi="no"
763     ])
764   fi
765   #
766   if test "$tst_compi_strcmpi" = "yes"; then
767     AC_MSG_CHECKING([if strcmpi usage allowed])
768     if test "x$curl_disallow_strcmpi" != "xyes"; then
769       AC_MSG_RESULT([yes])
770       tst_allow_strcmpi="yes"
771     else
772       AC_MSG_RESULT([no])
773       tst_allow_strcmpi="no"
774     fi
775   fi
776   #
777   AC_MSG_CHECKING([if strcmpi might be used])
778   if test "$tst_links_strcmpi" = "yes" &&
779      test "$tst_proto_strcmpi" = "yes" &&
780      test "$tst_compi_strcmpi" = "yes" &&
781      test "$tst_allow_strcmpi" = "yes"; then
782     AC_MSG_RESULT([yes])
783     AC_DEFINE_UNQUOTED(HAVE_STRCMPI, 1,
784       [Define to 1 if you have the strcmpi function.])
785     ac_cv_func_strcmpi="yes"
786   else
787     AC_MSG_RESULT([no])
788     ac_cv_func_strcmpi="no"
789   fi
790 ])
791
792
793 dnl CURL_CHECK_FUNC_STRDUP
794 dnl -------------------------------------------------
795 dnl Verify if strdup is available, prototyped, and
796 dnl can be compiled. If all of these are true, and
797 dnl usage has not been previously disallowed with
798 dnl shell variable curl_disallow_strdup, then
799 dnl HAVE_STRDUP will be defined.
800
801 AC_DEFUN([CURL_CHECK_FUNC_STRDUP], [
802   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
803   #
804   tst_links_strdup="unknown"
805   tst_proto_strdup="unknown"
806   tst_compi_strdup="unknown"
807   tst_allow_strdup="unknown"
808   #
809   AC_MSG_CHECKING([if strdup can be linked])
810   AC_LINK_IFELSE([
811     AC_LANG_FUNC_LINK_TRY([strdup])
812   ],[
813     AC_MSG_RESULT([yes])
814     tst_links_strdup="yes"
815   ],[
816     AC_MSG_RESULT([no])
817     tst_links_strdup="no"
818   ])
819   #
820   if test "$tst_links_strdup" = "yes"; then
821     AC_MSG_CHECKING([if strdup is prototyped])
822     AC_EGREP_CPP([strdup],[
823       $curl_includes_string
824     ],[
825       AC_MSG_RESULT([yes])
826       tst_proto_strdup="yes"
827     ],[
828       AC_MSG_RESULT([no])
829       tst_proto_strdup="no"
830     ])
831   fi
832   #
833   if test "$tst_proto_strdup" = "yes"; then
834     AC_MSG_CHECKING([if strdup is compilable])
835     AC_COMPILE_IFELSE([
836       AC_LANG_PROGRAM([[
837         $curl_includes_string
838       ]],[[
839         if(0 != strdup(0))
840           return 1;
841       ]])
842     ],[
843       AC_MSG_RESULT([yes])
844       tst_compi_strdup="yes"
845     ],[
846       AC_MSG_RESULT([no])
847       tst_compi_strdup="no"
848     ])
849   fi
850   #
851   if test "$tst_compi_strdup" = "yes"; then
852     AC_MSG_CHECKING([if strdup usage allowed])
853     if test "x$curl_disallow_strdup" != "xyes"; then
854       AC_MSG_RESULT([yes])
855       tst_allow_strdup="yes"
856     else
857       AC_MSG_RESULT([no])
858       tst_allow_strdup="no"
859     fi
860   fi
861   #
862   AC_MSG_CHECKING([if strdup might be used])
863   if test "$tst_links_strdup" = "yes" &&
864      test "$tst_proto_strdup" = "yes" &&
865      test "$tst_compi_strdup" = "yes" &&
866      test "$tst_allow_strdup" = "yes"; then
867     AC_MSG_RESULT([yes])
868     AC_DEFINE_UNQUOTED(HAVE_STRDUP, 1,
869       [Define to 1 if you have the strdup function.])
870     ac_cv_func_strdup="yes"
871   else
872     AC_MSG_RESULT([no])
873     ac_cv_func_strdup="no"
874   fi
875 ])
876
877
878 dnl CURL_CHECK_FUNC_STRERROR_R
879 dnl -------------------------------------------------
880 dnl Verify if strerror_r is available, prototyped, can be compiled and
881 dnl seems to work. If all of these are true, and usage has not been
882 dnl previously disallowed with shell variable curl_disallow_strerror_r,
883 dnl then HAVE_STRERROR_R and STRERROR_R_TYPE_ARG3 will be defined, as
884 dnl well as one of HAVE_GLIBC_STRERROR_R or HAVE_POSIX_STRERROR_R.
885 dnl
886 dnl glibc-style strerror_r:
887 dnl
888 dnl      char *strerror_r(int errnum, char *workbuf, size_t bufsize);
889 dnl
890 dnl  glibc-style strerror_r returns a pointer to the the error string,
891 dnl  and might use the provided workbuf as a scratch area if needed. A
892 dnl  quick test on a few systems shows that it's usually not used at all.
893 dnl
894 dnl POSIX-style strerror_r:
895 dnl
896 dnl      int strerror_r(int errnum, char *resultbuf, size_t bufsize);
897 dnl
898 dnl  POSIX-style strerror_r returns 0 upon successful completion and the
899 dnl  error string in the provided resultbuf.
900 dnl
901
902 AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [
903   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
904   #
905   tst_links_strerror_r="unknown"
906   tst_proto_strerror_r="unknown"
907   tst_compi_strerror_r="unknown"
908   tst_glibc_strerror_r="unknown"
909   tst_posix_strerror_r="unknown"
910   tst_allow_strerror_r="unknown"
911   tst_works_glibc_strerror_r="unknown"
912   tst_works_posix_strerror_r="unknown"
913   tst_glibc_strerror_r_type_arg3="unknown"
914   tst_posix_strerror_r_type_arg3="unknown"
915   #
916   AC_MSG_CHECKING([if strerror_r can be linked])
917   AC_LINK_IFELSE([
918     AC_LANG_FUNC_LINK_TRY([strerror_r])
919   ],[
920     AC_MSG_RESULT([yes])
921     tst_links_strerror_r="yes"
922   ],[
923     AC_MSG_RESULT([no])
924     tst_links_strerror_r="no"
925   ])
926   #
927   if test "$tst_links_strerror_r" = "yes"; then
928     AC_MSG_CHECKING([if strerror_r is prototyped])
929     AC_EGREP_CPP([strerror_r],[
930       $curl_includes_string
931     ],[
932       AC_MSG_RESULT([yes])
933       tst_proto_strerror_r="yes"
934     ],[
935       AC_MSG_RESULT([no])
936       tst_proto_strerror_r="no"
937     ])
938   fi
939   #
940   if test "$tst_proto_strerror_r" = "yes"; then
941     AC_MSG_CHECKING([if strerror_r is compilable])
942     AC_COMPILE_IFELSE([
943       AC_LANG_PROGRAM([[
944         $curl_includes_string
945       ]],[[
946         if(0 != strerror_r(0, 0, 0))
947           return 1;
948       ]])
949     ],[
950       AC_MSG_RESULT([yes])
951       tst_compi_strerror_r="yes"
952     ],[
953       AC_MSG_RESULT([no])
954       tst_compi_strerror_r="no"
955     ])
956   fi
957   #
958   if test "$tst_compi_strerror_r" = "yes"; then
959     AC_MSG_CHECKING([if strerror_r is glibc like])
960     tst_glibc_strerror_r_type_arg3="unknown"
961     for arg3 in 'size_t' 'int' 'unsigned int'; do
962       if test "$tst_glibc_strerror_r_type_arg3" = "unknown"; then
963         AC_COMPILE_IFELSE([
964           AC_LANG_PROGRAM([[
965             $curl_includes_string
966           ]],[[
967             char *strerror_r(int errnum, char *workbuf, $arg3 bufsize);
968             if(0 != strerror_r(0, 0, 0))
969               return 1;
970           ]])
971         ],[
972           tst_glibc_strerror_r_type_arg3="$arg3"
973         ])
974       fi
975     done
976     case "$tst_glibc_strerror_r_type_arg3" in
977       unknown)
978         AC_MSG_RESULT([no])
979         tst_glibc_strerror_r="no"
980         ;;
981       *)
982         AC_MSG_RESULT([yes])
983         tst_glibc_strerror_r="yes"
984         ;;
985     esac
986   fi
987   #
988   dnl only do runtime verification when not cross-compiling
989   if test "x$cross_compiling" != "xyes" &&
990     test "$tst_glibc_strerror_r" = "yes"; then
991     AC_MSG_CHECKING([if strerror_r seems to work])
992     AC_RUN_IFELSE([
993       AC_LANG_PROGRAM([[
994         $curl_includes_string
995 #       include <errno.h>
996       ]],[[
997         char buffer[1024];
998         char *string = 0;
999         buffer[0] = '\0';
1000         string = strerror_r(EACCES, buffer, sizeof(buffer));
1001         if(!string)
1002           exit(1); /* fail */
1003         if(!string[0])
1004           exit(1); /* fail */
1005         else
1006           exit(0);
1007       ]])
1008     ],[
1009       AC_MSG_RESULT([yes])
1010       tst_works_glibc_strerror_r="yes"
1011     ],[
1012       AC_MSG_RESULT([no])
1013       tst_works_glibc_strerror_r="no"
1014     ])
1015   fi
1016   #
1017   if test "$tst_compi_strerror_r" = "yes" &&
1018     test "$tst_works_glibc_strerror_r" != "yes"; then
1019     AC_MSG_CHECKING([if strerror_r is POSIX like])
1020     tst_posix_strerror_r_type_arg3="unknown"
1021     for arg3 in 'size_t' 'int' 'unsigned int'; do
1022       if test "$tst_posix_strerror_r_type_arg3" = "unknown"; then
1023         AC_COMPILE_IFELSE([
1024           AC_LANG_PROGRAM([[
1025             $curl_includes_string
1026           ]],[[
1027             int strerror_r(int errnum, char *resultbuf, $arg3 bufsize);
1028             if(0 != strerror_r(0, 0, 0))
1029               return 1;
1030           ]])
1031         ],[
1032           tst_posix_strerror_r_type_arg3="$arg3"
1033         ])
1034       fi
1035     done
1036     case "$tst_posix_strerror_r_type_arg3" in
1037       unknown)
1038         AC_MSG_RESULT([no])
1039         tst_posix_strerror_r="no"
1040         ;;
1041       *)
1042         AC_MSG_RESULT([yes])
1043         tst_posix_strerror_r="yes"
1044         ;;
1045     esac
1046   fi
1047   #
1048   dnl only do runtime verification when not cross-compiling
1049   if test "x$cross_compiling" != "xyes" &&
1050     test "$tst_posix_strerror_r" = "yes"; then
1051     AC_MSG_CHECKING([if strerror_r seems to work])
1052     AC_RUN_IFELSE([
1053       AC_LANG_PROGRAM([[
1054         $curl_includes_string
1055 #       include <errno.h>
1056       ]],[[
1057         char buffer[1024];
1058         int error = 1;
1059         buffer[0] = '\0';
1060         error = strerror_r(EACCES, buffer, sizeof(buffer));
1061         if(error)
1062           exit(1); /* fail */
1063         if(buffer[0] == '\0')
1064           exit(1); /* fail */
1065         else
1066           exit(0);
1067       ]])
1068     ],[
1069       AC_MSG_RESULT([yes])
1070       tst_works_posix_strerror_r="yes"
1071     ],[
1072       AC_MSG_RESULT([no])
1073       tst_works_posix_strerror_r="no"
1074     ])
1075   fi
1076   #
1077   if test "$tst_glibc_strerror_r" = "yes" &&
1078     test "$tst_works_glibc_strerror_r" != "no" &&
1079     test "$tst_posix_strerror_r" != "yes"; then
1080     tst_allow_strerror_r="check"
1081   fi
1082   if test "$tst_posix_strerror_r" = "yes" &&
1083     test "$tst_works_posix_strerror_r" != "no" &&
1084     test "$tst_glibc_strerror_r" != "yes"; then
1085     tst_allow_strerror_r="check"
1086   fi
1087   if test "$tst_allow_strerror_r" = "check"; then
1088     AC_MSG_CHECKING([if strerror_r usage allowed])
1089     if test "x$curl_disallow_strerror_r" != "xyes"; then
1090       AC_MSG_RESULT([yes])
1091       tst_allow_strerror_r="yes"
1092     else
1093       AC_MSG_RESULT([no])
1094       tst_allow_strerror_r="no"
1095     fi
1096   fi
1097   #
1098   AC_MSG_CHECKING([if strerror_r might be used])
1099   if test "$tst_links_strerror_r" = "yes" &&
1100      test "$tst_proto_strerror_r" = "yes" &&
1101      test "$tst_compi_strerror_r" = "yes" &&
1102      test "$tst_allow_strerror_r" = "yes"; then
1103     AC_MSG_RESULT([yes])
1104     if test "$tst_glibc_strerror_r" = "yes"; then
1105       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
1106         [Define to 1 if you have the strerror_r function.])
1107       AC_DEFINE_UNQUOTED(HAVE_GLIBC_STRERROR_R, 1,
1108         [Define to 1 if you have a working glibc-style strerror_r function.])
1109       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_glibc_strerror_r_type_arg3,
1110         [Define to the type of arg 3 for strerror_r.])
1111     fi
1112     if test "$tst_posix_strerror_r" = "yes"; then
1113       AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
1114         [Define to 1 if you have the strerror_r function.])
1115       AC_DEFINE_UNQUOTED(HAVE_POSIX_STRERROR_R, 1,
1116         [Define to 1 if you have a working POSIX-style strerror_r function.])
1117       AC_DEFINE_UNQUOTED(STRERROR_R_TYPE_ARG3, $tst_posix_strerror_r_type_arg3,
1118         [Define to the type of arg 3 for strerror_r.])
1119     fi
1120     ac_cv_func_strerror_r="yes"
1121   else
1122     AC_MSG_RESULT([no])
1123     ac_cv_func_strerror_r="no"
1124   fi
1125   #
1126   if test "$tst_compi_strerror_r" = "yes" &&
1127      test "$tst_allow_strerror_r" = "unknown"; then
1128     AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually.])
1129   fi
1130   #
1131 ])
1132
1133
1134 dnl CURL_CHECK_FUNC_STRICMP
1135 dnl -------------------------------------------------
1136 dnl Verify if stricmp is available, prototyped, and
1137 dnl can be compiled. If all of these are true, and
1138 dnl usage has not been previously disallowed with
1139 dnl shell variable curl_disallow_stricmp, then
1140 dnl HAVE_STRICMP will be defined.
1141
1142 AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [
1143   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1144   #
1145   tst_links_stricmp="unknown"
1146   tst_proto_stricmp="unknown"
1147   tst_compi_stricmp="unknown"
1148   tst_allow_stricmp="unknown"
1149   #
1150   AC_MSG_CHECKING([if stricmp can be linked])
1151   AC_LINK_IFELSE([
1152     AC_LANG_FUNC_LINK_TRY([stricmp])
1153   ],[
1154     AC_MSG_RESULT([yes])
1155     tst_links_stricmp="yes"
1156   ],[
1157     AC_MSG_RESULT([no])
1158     tst_links_stricmp="no"
1159   ])
1160   #
1161   if test "$tst_links_stricmp" = "yes"; then
1162     AC_MSG_CHECKING([if stricmp is prototyped])
1163     AC_EGREP_CPP([stricmp],[
1164       $curl_includes_string
1165     ],[
1166       AC_MSG_RESULT([yes])
1167       tst_proto_stricmp="yes"
1168     ],[
1169       AC_MSG_RESULT([no])
1170       tst_proto_stricmp="no"
1171     ])
1172   fi
1173   #
1174   if test "$tst_proto_stricmp" = "yes"; then
1175     AC_MSG_CHECKING([if stricmp is compilable])
1176     AC_COMPILE_IFELSE([
1177       AC_LANG_PROGRAM([[
1178         $curl_includes_string
1179       ]],[[
1180         if(0 != stricmp(0, 0))
1181           return 1;
1182       ]])
1183     ],[
1184       AC_MSG_RESULT([yes])
1185       tst_compi_stricmp="yes"
1186     ],[
1187       AC_MSG_RESULT([no])
1188       tst_compi_stricmp="no"
1189     ])
1190   fi
1191   #
1192   if test "$tst_compi_stricmp" = "yes"; then
1193     AC_MSG_CHECKING([if stricmp usage allowed])
1194     if test "x$curl_disallow_stricmp" != "xyes"; then
1195       AC_MSG_RESULT([yes])
1196       tst_allow_stricmp="yes"
1197     else
1198       AC_MSG_RESULT([no])
1199       tst_allow_stricmp="no"
1200     fi
1201   fi
1202   #
1203   AC_MSG_CHECKING([if stricmp might be used])
1204   if test "$tst_links_stricmp" = "yes" &&
1205      test "$tst_proto_stricmp" = "yes" &&
1206      test "$tst_compi_stricmp" = "yes" &&
1207      test "$tst_allow_stricmp" = "yes"; then
1208     AC_MSG_RESULT([yes])
1209     AC_DEFINE_UNQUOTED(HAVE_STRICMP, 1,
1210       [Define to 1 if you have the stricmp function.])
1211     ac_cv_func_stricmp="yes"
1212   else
1213     AC_MSG_RESULT([no])
1214     ac_cv_func_stricmp="no"
1215   fi
1216 ])
1217
1218
1219 dnl CURL_CHECK_FUNC_STRLCAT
1220 dnl -------------------------------------------------
1221 dnl Verify if strlcat is available, prototyped, and
1222 dnl can be compiled. If all of these are true, and
1223 dnl usage has not been previously disallowed with
1224 dnl shell variable curl_disallow_strlcat, then
1225 dnl HAVE_STRLCAT will be defined.
1226
1227 AC_DEFUN([CURL_CHECK_FUNC_STRLCAT], [
1228   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1229   #
1230   tst_links_strlcat="unknown"
1231   tst_proto_strlcat="unknown"
1232   tst_compi_strlcat="unknown"
1233   tst_allow_strlcat="unknown"
1234   #
1235   AC_MSG_CHECKING([if strlcat can be linked])
1236   AC_LINK_IFELSE([
1237     AC_LANG_FUNC_LINK_TRY([strlcat])
1238   ],[
1239     AC_MSG_RESULT([yes])
1240     tst_links_strlcat="yes"
1241   ],[
1242     AC_MSG_RESULT([no])
1243     tst_links_strlcat="no"
1244   ])
1245   #
1246   if test "$tst_links_strlcat" = "yes"; then
1247     AC_MSG_CHECKING([if strlcat is prototyped])
1248     AC_EGREP_CPP([strlcat],[
1249       $curl_includes_string
1250     ],[
1251       AC_MSG_RESULT([yes])
1252       tst_proto_strlcat="yes"
1253     ],[
1254       AC_MSG_RESULT([no])
1255       tst_proto_strlcat="no"
1256     ])
1257   fi
1258   #
1259   if test "$tst_proto_strlcat" = "yes"; then
1260     AC_MSG_CHECKING([if strlcat is compilable])
1261     AC_COMPILE_IFELSE([
1262       AC_LANG_PROGRAM([[
1263         $curl_includes_string
1264       ]],[[
1265         if(0 != strlcat(0, 0, 0))
1266           return 1;
1267       ]])
1268     ],[
1269       AC_MSG_RESULT([yes])
1270       tst_compi_strlcat="yes"
1271     ],[
1272       AC_MSG_RESULT([no])
1273       tst_compi_strlcat="no"
1274     ])
1275   fi
1276   #
1277   if test "$tst_compi_strlcat" = "yes"; then
1278     AC_MSG_CHECKING([if strlcat usage allowed])
1279     if test "x$curl_disallow_strlcat" != "xyes"; then
1280       AC_MSG_RESULT([yes])
1281       tst_allow_strlcat="yes"
1282     else
1283       AC_MSG_RESULT([no])
1284       tst_allow_strlcat="no"
1285     fi
1286   fi
1287   #
1288   AC_MSG_CHECKING([if strlcat might be used])
1289   if test "$tst_links_strlcat" = "yes" &&
1290      test "$tst_proto_strlcat" = "yes" &&
1291      test "$tst_compi_strlcat" = "yes" &&
1292      test "$tst_allow_strlcat" = "yes"; then
1293     AC_MSG_RESULT([yes])
1294     AC_DEFINE_UNQUOTED(HAVE_STRLCAT, 1,
1295       [Define to 1 if you have the strlcat function.])
1296     ac_cv_func_strlcat="yes"
1297   else
1298     AC_MSG_RESULT([no])
1299     ac_cv_func_strlcat="no"
1300   fi
1301 ])
1302
1303
1304 dnl CURL_CHECK_FUNC_STRNCASECMP
1305 dnl -------------------------------------------------
1306 dnl Verify if strncasecmp is available, prototyped, and
1307 dnl can be compiled. If all of these are true, and
1308 dnl usage has not been previously disallowed with
1309 dnl shell variable curl_disallow_strncasecmp, then
1310 dnl HAVE_STRNCASECMP will be defined.
1311
1312 AC_DEFUN([CURL_CHECK_FUNC_STRNCASECMP], [
1313   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1314   #
1315   tst_links_strncasecmp="unknown"
1316   tst_proto_strncasecmp="unknown"
1317   tst_compi_strncasecmp="unknown"
1318   tst_allow_strncasecmp="unknown"
1319   #
1320   AC_MSG_CHECKING([if strncasecmp can be linked])
1321   AC_LINK_IFELSE([
1322     AC_LANG_FUNC_LINK_TRY([strncasecmp])
1323   ],[
1324     AC_MSG_RESULT([yes])
1325     tst_links_strncasecmp="yes"
1326   ],[
1327     AC_MSG_RESULT([no])
1328     tst_links_strncasecmp="no"
1329   ])
1330   #
1331   if test "$tst_links_strncasecmp" = "yes"; then
1332     AC_MSG_CHECKING([if strncasecmp is prototyped])
1333     AC_EGREP_CPP([strncasecmp],[
1334       $curl_includes_string
1335     ],[
1336       AC_MSG_RESULT([yes])
1337       tst_proto_strncasecmp="yes"
1338     ],[
1339       AC_MSG_RESULT([no])
1340       tst_proto_strncasecmp="no"
1341     ])
1342   fi
1343   #
1344   if test "$tst_proto_strncasecmp" = "yes"; then
1345     AC_MSG_CHECKING([if strncasecmp is compilable])
1346     AC_COMPILE_IFELSE([
1347       AC_LANG_PROGRAM([[
1348         $curl_includes_string
1349       ]],[[
1350         if(0 != strncasecmp(0, 0, 0))
1351           return 1;
1352       ]])
1353     ],[
1354       AC_MSG_RESULT([yes])
1355       tst_compi_strncasecmp="yes"
1356     ],[
1357       AC_MSG_RESULT([no])
1358       tst_compi_strncasecmp="no"
1359     ])
1360   fi
1361   #
1362   if test "$tst_compi_strncasecmp" = "yes"; then
1363     AC_MSG_CHECKING([if strncasecmp usage allowed])
1364     if test "x$curl_disallow_strncasecmp" != "xyes"; then
1365       AC_MSG_RESULT([yes])
1366       tst_allow_strncasecmp="yes"
1367     else
1368       AC_MSG_RESULT([no])
1369       tst_allow_strncasecmp="no"
1370     fi
1371   fi
1372   #
1373   AC_MSG_CHECKING([if strncasecmp might be used])
1374   if test "$tst_links_strncasecmp" = "yes" &&
1375      test "$tst_proto_strncasecmp" = "yes" &&
1376      test "$tst_compi_strncasecmp" = "yes" &&
1377      test "$tst_allow_strncasecmp" = "yes"; then
1378     AC_MSG_RESULT([yes])
1379     AC_DEFINE_UNQUOTED(HAVE_STRNCASECMP, 1,
1380       [Define to 1 if you have the strncasecmp function.])
1381     ac_cv_func_strncasecmp="yes"
1382   else
1383     AC_MSG_RESULT([no])
1384     ac_cv_func_strncasecmp="no"
1385   fi
1386 ])
1387
1388
1389 dnl CURL_CHECK_FUNC_STRNCMPI
1390 dnl -------------------------------------------------
1391 dnl Verify if strncmpi is available, prototyped, and
1392 dnl can be compiled. If all of these are true, and
1393 dnl usage has not been previously disallowed with
1394 dnl shell variable curl_disallow_strncmpi, then
1395 dnl HAVE_STRNCMPI will be defined.
1396
1397 AC_DEFUN([CURL_CHECK_FUNC_STRNCMPI], [
1398   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1399   #
1400   tst_links_strncmpi="unknown"
1401   tst_proto_strncmpi="unknown"
1402   tst_compi_strncmpi="unknown"
1403   tst_allow_strncmpi="unknown"
1404   #
1405   AC_MSG_CHECKING([if strncmpi can be linked])
1406   AC_LINK_IFELSE([
1407     AC_LANG_FUNC_LINK_TRY([strncmpi])
1408   ],[
1409     AC_MSG_RESULT([yes])
1410     tst_links_strncmpi="yes"
1411   ],[
1412     AC_MSG_RESULT([no])
1413     tst_links_strncmpi="no"
1414   ])
1415   #
1416   if test "$tst_links_strncmpi" = "yes"; then
1417     AC_MSG_CHECKING([if strncmpi is prototyped])
1418     AC_EGREP_CPP([strncmpi],[
1419       $curl_includes_string
1420     ],[
1421       AC_MSG_RESULT([yes])
1422       tst_proto_strncmpi="yes"
1423     ],[
1424       AC_MSG_RESULT([no])
1425       tst_proto_strncmpi="no"
1426     ])
1427   fi
1428   #
1429   if test "$tst_proto_strncmpi" = "yes"; then
1430     AC_MSG_CHECKING([if strncmpi is compilable])
1431     AC_COMPILE_IFELSE([
1432       AC_LANG_PROGRAM([[
1433         $curl_includes_string
1434       ]],[[
1435         if(0 != strncmpi(0, 0))
1436           return 1;
1437       ]])
1438     ],[
1439       AC_MSG_RESULT([yes])
1440       tst_compi_strncmpi="yes"
1441     ],[
1442       AC_MSG_RESULT([no])
1443       tst_compi_strncmpi="no"
1444     ])
1445   fi
1446   #
1447   if test "$tst_compi_strncmpi" = "yes"; then
1448     AC_MSG_CHECKING([if strncmpi usage allowed])
1449     if test "x$curl_disallow_strncmpi" != "xyes"; then
1450       AC_MSG_RESULT([yes])
1451       tst_allow_strncmpi="yes"
1452     else
1453       AC_MSG_RESULT([no])
1454       tst_allow_strncmpi="no"
1455     fi
1456   fi
1457   #
1458   AC_MSG_CHECKING([if strncmpi might be used])
1459   if test "$tst_links_strncmpi" = "yes" &&
1460      test "$tst_proto_strncmpi" = "yes" &&
1461      test "$tst_compi_strncmpi" = "yes" &&
1462      test "$tst_allow_strncmpi" = "yes"; then
1463     AC_MSG_RESULT([yes])
1464     AC_DEFINE_UNQUOTED(HAVE_STRNCMPI, 1,
1465       [Define to 1 if you have the strncmpi function.])
1466     ac_cv_func_strncmpi="yes"
1467   else
1468     AC_MSG_RESULT([no])
1469     ac_cv_func_strncmpi="no"
1470   fi
1471 ])
1472
1473
1474 dnl CURL_CHECK_FUNC_STRNICMP
1475 dnl -------------------------------------------------
1476 dnl Verify if strnicmp is available, prototyped, and
1477 dnl can be compiled. If all of these are true, and
1478 dnl usage has not been previously disallowed with
1479 dnl shell variable curl_disallow_strnicmp, then
1480 dnl HAVE_STRNICMP will be defined.
1481
1482 AC_DEFUN([CURL_CHECK_FUNC_STRNICMP], [
1483   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1484   #
1485   tst_links_strnicmp="unknown"
1486   tst_proto_strnicmp="unknown"
1487   tst_compi_strnicmp="unknown"
1488   tst_allow_strnicmp="unknown"
1489   #
1490   AC_MSG_CHECKING([if strnicmp can be linked])
1491   AC_LINK_IFELSE([
1492     AC_LANG_FUNC_LINK_TRY([strnicmp])
1493   ],[
1494     AC_MSG_RESULT([yes])
1495     tst_links_strnicmp="yes"
1496   ],[
1497     AC_MSG_RESULT([no])
1498     tst_links_strnicmp="no"
1499   ])
1500   #
1501   if test "$tst_links_strnicmp" = "yes"; then
1502     AC_MSG_CHECKING([if strnicmp is prototyped])
1503     AC_EGREP_CPP([strnicmp],[
1504       $curl_includes_string
1505     ],[
1506       AC_MSG_RESULT([yes])
1507       tst_proto_strnicmp="yes"
1508     ],[
1509       AC_MSG_RESULT([no])
1510       tst_proto_strnicmp="no"
1511     ])
1512   fi
1513   #
1514   if test "$tst_proto_strnicmp" = "yes"; then
1515     AC_MSG_CHECKING([if strnicmp is compilable])
1516     AC_COMPILE_IFELSE([
1517       AC_LANG_PROGRAM([[
1518         $curl_includes_string
1519       ]],[[
1520         if(0 != strnicmp(0, 0))
1521           return 1;
1522       ]])
1523     ],[
1524       AC_MSG_RESULT([yes])
1525       tst_compi_strnicmp="yes"
1526     ],[
1527       AC_MSG_RESULT([no])
1528       tst_compi_strnicmp="no"
1529     ])
1530   fi
1531   #
1532   if test "$tst_compi_strnicmp" = "yes"; then
1533     AC_MSG_CHECKING([if strnicmp usage allowed])
1534     if test "x$curl_disallow_strnicmp" != "xyes"; then
1535       AC_MSG_RESULT([yes])
1536       tst_allow_strnicmp="yes"
1537     else
1538       AC_MSG_RESULT([no])
1539       tst_allow_strnicmp="no"
1540     fi
1541   fi
1542   #
1543   AC_MSG_CHECKING([if strnicmp might be used])
1544   if test "$tst_links_strnicmp" = "yes" &&
1545      test "$tst_proto_strnicmp" = "yes" &&
1546      test "$tst_compi_strnicmp" = "yes" &&
1547      test "$tst_allow_strnicmp" = "yes"; then
1548     AC_MSG_RESULT([yes])
1549     AC_DEFINE_UNQUOTED(HAVE_STRNICMP, 1,
1550       [Define to 1 if you have the strnicmp function.])
1551     ac_cv_func_strnicmp="yes"
1552   else
1553     AC_MSG_RESULT([no])
1554     ac_cv_func_strnicmp="no"
1555   fi
1556 ])
1557
1558
1559 dnl CURL_CHECK_FUNC_STRTOK_R
1560 dnl -------------------------------------------------
1561 dnl Verify if strtok_r is available, prototyped, and
1562 dnl can be compiled. If all of these are true, and
1563 dnl usage has not been previously disallowed with
1564 dnl shell variable curl_disallow_strtok_r, then
1565 dnl HAVE_STRTOK_R will be defined.
1566
1567 AC_DEFUN([CURL_CHECK_FUNC_STRTOK_R], [
1568   AC_REQUIRE([CURL_INCLUDES_STRING])dnl
1569   #
1570   tst_links_strtok_r="unknown"
1571   tst_proto_strtok_r="unknown"
1572   tst_compi_strtok_r="unknown"
1573   tst_allow_strtok_r="unknown"
1574   #
1575   AC_MSG_CHECKING([if strtok_r can be linked])
1576   AC_LINK_IFELSE([
1577     AC_LANG_FUNC_LINK_TRY([strtok_r])
1578   ],[
1579     AC_MSG_RESULT([yes])
1580     tst_links_strtok_r="yes"
1581   ],[
1582     AC_MSG_RESULT([no])
1583     tst_links_strtok_r="no"
1584   ])
1585   #
1586   if test "$tst_links_strtok_r" = "yes"; then
1587     AC_MSG_CHECKING([if strtok_r is prototyped])
1588     AC_EGREP_CPP([strtok_r],[
1589       $curl_includes_string
1590     ],[
1591       AC_MSG_RESULT([yes])
1592       tst_proto_strtok_r="yes"
1593     ],[
1594       AC_MSG_RESULT([no])
1595       tst_proto_strtok_r="no"
1596     ])
1597   fi
1598   #
1599   if test "$tst_proto_strtok_r" = "yes"; then
1600     AC_MSG_CHECKING([if strtok_r is compilable])
1601     AC_COMPILE_IFELSE([
1602       AC_LANG_PROGRAM([[
1603         $curl_includes_string
1604       ]],[[
1605         if(0 != strtok_r(0, 0, 0))
1606           return 1;
1607       ]])
1608     ],[
1609       AC_MSG_RESULT([yes])
1610       tst_compi_strtok_r="yes"
1611     ],[
1612       AC_MSG_RESULT([no])
1613       tst_compi_strtok_r="no"
1614       dnl temporary debug tracing follows
1615       echo " " >&6
1616       sed 's/^/cc-fail> /' conftest.err >&6
1617       echo " " >&6
1618     ])
1619   fi
1620   #
1621   if test "$tst_compi_strtok_r" = "yes"; then
1622     AC_MSG_CHECKING([if strtok_r usage allowed])
1623     if test "x$curl_disallow_strtok_r" != "xyes"; then
1624       AC_MSG_RESULT([yes])
1625       tst_allow_strtok_r="yes"
1626     else
1627       AC_MSG_RESULT([no])
1628       tst_allow_strtok_r="no"
1629     fi
1630   fi
1631   #
1632   AC_MSG_CHECKING([if strtok_r might be used])
1633   if test "$tst_links_strtok_r" = "yes" &&
1634      test "$tst_proto_strtok_r" = "yes" &&
1635      test "$tst_compi_strtok_r" = "yes" &&
1636      test "$tst_allow_strtok_r" = "yes"; then
1637     AC_MSG_RESULT([yes])
1638     AC_DEFINE_UNQUOTED(HAVE_STRTOK_R, 1,
1639       [Define to 1 if you have the strtok_r function.])
1640     ac_cv_func_strtok_r="yes"
1641   else
1642     AC_MSG_RESULT([no])
1643     ac_cv_func_strtok_r="no"
1644   fi
1645 ])
1646
1647
1648 dnl CURL_CHECK_FUNC_STRTOLL
1649 dnl -------------------------------------------------
1650 dnl Verify if strtoll is available, prototyped, and
1651 dnl can be compiled. If all of these are true, and
1652 dnl usage has not been previously disallowed with
1653 dnl shell variable curl_disallow_strtoll, then
1654 dnl HAVE_STRTOLL will be defined.
1655
1656 AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
1657   AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl
1658   #
1659   tst_links_strtoll="unknown"
1660   tst_proto_strtoll="unknown"
1661   tst_compi_strtoll="unknown"
1662   tst_allow_strtoll="unknown"
1663   #
1664   AC_MSG_CHECKING([if strtoll can be linked])
1665   AC_LINK_IFELSE([
1666     AC_LANG_FUNC_LINK_TRY([strtoll])
1667   ],[
1668     AC_MSG_RESULT([yes])
1669     tst_links_strtoll="yes"
1670   ],[
1671     AC_MSG_RESULT([no])
1672     tst_links_strtoll="no"
1673   ])
1674   #
1675   if test "$tst_links_strtoll" = "yes"; then
1676     AC_MSG_CHECKING([if strtoll is prototyped])
1677     AC_EGREP_CPP([strtoll],[
1678       $curl_includes_stdlib
1679     ],[
1680       AC_MSG_RESULT([yes])
1681       tst_proto_strtoll="yes"
1682     ],[
1683       AC_MSG_RESULT([no])
1684       tst_proto_strtoll="no"
1685     ])
1686   fi
1687   #
1688   if test "$tst_proto_strtoll" = "yes"; then
1689     AC_MSG_CHECKING([if strtoll is compilable])
1690     AC_COMPILE_IFELSE([
1691       AC_LANG_PROGRAM([[
1692         $curl_includes_stdlib
1693       ]],[[
1694         if(0 != strtoll(0, 0, 0))
1695           return 1;
1696       ]])
1697     ],[
1698       AC_MSG_RESULT([yes])
1699       tst_compi_strtoll="yes"
1700     ],[
1701       AC_MSG_RESULT([no])
1702       tst_compi_strtoll="no"
1703       dnl temporary debug tracing follows
1704       echo " " >&6
1705       sed 's/^/cc-fail> /' conftest.err >&6
1706       echo " " >&6
1707     ])
1708   fi
1709   #
1710   if test "$tst_compi_strtoll" = "yes"; then
1711     AC_MSG_CHECKING([if strtoll usage allowed])
1712     if test "x$curl_disallow_strtoll" != "xyes"; then
1713       AC_MSG_RESULT([yes])
1714       tst_allow_strtoll="yes"
1715     else
1716       AC_MSG_RESULT([no])
1717       tst_allow_strtoll="no"
1718     fi
1719   fi
1720   #
1721   AC_MSG_CHECKING([if strtoll might be used])
1722   if test "$tst_links_strtoll" = "yes" &&
1723      test "$tst_proto_strtoll" = "yes" &&
1724      test "$tst_compi_strtoll" = "yes" &&
1725      test "$tst_allow_strtoll" = "yes"; then
1726     AC_MSG_RESULT([yes])
1727     AC_DEFINE_UNQUOTED(HAVE_STRTOLL, 1,
1728       [Define to 1 if you have the strtoll function.])
1729     ac_cv_func_strtoll="yes"
1730   else
1731     AC_MSG_RESULT([no])
1732     ac_cv_func_strtoll="no"
1733   fi
1734 ])
1735
1736