1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.haxx.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21#***************************************************************************
22
23# File version for 'aclocal' use. Keep it a single number.
24# serial 19
25
26dnl CURL_CHECK_OPTION_THREADED_RESOLVER
27dnl -------------------------------------------------
28dnl Verify if configure has been invoked with option
29dnl --enable-threaded-resolver or --disable-threaded-resolver, and
30dnl set shell variable want_thres as appropriate.
31
32AC_DEFUN([CURL_CHECK_OPTION_THREADED_RESOLVER], [
33  AC_MSG_CHECKING([whether to enable the threaded resolver])
34  OPT_THRES="default"
35  AC_ARG_ENABLE(threaded_resolver,
36AC_HELP_STRING([--enable-threaded-resolver],[Enable threaded resolver])
37AC_HELP_STRING([--disable-threaded-resolver],[Disable threaded resolver]),
38  OPT_THRES=$enableval)
39  case "$OPT_THRES" in
40    no)
41      dnl --disable-threaded-resolver option used
42      want_thres="no"
43      ;;
44    *)
45      dnl configure option not specified
46      want_thres="yes"
47      ;;
48  esac
49  AC_MSG_RESULT([$want_thres])
50])
51
52dnl CURL_CHECK_OPTION_ARES
53dnl -------------------------------------------------
54dnl Verify if configure has been invoked with option
55dnl --enable-ares or --disable-ares, and
56dnl set shell variable want_ares as appropriate.
57
58AC_DEFUN([CURL_CHECK_OPTION_ARES], [
59dnl   AC_BEFORE([$0],[CURL_CHECK_OPTION_THREADS])dnl
60  AC_BEFORE([$0],[CURL_CHECK_LIB_ARES])dnl
61  AC_MSG_CHECKING([whether to enable c-ares for DNS lookups])
62  OPT_ARES="default"
63  AC_ARG_ENABLE(ares,
64AC_HELP_STRING([--enable-ares@<:@=PATH@:>@],[Enable c-ares for DNS lookups])
65AC_HELP_STRING([--disable-ares],[Disable c-ares for DNS lookups]),
66  OPT_ARES=$enableval)
67  case "$OPT_ARES" in
68    no)
69      dnl --disable-ares option used
70      want_ares="no"
71      ;;
72    default)
73      dnl configure option not specified
74      want_ares="no"
75      ;;
76    *)
77      dnl --enable-ares option used
78      want_ares="yes"
79      if test -n "$enableval" && test "$enableval" != "yes"; then
80        want_ares_path="$enableval"
81      fi
82      ;;
83  esac
84  AC_MSG_RESULT([$want_ares])
85])
86
87
88dnl CURL_CHECK_OPTION_CURLDEBUG
89dnl -------------------------------------------------
90dnl Verify if configure has been invoked with option
91dnl --enable-curldebug or --disable-curldebug, and set
92dnl shell variable want_curldebug value as appropriate.
93
94AC_DEFUN([CURL_CHECK_OPTION_CURLDEBUG], [
95  AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl
96  AC_MSG_CHECKING([whether to enable curl debug memory tracking])
97  OPT_CURLDEBUG_BUILD="default"
98  AC_ARG_ENABLE(curldebug,
99AC_HELP_STRING([--enable-curldebug],[Enable curl debug memory tracking])
100AC_HELP_STRING([--disable-curldebug],[Disable curl debug memory tracking]),
101  OPT_CURLDEBUG_BUILD=$enableval)
102  case "$OPT_CURLDEBUG_BUILD" in
103    no)
104      dnl --disable-curldebug option used
105      want_curldebug="no"
106      AC_MSG_RESULT([no])
107      ;;
108    default)
109      dnl configure's curldebug option not specified. Initially we will
110      dnl handle this as a request to use the same setting as option
111      dnl --enable-debug. IOW, initially, for debug-enabled builds
112      dnl this will be handled as a request to enable curldebug if
113      dnl possible, and for debug-disabled builds this will be handled
114      dnl as a request to disable curldebug.
115      if test "$want_debug" = "yes"; then
116        AC_MSG_RESULT([(assumed) yes])
117        AC_DEFINE(CURLDEBUG, 1, [to enable curl debug memory tracking])
118      else
119        AC_MSG_RESULT([no])
120      fi
121      want_curldebug_assumed="yes"
122      want_curldebug="$want_debug"
123      ;;
124    *)
125      dnl --enable-curldebug option used.
126      dnl The use of this option value is a request to enable curl's
127      dnl debug memory tracking for the libcurl library. This can only
128      dnl be done when some requisites are simultaneously satisfied.
129      dnl Later on, these requisites are verified and if they are not
130      dnl fully satisfied the option will be ignored and act as if
131      dnl --disable-curldebug had been given setting shell variable
132      dnl want_curldebug to 'no'.
133      want_curldebug="yes"
134      AC_DEFINE(CURLDEBUG, 1, [to enable curl debug memory tracking])
135      AC_MSG_RESULT([yes])
136      ;;
137  esac
138])
139
140
141dnl CURL_CHECK_OPTION_DEBUG
142dnl -------------------------------------------------
143dnl Verify if configure has been invoked with option
144dnl --enable-debug or --disable-debug, and set shell
145dnl variable want_debug value as appropriate.
146
147AC_DEFUN([CURL_CHECK_OPTION_DEBUG], [
148  AC_BEFORE([$0],[CURL_CHECK_OPTION_WARNINGS])dnl
149  AC_BEFORE([$0],[CURL_CHECK_OPTION_CURLDEBUG])dnl
150  AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
151  AC_MSG_CHECKING([whether to enable debug build options])
152  OPT_DEBUG_BUILD="default"
153  AC_ARG_ENABLE(debug,
154AC_HELP_STRING([--enable-debug],[Enable debug build options])
155AC_HELP_STRING([--disable-debug],[Disable debug build options]),
156  OPT_DEBUG_BUILD=$enableval)
157  case "$OPT_DEBUG_BUILD" in
158    no)
159      dnl --disable-debug option used
160      want_debug="no"
161      ;;
162    default)
163      dnl configure option not specified
164      want_debug="no"
165      ;;
166    *)
167      dnl --enable-debug option used
168      want_debug="yes"
169      AC_DEFINE(DEBUGBUILD, 1, [enable debug build options])
170      ;;
171  esac
172  AC_MSG_RESULT([$want_debug])
173])
174
175dnl CURL_CHECK_OPTION_OPTIMIZE
176dnl -------------------------------------------------
177dnl Verify if configure has been invoked with option
178dnl --enable-optimize or --disable-optimize, and set
179dnl shell variable want_optimize value as appropriate.
180
181AC_DEFUN([CURL_CHECK_OPTION_OPTIMIZE], [
182  AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
183  AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
184  AC_MSG_CHECKING([whether to enable compiler optimizer])
185  OPT_COMPILER_OPTIMIZE="default"
186  AC_ARG_ENABLE(optimize,
187AC_HELP_STRING([--enable-optimize],[Enable compiler optimizations])
188AC_HELP_STRING([--disable-optimize],[Disable compiler optimizations]),
189  OPT_COMPILER_OPTIMIZE=$enableval)
190  case "$OPT_COMPILER_OPTIMIZE" in
191    no)
192      dnl --disable-optimize option used. We will handle this as
193      dnl a request to disable compiler optimizations if possible.
194      dnl If the compiler is known CFLAGS and CPPFLAGS will be
195      dnl overridden, otherwise this can not be honored.
196      want_optimize="no"
197      AC_MSG_RESULT([no])
198      ;;
199    default)
200      dnl configure's optimize option not specified. Initially we will
201      dnl handle this as a request contrary to configure's setting
202      dnl for --enable-debug. IOW, initially, for debug-enabled builds
203      dnl this will be handled as a request to disable optimizations if
204      dnl possible, and for debug-disabled builds this will be handled
205      dnl initially as a request to enable optimizations if possible.
206      dnl Finally, if the compiler is known and CFLAGS and CPPFLAGS do
207      dnl not have any optimizer flag the request will be honored, in
208      dnl any other case the request can not be honored.
209      dnl IOW, existing optimizer flags defined in CFLAGS or CPPFLAGS
210      dnl will always take precedence over any initial assumption.
211      if test "$want_debug" = "yes"; then
212        want_optimize="assume_no"
213        AC_MSG_RESULT([(assumed) no])
214      else
215        want_optimize="assume_yes"
216        AC_MSG_RESULT([(assumed) yes])
217      fi
218      ;;
219    *)
220      dnl --enable-optimize option used. We will handle this as
221      dnl a request to enable compiler optimizations if possible.
222      dnl If the compiler is known CFLAGS and CPPFLAGS will be
223      dnl overridden, otherwise this can not be honored.
224      want_optimize="yes"
225      AC_MSG_RESULT([yes])
226      ;;
227  esac
228])
229
230
231dnl CURL_CHECK_OPTION_SYMBOL_HIDING
232dnl -------------------------------------------------
233dnl Verify if configure has been invoked with option
234dnl --enable-symbol-hiding or --disable-symbol-hiding,
235dnl setting shell variable want_symbol_hiding value.
236
237AC_DEFUN([CURL_CHECK_OPTION_SYMBOL_HIDING], [
238  AC_BEFORE([$0],[CURL_CHECK_COMPILER_SYMBOL_HIDING])dnl
239  AC_MSG_CHECKING([whether to enable hiding of library internal symbols])
240  OPT_SYMBOL_HIDING="default"
241  AC_ARG_ENABLE(symbol-hiding,
242AC_HELP_STRING([--enable-symbol-hiding],[Enable hiding of library internal symbols])
243AC_HELP_STRING([--disable-symbol-hiding],[Disable hiding of library internal symbols]),
244  OPT_SYMBOL_HIDING=$enableval)
245  AC_ARG_ENABLE(hidden-symbols,
246AC_HELP_STRING([--enable-hidden-symbols],[To be deprecated, use --enable-symbol-hiding])
247AC_HELP_STRING([--disable-hidden-symbols],[To be deprecated, use --disable-symbol-hiding]),
248  OPT_SYMBOL_HIDING=$enableval)
249  case "$OPT_SYMBOL_HIDING" in
250    no)
251      dnl --disable-symbol-hiding option used.
252      dnl This is an indication to not attempt hiding of library internal
253      dnl symbols. Default symbol visibility will be used, which normally
254      dnl exposes all library internal symbols.
255      want_symbol_hiding="no"
256      AC_MSG_RESULT([no])
257      ;;
258    default)
259      dnl configure's symbol-hiding option not specified.
260      dnl Handle this as if --enable-symbol-hiding option was given.
261      want_symbol_hiding="yes"
262      AC_MSG_RESULT([yes])
263      ;;
264    *)
265      dnl --enable-symbol-hiding option used.
266      dnl This is an indication to attempt hiding of library internal
267      dnl symbols. This is only supported on some compilers/linkers.
268      want_symbol_hiding="yes"
269      AC_MSG_RESULT([yes])
270      ;;
271  esac
272])
273
274
275dnl CURL_CHECK_OPTION_THREADS
276dnl -------------------------------------------------
277dnl Verify if configure has been invoked with option
278dnl --enable-threads or --disable-threads, and
279dnl set shell variable want_threads as appropriate.
280
281dnl AC_DEFUN([CURL_CHECK_OPTION_THREADS], [
282dnl   AC_BEFORE([$0],[CURL_CHECK_LIB_THREADS])dnl
283dnl   AC_MSG_CHECKING([whether to enable threads for DNS lookups])
284dnl   OPT_THREADS="default"
285dnl   AC_ARG_ENABLE(threads,
286dnl AC_HELP_STRING([--enable-threads@<:@=PATH@:>@],[Enable threads for DNS lookups])
287dnl AC_HELP_STRING([--disable-threads],[Disable threads for DNS lookups]),
288dnl   OPT_THREADS=$enableval)
289dnl   case "$OPT_THREADS" in
290dnl     no)
291dnl       dnl --disable-threads option used
292dnl       want_threads="no"
293dnl       AC_MSG_RESULT([no])
294dnl       ;;
295dnl     default)
296dnl       dnl configure option not specified
297dnl       want_threads="no"
298dnl       AC_MSG_RESULT([(assumed) no])
299dnl       ;;
300dnl     *)
301dnl       dnl --enable-threads option used
302dnl       want_threads="yes"
303dnl       want_threads_path="$enableval"
304dnl       AC_MSG_RESULT([yes])
305dnl       ;;
306dnl   esac
307dnl   #
308dnl   if test "$want_ares" = "assume_yes"; then
309dnl     if test "$want_threads" = "yes"; then
310dnl       AC_MSG_CHECKING([whether to ignore c-ares enabling assumed setting])
311dnl       AC_MSG_RESULT([yes])
312dnl       want_ares="no"
313dnl     else
314dnl       want_ares="yes"
315dnl     fi
316dnl   fi
317dnl   if test "$want_threads" = "yes" && test "$want_ares" = "yes"; then
318dnl     AC_MSG_ERROR([options --enable-ares and --enable-threads are mutually exclusive, at most one may be enabled.])
319dnl   fi
320dnl ])
321
322dnl CURL_CHECK_OPTION_RT
323dnl -------------------------------------------------
324dnl Verify if configure has been invoked with option
325dnl --disable-rt and set shell variable dontwant_rt
326dnl as appropriate.
327
328AC_DEFUN([CURL_CHECK_OPTION_RT], [
329  AC_BEFORE([$0], [CURL_CHECK_LIB_THREADS])dnl
330  AC_MSG_CHECKING([whether to disable dependency on -lrt])
331  OPT_RT="default"
332  AC_ARG_ENABLE(rt,
333 AC_HELP_STRING([--disable-rt],[disable dependency on -lrt]),
334  OPT_RT=$enableval)
335  case "$OPT_RT" in
336    no)
337      dnl --disable-rt used (reverse logic)
338      dontwant_rt="yes"
339      AC_MSG_RESULT([yes])
340      ;;
341    default)
342      dnl configure option not specified (so not disabled)
343      dontwant_rt="no"
344      AC_MSG_RESULT([(assumed no)])
345      ;;
346    *)
347      dnl --enable-rt option used (reverse logic)
348      dontwant_rt="no"
349      AC_MSG_RESULT([no])
350      ;;
351  esac
352])
353
354dnl CURL_CHECK_OPTION_WARNINGS
355dnl -------------------------------------------------
356dnl Verify if configure has been invoked with option
357dnl --enable-warnings or --disable-warnings, and set
358dnl shell variable want_warnings as appropriate.
359
360AC_DEFUN([CURL_CHECK_OPTION_WARNINGS], [
361  AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
362  AC_BEFORE([$0],[CURL_CHECK_OPTION_WERROR])dnl
363  AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
364  AC_MSG_CHECKING([whether to enable strict compiler warnings])
365  OPT_COMPILER_WARNINGS="default"
366  AC_ARG_ENABLE(warnings,
367AC_HELP_STRING([--enable-warnings],[Enable strict compiler warnings])
368AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
369  OPT_COMPILER_WARNINGS=$enableval)
370  case "$OPT_COMPILER_WARNINGS" in
371    no)
372      dnl --disable-warnings option used
373      want_warnings="no"
374      ;;
375    default)
376      dnl configure option not specified, so
377      dnl use same setting as --enable-debug
378      want_warnings="$want_debug"
379      ;;
380    *)
381      dnl --enable-warnings option used
382      want_warnings="yes"
383      ;;
384  esac
385  AC_MSG_RESULT([$want_warnings])
386])
387
388dnl CURL_CHECK_OPTION_WERROR
389dnl -------------------------------------------------
390dnl Verify if configure has been invoked with option
391dnl --enable-werror or --disable-werror, and set
392dnl shell variable want_werror as appropriate.
393
394AC_DEFUN([CURL_CHECK_OPTION_WERROR], [
395  AC_BEFORE([$0],[CURL_CHECK_COMPILER])dnl
396  AC_MSG_CHECKING([whether to enable compiler warnings as errors])
397  OPT_COMPILER_WERROR="default"
398  AC_ARG_ENABLE(werror,
399AC_HELP_STRING([--enable-werror],[Enable compiler warnings as errors])
400AC_HELP_STRING([--disable-werror],[Disable compiler warnings as errors]),
401  OPT_COMPILER_WERROR=$enableval)
402  case "$OPT_COMPILER_WERROR" in
403    no)
404      dnl --disable-werror option used
405      want_werror="no"
406      ;;
407    default)
408      dnl configure option not specified
409      want_werror="no"
410      ;;
411    *)
412      dnl --enable-werror option used
413      want_werror="yes"
414      ;;
415  esac
416  AC_MSG_RESULT([$want_werror])
417])
418
419
420dnl CURL_CHECK_NONBLOCKING_SOCKET
421dnl -------------------------------------------------
422dnl Check for how to set a socket into non-blocking state.
423
424AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
425  AC_REQUIRE([CURL_CHECK_FUNC_FCNTL])dnl
426  AC_REQUIRE([CURL_CHECK_FUNC_IOCTL])dnl
427  AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET])dnl
428  AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl
429  AC_REQUIRE([CURL_CHECK_FUNC_SETSOCKOPT])dnl
430  #
431  tst_method="unknown"
432
433  AC_MSG_CHECKING([how to set a socket into non-blocking mode])
434  if test "x$curl_cv_func_fcntl_o_nonblock" = "xyes"; then
435    tst_method="fcntl O_NONBLOCK"
436  elif test "x$curl_cv_func_ioctl_fionbio" = "xyes"; then
437    tst_method="ioctl FIONBIO"
438  elif test "x$curl_cv_func_ioctlsocket_fionbio" = "xyes"; then
439    tst_method="ioctlsocket FIONBIO"
440  elif test "x$curl_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then
441    tst_method="IoctlSocket FIONBIO"
442  elif test "x$curl_cv_func_setsockopt_so_nonblock" = "xyes"; then
443    tst_method="setsockopt SO_NONBLOCK"
444  fi
445  AC_MSG_RESULT([$tst_method])
446  if test "$tst_method" = "unknown"; then
447    AC_MSG_WARN([cannot determine non-blocking socket method.])
448  fi
449])
450
451
452dnl CURL_CONFIGURE_SYMBOL_HIDING
453dnl -------------------------------------------------
454dnl Depending on --enable-symbol-hiding or --disable-symbol-hiding
455dnl configure option, and compiler capability to actually honor such
456dnl option, this will modify compiler flags as appropriate and also
457dnl provide needed definitions for configuration and Makefile.am files.
458dnl This macro should not be used until all compilation tests have
459dnl been done to prevent interferences on other tests.
460
461AC_DEFUN([CURL_CONFIGURE_SYMBOL_HIDING], [
462  AC_MSG_CHECKING([whether hiding of library internal symbols will actually happen])
463  CFLAG_CURL_SYMBOL_HIDING=""
464  doing_symbol_hiding="no"
465  if test x"$curl_cv_native_windows" != "xyes" &&
466    test "$want_symbol_hiding" = "yes" &&
467    test "$supports_symbol_hiding" = "yes"; then
468    doing_symbol_hiding="yes"
469    CFLAG_CURL_SYMBOL_HIDING="$symbol_hiding_CFLAGS"
470    AC_DEFINE_UNQUOTED(CURL_EXTERN_SYMBOL, $symbol_hiding_EXTERN,
471      [Definition to make a library symbol externally visible.])
472    AC_MSG_RESULT([yes])
473  else
474    AC_MSG_RESULT([no])
475  fi
476  AM_CONDITIONAL(DOING_CURL_SYMBOL_HIDING, test x$doing_symbol_hiding = xyes)
477  AC_SUBST(CFLAG_CURL_SYMBOL_HIDING)
478])
479
480
481dnl CURL_CHECK_LIB_ARES
482dnl -------------------------------------------------
483dnl When c-ares library support has been requested,
484dnl performs necessary checks and adjustsments needed
485dnl to enable support of this library.
486
487AC_DEFUN([CURL_CHECK_LIB_ARES], [
488  #
489  if test "$want_ares" = "yes"; then
490    dnl c-ares library support has been requested
491    clean_CPPFLAGS="$CPPFLAGS"
492    clean_LDFLAGS="$LDFLAGS"
493    clean_LIBS="$LIBS"
494    embedded_ares="unknown"
495    configure_runpath=`pwd`
496    embedded_ares_builddir="$configure_runpath/ares"
497    if test -n "$want_ares_path"; then
498      dnl c-ares library path has been specified
499      ARES_PCDIR="$want_ares_path/lib/pkgconfig"
500      CURL_CHECK_PKGCONFIG(libcares, [$ARES_PCDIR])
501      if test "$PKGCONFIG" != "no" ; then
502        ares_LIBS=`CURL_EXPORT_PCDIR([$ARES_PCDIR])
503          $PKGCONFIG --libs-only-l libcares`
504        ares_LDFLAGS=`CURL_EXPORT_PCDIR([$ARES_PCDIR])
505          $PKGCONFIG --libs-only-L libcares`
506        ares_CPPFLAGS=`CURL_EXPORT_PCDIR([$ARES_PCDIR])
507          $PKGCONFIG --cflags-only-I libcares`
508        AC_MSG_NOTICE([pkg-config: ares LIBS: "$ares_LIBS"])
509        AC_MSG_NOTICE([pkg-config: ares LDFLAGS: "$ares_LDFLAGS"])
510        AC_MSG_NOTICE([pkg-config: ares CPPFLAGS: "$ares_CPPFLAGS"])
511      else
512        dnl ... path without pkg-config
513        ares_CPPFLAGS="-I$want_ares_path/include"
514        ares_LDFLAGS="-L$want_ares_path/lib"
515        ares_LIBS="-lcares"
516      fi
517    else
518      dnl c-ares library path has not been given
519      if test -d "$srcdir/ares"; then
520        dnl c-ares sources embedded in curl tree
521        embedded_ares="yes"
522        AC_CONFIG_SUBDIRS(ares)
523        dnl c-ares has installable configured header files, path
524        dnl inclusion fully done in makefiles for in-tree builds.
525        ares_CPPFLAGS=""
526        ares_LDFLAGS="-L$embedded_ares_builddir"
527        ares_LIBS="-lcares"
528      else
529        dnl c-ares path not specified, use defaults
530        CURL_CHECK_PKGCONFIG(libcares)
531        if test "$PKGCONFIG" != "no" ; then
532          ares_LIBS=`$PKGCONFIG --libs-only-l libcares`
533          ares_LDFLAGS=`$PKGCONFIG --libs-only-L libcares`
534          ares_CPPFLAGS=`$PKGCONFIG --cflags-only-I libcares`
535          AC_MSG_NOTICE([pkg-config: ares_LIBS: "$ares_LIBS"])
536          AC_MSG_NOTICE([pkg-config: ares_LDFLAGS: "$ares_LDFLAGS"])
537          AC_MSG_NOTICE([pkg-config: ares_CPPFLAGS: "$ares_CPPFLAGS"])
538        else
539          ares_CPPFLAGS=""
540          ares_LDFLAGS=""
541          ares_LIBS="-lcares"
542        fi
543      fi
544    fi
545    #
546    CPPFLAGS="$clean_CPPFLAGS $ares_CPPFLAGS"
547    LDFLAGS="$clean_LDFLAGS $ares_LDFLAGS"
548    LIBS="$ares_LIBS $clean_LIBS"
549    #
550    if test "$embedded_ares" != "yes"; then
551      dnl check if c-ares new enough when not using an embedded
552      dnl source tree one which normally has not been built yet.
553      AC_MSG_CHECKING([that c-ares is good and recent enough])
554      AC_LINK_IFELSE([
555        AC_LANG_PROGRAM([[
556#include <ares.h>
557          /* set of dummy functions in case c-ares was built with debug */
558          void curl_dofree() { }
559          void curl_sclose() { }
560          void curl_domalloc() { }
561          void curl_docalloc() { }
562          void curl_socket() { }
563        ]],[[
564          ares_channel channel;
565          ares_cancel(channel); /* added in 1.2.0 */
566          ares_process_fd(channel, 0, 0); /* added in 1.4.0 */
567          ares_dup(&channel, channel); /* added in 1.6.0 */
568        ]])
569      ],[
570        AC_MSG_RESULT([yes])
571      ],[
572        AC_MSG_RESULT([no])
573        AC_MSG_ERROR([c-ares library defective or too old])
574        dnl restore initial settings
575        CPPFLAGS="$clean_CPPFLAGS"
576        LDFLAGS="$clean_LDFLAGS"
577        LIBS="$clean_LIBS"
578        # prevent usage
579        want_ares="no"
580      ])
581    fi
582    if test "$want_ares" = "yes"; then
583      dnl finally c-ares will be used
584      AC_DEFINE(USE_ARES, 1, [Define to enable c-ares support])
585      AC_SUBST([USE_ARES], [1])
586      curl_res_msg="c-ares"
587    fi
588  fi
589])
590
591
592dnl CURL_CHECK_OPTION_NTLM_WB
593dnl -------------------------------------------------
594dnl Verify if configure has been invoked with option
595dnl --enable-ntlm-wb or --disable-ntlm-wb, and set
596dnl shell variable want_ntlm_wb and want_ntlm_wb_file
597dnl as appropriate.
598
599AC_DEFUN([CURL_CHECK_OPTION_NTLM_WB], [
600  AC_BEFORE([$0],[CURL_CHECK_NTLM_WB])dnl
601  OPT_NTLM_WB="default"
602  AC_ARG_ENABLE(ntlm-wb,
603AC_HELP_STRING([--enable-ntlm-wb@<:@=FILE@:>@],[Enable NTLM delegation to winbind's ntlm_auth helper, where FILE is ntlm_auth's absolute filename (default: /usr/bin/ntlm_auth)])
604AC_HELP_STRING([--disable-ntlm-wb],[Disable NTLM delegation to winbind's ntlm_auth helper]),
605  OPT_NTLM_WB=$enableval)
606  want_ntlm_wb_file="/usr/bin/ntlm_auth"
607  case "$OPT_NTLM_WB" in
608    no)
609      dnl --disable-ntlm-wb option used
610      want_ntlm_wb="no"
611      ;;
612    default)
613      dnl configure option not specified
614      want_ntlm_wb="yes"
615      ;;
616    *)
617      dnl --enable-ntlm-wb option used
618      want_ntlm_wb="yes"
619      if test -n "$enableval" && test "$enableval" != "yes"; then
620        want_ntlm_wb_file="$enableval"
621      fi
622      ;;
623  esac
624])
625
626
627dnl CURL_CHECK_NTLM_WB
628dnl -------------------------------------------------
629dnl Check if support for NTLM delegation to winbind's
630dnl ntlm_auth helper will finally be enabled depending
631dnl on given configure options and target platform.
632
633AC_DEFUN([CURL_CHECK_NTLM_WB], [
634  AC_REQUIRE([CURL_CHECK_OPTION_NTLM_WB])dnl
635  AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
636  AC_MSG_CHECKING([whether to enable NTLM delegation to winbind's helper])
637  if test "$curl_cv_native_windows" = "yes" ||
638    test "x$SSL_ENABLED" = "x"; then
639    want_ntlm_wb_file=""
640    want_ntlm_wb="no"
641  fi
642  AC_MSG_RESULT([$want_ntlm_wb])
643  if test "$want_ntlm_wb" = "yes"; then
644    AC_DEFINE(NTLM_WB_ENABLED, 1,
645      [Define to enable NTLM delegation to winbind's ntlm_auth helper.])
646    AC_DEFINE_UNQUOTED(NTLM_WB_FILE, "$want_ntlm_wb_file",
647      [Define absolute filename for winbind's ntlm_auth helper.])
648    NTLM_WB_ENABLED=1
649  fi
650])
651
652dnl CURL_CHECK_OPTION_ECH
653dnl -----------------------------------------------------
654dnl Verify whether configure has been invoked with option
655dnl --enable-ech or --disable-ech, and set
656dnl shell variable want_ech as appropriate.
657
658AC_DEFUN([CURL_CHECK_OPTION_ECH], [
659  AC_MSG_CHECKING([whether to enable ECH support])
660  OPT_ECH="default"
661  AC_ARG_ENABLE(ech,
662AC_HELP_STRING([--enable-ech],[Enable ECH support])
663AC_HELP_STRING([--disable-ech],[Disable ECH support]),
664  OPT_ECH=$enableval)
665  case "$OPT_ECH" in
666    no)
667      dnl --disable-ech option used
668      want_ech="no"
669      curl_ech_msg="no      (--enable-ech)"
670      AC_MSG_RESULT([no])
671      ;;
672    default)
673      dnl configure option not specified
674      want_ech="no"
675      curl_ech_msg="no      (--enable-ech)"
676      AC_MSG_RESULT([no])
677      ;;
678    *)
679      dnl --enable-ech option used
680      want_ech="yes"
681      curl_ech_msg="enabled (--disable-ech)"
682      experimental="ech"
683      AC_MSG_RESULT([yes])
684      ;;
685  esac
686])
687