xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 1 | #*************************************************************************** |
| 2 | # _ _ ____ _ |
| 3 | # Project ___| | | | _ \| | |
| 4 | # / __| | | | |_) | | |
| 5 | # | (__| |_| | _ <| |___ |
| 6 | # \___|\___/|_| \_\_____| |
| 7 | # |
| 8 | # Copyright (C) 1998 - 2022, 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.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 | # SPDX-License-Identifier: curl |
| 22 | # |
| 23 | #*************************************************************************** |
| 24 | |
| 25 | # File version for 'aclocal' use. Keep it a single number. |
| 26 | # serial 10 |
| 27 | |
| 28 | dnl Note 1 |
| 29 | dnl ------ |
| 30 | dnl None of the CURL_CHECK_NEED_REENTRANT_* macros shall use HAVE_FOO_H to |
| 31 | dnl conditionally include header files. These macros are used early in the |
| 32 | dnl configure process much before header file availability is known. |
| 33 | |
| 34 | |
| 35 | dnl CURL_CHECK_NEED_REENTRANT_ERRNO |
| 36 | dnl ------------------------------------------------- |
| 37 | dnl Checks if the preprocessor _REENTRANT definition |
| 38 | dnl makes errno available as a preprocessor macro. |
| 39 | |
| 40 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_ERRNO], [ |
| 41 | AC_COMPILE_IFELSE([ |
| 42 | AC_LANG_PROGRAM([[ |
| 43 | #include <errno.h> |
| 44 | ]],[[ |
| 45 | if(0 != errno) |
| 46 | return 1; |
| 47 | ]]) |
| 48 | ],[ |
| 49 | tmp_errno="yes" |
| 50 | ],[ |
| 51 | tmp_errno="no" |
| 52 | ]) |
| 53 | if test "$tmp_errno" = "yes"; then |
| 54 | AC_COMPILE_IFELSE([ |
| 55 | AC_LANG_PROGRAM([[ |
| 56 | #include <errno.h> |
| 57 | ]],[[ |
| 58 | #ifdef errno |
| 59 | int dummy=1; |
| 60 | #else |
| 61 | force compilation error |
| 62 | #endif |
| 63 | ]]) |
| 64 | ],[ |
| 65 | tmp_errno="errno_macro_defined" |
| 66 | ],[ |
| 67 | AC_COMPILE_IFELSE([ |
| 68 | AC_LANG_PROGRAM([[ |
| 69 | #define _REENTRANT |
| 70 | #include <errno.h> |
| 71 | ]],[[ |
| 72 | #ifdef errno |
| 73 | int dummy=1; |
| 74 | #else |
| 75 | force compilation error |
| 76 | #endif |
| 77 | ]]) |
| 78 | ],[ |
| 79 | tmp_errno="errno_macro_needs_reentrant" |
| 80 | tmp_need_reentrant="yes" |
| 81 | ]) |
| 82 | ]) |
| 83 | fi |
| 84 | ]) |
| 85 | |
| 86 | |
| 87 | dnl CURL_CHECK_NEED_REENTRANT_GMTIME_R |
| 88 | dnl ------------------------------------------------- |
| 89 | dnl Checks if the preprocessor _REENTRANT definition |
| 90 | dnl makes function gmtime_r compiler visible. |
| 91 | |
| 92 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GMTIME_R], [ |
| 93 | AC_LINK_IFELSE([ |
| 94 | AC_LANG_FUNC_LINK_TRY([gmtime_r]) |
| 95 | ],[ |
| 96 | tmp_gmtime_r="yes" |
| 97 | ],[ |
| 98 | tmp_gmtime_r="no" |
| 99 | ]) |
| 100 | if test "$tmp_gmtime_r" = "yes"; then |
| 101 | AC_EGREP_CPP([gmtime_r],[ |
| 102 | #include <sys/types.h> |
| 103 | #include <time.h> |
| 104 | ],[ |
| 105 | tmp_gmtime_r="proto_declared" |
| 106 | ],[ |
| 107 | AC_EGREP_CPP([gmtime_r],[ |
| 108 | #define _REENTRANT |
| 109 | #include <sys/types.h> |
| 110 | #include <time.h> |
| 111 | ],[ |
| 112 | tmp_gmtime_r="proto_needs_reentrant" |
| 113 | tmp_need_reentrant="yes" |
| 114 | ]) |
| 115 | ]) |
| 116 | fi |
| 117 | ]) |
| 118 | |
| 119 | |
| 120 | dnl CURL_CHECK_NEED_REENTRANT_LOCALTIME_R |
| 121 | dnl ------------------------------------------------- |
| 122 | dnl Checks if the preprocessor _REENTRANT definition |
| 123 | dnl makes function localtime_r compiler visible. |
| 124 | |
| 125 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_LOCALTIME_R], [ |
| 126 | AC_LINK_IFELSE([ |
| 127 | AC_LANG_FUNC_LINK_TRY([localtime_r]) |
| 128 | ],[ |
| 129 | tmp_localtime_r="yes" |
| 130 | ],[ |
| 131 | tmp_localtime_r="no" |
| 132 | ]) |
| 133 | if test "$tmp_localtime_r" = "yes"; then |
| 134 | AC_EGREP_CPP([localtime_r],[ |
| 135 | #include <sys/types.h> |
| 136 | #include <time.h> |
| 137 | ],[ |
| 138 | tmp_localtime_r="proto_declared" |
| 139 | ],[ |
| 140 | AC_EGREP_CPP([localtime_r],[ |
| 141 | #define _REENTRANT |
| 142 | #include <sys/types.h> |
| 143 | #include <time.h> |
| 144 | ],[ |
| 145 | tmp_localtime_r="proto_needs_reentrant" |
| 146 | tmp_need_reentrant="yes" |
| 147 | ]) |
| 148 | ]) |
| 149 | fi |
| 150 | ]) |
| 151 | |
| 152 | |
| 153 | dnl CURL_CHECK_NEED_REENTRANT_STRERROR_R |
| 154 | dnl ------------------------------------------------- |
| 155 | dnl Checks if the preprocessor _REENTRANT definition |
| 156 | dnl makes function strerror_r compiler visible. |
| 157 | |
| 158 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRERROR_R], [ |
| 159 | AC_LINK_IFELSE([ |
| 160 | AC_LANG_FUNC_LINK_TRY([strerror_r]) |
| 161 | ],[ |
| 162 | tmp_strerror_r="yes" |
| 163 | ],[ |
| 164 | tmp_strerror_r="no" |
| 165 | ]) |
| 166 | if test "$tmp_strerror_r" = "yes"; then |
| 167 | AC_EGREP_CPP([strerror_r],[ |
| 168 | #include <sys/types.h> |
| 169 | #include <string.h> |
| 170 | ],[ |
| 171 | tmp_strerror_r="proto_declared" |
| 172 | ],[ |
| 173 | AC_EGREP_CPP([strerror_r],[ |
| 174 | #define _REENTRANT |
| 175 | #include <sys/types.h> |
| 176 | #include <string.h> |
| 177 | ],[ |
| 178 | tmp_strerror_r="proto_needs_reentrant" |
| 179 | tmp_need_reentrant="yes" |
| 180 | ]) |
| 181 | ]) |
| 182 | fi |
| 183 | ]) |
| 184 | |
| 185 | |
| 186 | dnl CURL_CHECK_NEED_REENTRANT_STRTOK_R |
| 187 | dnl ------------------------------------------------- |
| 188 | dnl Checks if the preprocessor _REENTRANT definition |
| 189 | dnl makes function strtok_r compiler visible. |
| 190 | |
| 191 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRTOK_R], [ |
| 192 | AC_LINK_IFELSE([ |
| 193 | AC_LANG_FUNC_LINK_TRY([strtok_r]) |
| 194 | ],[ |
| 195 | tmp_strtok_r="yes" |
| 196 | ],[ |
| 197 | tmp_strtok_r="no" |
| 198 | ]) |
| 199 | if test "$tmp_strtok_r" = "yes"; then |
| 200 | AC_EGREP_CPP([strtok_r],[ |
| 201 | #include <sys/types.h> |
| 202 | #include <string.h> |
| 203 | ],[ |
| 204 | tmp_strtok_r="proto_declared" |
| 205 | ],[ |
| 206 | AC_EGREP_CPP([strtok_r],[ |
| 207 | #define _REENTRANT |
| 208 | #include <sys/types.h> |
| 209 | #include <string.h> |
| 210 | ],[ |
| 211 | tmp_strtok_r="proto_needs_reentrant" |
| 212 | tmp_need_reentrant="yes" |
| 213 | ]) |
| 214 | ]) |
| 215 | fi |
| 216 | ]) |
| 217 | |
| 218 | |
| 219 | dnl CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R |
| 220 | dnl ------------------------------------------------- |
| 221 | dnl Checks if the preprocessor _REENTRANT definition |
| 222 | dnl makes function gethostbyname_r compiler visible. |
| 223 | |
| 224 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R], [ |
| 225 | AC_LINK_IFELSE([ |
| 226 | AC_LANG_FUNC_LINK_TRY([gethostbyname_r]) |
| 227 | ],[ |
| 228 | tmp_gethostbyname_r="yes" |
| 229 | ],[ |
| 230 | tmp_gethostbyname_r="no" |
| 231 | ]) |
| 232 | if test "$tmp_gethostbyname_r" = "yes"; then |
| 233 | AC_EGREP_CPP([gethostbyname_r],[ |
| 234 | #include <sys/types.h> |
| 235 | #include <netdb.h> |
| 236 | ],[ |
| 237 | tmp_gethostbyname_r="proto_declared" |
| 238 | ],[ |
| 239 | AC_EGREP_CPP([gethostbyname_r],[ |
| 240 | #define _REENTRANT |
| 241 | #include <sys/types.h> |
| 242 | #include <netdb.h> |
| 243 | ],[ |
| 244 | tmp_gethostbyname_r="proto_needs_reentrant" |
| 245 | tmp_need_reentrant="yes" |
| 246 | ]) |
| 247 | ]) |
| 248 | fi |
| 249 | ]) |
| 250 | |
| 251 | |
| 252 | dnl CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R |
| 253 | dnl ------------------------------------------------- |
| 254 | dnl Checks if the preprocessor _REENTRANT definition |
| 255 | dnl makes function getprotobyname_r compiler visible. |
| 256 | |
| 257 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R], [ |
| 258 | AC_LINK_IFELSE([ |
| 259 | AC_LANG_FUNC_LINK_TRY([getprotobyname_r]) |
| 260 | ],[ |
| 261 | tmp_getprotobyname_r="yes" |
| 262 | ],[ |
| 263 | tmp_getprotobyname_r="no" |
| 264 | ]) |
| 265 | if test "$tmp_getprotobyname_r" = "yes"; then |
| 266 | AC_EGREP_CPP([getprotobyname_r],[ |
| 267 | #include <sys/types.h> |
| 268 | #include <netdb.h> |
| 269 | ],[ |
| 270 | tmp_getprotobyname_r="proto_declared" |
| 271 | ],[ |
| 272 | AC_EGREP_CPP([getprotobyname_r],[ |
| 273 | #define _REENTRANT |
| 274 | #include <sys/types.h> |
| 275 | #include <netdb.h> |
| 276 | ],[ |
| 277 | tmp_getprotobyname_r="proto_needs_reentrant" |
| 278 | tmp_need_reentrant="yes" |
| 279 | ]) |
| 280 | ]) |
| 281 | fi |
| 282 | ]) |
| 283 | |
| 284 | |
| 285 | dnl CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R |
| 286 | dnl ------------------------------------------------- |
| 287 | dnl Checks if the preprocessor _REENTRANT definition |
| 288 | dnl makes several _r functions compiler visible. |
| 289 | dnl Internal macro for CURL_CONFIGURE_REENTRANT. |
| 290 | |
| 291 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R], [ |
| 292 | if test "$tmp_need_reentrant" = "no"; then |
| 293 | CURL_CHECK_NEED_REENTRANT_GMTIME_R |
| 294 | fi |
| 295 | if test "$tmp_need_reentrant" = "no"; then |
| 296 | CURL_CHECK_NEED_REENTRANT_LOCALTIME_R |
| 297 | fi |
| 298 | if test "$tmp_need_reentrant" = "no"; then |
| 299 | CURL_CHECK_NEED_REENTRANT_STRERROR_R |
| 300 | fi |
| 301 | if test "$tmp_need_reentrant" = "no"; then |
| 302 | CURL_CHECK_NEED_REENTRANT_STRTOK_R |
| 303 | fi |
| 304 | if test "$tmp_need_reentrant" = "no"; then |
| 305 | CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R |
| 306 | fi |
| 307 | if test "$tmp_need_reentrant" = "no"; then |
| 308 | CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R |
| 309 | fi |
| 310 | ]) |
| 311 | |
| 312 | |
| 313 | dnl CURL_CHECK_NEED_REENTRANT_SYSTEM |
| 314 | dnl ------------------------------------------------- |
| 315 | dnl Checks if the preprocessor _REENTRANT definition |
| 316 | dnl must be unconditionally done for this platform. |
| 317 | dnl Internal macro for CURL_CONFIGURE_REENTRANT. |
| 318 | |
| 319 | AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [ |
| 320 | case $host_os in |
| 321 | solaris*) |
| 322 | tmp_need_reentrant="yes" |
| 323 | ;; |
| 324 | *) |
| 325 | tmp_need_reentrant="no" |
| 326 | ;; |
| 327 | esac |
| 328 | ]) |
| 329 | |
| 330 | |
| 331 | dnl CURL_CHECK_NEED_THREAD_SAFE_SYSTEM |
| 332 | dnl ------------------------------------------------- |
| 333 | dnl Checks if the preprocessor _THREAD_SAFE definition |
| 334 | dnl must be unconditionally done for this platform. |
| 335 | dnl Internal macro for CURL_CONFIGURE_THREAD_SAFE. |
| 336 | |
| 337 | AC_DEFUN([CURL_CHECK_NEED_THREAD_SAFE_SYSTEM], [ |
| 338 | case $host_os in |
| 339 | aix[[123]].* | aix4.[[012]].*) |
| 340 | dnl aix 4.2 and older |
| 341 | tmp_need_thread_safe="no" |
| 342 | ;; |
| 343 | aix*) |
| 344 | dnl AIX 4.3 and newer |
| 345 | tmp_need_thread_safe="yes" |
| 346 | ;; |
| 347 | *) |
| 348 | tmp_need_thread_safe="no" |
| 349 | ;; |
| 350 | esac |
| 351 | ]) |
| 352 | |
| 353 | |
| 354 | dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT |
| 355 | dnl ------------------------------------------------- |
| 356 | dnl This macro ensures that configuration tests done |
| 357 | dnl after this will execute with preprocessor symbol |
| 358 | dnl _REENTRANT defined. This macro also ensures that |
| 359 | dnl the generated config file defines NEED_REENTRANT |
| 360 | dnl and that in turn curl_setup.h will define _REENTRANT. |
| 361 | dnl Internal macro for CURL_CONFIGURE_REENTRANT. |
| 362 | |
| 363 | AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [ |
| 364 | AC_DEFINE(NEED_REENTRANT, 1, |
| 365 | [Define to 1 if _REENTRANT preprocessor symbol must be defined.]) |
| 366 | cat >>confdefs.h <<_EOF |
| 367 | #ifndef _REENTRANT |
| 368 | # define _REENTRANT |
| 369 | #endif |
| 370 | _EOF |
| 371 | ]) |
| 372 | |
| 373 | |
| 374 | dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE |
| 375 | dnl ------------------------------------------------- |
| 376 | dnl This macro ensures that configuration tests done |
| 377 | dnl after this will execute with preprocessor symbol |
| 378 | dnl _THREAD_SAFE defined. This macro also ensures that |
| 379 | dnl the generated config file defines NEED_THREAD_SAFE |
| 380 | dnl and that in turn curl_setup.h will define _THREAD_SAFE. |
| 381 | dnl Internal macro for CURL_CONFIGURE_THREAD_SAFE. |
| 382 | |
| 383 | AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE], [ |
| 384 | AC_DEFINE(NEED_THREAD_SAFE, 1, |
| 385 | [Define to 1 if _THREAD_SAFE preprocessor symbol must be defined.]) |
| 386 | cat >>confdefs.h <<_EOF |
| 387 | #ifndef _THREAD_SAFE |
| 388 | # define _THREAD_SAFE |
| 389 | #endif |
| 390 | _EOF |
| 391 | ]) |
| 392 | |
| 393 | |
| 394 | dnl CURL_CONFIGURE_REENTRANT |
| 395 | dnl ------------------------------------------------- |
| 396 | dnl This first checks if the preprocessor _REENTRANT |
| 397 | dnl symbol is already defined. If it isn't currently |
| 398 | dnl defined a set of checks are performed to verify |
| 399 | dnl if its definition is required to make visible to |
| 400 | dnl the compiler a set of *_r functions. Finally, if |
| 401 | dnl _REENTRANT is already defined or needed it takes |
| 402 | dnl care of making adjustments necessary to ensure |
| 403 | dnl that it is defined equally for further configure |
| 404 | dnl tests and generated config file. |
| 405 | |
| 406 | AC_DEFUN([CURL_CONFIGURE_REENTRANT], [ |
| 407 | AC_PREREQ([2.50])dnl |
| 408 | # |
| 409 | AC_MSG_CHECKING([if _REENTRANT is already defined]) |
| 410 | AC_COMPILE_IFELSE([ |
| 411 | AC_LANG_PROGRAM([[ |
| 412 | ]],[[ |
| 413 | #ifdef _REENTRANT |
| 414 | int dummy=1; |
| 415 | #else |
| 416 | force compilation error |
| 417 | #endif |
| 418 | ]]) |
| 419 | ],[ |
| 420 | AC_MSG_RESULT([yes]) |
| 421 | tmp_reentrant_initially_defined="yes" |
| 422 | ],[ |
| 423 | AC_MSG_RESULT([no]) |
| 424 | tmp_reentrant_initially_defined="no" |
| 425 | ]) |
| 426 | # |
| 427 | if test "$tmp_reentrant_initially_defined" = "no"; then |
| 428 | AC_MSG_CHECKING([if _REENTRANT is actually needed]) |
| 429 | CURL_CHECK_NEED_REENTRANT_SYSTEM |
| 430 | if test "$tmp_need_reentrant" = "no"; then |
| 431 | CURL_CHECK_NEED_REENTRANT_ERRNO |
| 432 | fi |
| 433 | if test "$tmp_need_reentrant" = "no"; then |
| 434 | CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R |
| 435 | fi |
| 436 | if test "$tmp_need_reentrant" = "yes"; then |
| 437 | AC_MSG_RESULT([yes]) |
| 438 | else |
| 439 | AC_MSG_RESULT([no]) |
| 440 | fi |
| 441 | fi |
| 442 | # |
| 443 | AC_MSG_CHECKING([if _REENTRANT is onwards defined]) |
| 444 | if test "$tmp_reentrant_initially_defined" = "yes" || |
| 445 | test "$tmp_need_reentrant" = "yes"; then |
| 446 | CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT |
| 447 | AC_MSG_RESULT([yes]) |
| 448 | else |
| 449 | AC_MSG_RESULT([no]) |
| 450 | fi |
| 451 | # |
| 452 | ]) |
| 453 | |
| 454 | |
| 455 | dnl CURL_CONFIGURE_THREAD_SAFE |
| 456 | dnl ------------------------------------------------- |
| 457 | dnl This first checks if the preprocessor _THREAD_SAFE |
| 458 | dnl symbol is already defined. If it isn't currently |
| 459 | dnl defined a set of checks are performed to verify |
| 460 | dnl if its definition is required. Finally, if |
| 461 | dnl _THREAD_SAFE is already defined or needed it takes |
| 462 | dnl care of making adjustments necessary to ensure |
| 463 | dnl that it is defined equally for further configure |
| 464 | dnl tests and generated config file. |
| 465 | |
| 466 | AC_DEFUN([CURL_CONFIGURE_THREAD_SAFE], [ |
| 467 | AC_PREREQ([2.50])dnl |
| 468 | # |
| 469 | AC_MSG_CHECKING([if _THREAD_SAFE is already defined]) |
| 470 | AC_COMPILE_IFELSE([ |
| 471 | AC_LANG_PROGRAM([[ |
| 472 | ]],[[ |
| 473 | #ifdef _THREAD_SAFE |
| 474 | int dummy=1; |
| 475 | #else |
| 476 | force compilation error |
| 477 | #endif |
| 478 | ]]) |
| 479 | ],[ |
| 480 | AC_MSG_RESULT([yes]) |
| 481 | tmp_thread_safe_initially_defined="yes" |
| 482 | ],[ |
| 483 | AC_MSG_RESULT([no]) |
| 484 | tmp_thread_safe_initially_defined="no" |
| 485 | ]) |
| 486 | # |
| 487 | if test "$tmp_thread_safe_initially_defined" = "no"; then |
| 488 | AC_MSG_CHECKING([if _THREAD_SAFE is actually needed]) |
| 489 | CURL_CHECK_NEED_THREAD_SAFE_SYSTEM |
| 490 | if test "$tmp_need_thread_safe" = "yes"; then |
| 491 | AC_MSG_RESULT([yes]) |
| 492 | else |
| 493 | AC_MSG_RESULT([no]) |
| 494 | fi |
| 495 | fi |
| 496 | # |
| 497 | AC_MSG_CHECKING([if _THREAD_SAFE is onwards defined]) |
| 498 | if test "$tmp_thread_safe_initially_defined" = "yes" || |
| 499 | test "$tmp_need_thread_safe" = "yes"; then |
| 500 | CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE |
| 501 | AC_MSG_RESULT([yes]) |
| 502 | else |
| 503 | AC_MSG_RESULT([no]) |
| 504 | fi |
| 505 | # |
| 506 | ]) |