linkage.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. dnl
  2. dnl This file contains macros for testing linkage.
  3. dnl
  4. dnl
  5. dnl Check to see if the (math function) argument passed is
  6. dnl declared when using the c++ compiler
  7. dnl ASSUMES argument is a math function with ONE parameter
  8. dnl
  9. dnl GLIBCXX_CHECK_MATH_DECL_1
  10. AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_1], [
  11. AC_MSG_CHECKING([for $1 declaration])
  12. if test x${glibcxx_cv_func_$1_use+set} != xset; then
  13. AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
  14. AC_LANG_SAVE
  15. AC_LANG_CPLUSPLUS
  16. AC_TRY_COMPILE([#include <math.h>
  17. #ifdef HAVE_IEEEFP_H
  18. #include <ieeefp.h>
  19. #endif
  20. ],
  21. [ $1(0);],
  22. [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
  23. AC_LANG_RESTORE
  24. ])
  25. fi
  26. AC_MSG_RESULT($glibcxx_cv_func_$1_use)
  27. ])
  28. dnl
  29. dnl Define autoheader template for using the underscore functions
  30. dnl For each parameter, create a macro where if func doesn't exist,
  31. dnl but _func does, then it will "#define func _func".
  32. dnl
  33. dnl GLIBCXX_MAYBE_UNDERSCORED_FUNCS
  34. AC_DEFUN([GLIBCXX_MAYBE_UNDERSCORED_FUNCS],
  35. [AC_FOREACH([glibcxx_ufunc], [$1],
  36. [AH_VERBATIM(_[]glibcxx_ufunc,
  37. [#if defined (]AS_TR_CPP(HAVE__[]glibcxx_ufunc)[) && ! defined (]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[)
  38. # define ]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[ 1
  39. # define ]glibcxx_ufunc[ _]glibcxx_ufunc[
  40. #endif])])
  41. ])
  42. dnl
  43. dnl Check to see if the (math function) argument passed is
  44. dnl 1) declared when using the c++ compiler
  45. dnl 2) has "C" linkage
  46. dnl 3) if not, see if 1) and 2) for argument prepended with '_'
  47. dnl
  48. dnl Define HAVE_CARGF etc if "cargf" is declared and links
  49. dnl
  50. dnl argument 1 is name of function to check
  51. dnl
  52. dnl ASSUMES argument is a math function with ONE parameter
  53. dnl
  54. dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1
  55. AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1], [
  56. GLIBCXX_CHECK_MATH_DECL_1($1)
  57. if test x$glibcxx_cv_func_$1_use = x"yes"; then
  58. AC_CHECK_FUNCS($1)
  59. else
  60. GLIBCXX_CHECK_MATH_DECL_1(_$1)
  61. if test x$glibcxx_cv_func__$1_use = x"yes"; then
  62. AC_CHECK_FUNCS(_$1)
  63. fi
  64. fi
  65. GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
  66. ])
  67. dnl
  68. dnl Like GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
  69. dnl of functions at once. It's an all-or-nothing check -- either
  70. dnl HAVE_XYZ is defined for each of the functions, or for none of them.
  71. dnl Doing it this way saves significant configure time.
  72. AC_DEFUN([GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1], [
  73. define([funclist],patsubst($3,\(\w+\)\(\W*\),\1 ))dnl
  74. AC_MSG_CHECKING([for $1 functions])
  75. AC_CACHE_VAL(glibcxx_cv_func_$2_use, [
  76. AC_LANG_SAVE
  77. AC_LANG_CPLUSPLUS
  78. AC_TRY_COMPILE([#include <math.h>],
  79. patsubst(funclist,[\w+],[\& (0);]),
  80. [glibcxx_cv_func_$2_use=yes],
  81. [glibcxx_cv_func_$2_use=no])
  82. AC_LANG_RESTORE])
  83. AC_MSG_RESULT($glibcxx_cv_func_$2_use)
  84. if test x$glibcxx_cv_func_$2_use = x"yes"; then
  85. AC_CHECK_FUNCS(funclist)
  86. else
  87. AC_MSG_CHECKING([for _$1 functions])
  88. AC_CACHE_VAL(glibcxx_cv_func__$2_use, [
  89. AC_LANG_SAVE
  90. AC_LANG_CPLUSPLUS
  91. AC_TRY_COMPILE([#include <math.h>],
  92. patsubst(funclist,[\w+],[_\& (0);]),
  93. [glibcxx_cv_func__$2_use=yes],
  94. [glibcxx_cv_func__$2_use=no])
  95. AC_LANG_RESTORE])
  96. AC_MSG_RESULT($glibcxx_cv_func__$2_use)
  97. if test x$glibcxx_cv_func__$2_use = x"yes"; then
  98. AC_CHECK_FUNCS(patsubst(funclist,[\w+],[_\&]))
  99. fi
  100. fi
  101. GLIBCXX_MAYBE_UNDERSCORED_FUNCS(funclist)
  102. undefine([funclist])
  103. ])
  104. dnl
  105. dnl Check to see if the (math function) argument passed is
  106. dnl declared when using the c++ compiler
  107. dnl ASSUMES argument is a math function with TWO parameters
  108. dnl
  109. dnl GLIBCXX_CHECK_MATH_DECL_2
  110. AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_2], [
  111. AC_MSG_CHECKING([for $1 declaration])
  112. if test x${glibcxx_cv_func_$1_use+set} != xset; then
  113. AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
  114. AC_LANG_SAVE
  115. AC_LANG_CPLUSPLUS
  116. AC_TRY_COMPILE([#include <math.h>],
  117. [ $1(0, 0);],
  118. [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
  119. AC_LANG_RESTORE
  120. ])
  121. fi
  122. AC_MSG_RESULT($glibcxx_cv_func_$1_use)
  123. ])
  124. dnl
  125. dnl Check to see if the (math function) argument passed is
  126. dnl 1) declared when using the c++ compiler
  127. dnl 2) has "C" linkage
  128. dnl
  129. dnl Define HAVE_CARGF etc if "cargf" is declared and links
  130. dnl
  131. dnl argument 1 is name of function to check
  132. dnl
  133. dnl ASSUMES argument is a math function with TWO parameters
  134. dnl
  135. dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2
  136. AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2], [
  137. GLIBCXX_CHECK_MATH_DECL_2($1)
  138. if test x$glibcxx_cv_func_$1_use = x"yes"; then
  139. AC_CHECK_FUNCS($1)
  140. else
  141. GLIBCXX_CHECK_MATH_DECL_2(_$1)
  142. if test x$glibcxx_cv_func__$1_use = x"yes"; then
  143. AC_CHECK_FUNCS(_$1)
  144. fi
  145. fi
  146. GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
  147. ])
  148. dnl
  149. dnl Check to see if the (math function) argument passed is
  150. dnl declared when using the c++ compiler
  151. dnl ASSUMES argument is a math function with THREE parameters
  152. dnl
  153. dnl GLIBCXX_CHECK_MATH_DECL_3
  154. AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_3], [
  155. AC_MSG_CHECKING([for $1 declaration])
  156. if test x${glibcxx_cv_func_$1_use+set} != xset; then
  157. AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
  158. AC_LANG_SAVE
  159. AC_LANG_CPLUSPLUS
  160. AC_TRY_COMPILE([#include <math.h>],
  161. [ $1(0, 0, 0);],
  162. [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
  163. AC_LANG_RESTORE
  164. ])
  165. fi
  166. AC_MSG_RESULT($glibcxx_cv_func_$1_use)
  167. ])
  168. dnl
  169. dnl Check to see if the (math function) argument passed is
  170. dnl 1) declared when using the c++ compiler
  171. dnl 2) has "C" linkage
  172. dnl
  173. dnl Define HAVE_CARGF etc if "cargf" is declared and links
  174. dnl
  175. dnl argument 1 is name of function to check
  176. dnl
  177. dnl ASSUMES argument is a math function with THREE parameters
  178. dnl
  179. dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3
  180. AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3], [
  181. GLIBCXX_CHECK_MATH_DECL_3($1)
  182. if test x$glibcxx_cv_func_$1_use = x"yes"; then
  183. AC_CHECK_FUNCS($1)
  184. else
  185. GLIBCXX_CHECK_MATH_DECL_3(_$1)
  186. if test x$glibcxx_cv_func__$1_use = x"yes"; then
  187. AC_CHECK_FUNCS(_$1)
  188. fi
  189. fi
  190. GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
  191. ])
  192. dnl
  193. dnl Check to see if the (stdlib function) argument passed is
  194. dnl 1) declared when using the c++ compiler
  195. dnl 2) has "C" linkage
  196. dnl
  197. dnl argument 1 is name of function to check
  198. dnl
  199. dnl ASSUMES argument is a stdlib function without parameters
  200. dnl
  201. dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0
  202. AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0], [
  203. AC_MSG_CHECKING([for $1 declaration])
  204. if test x${glibcxx_cv_func_$1_use+set} != xset; then
  205. AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
  206. AC_LANG_SAVE
  207. AC_LANG_CPLUSPLUS
  208. AC_TRY_COMPILE([#include <stdlib.h>],
  209. [ $1();],
  210. [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
  211. AC_LANG_RESTORE
  212. ])
  213. fi
  214. AC_MSG_RESULT($glibcxx_cv_func_$1_use)
  215. if test x$glibcxx_cv_func_$1_use = x"yes"; then
  216. AC_CHECK_FUNCS($1)
  217. fi
  218. ])
  219. dnl
  220. dnl Check to see if the (stdlib function) argument passed is
  221. dnl 1) declared when using the c++ compiler
  222. dnl 2) has "C" linkage
  223. dnl
  224. dnl argument 1 is name of function to check
  225. dnl
  226. dnl ASSUMES argument is a stdlib function with ONE parameter
  227. dnl
  228. dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1
  229. AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1], [
  230. AC_MSG_CHECKING([for $1 declaration])
  231. if test x${glibcxx_cv_func_$1_use+set} != xset; then
  232. AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
  233. AC_LANG_SAVE
  234. AC_LANG_CPLUSPLUS
  235. AC_TRY_COMPILE([#include <stdlib.h>],
  236. [ $1(0);],
  237. [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
  238. AC_LANG_RESTORE
  239. ])
  240. fi
  241. AC_MSG_RESULT($glibcxx_cv_func_$1_use)
  242. if test x$glibcxx_cv_func_$1_use = x"yes"; then
  243. AC_CHECK_FUNCS($1)
  244. fi
  245. ])
  246. dnl
  247. dnl Check to see if the (stdlib function) argument passed is
  248. dnl 1) declared when using the c++ compiler
  249. dnl 2) has "C" linkage
  250. dnl
  251. dnl argument 1 is name of function to check
  252. dnl
  253. dnl ASSUMES argument is a stdlib function with TWO parameters
  254. dnl
  255. dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
  256. AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2], [
  257. AC_MSG_CHECKING([for $1 declaration])
  258. if test x${glibcxx_cv_func_$1_use+set} != xset; then
  259. AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
  260. AC_LANG_SAVE
  261. AC_LANG_CPLUSPLUS
  262. AC_TRY_COMPILE([#include <stdlib.h>],
  263. [ $1(0, 0);],
  264. [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
  265. AC_LANG_RESTORE
  266. ])
  267. fi
  268. AC_MSG_RESULT($glibcxx_cv_func_$1_use)
  269. if test x$glibcxx_cv_func_$1_use = x"yes"; then
  270. AC_CHECK_FUNCS($1)
  271. fi
  272. GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
  273. ])
  274. dnl
  275. dnl Check to see if the (stdlib function) argument passed is
  276. dnl 1) declared when using the c++ compiler
  277. dnl 2) has "C" linkage
  278. dnl
  279. dnl argument 1 is name of function to check
  280. dnl
  281. dnl ASSUMES argument is a stdlib function with THREE parameters
  282. dnl
  283. dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3
  284. AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3], [
  285. AC_MSG_CHECKING([for $1 declaration])
  286. if test x${glibcxx_cv_func_$1_use+set} != xset; then
  287. AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
  288. AC_LANG_SAVE
  289. AC_LANG_CPLUSPLUS
  290. AC_TRY_COMPILE([#include <stdlib.h>],
  291. [ $1(0, 0, 0);],
  292. [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
  293. AC_LANG_RESTORE
  294. ])
  295. fi
  296. AC_MSG_RESULT($glibcxx_cv_func_$1_use)
  297. if test x$glibcxx_cv_func_$1_use = x"yes"; then
  298. AC_CHECK_FUNCS($1)
  299. fi
  300. ])
  301. dnl
  302. dnl Check to see what the underlying c library is like
  303. dnl These checks need to do two things:
  304. dnl 1) make sure the name is declared when using the c++ compiler
  305. dnl 2) make sure the name has "C" linkage
  306. dnl This might seem like overkill but experience has shown that it's not...
  307. dnl
  308. dnl Define HAVE_STRTOLD if "strtold" is declared and links
  309. dnl Define HAVE_STRTOF if "strtof" is declared and links
  310. dnl
  311. dnl GLIBCXX_CHECK_STDLIB_SUPPORT
  312. AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [
  313. ac_test_CXXFLAGS="${CXXFLAGS+set}"
  314. ac_save_CXXFLAGS="$CXXFLAGS"
  315. CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
  316. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(at_quick_exit)
  317. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(quick_exit)
  318. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
  319. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
  320. CXXFLAGS="$ac_save_CXXFLAGS"
  321. ])
  322. dnl
  323. dnl Check to see what the underlying c library or math library is like.
  324. dnl These checks need to do two things:
  325. dnl 1) make sure the name is declared when using the c++ compiler
  326. dnl 2) make sure the name has "C" linkage
  327. dnl This might seem like overkill but experience has shown that it's not...
  328. dnl
  329. dnl Define HAVE_CARGF etc if "cargf" is found.
  330. dnl
  331. dnl GLIBCXX_CHECK_MATH_SUPPORT
  332. AC_DEFUN([GLIBCXX_CHECK_MATH_SUPPORT], [
  333. ac_test_CXXFLAGS="${CXXFLAGS+set}"
  334. ac_save_CXXFLAGS="$CXXFLAGS"
  335. CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
  336. dnl Check libm
  337. AC_CHECK_LIB(m, sin, libm="-lm")
  338. ac_save_LIBS="$LIBS"
  339. LIBS="$LIBS $libm"
  340. dnl Check to see if certain C math functions exist.
  341. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
  342. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
  343. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
  344. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
  345. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
  346. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
  347. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
  348. dnl Check to see if basic C math functions have float versions.
  349. GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
  350. float_trig,
  351. acosf asinf atanf \
  352. cosf sinf tanf \
  353. coshf sinhf tanhf)
  354. GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
  355. float_round,
  356. ceilf floorf)
  357. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
  358. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
  359. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
  360. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
  361. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
  362. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
  363. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
  364. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
  365. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
  366. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
  367. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
  368. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
  369. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modf)
  370. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
  371. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
  372. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
  373. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
  374. dnl Check to see if basic C math functions have long double versions.
  375. GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
  376. long_double_trig,
  377. acosl asinl atanl \
  378. cosl sinl tanl \
  379. coshl sinhl tanhl)
  380. GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
  381. long_double_round,
  382. ceill floorl)
  383. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
  384. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
  385. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
  386. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
  387. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
  388. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
  389. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
  390. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
  391. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
  392. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
  393. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
  394. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
  395. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
  396. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
  397. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
  398. GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
  399. LIBS="$ac_save_LIBS"
  400. CXXFLAGS="$ac_save_CXXFLAGS"
  401. ])