You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xc-lt-iface.m4 12KB

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