1 #---------------------------------------------------------------------------
5 # Copyright (c) 2013 Daniel Stenberg <daniel@haxx.se>
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.
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.
19 #---------------------------------------------------------------------------
24 dnl _XC_LIBTOOL_PREAMBLE
25 dnl -------------------------------------------------
28 dnl Checks some configure script options related with
29 dnl libtool and customizes its default behavior before
30 dnl libtool code is actually used in script.
32 m4_define([_XC_LIBTOOL_PREAMBLE],
34 # ------------------------------------ #
35 # Determine libtool default behavior #
36 # ------------------------------------ #
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.
44 xc_lt_want_enable_shared='yes'
45 xc_lt_want_enable_static='yes'
48 # User may have disabled shared or static libraries.
50 case "x$enable_shared" in @%:@ (
52 xc_lt_want_enable_shared='no'
55 case "x$enable_static" in @%:@ (
57 xc_lt_want_enable_static='no'
60 if 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])
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.
72 if 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'
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.
87 enable_shared=$xc_lt_want_enable_shared
88 enable_static=$xc_lt_want_enable_static
91 # Default behavior is to build PIC objects for shared libraries and
92 # non-PIC objects for static libraries.
95 xc_lt_want_with_pic='default'
98 # User may have specified PIC preference.
101 case "x$with_pic" in @%:@ ((
103 xc_lt_want_with_pic='no'
106 xc_lt_want_with_pic='yes'
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 overridden using 'configure --disable-shared --without-pic'.
118 if test "x$xc_lt_want_with_pic" = 'xdefault'; then
119 case $host_cpu in @%:@ (
120 x86_64 | amd64 | ia64)
121 case $host_os in @%:@ (
123 xc_lt_want_with_pic='yes'
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.
136 with_pic=$xc_lt_want_with_pic
138 m4_define([$0],[])dnl
143 dnl -------------------------------------------------
146 dnl This macro performs embedding of libtool code into
147 dnl configure script, regardless of libtool version in
148 dnl use when generating configure script.
150 m4_define([_XC_LIBTOOL_BODY],
152 ## ----------------------- ##
153 ## Start of libtool code ##
154 ## ----------------------- ##
162 ## --------------------- ##
163 ## End of libtool code ##
164 ## --------------------- ##
166 m4_define([$0], [])[]dnl
170 dnl _XC_CHECK_LT_BUILD_LIBRARIES
171 dnl -------------------------------------------------
174 dnl Checks whether libtool shared and static libraries
175 dnl are finally built depending on user input, default
176 dnl behavior and knowledge that libtool has about host
178 dnl Results stored in following shell variables:
179 dnl xc_lt_build_shared
180 dnl xc_lt_build_static
182 m4_define([_XC_CHECK_LT_BUILD_LIBRARIES],
185 # Verify if finally libtool shared libraries will be built
188 case "x$enable_shared" in @%:@ ((
190 xc_lt_build_shared=$enable_shared
193 AC_MSG_ERROR([unexpected libtool enable_shared value: $enable_shared])
198 # Verify if finally libtool static libraries will be built
201 case "x$enable_static" in @%:@ ((
203 xc_lt_build_static=$enable_static
206 AC_MSG_ERROR([unexpected libtool enable_static value: $enable_static])
210 m4_define([$0],[])dnl
214 dnl _XC_CHECK_LT_SHLIB_USE_VERSION_INFO
215 dnl -------------------------------------------------
218 dnl Checks if the -version-info linker flag must be
219 dnl provided when building libtool shared libraries.
220 dnl Result stored in xc_lt_shlib_use_version_info.
222 m4_define([_XC_CHECK_LT_SHLIB_USE_VERSION_INFO],
225 # Verify if libtool shared libraries should be linked using flag -version-info
228 AC_MSG_CHECKING([whether to build shared libraries with -version-info])
229 xc_lt_shlib_use_version_info='yes'
230 if test "x$version_type" = 'xnone'; then
231 xc_lt_shlib_use_version_info='no'
233 case $host_os in @%:@ (
235 xc_lt_shlib_use_version_info='yes'
238 AC_MSG_RESULT([$xc_lt_shlib_use_version_info])
240 m4_define([$0], [])[]dnl
244 dnl _XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED
245 dnl -------------------------------------------------
248 dnl Checks if the -no-undefined linker flag must be
249 dnl provided when building libtool shared libraries.
250 dnl Result stored in xc_lt_shlib_use_no_undefined.
252 m4_define([_XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED],
255 # Verify if libtool shared libraries should be linked using flag -no-undefined
258 AC_MSG_CHECKING([whether to build shared libraries with -no-undefined])
259 xc_lt_shlib_use_no_undefined='no'
260 if test "x$allow_undefined" = 'xno'; then
261 xc_lt_shlib_use_no_undefined='yes'
262 elif test "x$allow_undefined_flag" = 'xunsupported'; then
263 xc_lt_shlib_use_no_undefined='yes'
265 case $host_os in @%:@ (
266 cygwin* | mingw* | pw32* | cegcc* | os2* | aix*)
267 xc_lt_shlib_use_no_undefined='yes'
270 AC_MSG_RESULT([$xc_lt_shlib_use_no_undefined])
272 m4_define([$0], [])[]dnl
276 dnl _XC_CHECK_LT_SHLIB_USE_MIMPURE_TEXT
277 dnl -------------------------------------------------
280 dnl Checks if the -mimpure-text linker flag must be
281 dnl provided when building libtool shared libraries.
282 dnl Result stored in xc_lt_shlib_use_mimpure_text.
284 m4_define([_XC_CHECK_LT_SHLIB_USE_MIMPURE_TEXT],
287 # Verify if libtool shared libraries should be linked using flag -mimpure-text
290 AC_MSG_CHECKING([whether to build shared libraries with -mimpure-text])
291 xc_lt_shlib_use_mimpure_text='no'
292 case $host_os in @%:@ (
294 if test "x$GCC" = 'xyes'; then
295 xc_lt_shlib_use_mimpure_text='yes'
299 AC_MSG_RESULT([$xc_lt_shlib_use_mimpure_text])
301 m4_define([$0], [])[]dnl
305 dnl _XC_CHECK_LT_BUILD_WITH_PIC
306 dnl -------------------------------------------------
309 dnl Checks whether libtool shared and static libraries
310 dnl would be built with PIC depending on user input,
311 dnl default behavior and knowledge that libtool has
312 dnl about host characteristics.
313 dnl Results stored in following shell variables:
314 dnl xc_lt_build_shared_with_pic
315 dnl xc_lt_build_static_with_pic
317 m4_define([_XC_CHECK_LT_BUILD_WITH_PIC],
320 # Find out whether libtool libraries would be built wit PIC
323 case "x$pic_mode" in @%:@ ((((
325 xc_lt_build_shared_with_pic='yes'
326 xc_lt_build_static_with_pic='no'
329 xc_lt_build_shared_with_pic='yes'
330 xc_lt_build_static_with_pic='yes'
333 xc_lt_build_shared_with_pic='no'
334 xc_lt_build_static_with_pic='no'
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])
342 AC_MSG_CHECKING([whether to build shared libraries with PIC])
343 AC_MSG_RESULT([$xc_lt_build_shared_with_pic])
344 AC_MSG_CHECKING([whether to build static libraries with PIC])
345 AC_MSG_RESULT([$xc_lt_build_static_with_pic])
347 m4_define([$0],[])dnl
351 dnl _XC_CHECK_LT_BUILD_SINGLE_VERSION
352 dnl -------------------------------------------------
355 dnl Checks whether a libtool shared or static library
356 dnl is finally built exclusively without the other.
357 dnl Results stored in following shell variables:
358 dnl xc_lt_build_shared_only
359 dnl xc_lt_build_static_only
361 m4_define([_XC_CHECK_LT_BUILD_SINGLE_VERSION],
364 # Verify if libtool shared libraries will be built while static not built
367 AC_MSG_CHECKING([whether to build shared libraries only])
368 if test "$xc_lt_build_shared" = 'yes' &&
369 test "$xc_lt_build_static" = 'no'; then
370 xc_lt_build_shared_only='yes'
372 xc_lt_build_shared_only='no'
374 AC_MSG_RESULT([$xc_lt_build_shared_only])
377 # Verify if libtool static libraries will be built while shared not built
380 AC_MSG_CHECKING([whether to build static libraries only])
381 if test "$xc_lt_build_static" = 'yes' &&
382 test "$xc_lt_build_shared" = 'no'; then
383 xc_lt_build_static_only='yes'
385 xc_lt_build_static_only='no'
387 AC_MSG_RESULT([$xc_lt_build_static_only])
389 m4_define([$0],[])dnl
393 dnl _XC_LIBTOOL_POSTLUDE
394 dnl -------------------------------------------------
397 dnl Performs several checks related with libtool that
398 dnl can not be done unless libtool code has already
399 dnl been executed. See individual check descriptions
400 dnl for further info.
402 m4_define([_XC_LIBTOOL_POSTLUDE],
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
411 m4_define([$0],[])dnl
416 dnl -------------------------------------------------
419 dnl This macro embeds libtool machinery into configure
420 dnl script, regardless of libtool version, and performs
421 dnl several additional checks whose results can be used
424 dnl Usage of this macro ensures that generated configure
425 dnl script uses equivalent logic irrespective of autoconf
426 dnl or libtool version being used to generate configure
429 dnl Results stored in following shell variables:
430 dnl xc_lt_build_shared
431 dnl xc_lt_build_static
432 dnl xc_lt_shlib_use_version_info
433 dnl xc_lt_shlib_use_no_undefined
434 dnl xc_lt_shlib_use_mimpure_text
435 dnl xc_lt_build_shared_with_pic
436 dnl xc_lt_build_static_with_pic
437 dnl xc_lt_build_shared_only
438 dnl xc_lt_build_static_only
440 AC_DEFUN([XC_LIBTOOL],
444 AC_BEFORE([$0],[LT_INIT])dnl
445 AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
446 AC_BEFORE([$0],[AC_LIBTOOL_WIN32_DLL])dnl
448 AC_REQUIRE([XC_CHECK_PATH_SEPARATOR])dnl
449 AC_REQUIRE([AC_CANONICAL_HOST])dnl
450 AC_REQUIRE([AC_PROG_CC])dnl
456 m4_ifdef([AC_LIBTOOL_WIN32_DLL],
457 [m4_undefine([AC_LIBTOOL_WIN32_DLL])])dnl
458 m4_ifdef([AC_PROG_LIBTOOL],
459 [m4_undefine([AC_PROG_LIBTOOL])])dnl
461 [m4_undefine([LT_INIT])])dnl
463 m4_define([$0],[])dnl