xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | #--------------------------------------------------------------------------- |
| 2 | # |
| 3 | # xc-lt-iface.m4 |
| 4 | # |
| 5 | # Copyright (c) 2013 - 2022, Daniel Stenberg <daniel@haxx.se> |
| 6 | # |
| 7 | # Permission to use, copy, modify, and distribute this software for any |
| 8 | # purpose with or without fee is hereby granted, provided that the above |
| 9 | # copyright notice and this permission notice appear in all copies. |
| 10 | # |
| 11 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 12 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 13 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 14 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 15 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 16 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 17 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 18 | # |
| 19 | # SPDX-License-Identifier: ISC |
| 20 | # |
| 21 | #--------------------------------------------------------------------------- |
| 22 | |
| 23 | # serial 1 |
| 24 | |
| 25 | |
| 26 | dnl _XC_LIBTOOL_PREAMBLE |
| 27 | dnl ------------------------------------------------- |
| 28 | dnl Private macro. |
| 29 | dnl |
| 30 | dnl Checks some configure script options related with |
| 31 | dnl libtool and customizes its default behavior before |
| 32 | dnl libtool code is actually used in script. |
| 33 | |
| 34 | m4_define([_XC_LIBTOOL_PREAMBLE], |
| 35 | [dnl |
| 36 | # ------------------------------------ # |
| 37 | # Determine libtool default behavior # |
| 38 | # ------------------------------------ # |
| 39 | |
| 40 | # |
| 41 | # Default behavior is to enable shared and static libraries on systems |
| 42 | # where libtool knows how to build both library versions, and does not |
| 43 | # require separate configuration and build runs for each flavor. |
| 44 | # |
| 45 | |
| 46 | xc_lt_want_enable_shared='yes' |
| 47 | xc_lt_want_enable_static='yes' |
| 48 | |
| 49 | # |
| 50 | # User may have disabled shared or static libraries. |
| 51 | # |
| 52 | case "x$enable_shared" in @%:@ ( |
| 53 | xno) |
| 54 | xc_lt_want_enable_shared='no' |
| 55 | ;; |
| 56 | esac |
| 57 | case "x$enable_static" in @%:@ ( |
| 58 | xno) |
| 59 | xc_lt_want_enable_static='no' |
| 60 | ;; |
| 61 | esac |
| 62 | if test "x$xc_lt_want_enable_shared" = 'xno' && |
| 63 | test "x$xc_lt_want_enable_static" = 'xno'; then |
| 64 | AC_MSG_ERROR([can not disable shared and static libraries simultaneously]) |
| 65 | fi |
| 66 | |
| 67 | # |
| 68 | # Default behavior on systems that require independent configuration |
| 69 | # and build runs for shared and static is to enable shared libraries |
| 70 | # and disable static ones. On these systems option '--disable-shared' |
| 71 | # must be used in order to build a proper static library. |
| 72 | # |
| 73 | |
| 74 | if test "x$xc_lt_want_enable_shared" = 'xyes' && |
| 75 | test "x$xc_lt_want_enable_static" = 'xyes'; then |
| 76 | case $host_os in @%:@ ( |
| 77 | pw32* | cegcc* | os2* | aix*) |
| 78 | xc_lt_want_enable_static='no' |
| 79 | ;; |
| 80 | esac |
| 81 | fi |
| 82 | |
| 83 | # |
| 84 | # Make libtool aware of current shared and static library preferences |
| 85 | # taking in account that, depending on host characteristics, libtool |
| 86 | # may modify these option preferences later in this configure script. |
| 87 | # |
| 88 | |
| 89 | enable_shared=$xc_lt_want_enable_shared |
| 90 | enable_static=$xc_lt_want_enable_static |
| 91 | |
| 92 | # |
| 93 | # Default behavior is to build PIC objects for shared libraries and |
| 94 | # non-PIC objects for static libraries. |
| 95 | # |
| 96 | |
| 97 | xc_lt_want_with_pic='default' |
| 98 | |
| 99 | # |
| 100 | # User may have specified PIC preference. |
| 101 | # |
| 102 | |
| 103 | case "x$with_pic" in @%:@ (( |
| 104 | xno) |
| 105 | xc_lt_want_with_pic='no' |
| 106 | ;; |
| 107 | xyes) |
| 108 | xc_lt_want_with_pic='yes' |
| 109 | ;; |
| 110 | esac |
| 111 | |
| 112 | # |
| 113 | # Default behavior on some systems where building a shared library out |
| 114 | # of non-PIC compiled objects will fail with following linker error |
| 115 | # "relocation R_X86_64_32 can not be used when making a shared object" |
| 116 | # is to build PIC objects even for static libraries. This behavior may |
| 117 | # be overridden using 'configure --disable-shared --without-pic'. |
| 118 | # |
| 119 | |
| 120 | if test "x$xc_lt_want_with_pic" = 'xdefault'; then |
| 121 | case $host_cpu in @%:@ ( |
| 122 | x86_64 | amd64 | ia64) |
| 123 | case $host_os in @%:@ ( |
| 124 | linux* | freebsd* | midnightbsd*) |
| 125 | xc_lt_want_with_pic='yes' |
| 126 | ;; |
| 127 | esac |
| 128 | ;; |
| 129 | esac |
| 130 | fi |
| 131 | |
| 132 | # |
| 133 | # Make libtool aware of current PIC preference taking in account that, |
| 134 | # depending on host characteristics, libtool may modify PIC default |
| 135 | # behavior to fit host system idiosyncrasies later in this script. |
| 136 | # |
| 137 | |
| 138 | with_pic=$xc_lt_want_with_pic |
| 139 | dnl |
| 140 | m4_define([$0],[])dnl |
| 141 | ]) |
| 142 | |
| 143 | |
| 144 | dnl _XC_LIBTOOL_BODY |
| 145 | dnl ------------------------------------------------- |
| 146 | dnl Private macro. |
| 147 | dnl |
| 148 | dnl This macro performs embedding of libtool code into |
| 149 | dnl configure script, regardless of libtool version in |
| 150 | dnl use when generating configure script. |
| 151 | |
| 152 | m4_define([_XC_LIBTOOL_BODY], |
| 153 | [dnl |
| 154 | ## ----------------------- ## |
| 155 | ## Start of libtool code ## |
| 156 | ## ----------------------- ## |
| 157 | m4_ifdef([LT_INIT], |
| 158 | [dnl |
| 159 | LT_INIT([win32-dll]) |
| 160 | ],[dnl |
| 161 | AC_LIBTOOL_WIN32_DLL |
| 162 | AC_PROG_LIBTOOL |
| 163 | ])dnl |
| 164 | ## --------------------- ## |
| 165 | ## End of libtool code ## |
| 166 | ## --------------------- ## |
| 167 | dnl |
| 168 | m4_define([$0], [])[]dnl |
| 169 | ]) |
| 170 | |
| 171 | |
| 172 | dnl _XC_CHECK_LT_BUILD_LIBRARIES |
| 173 | dnl ------------------------------------------------- |
| 174 | dnl Private macro. |
| 175 | dnl |
| 176 | dnl Checks whether libtool shared and static libraries |
| 177 | dnl are finally built depending on user input, default |
| 178 | dnl behavior and knowledge that libtool has about host |
| 179 | dnl characteristics. |
| 180 | dnl Results stored in following shell variables: |
| 181 | dnl xc_lt_build_shared |
| 182 | dnl xc_lt_build_static |
| 183 | |
| 184 | m4_define([_XC_CHECK_LT_BUILD_LIBRARIES], |
| 185 | [dnl |
| 186 | # |
| 187 | # Verify if finally libtool shared libraries will be built |
| 188 | # |
| 189 | |
| 190 | case "x$enable_shared" in @%:@ (( |
| 191 | xyes | xno) |
| 192 | xc_lt_build_shared=$enable_shared |
| 193 | ;; |
| 194 | *) |
| 195 | AC_MSG_ERROR([unexpected libtool enable_shared value: $enable_shared]) |
| 196 | ;; |
| 197 | esac |
| 198 | |
| 199 | # |
| 200 | # Verify if finally libtool static libraries will be built |
| 201 | # |
| 202 | |
| 203 | case "x$enable_static" in @%:@ (( |
| 204 | xyes | xno) |
| 205 | xc_lt_build_static=$enable_static |
| 206 | ;; |
| 207 | *) |
| 208 | AC_MSG_ERROR([unexpected libtool enable_static value: $enable_static]) |
| 209 | ;; |
| 210 | esac |
| 211 | dnl |
| 212 | m4_define([$0],[])dnl |
| 213 | ]) |
| 214 | |
| 215 | |
| 216 | dnl _XC_CHECK_LT_SHLIB_USE_VERSION_INFO |
| 217 | dnl ------------------------------------------------- |
| 218 | dnl Private macro. |
| 219 | dnl |
| 220 | dnl Checks if the -version-info linker flag must be |
| 221 | dnl provided when building libtool shared libraries. |
| 222 | dnl Result stored in xc_lt_shlib_use_version_info. |
| 223 | |
| 224 | m4_define([_XC_CHECK_LT_SHLIB_USE_VERSION_INFO], |
| 225 | [dnl |
| 226 | # |
| 227 | # Verify if libtool shared libraries should be linked using flag -version-info |
| 228 | # |
| 229 | |
| 230 | AC_MSG_CHECKING([whether to build shared libraries with -version-info]) |
| 231 | xc_lt_shlib_use_version_info='yes' |
| 232 | if test "x$version_type" = 'xnone'; then |
| 233 | xc_lt_shlib_use_version_info='no' |
| 234 | fi |
| 235 | case $host_os in @%:@ ( |
| 236 | amigaos*) |
| 237 | xc_lt_shlib_use_version_info='yes' |
| 238 | ;; |
| 239 | esac |
| 240 | AC_MSG_RESULT([$xc_lt_shlib_use_version_info]) |
| 241 | dnl |
| 242 | m4_define([$0], [])[]dnl |
| 243 | ]) |
| 244 | |
| 245 | |
| 246 | dnl _XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED |
| 247 | dnl ------------------------------------------------- |
| 248 | dnl Private macro. |
| 249 | dnl |
| 250 | dnl Checks if the -no-undefined linker flag must be |
| 251 | dnl provided when building libtool shared libraries. |
| 252 | dnl Result stored in xc_lt_shlib_use_no_undefined. |
| 253 | |
| 254 | m4_define([_XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED], |
| 255 | [dnl |
| 256 | # |
| 257 | # Verify if libtool shared libraries should be linked using flag -no-undefined |
| 258 | # |
| 259 | |
| 260 | AC_MSG_CHECKING([whether to build shared libraries with -no-undefined]) |
| 261 | xc_lt_shlib_use_no_undefined='no' |
| 262 | if test "x$allow_undefined" = 'xno'; then |
| 263 | xc_lt_shlib_use_no_undefined='yes' |
| 264 | elif test "x$allow_undefined_flag" = 'xunsupported'; then |
| 265 | xc_lt_shlib_use_no_undefined='yes' |
| 266 | fi |
| 267 | case $host_os in @%:@ ( |
| 268 | cygwin* | mingw* | pw32* | cegcc* | os2* | aix*) |
| 269 | xc_lt_shlib_use_no_undefined='yes' |
| 270 | ;; |
| 271 | esac |
| 272 | AC_MSG_RESULT([$xc_lt_shlib_use_no_undefined]) |
| 273 | dnl |
| 274 | m4_define([$0], [])[]dnl |
| 275 | ]) |
| 276 | |
| 277 | |
| 278 | dnl _XC_CHECK_LT_SHLIB_USE_MIMPURE_TEXT |
| 279 | dnl ------------------------------------------------- |
| 280 | dnl Private macro. |
| 281 | dnl |
| 282 | dnl Checks if the -mimpure-text linker flag must be |
| 283 | dnl provided when building libtool shared libraries. |
| 284 | dnl Result stored in xc_lt_shlib_use_mimpure_text. |
| 285 | |
| 286 | m4_define([_XC_CHECK_LT_SHLIB_USE_MIMPURE_TEXT], |
| 287 | [dnl |
| 288 | # |
| 289 | # Verify if libtool shared libraries should be linked using flag -mimpure-text |
| 290 | # |
| 291 | |
| 292 | AC_MSG_CHECKING([whether to build shared libraries with -mimpure-text]) |
| 293 | xc_lt_shlib_use_mimpure_text='no' |
| 294 | case $host_os in @%:@ ( |
| 295 | solaris2*) |
| 296 | if test "x$GCC" = 'xyes'; then |
| 297 | xc_lt_shlib_use_mimpure_text='yes' |
| 298 | fi |
| 299 | ;; |
| 300 | esac |
| 301 | AC_MSG_RESULT([$xc_lt_shlib_use_mimpure_text]) |
| 302 | dnl |
| 303 | m4_define([$0], [])[]dnl |
| 304 | ]) |
| 305 | |
| 306 | |
| 307 | dnl _XC_CHECK_LT_BUILD_WITH_PIC |
| 308 | dnl ------------------------------------------------- |
| 309 | dnl Private macro. |
| 310 | dnl |
| 311 | dnl Checks whether libtool shared and static libraries |
| 312 | dnl would be built with PIC depending on user input, |
| 313 | dnl default behavior and knowledge that libtool has |
| 314 | dnl about host characteristics. |
| 315 | dnl Results stored in following shell variables: |
| 316 | dnl xc_lt_build_shared_with_pic |
| 317 | dnl xc_lt_build_static_with_pic |
| 318 | |
| 319 | m4_define([_XC_CHECK_LT_BUILD_WITH_PIC], |
| 320 | [dnl |
| 321 | # |
| 322 | # Find out whether libtool libraries would be built with PIC |
| 323 | # |
| 324 | |
| 325 | case "x$pic_mode" in @%:@ (((( |
| 326 | xdefault) |
| 327 | xc_lt_build_shared_with_pic='yes' |
| 328 | xc_lt_build_static_with_pic='no' |
| 329 | ;; |
| 330 | xyes) |
| 331 | xc_lt_build_shared_with_pic='yes' |
| 332 | xc_lt_build_static_with_pic='yes' |
| 333 | ;; |
| 334 | xno) |
| 335 | xc_lt_build_shared_with_pic='no' |
| 336 | xc_lt_build_static_with_pic='no' |
| 337 | ;; |
| 338 | *) |
| 339 | xc_lt_build_shared_with_pic='unknown' |
| 340 | xc_lt_build_static_with_pic='unknown' |
| 341 | AC_MSG_WARN([unexpected libtool pic_mode value: $pic_mode]) |
| 342 | ;; |
| 343 | esac |
| 344 | AC_MSG_CHECKING([whether to build shared libraries with PIC]) |
| 345 | AC_MSG_RESULT([$xc_lt_build_shared_with_pic]) |
| 346 | AC_MSG_CHECKING([whether to build static libraries with PIC]) |
| 347 | AC_MSG_RESULT([$xc_lt_build_static_with_pic]) |
| 348 | dnl |
| 349 | m4_define([$0],[])dnl |
| 350 | ]) |
| 351 | |
| 352 | |
| 353 | dnl _XC_CHECK_LT_BUILD_SINGLE_VERSION |
| 354 | dnl ------------------------------------------------- |
| 355 | dnl Private macro. |
| 356 | dnl |
| 357 | dnl Checks whether a libtool shared or static library |
| 358 | dnl is finally built exclusively without the other. |
| 359 | dnl Results stored in following shell variables: |
| 360 | dnl xc_lt_build_shared_only |
| 361 | dnl xc_lt_build_static_only |
| 362 | |
| 363 | m4_define([_XC_CHECK_LT_BUILD_SINGLE_VERSION], |
| 364 | [dnl |
| 365 | # |
| 366 | # Verify if libtool shared libraries will be built while static not built |
| 367 | # |
| 368 | |
| 369 | AC_MSG_CHECKING([whether to build shared libraries only]) |
| 370 | if test "$xc_lt_build_shared" = 'yes' && |
| 371 | test "$xc_lt_build_static" = 'no'; then |
| 372 | xc_lt_build_shared_only='yes' |
| 373 | else |
| 374 | xc_lt_build_shared_only='no' |
| 375 | fi |
| 376 | AC_MSG_RESULT([$xc_lt_build_shared_only]) |
| 377 | |
| 378 | # |
| 379 | # Verify if libtool static libraries will be built while shared not built |
| 380 | # |
| 381 | |
| 382 | AC_MSG_CHECKING([whether to build static libraries only]) |
| 383 | if test "$xc_lt_build_static" = 'yes' && |
| 384 | test "$xc_lt_build_shared" = 'no'; then |
| 385 | xc_lt_build_static_only='yes' |
| 386 | else |
| 387 | xc_lt_build_static_only='no' |
| 388 | fi |
| 389 | AC_MSG_RESULT([$xc_lt_build_static_only]) |
| 390 | dnl |
| 391 | m4_define([$0],[])dnl |
| 392 | ]) |
| 393 | |
| 394 | |
| 395 | dnl _XC_LIBTOOL_POSTLUDE |
| 396 | dnl ------------------------------------------------- |
| 397 | dnl Private macro. |
| 398 | dnl |
| 399 | dnl Performs several checks related with libtool that |
| 400 | dnl can not be done unless libtool code has already |
| 401 | dnl been executed. See individual check descriptions |
| 402 | dnl for further info. |
| 403 | |
| 404 | m4_define([_XC_LIBTOOL_POSTLUDE], |
| 405 | [dnl |
| 406 | _XC_CHECK_LT_BUILD_LIBRARIES |
| 407 | _XC_CHECK_LT_SHLIB_USE_VERSION_INFO |
| 408 | _XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED |
| 409 | _XC_CHECK_LT_SHLIB_USE_MIMPURE_TEXT |
| 410 | _XC_CHECK_LT_BUILD_WITH_PIC |
| 411 | _XC_CHECK_LT_BUILD_SINGLE_VERSION |
| 412 | dnl |
| 413 | m4_define([$0],[])dnl |
| 414 | ]) |
| 415 | |
| 416 | |
| 417 | dnl XC_LIBTOOL |
| 418 | dnl ------------------------------------------------- |
| 419 | dnl Public macro. |
| 420 | dnl |
| 421 | dnl This macro embeds libtool machinery into configure |
| 422 | dnl script, regardless of libtool version, and performs |
| 423 | dnl several additional checks whose results can be used |
| 424 | dnl later on. |
| 425 | dnl |
| 426 | dnl Usage of this macro ensures that generated configure |
| 427 | dnl script uses equivalent logic irrespective of autoconf |
| 428 | dnl or libtool version being used to generate configure |
| 429 | dnl script. |
| 430 | dnl |
| 431 | dnl Results stored in following shell variables: |
| 432 | dnl xc_lt_build_shared |
| 433 | dnl xc_lt_build_static |
| 434 | dnl xc_lt_shlib_use_version_info |
| 435 | dnl xc_lt_shlib_use_no_undefined |
| 436 | dnl xc_lt_shlib_use_mimpure_text |
| 437 | dnl xc_lt_build_shared_with_pic |
| 438 | dnl xc_lt_build_static_with_pic |
| 439 | dnl xc_lt_build_shared_only |
| 440 | dnl xc_lt_build_static_only |
| 441 | |
| 442 | AC_DEFUN([XC_LIBTOOL], |
| 443 | [dnl |
| 444 | AC_PREREQ([2.50])dnl |
| 445 | dnl |
| 446 | AC_BEFORE([$0],[LT_INIT])dnl |
| 447 | AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl |
| 448 | AC_BEFORE([$0],[AC_LIBTOOL_WIN32_DLL])dnl |
| 449 | dnl |
| 450 | AC_REQUIRE([XC_CHECK_PATH_SEPARATOR])dnl |
| 451 | AC_REQUIRE([AC_CANONICAL_HOST])dnl |
| 452 | AC_REQUIRE([AC_PROG_CC])dnl |
| 453 | dnl |
| 454 | _XC_LIBTOOL_PREAMBLE |
| 455 | _XC_LIBTOOL_BODY |
| 456 | _XC_LIBTOOL_POSTLUDE |
| 457 | dnl |
| 458 | m4_ifdef([AC_LIBTOOL_WIN32_DLL], |
| 459 | [m4_undefine([AC_LIBTOOL_WIN32_DLL])])dnl |
| 460 | m4_ifdef([AC_PROG_LIBTOOL], |
| 461 | [m4_undefine([AC_PROG_LIBTOOL])])dnl |
| 462 | m4_ifdef([LT_INIT], |
| 463 | [m4_undefine([LT_INIT])])dnl |
| 464 | dnl |
| 465 | m4_define([$0],[])dnl |
| 466 | ]) |