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