1 #***************************************************************************
4 # Copyright (C) 2008 by Daniel Stenberg et al
6 # Permission to use, copy, modify, and distribute this software and its
7 # documentation for any purpose and without fee is hereby granted, provided
8 # that the above copyright notice appear in all copies and that both that
9 # copyright notice and this permission notice appear in supporting
10 # documentation, and that the name of M.I.T. not be used in advertising or
11 # publicity pertaining to distribution of the software without specific,
12 # written prior permission. M.I.T. makes no representations about the
13 # suitability of this software for any purpose. It is provided "as is"
14 # without express or implied warranty.
16 #***************************************************************************
18 # File version for 'aclocal' use.
23 dnl None of the CARES_CHECK_NEED_REENTRANT_* macros shall use HAVE_FOO_H to
24 dnl conditionally include header files. These macros are used early in the
25 dnl configure process much before header file availability is known.
28 dnl CARES_CHECK_NEED_REENTRANT_GMTIME_R
29 dnl -------------------------------------------------
30 dnl Checks if the preprocessor _REENTRANT definition
31 dnl makes function gmtime_r compiler visible.
33 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_GMTIME_R], [
35 AC_LANG_FUNC_LINK_TRY([gmtime_r])
41 if test "$tmp_gmtime_r" = "yes"; then
42 AC_EGREP_CPP([gmtime_r],[
43 #include <sys/types.h>
46 tmp_gmtime_r="proto_declared"
48 AC_EGREP_CPP([gmtime_r],[
50 #include <sys/types.h>
53 tmp_gmtime_r="proto_needs_reentrant"
54 tmp_need_reentrant="yes"
61 dnl CARES_CHECK_NEED_REENTRANT_LOCALTIME_R
62 dnl -------------------------------------------------
63 dnl Checks if the preprocessor _REENTRANT definition
64 dnl makes function localtime_r compiler visible.
66 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_LOCALTIME_R], [
68 AC_LANG_FUNC_LINK_TRY([localtime_r])
74 if test "$tmp_localtime_r" = "yes"; then
75 AC_EGREP_CPP([localtime_r],[
76 #include <sys/types.h>
79 tmp_localtime_r="proto_declared"
81 AC_EGREP_CPP([localtime_r],[
83 #include <sys/types.h>
86 tmp_localtime_r="proto_needs_reentrant"
87 tmp_need_reentrant="yes"
94 dnl CARES_CHECK_NEED_REENTRANT_STRERROR_R
95 dnl -------------------------------------------------
96 dnl Checks if the preprocessor _REENTRANT definition
97 dnl makes function strerror_r compiler visible.
99 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_STRERROR_R], [
101 AC_LANG_FUNC_LINK_TRY([strerror_r])
107 if test "$tmp_strerror_r" = "yes"; then
108 AC_EGREP_CPP([strerror_r],[
109 #include <sys/types.h>
112 tmp_strerror_r="proto_declared"
114 AC_EGREP_CPP([strerror_r],[
116 #include <sys/types.h>
119 tmp_strerror_r="proto_needs_reentrant"
120 tmp_need_reentrant="yes"
127 dnl CARES_CHECK_NEED_REENTRANT_STRTOK_R
128 dnl -------------------------------------------------
129 dnl Checks if the preprocessor _REENTRANT definition
130 dnl makes function strtok_r compiler visible.
132 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_STRTOK_R], [
134 AC_LANG_FUNC_LINK_TRY([strtok_r])
140 if test "$tmp_strtok_r" = "yes"; then
141 AC_EGREP_CPP([strtok_r],[
142 #include <sys/types.h>
145 tmp_strtok_r="proto_declared"
147 AC_EGREP_CPP([strtok_r],[
149 #include <sys/types.h>
152 tmp_strtok_r="proto_needs_reentrant"
153 tmp_need_reentrant="yes"
160 dnl CARES_CHECK_NEED_REENTRANT_INET_NTOA_R
161 dnl -------------------------------------------------
162 dnl Checks if the preprocessor _REENTRANT definition
163 dnl makes function inet_ntoa_r compiler visible.
165 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_INET_NTOA_R], [
167 AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
169 tmp_inet_ntoa_r="yes"
173 if test "$tmp_inet_ntoa_r" = "yes"; then
174 AC_EGREP_CPP([inet_ntoa_r],[
175 #include <sys/types.h>
176 #include <sys/socket.h>
177 #include <netinet/in.h>
178 #include <arpa/inet.h>
180 tmp_inet_ntoa_r="proto_declared"
182 AC_EGREP_CPP([inet_ntoa_r],[
184 #include <sys/types.h>
185 #include <sys/socket.h>
186 #include <netinet/in.h>
187 #include <arpa/inet.h>
189 tmp_inet_ntoa_r="proto_needs_reentrant"
190 tmp_need_reentrant="yes"
197 dnl CARES_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
198 dnl -------------------------------------------------
199 dnl Checks if the preprocessor _REENTRANT definition
200 dnl makes function gethostbyaddr_r compiler visible.
202 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R], [
204 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
206 tmp_gethostbyaddr_r="yes"
208 tmp_gethostbyaddr_r="no"
210 if test "$tmp_gethostbyaddr_r" = "yes"; then
211 AC_EGREP_CPP([gethostbyaddr_r],[
212 #include <sys/types.h>
215 tmp_gethostbyaddr_r="proto_declared"
217 AC_EGREP_CPP([gethostbyaddr_r],[
219 #include <sys/types.h>
222 tmp_gethostbyaddr_r="proto_needs_reentrant"
223 tmp_need_reentrant="yes"
230 dnl CARES_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
231 dnl -------------------------------------------------
232 dnl Checks if the preprocessor _REENTRANT definition
233 dnl makes function gethostbyname_r compiler visible.
235 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R], [
237 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
239 tmp_gethostbyname_r="yes"
241 tmp_gethostbyname_r="no"
243 if test "$tmp_gethostbyname_r" = "yes"; then
244 AC_EGREP_CPP([gethostbyname_r],[
245 #include <sys/types.h>
248 tmp_gethostbyname_r="proto_declared"
250 AC_EGREP_CPP([gethostbyname_r],[
252 #include <sys/types.h>
255 tmp_gethostbyname_r="proto_needs_reentrant"
256 tmp_need_reentrant="yes"
263 dnl CARES_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
264 dnl -------------------------------------------------
265 dnl Checks if the preprocessor _REENTRANT definition
266 dnl makes function getprotobyname_r compiler visible.
268 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R], [
270 AC_LANG_FUNC_LINK_TRY([getprotobyname_r])
272 tmp_getprotobyname_r="yes"
274 tmp_getprotobyname_r="no"
276 if test "$tmp_getprotobyname_r" = "yes"; then
277 AC_EGREP_CPP([getprotobyname_r],[
278 #include <sys/types.h>
281 tmp_getprotobyname_r="proto_declared"
283 AC_EGREP_CPP([getprotobyname_r],[
285 #include <sys/types.h>
288 tmp_getprotobyname_r="proto_needs_reentrant"
289 tmp_need_reentrant="yes"
296 dnl CARES_CHECK_NEED_REENTRANT_GETSERVBYPORT_R
297 dnl -------------------------------------------------
298 dnl Checks if the preprocessor _REENTRANT definition
299 dnl makes function getservbyport_r compiler visible.
301 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_GETSERVBYPORT_R], [
303 AC_LANG_FUNC_LINK_TRY([getservbyport_r])
305 tmp_getservbyport_r="yes"
307 tmp_getservbyport_r="no"
309 if test "$tmp_getservbyport_r" = "yes"; then
310 AC_EGREP_CPP([getservbyport_r],[
311 #include <sys/types.h>
314 tmp_getservbyport_r="proto_declared"
316 AC_EGREP_CPP([getservbyport_r],[
318 #include <sys/types.h>
321 tmp_getservbyport_r="proto_needs_reentrant"
322 tmp_need_reentrant="yes"
329 dnl CARES_CHECK_NEED_REENTRANT_FUNCTIONS_R
330 dnl -------------------------------------------------
331 dnl Checks if the preprocessor _REENTRANT definition
332 dnl makes several _r functions compiler visible.
333 dnl Internal macro for CARES_CONFIGURE_REENTRANT.
335 AC_DEFUN([CARES_CHECK_NEED_REENTRANT_FUNCTIONS_R], [
337 tmp_need_reentrant="no"
339 if test "$tmp_need_reentrant" = "no"; then
340 CARES_CHECK_NEED_REENTRANT_GMTIME_R
342 if test "$tmp_need_reentrant" = "no"; then
343 CARES_CHECK_NEED_REENTRANT_LOCALTIME_R
345 if test "$tmp_need_reentrant" = "no"; then
346 CARES_CHECK_NEED_REENTRANT_STRERROR_R
348 if test "$tmp_need_reentrant" = "no"; then
349 CARES_CHECK_NEED_REENTRANT_STRTOK_R
351 if test "$tmp_need_reentrant" = "no"; then
352 CARES_CHECK_NEED_REENTRANT_INET_NTOA_R
354 if test "$tmp_need_reentrant" = "no"; then
355 CARES_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
357 if test "$tmp_need_reentrant" = "no"; then
358 CARES_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
360 if test "$tmp_need_reentrant" = "no"; then
361 CARES_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
363 if test "$tmp_need_reentrant" = "no"; then
364 CARES_CHECK_NEED_REENTRANT_GETSERVBYPORT_R
369 dnl CARES_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
370 dnl -------------------------------------------------
371 dnl This macro ensures that configuration tests done
372 dnl after this will execute with preprocessor symbol
373 dnl _REENTRANT defined. This macro also ensures that
374 dnl the generated config file defines NEED_REENTRANT
375 dnl and that in turn setup.h will define _REENTRANT.
376 dnl Internal macro for CARES_CONFIGURE_REENTRANT.
378 AC_DEFUN([CARES_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
379 AC_DEFINE(NEED_REENTRANT, 1,
380 [Define to 1 if _REENTRANT preprocessor symbol must be defined.])
381 cat >>confdefs.h <<_EOF
389 dnl CARES_CONFIGURE_REENTRANT
390 dnl -------------------------------------------------
391 dnl This first checks if the preprocessor _REENTRANT
392 dnl symbol is already defined. If it isn't currently
393 dnl defined a set of checks are performed to verify
394 dnl if its definition is required to make visible to
395 dnl the compiler a set of *_r functions. Finally, if
396 dnl _REENTRANT is already defined or needed it takes
397 dnl care of making adjustments necessary to ensure
398 dnl that it is defined equally for further configure
399 dnl tests and generated config file.
401 AC_DEFUN([CARES_CONFIGURE_REENTRANT], [
404 AC_MSG_CHECKING([if _REENTRANT is already defined])
411 force compilation error
416 tmp_reentrant_initially_defined="yes"
419 tmp_reentrant_initially_defined="no"
422 if test "$tmp_reentrant_initially_defined" = "no"; then
423 AC_MSG_CHECKING([if _REENTRANT is actually needed])
424 CARES_CHECK_NEED_REENTRANT_FUNCTIONS_R
425 if test "$tmp_need_reentrant" = "yes"; then
432 AC_MSG_CHECKING([if _REENTRANT is onwards defined])
433 if test "$tmp_reentrant_initially_defined" = "yes" ||
434 test "$tmp_need_reentrant" = "yes"; then
435 CARES_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT