blob: 135036a742fa15207ce6452aa00b681090cc511f [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#***************************************************************************
2#
3# Copyright (C) 2008 - 2013 by Daniel Stenberg et al
4#
5# Permission to use, copy, modify, and distribute this software and its
6# documentation for any purpose and without fee is hereby granted, provided
7# that the above copyright notice appear in all copies and that both that
8# copyright notice and this permission notice appear in supporting
9# documentation, and that the name of M.I.T. not be used in advertising or
10# publicity pertaining to distribution of the software without specific,
11# written prior permission. M.I.T. makes no representations about the
12# suitability of this software for any purpose. It is provided "as is"
13# without express or implied warranty.
14#
15#***************************************************************************
16
17# File version for 'aclocal' use. Keep it a single number.
18# serial 11
19
20
21dnl CARES_CHECK_OPTION_CURLDEBUG
22dnl -------------------------------------------------
23dnl Verify if configure has been invoked with option
24dnl --enable-curldebug or --disable-curldebug, and set
25dnl shell variable want_curldebug value as appropriate.
26
27AC_DEFUN([CARES_CHECK_OPTION_CURLDEBUG], [
28 AC_BEFORE([$0],[CARES_CHECK_CURLDEBUG])dnl
29 AC_MSG_CHECKING([whether to enable curl debug memory tracking])
30 OPT_CURLDEBUG_BUILD="default"
31 AC_ARG_ENABLE(curldebug,
32AC_HELP_STRING([--enable-curldebug],[Enable curl debug memory tracking])
33AC_HELP_STRING([--disable-curldebug],[Disable curl debug memory tracking]),
34 OPT_CURLDEBUG_BUILD=$enableval)
35 case "$OPT_CURLDEBUG_BUILD" in
36 no)
37 dnl --disable-curldebug option used
38 want_curldebug="no"
39 ;;
40 default)
41 dnl configure option not specified
42 want_curldebug="no"
43 ;;
44 *)
45 dnl --enable-curldebug option used.
46 dnl The use of this option value is a request to enable curl's
47 dnl debug memory tracking for the c-ares library. This is a big
48 dnl hack that can only be done when a whole bunch of requisites
49 dnl are simultaneously satisfied. Later on, these requisites are
50 dnl verified and if they are not fully satisfied the option will
51 dnl be ignored and act as if --disable-curldebug had been given
52 dnl setting shell variable want_curldebug to 'no'.
53 want_curldebug="yes"
54 ;;
55 esac
56 AC_MSG_RESULT([$want_curldebug])
57])
58
59
60dnl CARES_CHECK_OPTION_DEBUG
61dnl -------------------------------------------------
62dnl Verify if configure has been invoked with option
63dnl --enable-debug or --disable-debug, and set shell
64dnl variable want_debug value as appropriate.
65
66AC_DEFUN([CARES_CHECK_OPTION_DEBUG], [
67 AC_BEFORE([$0],[CARES_CHECK_OPTION_WARNINGS])dnl
68 AC_BEFORE([$0],[CARES_CHECK_OPTION_CURLDEBUG])dnl
69 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
70 AC_MSG_CHECKING([whether to enable debug build options])
71 OPT_DEBUG_BUILD="default"
72 AC_ARG_ENABLE(debug,
73AC_HELP_STRING([--enable-debug],[Enable debug build options])
74AC_HELP_STRING([--disable-debug],[Disable debug build options]),
75 OPT_DEBUG_BUILD=$enableval)
76 case "$OPT_DEBUG_BUILD" in
77 no)
78 dnl --disable-debug option used
79 want_debug="no"
80 ;;
81 default)
82 dnl configure option not specified
83 want_debug="no"
84 ;;
85 *)
86 dnl --enable-debug option used
87 want_debug="yes"
88 ;;
89 esac
90 AC_MSG_RESULT([$want_debug])
91])
92
93
94dnl CARES_CHECK_OPTION_NONBLOCKING
95dnl -------------------------------------------------
96dnl Verify if configure has been invoked with option
97dnl --enable-nonblocking or --disable-nonblocking, and
98dnl set shell variable want_nonblocking as appropriate.
99
100AC_DEFUN([CARES_CHECK_OPTION_NONBLOCKING], [
101 AC_BEFORE([$0],[CARES_CHECK_NONBLOCKING_SOCKET])dnl
102 AC_MSG_CHECKING([whether to enable non-blocking communications])
103 OPT_NONBLOCKING="default"
104 AC_ARG_ENABLE(nonblocking,
105AC_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications])
106AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking communications]),
107 OPT_NONBLOCKING=$enableval)
108 case "$OPT_NONBLOCKING" in
109 no)
110 dnl --disable-nonblocking option used
111 want_nonblocking="no"
112 ;;
113 default)
114 dnl configure option not specified
115 want_nonblocking="yes"
116 ;;
117 *)
118 dnl --enable-nonblocking option used
119 want_nonblocking="yes"
120 ;;
121 esac
122 AC_MSG_RESULT([$want_nonblocking])
123])
124
125
126dnl CARES_CHECK_OPTION_OPTIMIZE
127dnl -------------------------------------------------
128dnl Verify if configure has been invoked with option
129dnl --enable-optimize or --disable-optimize, and set
130dnl shell variable want_optimize value as appropriate.
131
132AC_DEFUN([CARES_CHECK_OPTION_OPTIMIZE], [
133 AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl
134 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
135 AC_MSG_CHECKING([whether to enable compiler optimizer])
136 OPT_COMPILER_OPTIMIZE="default"
137 AC_ARG_ENABLE(optimize,
138AC_HELP_STRING([--enable-optimize(=OPT)],[Enable compiler optimizations (default=-O2)])
139AC_HELP_STRING([--disable-optimize],[Disable compiler optimizations]),
140 OPT_COMPILER_OPTIMIZE=$enableval)
141 case "$OPT_COMPILER_OPTIMIZE" in
142 no)
143 dnl --disable-optimize option used. We will handle this as
144 dnl a request to disable compiler optimizations if possible.
145 dnl If the compiler is known CFLAGS and CPPFLAGS will be
146 dnl overridden, otherwise this can not be honored.
147 want_optimize="no"
148 AC_MSG_RESULT([no])
149 ;;
150 default)
151 dnl configure's optimize option not specified. Initially we will
152 dnl handle this as a a request contrary to configure's setting
153 dnl for --enable-debug. IOW, initially, for debug-enabled builds
154 dnl this will be handled as a request to disable optimizations if
155 dnl possible, and for debug-disabled builds this will be handled
156 dnl initially as a request to enable optimizations if possible.
157 dnl Finally, if the compiler is known and CFLAGS and CPPFLAGS do
158 dnl not have any optimizer flag the request will be honored, in
159 dnl any other case the request can not be honored.
160 dnl IOW, existing optimizer flags defined in CFLAGS or CPPFLAGS
161 dnl will always take precedence over any initial assumption.
162 if test "$want_debug" = "yes"; then
163 want_optimize="assume_no"
164 AC_MSG_RESULT([not specified (assuming no)])
165 else
166 want_optimize="assume_yes"
167 AC_MSG_RESULT([not specified (assuming yes)])
168 fi
169 ;;
170 *)
171 dnl --enable-optimize option used. We will handle this as
172 dnl a request to enable compiler optimizations if possible.
173 dnl If the compiler is known CFLAGS and CPPFLAGS will be
174 dnl overridden, otherwise this can not be honored.
175 want_optimize="yes"
176 AC_MSG_RESULT([yes])
177 ;;
178 esac
179])
180
181
182dnl CARES_CHECK_OPTION_SYMBOL_HIDING
183dnl -------------------------------------------------
184dnl Verify if configure has been invoked with option
185dnl --enable-symbol-hiding or --disable-symbol-hiding,
186dnl setting shell variable want_symbol_hiding value.
187
188AC_DEFUN([CARES_CHECK_OPTION_SYMBOL_HIDING], [
189 AC_BEFORE([$0],[CARES_CHECK_COMPILER_SYMBOL_HIDING])dnl
190 AC_MSG_CHECKING([whether to enable hiding of library internal symbols])
191 OPT_SYMBOL_HIDING="default"
192 AC_ARG_ENABLE(symbol-hiding,
193AC_HELP_STRING([--enable-symbol-hiding],[Enable hiding of library internal symbols])
194AC_HELP_STRING([--disable-symbol-hiding],[Disable hiding of library internal symbols]),
195 OPT_SYMBOL_HIDING=$enableval)
196 case "$OPT_SYMBOL_HIDING" in
197 no)
198 dnl --disable-symbol-hiding option used.
199 dnl This is an indication to not attempt hiding of library internal
200 dnl symbols. Default symbol visibility will be used, which normally
201 dnl exposes all library internal symbols.
202 want_symbol_hiding="no"
203 AC_MSG_RESULT([no])
204 ;;
205 default)
206 dnl configure's symbol-hiding option not specified.
207 dnl Handle this as if --enable-symbol-hiding option was given.
208 want_symbol_hiding="yes"
209 AC_MSG_RESULT([yes])
210 ;;
211 *)
212 dnl --enable-symbol-hiding option used.
213 dnl This is an indication to attempt hiding of library internal
214 dnl symbols. This is only supported on some compilers/linkers.
215 want_symbol_hiding="yes"
216 AC_MSG_RESULT([yes])
217 ;;
218 esac
219])
220
221
222dnl CARES_CHECK_OPTION_EXPOSE_STATICS
223dnl -------------------------------------------------
224dnl Verify if configure has been invoked with option
225dnl --enable-expose-statics or --disable-expose-statics,
226dnl setting shell variable want_expose_statics value.
227
228AC_DEFUN([CARES_CHECK_OPTION_EXPOSE_STATICS], [
229 AC_MSG_CHECKING([whether to expose internal static functions for testing])
230 OPT_EXPOSE_STATICS="default"
231 AC_ARG_ENABLE(expose-statics,
232AC_HELP_STRING([--enable-expose-statics],[Enable exposure of internal static functions for testing])
233AC_HELP_STRING([--disable-expose-statics],[Disable exposure of internal static functions for testing]),
234 OPT_EXPOSE_STATICS=$enableval)
235 case "$OPT_EXPOSE_STATICS" in
236 no)
237 dnl --disable-expose-statics option used.
238 want_expose_statics="no"
239 AC_MSG_RESULT([no])
240 ;;
241 default)
242 dnl configure's expose-statics option not specified.
243 dnl Handle this as if --disable-expose-statics option was given.
244 want_expose_statics="no"
245 AC_MSG_RESULT([no])
246 ;;
247 *)
248 dnl --enable-expose-statics option used.
249 want_expose_statics="yes"
250 AC_MSG_RESULT([yes])
251 ;;
252 esac
253 if test "$want_expose_statics" = "yes"; then
254 AC_DEFINE_UNQUOTED(CARES_EXPOSE_STATICS, 1,
255 [Defined for build that exposes internal static functions for testing.])
256 fi
257])
258
259
260dnl CARES_CHECK_OPTION_WARNINGS
261dnl -------------------------------------------------
262dnl Verify if configure has been invoked with option
263dnl --enable-warnings or --disable-warnings, and set
264dnl shell variable want_warnings as appropriate.
265
266AC_DEFUN([CARES_CHECK_OPTION_WARNINGS], [
267 AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl
268 AC_BEFORE([$0],[CARES_CHECK_OPTION_WERROR])dnl
269 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
270 AC_MSG_CHECKING([whether to enable strict compiler warnings])
271 OPT_COMPILER_WARNINGS="default"
272 AC_ARG_ENABLE(warnings,
273AC_HELP_STRING([--enable-warnings],[Enable strict compiler warnings])
274AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
275 OPT_COMPILER_WARNINGS=$enableval)
276 case "$OPT_COMPILER_WARNINGS" in
277 no)
278 dnl --disable-warnings option used
279 want_warnings="no"
280 ;;
281 default)
282 dnl configure option not specified, so
283 dnl use same setting as --enable-debug
284 want_warnings="$want_debug"
285 ;;
286 *)
287 dnl --enable-warnings option used
288 want_warnings="yes"
289 ;;
290 esac
291 AC_MSG_RESULT([$want_warnings])
292])
293
294dnl CARES_CHECK_OPTION_WERROR
295dnl -------------------------------------------------
296dnl Verify if configure has been invoked with option
297dnl --enable-werror or --disable-werror, and set
298dnl shell variable want_werror as appropriate.
299
300AC_DEFUN([CARES_CHECK_OPTION_WERROR], [
301 AC_BEFORE([$0],[CARES_CHECK_COMPILER])dnl
302 AC_MSG_CHECKING([whether to enable compiler warnings as errors])
303 OPT_COMPILER_WERROR="default"
304 AC_ARG_ENABLE(werror,
305AC_HELP_STRING([--enable-werror],[Enable compiler warnings as errors])
306AC_HELP_STRING([--disable-werror],[Disable compiler warnings as errors]),
307 OPT_COMPILER_WERROR=$enableval)
308 case "$OPT_COMPILER_WERROR" in
309 no)
310 dnl --disable-werror option used
311 want_werror="no"
312 ;;
313 default)
314 dnl configure option not specified
315 want_werror="no"
316 ;;
317 *)
318 dnl --enable-werror option used
319 want_werror="yes"
320 ;;
321 esac
322 AC_MSG_RESULT([$want_werror])
323])
324
325
326dnl CARES_CHECK_NONBLOCKING_SOCKET
327dnl -------------------------------------------------
328dnl Check for how to set a socket into non-blocking state.
329
330AC_DEFUN([CARES_CHECK_NONBLOCKING_SOCKET], [
331 AC_REQUIRE([CARES_CHECK_OPTION_NONBLOCKING])dnl
332 AC_REQUIRE([CARES_CHECK_FUNC_FCNTL])dnl
333 AC_REQUIRE([CARES_CHECK_FUNC_IOCTL])dnl
334 AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET])dnl
335 AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl
336 AC_REQUIRE([CARES_CHECK_FUNC_SETSOCKOPT])dnl
337 #
338 tst_method="unknown"
339 if test "$want_nonblocking" = "yes"; then
340 AC_MSG_CHECKING([how to set a socket into non-blocking mode])
341 if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then
342 tst_method="fcntl O_NONBLOCK"
343 elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then
344 tst_method="ioctl FIONBIO"
345 elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then
346 tst_method="ioctlsocket FIONBIO"
347 elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then
348 tst_method="IoctlSocket FIONBIO"
349 elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then
350 tst_method="setsockopt SO_NONBLOCK"
351 fi
352 AC_MSG_RESULT([$tst_method])
353 if test "$tst_method" = "unknown"; then
354 AC_MSG_WARN([cannot determine non-blocking socket method.])
355 fi
356 fi
357 if test "$tst_method" = "unknown"; then
358 AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1,
359 [Define to disable non-blocking sockets.])
360 AC_MSG_WARN([non-blocking sockets disabled.])
361 fi
362])
363
364
365dnl CARES_CONFIGURE_SYMBOL_HIDING
366dnl -------------------------------------------------
367dnl Depending on --enable-symbol-hiding or --disable-symbol-hiding
368dnl configure option, and compiler capability to actually honor such
369dnl option, this will modify compiler flags as appropriate and also
370dnl provide needed definitions for configuration and Makefile.am files.
371dnl This macro should not be used until all compilation tests have
372dnl been done to prevent interferences on other tests.
373
374AC_DEFUN([CARES_CONFIGURE_SYMBOL_HIDING], [
375 AC_MSG_CHECKING([whether hiding of library internal symbols will actually happen])
376 CFLAG_CARES_SYMBOL_HIDING=""
377 doing_symbol_hiding="no"
378 if test x"$ac_cv_native_windows" != "xyes" &&
379 test "$want_symbol_hiding" = "yes" &&
380 test "$supports_symbol_hiding" = "yes"; then
381 doing_symbol_hiding="yes"
382 CFLAG_CARES_SYMBOL_HIDING="$symbol_hiding_CFLAGS"
383 AC_DEFINE_UNQUOTED(CARES_SYMBOL_SCOPE_EXTERN, $symbol_hiding_EXTERN,
384 [Definition to make a library symbol externally visible.])
385 AC_MSG_RESULT([yes])
386 else
387 AC_MSG_RESULT([no])
388 fi
389 AM_CONDITIONAL(DOING_CARES_SYMBOL_HIDING, test x$doing_symbol_hiding = xyes)
390 AC_SUBST(CFLAG_CARES_SYMBOL_HIDING)
391 if test "$doing_symbol_hiding" = "yes"; then
392 AC_DEFINE_UNQUOTED(CARES_SYMBOL_HIDING, 1,
393 [Defined for build with symbol hiding.])
394 fi
395])
396