1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
21 # $Id: curl-reentrant.m4,v 1.1.1.1 2008-09-23 16:32:05 hoffman Exp $
22 #***************************************************************************
24 # File version for 'aclocal' use. Keep it a single number.
29 dnl None of the CURL_CHECK_NEED_REENTRANT_* macros shall use HAVE_FOO_H to
30 dnl conditionally include header files. These macros are used early in the
31 dnl configure process much before header file availability is known.
34 dnl CURL_CHECK_NEED_REENTRANT_GMTIME_R
35 dnl -------------------------------------------------
36 dnl Checks if the preprocessor _REENTRANT definition
37 dnl makes function gmtime_r compiler visible.
39 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GMTIME_R], [
41 AC_LANG_FUNC_LINK_TRY([gmtime_r])
47 if test "$tmp_gmtime_r" = "yes"; then
48 AC_EGREP_CPP([gmtime_r],[
49 #include <sys/types.h>
52 tmp_gmtime_r="proto_declared"
54 AC_EGREP_CPP([gmtime_r],[
56 #include <sys/types.h>
59 tmp_gmtime_r="proto_needs_reentrant"
60 tmp_need_reentrant="yes"
67 dnl CURL_CHECK_NEED_REENTRANT_LOCALTIME_R
68 dnl -------------------------------------------------
69 dnl Checks if the preprocessor _REENTRANT definition
70 dnl makes function localtime_r compiler visible.
72 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_LOCALTIME_R], [
74 AC_LANG_FUNC_LINK_TRY([localtime_r])
80 if test "$tmp_localtime_r" = "yes"; then
81 AC_EGREP_CPP([localtime_r],[
82 #include <sys/types.h>
85 tmp_localtime_r="proto_declared"
87 AC_EGREP_CPP([localtime_r],[
89 #include <sys/types.h>
92 tmp_localtime_r="proto_needs_reentrant"
93 tmp_need_reentrant="yes"
100 dnl CURL_CHECK_NEED_REENTRANT_STRERROR_R
101 dnl -------------------------------------------------
102 dnl Checks if the preprocessor _REENTRANT definition
103 dnl makes function strerror_r compiler visible.
105 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRERROR_R], [
107 AC_LANG_FUNC_LINK_TRY([strerror_r])
113 if test "$tmp_strerror_r" = "yes"; then
114 AC_EGREP_CPP([strerror_r],[
115 #include <sys/types.h>
118 tmp_strerror_r="proto_declared"
120 AC_EGREP_CPP([strerror_r],[
122 #include <sys/types.h>
125 tmp_strerror_r="proto_needs_reentrant"
126 tmp_need_reentrant="yes"
133 dnl CURL_CHECK_NEED_REENTRANT_STRTOK_R
134 dnl -------------------------------------------------
135 dnl Checks if the preprocessor _REENTRANT definition
136 dnl makes function strtok_r compiler visible.
138 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRTOK_R], [
140 AC_LANG_FUNC_LINK_TRY([strtok_r])
146 if test "$tmp_strtok_r" = "yes"; then
147 AC_EGREP_CPP([strtok_r],[
148 #include <sys/types.h>
151 tmp_strtok_r="proto_declared"
153 AC_EGREP_CPP([strtok_r],[
155 #include <sys/types.h>
158 tmp_strtok_r="proto_needs_reentrant"
159 tmp_need_reentrant="yes"
166 dnl CURL_CHECK_NEED_REENTRANT_INET_NTOA_R
167 dnl -------------------------------------------------
168 dnl Checks if the preprocessor _REENTRANT definition
169 dnl makes function inet_ntoa_r compiler visible.
171 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_INET_NTOA_R], [
173 AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
175 tmp_inet_ntoa_r="yes"
179 if test "$tmp_inet_ntoa_r" = "yes"; then
180 AC_EGREP_CPP([inet_ntoa_r],[
181 #include <sys/types.h>
182 #include <sys/socket.h>
183 #include <netinet/in.h>
184 #include <arpa/inet.h>
186 tmp_inet_ntoa_r="proto_declared"
188 AC_EGREP_CPP([inet_ntoa_r],[
190 #include <sys/types.h>
191 #include <sys/socket.h>
192 #include <netinet/in.h>
193 #include <arpa/inet.h>
195 tmp_inet_ntoa_r="proto_needs_reentrant"
196 tmp_need_reentrant="yes"
203 dnl CURL_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
204 dnl -------------------------------------------------
205 dnl Checks if the preprocessor _REENTRANT definition
206 dnl makes function gethostbyaddr_r compiler visible.
208 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R], [
210 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
212 tmp_gethostbyaddr_r="yes"
214 tmp_gethostbyaddr_r="no"
216 if test "$tmp_gethostbyaddr_r" = "yes"; then
217 AC_EGREP_CPP([gethostbyaddr_r],[
218 #include <sys/types.h>
221 tmp_gethostbyaddr_r="proto_declared"
223 AC_EGREP_CPP([gethostbyaddr_r],[
225 #include <sys/types.h>
228 tmp_gethostbyaddr_r="proto_needs_reentrant"
229 tmp_need_reentrant="yes"
236 dnl CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
237 dnl -------------------------------------------------
238 dnl Checks if the preprocessor _REENTRANT definition
239 dnl makes function gethostbyname_r compiler visible.
241 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R], [
243 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
245 tmp_gethostbyname_r="yes"
247 tmp_gethostbyname_r="no"
249 if test "$tmp_gethostbyname_r" = "yes"; then
250 AC_EGREP_CPP([gethostbyname_r],[
251 #include <sys/types.h>
254 tmp_gethostbyname_r="proto_declared"
256 AC_EGREP_CPP([gethostbyname_r],[
258 #include <sys/types.h>
261 tmp_gethostbyname_r="proto_needs_reentrant"
262 tmp_need_reentrant="yes"
269 dnl CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
270 dnl -------------------------------------------------
271 dnl Checks if the preprocessor _REENTRANT definition
272 dnl makes function getprotobyname_r compiler visible.
274 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R], [
276 AC_LANG_FUNC_LINK_TRY([getprotobyname_r])
278 tmp_getprotobyname_r="yes"
280 tmp_getprotobyname_r="no"
282 if test "$tmp_getprotobyname_r" = "yes"; then
283 AC_EGREP_CPP([getprotobyname_r],[
284 #include <sys/types.h>
287 tmp_getprotobyname_r="proto_declared"
289 AC_EGREP_CPP([getprotobyname_r],[
291 #include <sys/types.h>
294 tmp_getprotobyname_r="proto_needs_reentrant"
295 tmp_need_reentrant="yes"
302 dnl CURL_CHECK_NEED_REENTRANT_GETSERVBYPORT_R
303 dnl -------------------------------------------------
304 dnl Checks if the preprocessor _REENTRANT definition
305 dnl makes function getservbyport_r compiler visible.
307 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETSERVBYPORT_R], [
309 AC_LANG_FUNC_LINK_TRY([getservbyport_r])
311 tmp_getservbyport_r="yes"
313 tmp_getservbyport_r="no"
315 if test "$tmp_getservbyport_r" = "yes"; then
316 AC_EGREP_CPP([getservbyport_r],[
317 #include <sys/types.h>
320 tmp_getservbyport_r="proto_declared"
322 AC_EGREP_CPP([getservbyport_r],[
324 #include <sys/types.h>
327 tmp_getservbyport_r="proto_needs_reentrant"
328 tmp_need_reentrant="yes"
335 dnl CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R
336 dnl -------------------------------------------------
337 dnl Checks if the preprocessor _REENTRANT definition
338 dnl makes several _r functions compiler visible.
339 dnl Internal macro for CURL_CONFIGURE_REENTRANT.
341 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R], [
343 tmp_need_reentrant="no"
345 if test "$tmp_need_reentrant" = "no"; then
346 CURL_CHECK_NEED_REENTRANT_GMTIME_R
348 if test "$tmp_need_reentrant" = "no"; then
349 CURL_CHECK_NEED_REENTRANT_LOCALTIME_R
351 if test "$tmp_need_reentrant" = "no"; then
352 CURL_CHECK_NEED_REENTRANT_STRERROR_R
354 if test "$tmp_need_reentrant" = "no"; then
355 CURL_CHECK_NEED_REENTRANT_STRTOK_R
357 if test "$tmp_need_reentrant" = "no"; then
358 CURL_CHECK_NEED_REENTRANT_INET_NTOA_R
360 if test "$tmp_need_reentrant" = "no"; then
361 CURL_CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
363 if test "$tmp_need_reentrant" = "no"; then
364 CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
366 if test "$tmp_need_reentrant" = "no"; then
367 CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
369 if test "$tmp_need_reentrant" = "no"; then
370 CURL_CHECK_NEED_REENTRANT_GETSERVBYPORT_R
375 dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
376 dnl -------------------------------------------------
377 dnl This macro ensures that configuration tests done
378 dnl after this will execute with preprocessor symbol
379 dnl _REENTRANT defined. This macro also ensures that
380 dnl the generated config file defines NEED_REENTRANT
381 dnl and that in turn setup.h will define _REENTRANT.
382 dnl Internal macro for CURL_CONFIGURE_REENTRANT.
384 AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
385 AC_DEFINE(NEED_REENTRANT, 1,
386 [Define to 1 if _REENTRANT preprocessor symbol must be defined.])
387 cat >>confdefs.h <<_EOF
395 dnl CURL_CONFIGURE_REENTRANT
396 dnl -------------------------------------------------
397 dnl This first checks if the preprocessor _REENTRANT
398 dnl symbol is already defined. If it isn't currently
399 dnl defined a set of checks are performed to verify
400 dnl if its definition is required to make visible to
401 dnl the compiler a set of *_r functions. Finally, if
402 dnl _REENTRANT is already defined or needed it takes
403 dnl care of making adjustments necessary to ensure
404 dnl that it is defined equally for further configure
405 dnl tests and generated config file.
407 AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
410 AC_MSG_CHECKING([if _REENTRANT is already defined])
417 force compilation error
422 tmp_reentrant_initially_defined="yes"
425 tmp_reentrant_initially_defined="no"
428 if test "$tmp_reentrant_initially_defined" = "no"; then
429 AC_MSG_CHECKING([if _REENTRANT is actually needed])
430 CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R
431 if test "$tmp_need_reentrant" = "yes"; then
438 AC_MSG_CHECKING([if _REENTRANT is onwards defined])
439 if test "$tmp_reentrant_initially_defined" = "yes" ||
440 test "$tmp_need_reentrant" = "yes"; then
441 CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT