blob: e32d3f8a700a364e25a65b953a4b4853af0f8e70 [file] [log] [blame]
Lucas Eckels9bd90e62012-08-06 15:07:02 -07001#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2009, 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
Alex Deymo8f1a2142016-06-28 14:49:26 -070012# are also available at https://curl.haxx.se/docs/copyright.html.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070013#
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.
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070024# serial 10
Lucas Eckels9bd90e62012-08-06 15:07:02 -070025
26dnl Note 1
27dnl ------
28dnl None of the CURL_CHECK_NEED_REENTRANT_* macros shall use HAVE_FOO_H to
29dnl conditionally include header files. These macros are used early in the
30dnl configure process much before header file availability is known.
31
32
33dnl CURL_CHECK_NEED_REENTRANT_ERRNO
34dnl -------------------------------------------------
35dnl Checks if the preprocessor _REENTRANT definition
36dnl makes errno available as a preprocessor macro.
37
38AC_DEFUN([CURL_CHECK_NEED_REENTRANT_ERRNO], [
39 AC_COMPILE_IFELSE([
40 AC_LANG_PROGRAM([[
41#include <errno.h>
42 ]],[[
43 if(0 != errno)
44 return 1;
45 ]])
46 ],[
47 tmp_errno="yes"
48 ],[
49 tmp_errno="no"
50 ])
51 if test "$tmp_errno" = "yes"; then
52 AC_COMPILE_IFELSE([
53 AC_LANG_PROGRAM([[
54#include <errno.h>
55 ]],[[
56#ifdef errno
57 int dummy=1;
58#else
59 force compilation error
60#endif
61 ]])
62 ],[
63 tmp_errno="errno_macro_defined"
64 ],[
65 AC_COMPILE_IFELSE([
66 AC_LANG_PROGRAM([[
67#define _REENTRANT
68#include <errno.h>
69 ]],[[
70#ifdef errno
71 int dummy=1;
72#else
73 force compilation error
74#endif
75 ]])
76 ],[
77 tmp_errno="errno_macro_needs_reentrant"
78 tmp_need_reentrant="yes"
79 ])
80 ])
81 fi
82])
83
84
85dnl CURL_CHECK_NEED_REENTRANT_GMTIME_R
86dnl -------------------------------------------------
87dnl Checks if the preprocessor _REENTRANT definition
88dnl makes function gmtime_r compiler visible.
89
90AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GMTIME_R], [
91 AC_LINK_IFELSE([
92 AC_LANG_FUNC_LINK_TRY([gmtime_r])
93 ],[
94 tmp_gmtime_r="yes"
95 ],[
96 tmp_gmtime_r="no"
97 ])
98 if test "$tmp_gmtime_r" = "yes"; then
99 AC_EGREP_CPP([gmtime_r],[
100#include <sys/types.h>
101#include <time.h>
102 ],[
103 tmp_gmtime_r="proto_declared"
104 ],[
105 AC_EGREP_CPP([gmtime_r],[
106#define _REENTRANT
107#include <sys/types.h>
108#include <time.h>
109 ],[
110 tmp_gmtime_r="proto_needs_reentrant"
111 tmp_need_reentrant="yes"
112 ])
113 ])
114 fi
115])
116
117
118dnl CURL_CHECK_NEED_REENTRANT_LOCALTIME_R
119dnl -------------------------------------------------
120dnl Checks if the preprocessor _REENTRANT definition
121dnl makes function localtime_r compiler visible.
122
123AC_DEFUN([CURL_CHECK_NEED_REENTRANT_LOCALTIME_R], [
124 AC_LINK_IFELSE([
125 AC_LANG_FUNC_LINK_TRY([localtime_r])
126 ],[
127 tmp_localtime_r="yes"
128 ],[
129 tmp_localtime_r="no"
130 ])
131 if test "$tmp_localtime_r" = "yes"; then
132 AC_EGREP_CPP([localtime_r],[
133#include <sys/types.h>
134#include <time.h>
135 ],[
136 tmp_localtime_r="proto_declared"
137 ],[
138 AC_EGREP_CPP([localtime_r],[
139#define _REENTRANT
140#include <sys/types.h>
141#include <time.h>
142 ],[
143 tmp_localtime_r="proto_needs_reentrant"
144 tmp_need_reentrant="yes"
145 ])
146 ])
147 fi
148])
149
150
151dnl CURL_CHECK_NEED_REENTRANT_STRERROR_R
152dnl -------------------------------------------------
153dnl Checks if the preprocessor _REENTRANT definition
154dnl makes function strerror_r compiler visible.
155
156AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRERROR_R], [
157 AC_LINK_IFELSE([
158 AC_LANG_FUNC_LINK_TRY([strerror_r])
159 ],[
160 tmp_strerror_r="yes"
161 ],[
162 tmp_strerror_r="no"
163 ])
164 if test "$tmp_strerror_r" = "yes"; then
165 AC_EGREP_CPP([strerror_r],[
166#include <sys/types.h>
167#include <string.h>
168 ],[
169 tmp_strerror_r="proto_declared"
170 ],[
171 AC_EGREP_CPP([strerror_r],[
172#define _REENTRANT
173#include <sys/types.h>
174#include <string.h>
175 ],[
176 tmp_strerror_r="proto_needs_reentrant"
177 tmp_need_reentrant="yes"
178 ])
179 ])
180 fi
181])
182
183
184dnl CURL_CHECK_NEED_REENTRANT_STRTOK_R
185dnl -------------------------------------------------
186dnl Checks if the preprocessor _REENTRANT definition
187dnl makes function strtok_r compiler visible.
188
189AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRTOK_R], [
190 AC_LINK_IFELSE([
191 AC_LANG_FUNC_LINK_TRY([strtok_r])
192 ],[
193 tmp_strtok_r="yes"
194 ],[
195 tmp_strtok_r="no"
196 ])
197 if test "$tmp_strtok_r" = "yes"; then
198 AC_EGREP_CPP([strtok_r],[
199#include <sys/types.h>
200#include <string.h>
201 ],[
202 tmp_strtok_r="proto_declared"
203 ],[
204 AC_EGREP_CPP([strtok_r],[
205#define _REENTRANT
206#include <sys/types.h>
207#include <string.h>
208 ],[
209 tmp_strtok_r="proto_needs_reentrant"
210 tmp_need_reentrant="yes"
211 ])
212 ])
213 fi
214])
215
216
217dnl CURL_CHECK_NEED_REENTRANT_INET_NTOA_R
218dnl -------------------------------------------------
219dnl Checks if the preprocessor _REENTRANT definition
220dnl makes function inet_ntoa_r compiler visible.
221
222AC_DEFUN([CURL_CHECK_NEED_REENTRANT_INET_NTOA_R], [
223 AC_LINK_IFELSE([
224 AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
225 ],[
226 tmp_inet_ntoa_r="yes"
227 ],[
228 tmp_inet_ntoa_r="no"
229 ])
230 if test "$tmp_inet_ntoa_r" = "yes"; then
231 AC_EGREP_CPP([inet_ntoa_r],[
232#include <sys/types.h>
233#include <sys/socket.h>
234#include <netinet/in.h>
235#include <arpa/inet.h>
236 ],[
237 tmp_inet_ntoa_r="proto_declared"
238 ],[
239 AC_EGREP_CPP([inet_ntoa_r],[
240#define _REENTRANT
241#include <sys/types.h>
242#include <sys/socket.h>
243#include <netinet/in.h>
244#include <arpa/inet.h>
245 ],[
246 tmp_inet_ntoa_r="proto_needs_reentrant"
247 tmp_need_reentrant="yes"
248 ])
249 ])
250 fi
251])
252
253
254dnl CURL_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
255dnl -------------------------------------------------
256dnl Checks if the preprocessor _REENTRANT definition
257dnl makes function gethostbyaddr_r compiler visible.
258
259AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R], [
260 AC_LINK_IFELSE([
261 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
262 ],[
263 tmp_gethostbyaddr_r="yes"
264 ],[
265 tmp_gethostbyaddr_r="no"
266 ])
267 if test "$tmp_gethostbyaddr_r" = "yes"; then
268 AC_EGREP_CPP([gethostbyaddr_r],[
269#include <sys/types.h>
270#include <netdb.h>
271 ],[
272 tmp_gethostbyaddr_r="proto_declared"
273 ],[
274 AC_EGREP_CPP([gethostbyaddr_r],[
275#define _REENTRANT
276#include <sys/types.h>
277#include <netdb.h>
278 ],[
279 tmp_gethostbyaddr_r="proto_needs_reentrant"
280 tmp_need_reentrant="yes"
281 ])
282 ])
283 fi
284])
285
286
287dnl CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
288dnl -------------------------------------------------
289dnl Checks if the preprocessor _REENTRANT definition
290dnl makes function gethostbyname_r compiler visible.
291
292AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R], [
293 AC_LINK_IFELSE([
294 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
295 ],[
296 tmp_gethostbyname_r="yes"
297 ],[
298 tmp_gethostbyname_r="no"
299 ])
300 if test "$tmp_gethostbyname_r" = "yes"; then
301 AC_EGREP_CPP([gethostbyname_r],[
302#include <sys/types.h>
303#include <netdb.h>
304 ],[
305 tmp_gethostbyname_r="proto_declared"
306 ],[
307 AC_EGREP_CPP([gethostbyname_r],[
308#define _REENTRANT
309#include <sys/types.h>
310#include <netdb.h>
311 ],[
312 tmp_gethostbyname_r="proto_needs_reentrant"
313 tmp_need_reentrant="yes"
314 ])
315 ])
316 fi
317])
318
319
320dnl CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
321dnl -------------------------------------------------
322dnl Checks if the preprocessor _REENTRANT definition
323dnl makes function getprotobyname_r compiler visible.
324
325AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R], [
326 AC_LINK_IFELSE([
327 AC_LANG_FUNC_LINK_TRY([getprotobyname_r])
328 ],[
329 tmp_getprotobyname_r="yes"
330 ],[
331 tmp_getprotobyname_r="no"
332 ])
333 if test "$tmp_getprotobyname_r" = "yes"; then
334 AC_EGREP_CPP([getprotobyname_r],[
335#include <sys/types.h>
336#include <netdb.h>
337 ],[
338 tmp_getprotobyname_r="proto_declared"
339 ],[
340 AC_EGREP_CPP([getprotobyname_r],[
341#define _REENTRANT
342#include <sys/types.h>
343#include <netdb.h>
344 ],[
345 tmp_getprotobyname_r="proto_needs_reentrant"
346 tmp_need_reentrant="yes"
347 ])
348 ])
349 fi
350])
351
352
353dnl CURL_CHECK_NEED_REENTRANT_GETSERVBYPORT_R
354dnl -------------------------------------------------
355dnl Checks if the preprocessor _REENTRANT definition
356dnl makes function getservbyport_r compiler visible.
357
358AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETSERVBYPORT_R], [
359 AC_LINK_IFELSE([
360 AC_LANG_FUNC_LINK_TRY([getservbyport_r])
361 ],[
362 tmp_getservbyport_r="yes"
363 ],[
364 tmp_getservbyport_r="no"
365 ])
366 if test "$tmp_getservbyport_r" = "yes"; then
367 AC_EGREP_CPP([getservbyport_r],[
368#include <sys/types.h>
369#include <netdb.h>
370 ],[
371 tmp_getservbyport_r="proto_declared"
372 ],[
373 AC_EGREP_CPP([getservbyport_r],[
374#define _REENTRANT
375#include <sys/types.h>
376#include <netdb.h>
377 ],[
378 tmp_getservbyport_r="proto_needs_reentrant"
379 tmp_need_reentrant="yes"
380 ])
381 ])
382 fi
383])
384
385
386dnl CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R
387dnl -------------------------------------------------
388dnl Checks if the preprocessor _REENTRANT definition
389dnl makes several _r functions compiler visible.
390dnl Internal macro for CURL_CONFIGURE_REENTRANT.
391
392AC_DEFUN([CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R], [
393 if test "$tmp_need_reentrant" = "no"; then
394 CURL_CHECK_NEED_REENTRANT_GMTIME_R
395 fi
396 if test "$tmp_need_reentrant" = "no"; then
397 CURL_CHECK_NEED_REENTRANT_LOCALTIME_R
398 fi
399 if test "$tmp_need_reentrant" = "no"; then
400 CURL_CHECK_NEED_REENTRANT_STRERROR_R
401 fi
402 if test "$tmp_need_reentrant" = "no"; then
403 CURL_CHECK_NEED_REENTRANT_STRTOK_R
404 fi
405 if test "$tmp_need_reentrant" = "no"; then
406 CURL_CHECK_NEED_REENTRANT_INET_NTOA_R
407 fi
408 if test "$tmp_need_reentrant" = "no"; then
409 CURL_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
410 fi
411 if test "$tmp_need_reentrant" = "no"; then
412 CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
413 fi
414 if test "$tmp_need_reentrant" = "no"; then
415 CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
416 fi
417 if test "$tmp_need_reentrant" = "no"; then
418 CURL_CHECK_NEED_REENTRANT_GETSERVBYPORT_R
419 fi
420])
421
422
423dnl CURL_CHECK_NEED_REENTRANT_SYSTEM
424dnl -------------------------------------------------
425dnl Checks if the preprocessor _REENTRANT definition
426dnl must be unconditionally done for this platform.
427dnl Internal macro for CURL_CONFIGURE_REENTRANT.
428
429AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
430 case $host_os in
431 solaris*)
432 tmp_need_reentrant="yes"
433 ;;
434 *)
435 tmp_need_reentrant="no"
436 ;;
437 esac
438])
439
440
441dnl CURL_CHECK_NEED_THREAD_SAFE_SYSTEM
442dnl -------------------------------------------------
443dnl Checks if the preprocessor _THREAD_SAFE definition
444dnl must be unconditionally done for this platform.
445dnl Internal macro for CURL_CONFIGURE_THREAD_SAFE.
446
447AC_DEFUN([CURL_CHECK_NEED_THREAD_SAFE_SYSTEM], [
448 case $host_os in
449 aix[[123]].* | aix4.[[012]].*)
450 dnl aix 4.2 and older
451 tmp_need_thread_safe="no"
452 ;;
453 aix*)
454 dnl AIX 4.3 and newer
455 tmp_need_thread_safe="yes"
456 ;;
457 *)
458 tmp_need_thread_safe="no"
459 ;;
460 esac
461])
462
463
464dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
465dnl -------------------------------------------------
466dnl This macro ensures that configuration tests done
467dnl after this will execute with preprocessor symbol
468dnl _REENTRANT defined. This macro also ensures that
469dnl the generated config file defines NEED_REENTRANT
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700470dnl and that in turn curl_setup.h will define _REENTRANT.
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700471dnl Internal macro for CURL_CONFIGURE_REENTRANT.
472
473AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
474AC_DEFINE(NEED_REENTRANT, 1,
475 [Define to 1 if _REENTRANT preprocessor symbol must be defined.])
476cat >>confdefs.h <<_EOF
477#ifndef _REENTRANT
478# define _REENTRANT
479#endif
480_EOF
481])
482
483
484dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE
485dnl -------------------------------------------------
486dnl This macro ensures that configuration tests done
487dnl after this will execute with preprocessor symbol
488dnl _THREAD_SAFE defined. This macro also ensures that
489dnl the generated config file defines NEED_THREAD_SAFE
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700490dnl and that in turn curl_setup.h will define _THREAD_SAFE.
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700491dnl Internal macro for CURL_CONFIGURE_THREAD_SAFE.
492
493AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE], [
494AC_DEFINE(NEED_THREAD_SAFE, 1,
495 [Define to 1 if _THREAD_SAFE preprocessor symbol must be defined.])
496cat >>confdefs.h <<_EOF
497#ifndef _THREAD_SAFE
498# define _THREAD_SAFE
499#endif
500_EOF
501])
502
503
504dnl CURL_CONFIGURE_REENTRANT
505dnl -------------------------------------------------
506dnl This first checks if the preprocessor _REENTRANT
507dnl symbol is already defined. If it isn't currently
508dnl defined a set of checks are performed to verify
509dnl if its definition is required to make visible to
510dnl the compiler a set of *_r functions. Finally, if
511dnl _REENTRANT is already defined or needed it takes
512dnl care of making adjustments necessary to ensure
513dnl that it is defined equally for further configure
514dnl tests and generated config file.
515
516AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
517 AC_PREREQ([2.50])dnl
518 #
519 AC_MSG_CHECKING([if _REENTRANT is already defined])
520 AC_COMPILE_IFELSE([
521 AC_LANG_PROGRAM([[
522 ]],[[
523#ifdef _REENTRANT
524 int dummy=1;
525#else
526 force compilation error
527#endif
528 ]])
529 ],[
530 AC_MSG_RESULT([yes])
531 tmp_reentrant_initially_defined="yes"
532 ],[
533 AC_MSG_RESULT([no])
534 tmp_reentrant_initially_defined="no"
535 ])
536 #
537 if test "$tmp_reentrant_initially_defined" = "no"; then
538 AC_MSG_CHECKING([if _REENTRANT is actually needed])
539 CURL_CHECK_NEED_REENTRANT_SYSTEM
540 if test "$tmp_need_reentrant" = "no"; then
541 CURL_CHECK_NEED_REENTRANT_ERRNO
542 fi
543 if test "$tmp_need_reentrant" = "no"; then
544 CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R
545 fi
546 if test "$tmp_need_reentrant" = "yes"; then
547 AC_MSG_RESULT([yes])
548 else
549 AC_MSG_RESULT([no])
550 fi
551 fi
552 #
553 AC_MSG_CHECKING([if _REENTRANT is onwards defined])
554 if test "$tmp_reentrant_initially_defined" = "yes" ||
555 test "$tmp_need_reentrant" = "yes"; then
556 CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
557 AC_MSG_RESULT([yes])
558 else
559 AC_MSG_RESULT([no])
560 fi
561 #
562])
563
564
565dnl CURL_CONFIGURE_THREAD_SAFE
566dnl -------------------------------------------------
567dnl This first checks if the preprocessor _THREAD_SAFE
568dnl symbol is already defined. If it isn't currently
569dnl defined a set of checks are performed to verify
570dnl if its definition is required. Finally, if
571dnl _THREAD_SAFE is already defined or needed it takes
572dnl care of making adjustments necessary to ensure
573dnl that it is defined equally for further configure
574dnl tests and generated config file.
575
576AC_DEFUN([CURL_CONFIGURE_THREAD_SAFE], [
577 AC_PREREQ([2.50])dnl
578 #
579 AC_MSG_CHECKING([if _THREAD_SAFE is already defined])
580 AC_COMPILE_IFELSE([
581 AC_LANG_PROGRAM([[
582 ]],[[
583#ifdef _THREAD_SAFE
584 int dummy=1;
585#else
586 force compilation error
587#endif
588 ]])
589 ],[
590 AC_MSG_RESULT([yes])
591 tmp_thread_safe_initially_defined="yes"
592 ],[
593 AC_MSG_RESULT([no])
594 tmp_thread_safe_initially_defined="no"
595 ])
596 #
597 if test "$tmp_thread_safe_initially_defined" = "no"; then
598 AC_MSG_CHECKING([if _THREAD_SAFE is actually needed])
599 CURL_CHECK_NEED_THREAD_SAFE_SYSTEM
600 if test "$tmp_need_thread_safe" = "yes"; then
601 AC_MSG_RESULT([yes])
602 else
603 AC_MSG_RESULT([no])
604 fi
605 fi
606 #
607 AC_MSG_CHECKING([if _THREAD_SAFE is onwards defined])
608 if test "$tmp_thread_safe_initially_defined" = "yes" ||
609 test "$tmp_need_thread_safe" = "yes"; then
610 CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE
611 AC_MSG_RESULT([yes])
612 else
613 AC_MSG_RESULT([no])
614 fi
615 #
616])
617