blob: 337c9f9cdf3d5ca36d7579460100f373f4b0cc93 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001#---------------------------------------------------------------------------
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
26dnl _XC_LIBTOOL_PREAMBLE
27dnl -------------------------------------------------
28dnl Private macro.
29dnl
30dnl Checks some configure script options related with
31dnl libtool and customizes its default behavior before
32dnl libtool code is actually used in script.
33
34m4_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
46xc_lt_want_enable_shared='yes'
47xc_lt_want_enable_static='yes'
48
49#
50# User may have disabled shared or static libraries.
51#
52case "x$enable_shared" in @%:@ (
53 xno)
54 xc_lt_want_enable_shared='no'
55 ;;
56esac
57case "x$enable_static" in @%:@ (
58 xno)
59 xc_lt_want_enable_static='no'
60 ;;
61esac
62if 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])
65fi
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
74if 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
81fi
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
89enable_shared=$xc_lt_want_enable_shared
90enable_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
97xc_lt_want_with_pic='default'
98
99#
100# User may have specified PIC preference.
101#
102
103case "x$with_pic" in @%:@ ((
104 xno)
105 xc_lt_want_with_pic='no'
106 ;;
107 xyes)
108 xc_lt_want_with_pic='yes'
109 ;;
110esac
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
120if 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
130fi
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
138with_pic=$xc_lt_want_with_pic
139dnl
140m4_define([$0],[])dnl
141])
142
143
144dnl _XC_LIBTOOL_BODY
145dnl -------------------------------------------------
146dnl Private macro.
147dnl
148dnl This macro performs embedding of libtool code into
149dnl configure script, regardless of libtool version in
150dnl use when generating configure script.
151
152m4_define([_XC_LIBTOOL_BODY],
153[dnl
154## ----------------------- ##
155## Start of libtool code ##
156## ----------------------- ##
157m4_ifdef([LT_INIT],
158[dnl
159LT_INIT([win32-dll])
160],[dnl
161AC_LIBTOOL_WIN32_DLL
162AC_PROG_LIBTOOL
163])dnl
164## --------------------- ##
165## End of libtool code ##
166## --------------------- ##
167dnl
168m4_define([$0], [])[]dnl
169])
170
171
172dnl _XC_CHECK_LT_BUILD_LIBRARIES
173dnl -------------------------------------------------
174dnl Private macro.
175dnl
176dnl Checks whether libtool shared and static libraries
177dnl are finally built depending on user input, default
178dnl behavior and knowledge that libtool has about host
179dnl characteristics.
180dnl Results stored in following shell variables:
181dnl xc_lt_build_shared
182dnl xc_lt_build_static
183
184m4_define([_XC_CHECK_LT_BUILD_LIBRARIES],
185[dnl
186#
187# Verify if finally libtool shared libraries will be built
188#
189
190case "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 ;;
197esac
198
199#
200# Verify if finally libtool static libraries will be built
201#
202
203case "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 ;;
210esac
211dnl
212m4_define([$0],[])dnl
213])
214
215
216dnl _XC_CHECK_LT_SHLIB_USE_VERSION_INFO
217dnl -------------------------------------------------
218dnl Private macro.
219dnl
220dnl Checks if the -version-info linker flag must be
221dnl provided when building libtool shared libraries.
222dnl Result stored in xc_lt_shlib_use_version_info.
223
224m4_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
230AC_MSG_CHECKING([whether to build shared libraries with -version-info])
231xc_lt_shlib_use_version_info='yes'
232if test "x$version_type" = 'xnone'; then
233 xc_lt_shlib_use_version_info='no'
234fi
235case $host_os in @%:@ (
236 amigaos*)
237 xc_lt_shlib_use_version_info='yes'
238 ;;
239esac
240AC_MSG_RESULT([$xc_lt_shlib_use_version_info])
241dnl
242m4_define([$0], [])[]dnl
243])
244
245
246dnl _XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED
247dnl -------------------------------------------------
248dnl Private macro.
249dnl
250dnl Checks if the -no-undefined linker flag must be
251dnl provided when building libtool shared libraries.
252dnl Result stored in xc_lt_shlib_use_no_undefined.
253
254m4_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
260AC_MSG_CHECKING([whether to build shared libraries with -no-undefined])
261xc_lt_shlib_use_no_undefined='no'
262if test "x$allow_undefined" = 'xno'; then
263 xc_lt_shlib_use_no_undefined='yes'
264elif test "x$allow_undefined_flag" = 'xunsupported'; then
265 xc_lt_shlib_use_no_undefined='yes'
266fi
267case $host_os in @%:@ (
268 cygwin* | mingw* | pw32* | cegcc* | os2* | aix*)
269 xc_lt_shlib_use_no_undefined='yes'
270 ;;
271esac
272AC_MSG_RESULT([$xc_lt_shlib_use_no_undefined])
273dnl
274m4_define([$0], [])[]dnl
275])
276
277
278dnl _XC_CHECK_LT_SHLIB_USE_MIMPURE_TEXT
279dnl -------------------------------------------------
280dnl Private macro.
281dnl
282dnl Checks if the -mimpure-text linker flag must be
283dnl provided when building libtool shared libraries.
284dnl Result stored in xc_lt_shlib_use_mimpure_text.
285
286m4_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
292AC_MSG_CHECKING([whether to build shared libraries with -mimpure-text])
293xc_lt_shlib_use_mimpure_text='no'
294case $host_os in @%:@ (
295 solaris2*)
296 if test "x$GCC" = 'xyes'; then
297 xc_lt_shlib_use_mimpure_text='yes'
298 fi
299 ;;
300esac
301AC_MSG_RESULT([$xc_lt_shlib_use_mimpure_text])
302dnl
303m4_define([$0], [])[]dnl
304])
305
306
307dnl _XC_CHECK_LT_BUILD_WITH_PIC
308dnl -------------------------------------------------
309dnl Private macro.
310dnl
311dnl Checks whether libtool shared and static libraries
312dnl would be built with PIC depending on user input,
313dnl default behavior and knowledge that libtool has
314dnl about host characteristics.
315dnl Results stored in following shell variables:
316dnl xc_lt_build_shared_with_pic
317dnl xc_lt_build_static_with_pic
318
319m4_define([_XC_CHECK_LT_BUILD_WITH_PIC],
320[dnl
321#
322# Find out whether libtool libraries would be built with PIC
323#
324
325case "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 ;;
343esac
344AC_MSG_CHECKING([whether to build shared libraries with PIC])
345AC_MSG_RESULT([$xc_lt_build_shared_with_pic])
346AC_MSG_CHECKING([whether to build static libraries with PIC])
347AC_MSG_RESULT([$xc_lt_build_static_with_pic])
348dnl
349m4_define([$0],[])dnl
350])
351
352
353dnl _XC_CHECK_LT_BUILD_SINGLE_VERSION
354dnl -------------------------------------------------
355dnl Private macro.
356dnl
357dnl Checks whether a libtool shared or static library
358dnl is finally built exclusively without the other.
359dnl Results stored in following shell variables:
360dnl xc_lt_build_shared_only
361dnl xc_lt_build_static_only
362
363m4_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
369AC_MSG_CHECKING([whether to build shared libraries only])
370if test "$xc_lt_build_shared" = 'yes' &&
371 test "$xc_lt_build_static" = 'no'; then
372 xc_lt_build_shared_only='yes'
373else
374 xc_lt_build_shared_only='no'
375fi
376AC_MSG_RESULT([$xc_lt_build_shared_only])
377
378#
379# Verify if libtool static libraries will be built while shared not built
380#
381
382AC_MSG_CHECKING([whether to build static libraries only])
383if test "$xc_lt_build_static" = 'yes' &&
384 test "$xc_lt_build_shared" = 'no'; then
385 xc_lt_build_static_only='yes'
386else
387 xc_lt_build_static_only='no'
388fi
389AC_MSG_RESULT([$xc_lt_build_static_only])
390dnl
391m4_define([$0],[])dnl
392])
393
394
395dnl _XC_LIBTOOL_POSTLUDE
396dnl -------------------------------------------------
397dnl Private macro.
398dnl
399dnl Performs several checks related with libtool that
400dnl can not be done unless libtool code has already
401dnl been executed. See individual check descriptions
402dnl for further info.
403
404m4_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
412dnl
413m4_define([$0],[])dnl
414])
415
416
417dnl XC_LIBTOOL
418dnl -------------------------------------------------
419dnl Public macro.
420dnl
421dnl This macro embeds libtool machinery into configure
422dnl script, regardless of libtool version, and performs
423dnl several additional checks whose results can be used
424dnl later on.
425dnl
426dnl Usage of this macro ensures that generated configure
427dnl script uses equivalent logic irrespective of autoconf
428dnl or libtool version being used to generate configure
429dnl script.
430dnl
431dnl Results stored in following shell variables:
432dnl xc_lt_build_shared
433dnl xc_lt_build_static
434dnl xc_lt_shlib_use_version_info
435dnl xc_lt_shlib_use_no_undefined
436dnl xc_lt_shlib_use_mimpure_text
437dnl xc_lt_build_shared_with_pic
438dnl xc_lt_build_static_with_pic
439dnl xc_lt_build_shared_only
440dnl xc_lt_build_static_only
441
442AC_DEFUN([XC_LIBTOOL],
443[dnl
444AC_PREREQ([2.50])dnl
445dnl
446AC_BEFORE([$0],[LT_INIT])dnl
447AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
448AC_BEFORE([$0],[AC_LIBTOOL_WIN32_DLL])dnl
449dnl
450AC_REQUIRE([XC_CHECK_PATH_SEPARATOR])dnl
451AC_REQUIRE([AC_CANONICAL_HOST])dnl
452AC_REQUIRE([AC_PROG_CC])dnl
453dnl
454_XC_LIBTOOL_PREAMBLE
455_XC_LIBTOOL_BODY
456_XC_LIBTOOL_POSTLUDE
457dnl
458m4_ifdef([AC_LIBTOOL_WIN32_DLL],
459 [m4_undefine([AC_LIBTOOL_WIN32_DLL])])dnl
460m4_ifdef([AC_PROG_LIBTOOL],
461 [m4_undefine([AC_PROG_LIBTOOL])])dnl
462m4_ifdef([LT_INIT],
463 [m4_undefine([LT_INIT])])dnl
464dnl
465m4_define([$0],[])dnl
466])