xc-lt-iface.m4 12 KB

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