2
0

xc-lt-iface.m4 12 KB

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