2 dnl This file contains macros for testing linkage.
6 dnl Check to see if the (math function) argument passed is
7 dnl declared when using the c++ compiler
8 dnl ASSUMES argument is a math function with ONE parameter
10 dnl GLIBCXX_CHECK_MATH_DECL_1
11 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_1], [
12 AC_MSG_CHECKING([for $1 declaration])
13 if test x${glibcxx_cv_func_$1_use+set} != xset; then
14 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
17 AC_TRY_COMPILE([#include <math.h>
23 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
27 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
32 dnl Check to see if the (math function) argument passed is
33 dnl 1) declared when using the c++ compiler
34 dnl 2) has "C" linkage
35 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
37 dnl Define HAVE_CARGF etc if "cargf" is declared and links
39 dnl argument 1 is name of function to check
41 dnl ASSUMES argument is a math function with ONE parameter
43 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1
44 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1], [
45 GLIBCXX_CHECK_MATH_DECL_1($1)
46 if test x$glibcxx_cv_func_$1_use = x"yes"; then
49 GLIBCXX_CHECK_MATH_DECL_1(_$1)
50 if test x$glibcxx_cv_func__$1_use = x"yes"; then
58 dnl Like GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
59 dnl of functions at once. It's an all-or-nothing check -- either
60 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
61 dnl Doing it this way saves significant configure time.
62 AC_DEFUN([GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1], [
63 define([funclist],patsubst($3,\(\w+\)\(\W*\),\1 ))dnl
64 AC_MSG_CHECKING([for $1 functions])
65 AC_CACHE_VAL(glibcxx_cv_func_$2_use, [
68 AC_TRY_COMPILE([#include <math.h>],
69 patsubst(funclist,[\w+],[\& (0);]),
70 [glibcxx_cv_func_$2_use=yes],
71 [glibcxx_cv_func_$2_use=no])
73 AC_MSG_RESULT($glibcxx_cv_func_$2_use)
74 if test x$glibcxx_cv_func_$2_use = x"yes"; then
75 AC_CHECK_FUNCS(funclist)
77 AC_MSG_CHECKING([for _$1 functions])
78 AC_CACHE_VAL(glibcxx_cv_func__$2_use, [
81 AC_TRY_COMPILE([#include <math.h>],
82 patsubst(funclist,[\w+],[_\& (0);]),
83 [glibcxx_cv_func__$2_use=yes],
84 [glibcxx_cv_func__$2_use=no])
86 AC_MSG_RESULT($glibcxx_cv_func__$2_use)
87 if test x$glibcxx_cv_func__$2_use = x"yes"; then
88 AC_CHECK_FUNCS(patsubst(funclist,[\w+],[_\&]))
95 dnl Check to see if the (math function) argument passed is
96 dnl declared when using the c++ compiler
97 dnl ASSUMES argument is a math function with TWO parameters
99 dnl GLIBCXX_CHECK_MATH_DECL_2
100 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_2], [
101 AC_MSG_CHECKING([for $1 declaration])
102 if test x${glibcxx_cv_func_$1_use+set} != xset; then
103 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
106 AC_TRY_COMPILE([#include <math.h>],
108 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
112 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
116 dnl Check to see if the (math function) argument passed is
117 dnl 1) declared when using the c++ compiler
118 dnl 2) has "C" linkage
120 dnl Define HAVE_CARGF etc if "cargf" is declared and links
122 dnl argument 1 is name of function to check
124 dnl ASSUMES argument is a math function with TWO parameters
126 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2
127 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2], [
128 GLIBCXX_CHECK_MATH_DECL_2($1)
129 if test x$glibcxx_cv_func_$1_use = x"yes"; then
132 GLIBCXX_CHECK_MATH_DECL_2(_$1)
133 if test x$glibcxx_cv_func__$1_use = x"yes"; then
141 dnl Check to see if the (math function) argument passed is
142 dnl declared when using the c++ compiler
143 dnl ASSUMES argument is a math function with THREE parameters
145 dnl GLIBCXX_CHECK_MATH_DECL_3
146 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_3], [
147 AC_MSG_CHECKING([for $1 declaration])
148 if test x${glibcxx_cv_func_$1_use+set} != xset; then
149 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
152 AC_TRY_COMPILE([#include <math.h>],
154 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
158 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
162 dnl Check to see if the (math function) argument passed is
163 dnl 1) declared when using the c++ compiler
164 dnl 2) has "C" linkage
166 dnl Define HAVE_CARGF etc if "cargf" is declared and links
168 dnl argument 1 is name of function to check
170 dnl ASSUMES argument is a math function with THREE parameters
172 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3
173 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3], [
174 GLIBCXX_CHECK_MATH_DECL_3($1)
175 if test x$glibcxx_cv_func_$1_use = x"yes"; then
178 GLIBCXX_CHECK_MATH_DECL_3(_$1)
179 if test x$glibcxx_cv_func__$1_use = x"yes"; then
187 dnl Check to see if the (stdlib function) argument passed is
188 dnl 1) declared when using the c++ compiler
189 dnl 2) has "C" linkage
191 dnl argument 1 is name of function to check
193 dnl ASSUMES argument is a stdlib function without parameters
195 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0
196 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0], [
197 AC_MSG_CHECKING([for $1 declaration])
198 if test x${glibcxx_cv_func_$1_use+set} != xset; then
199 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
202 AC_TRY_COMPILE([#include <stdlib.h>],
204 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
208 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
209 if test x$glibcxx_cv_func_$1_use = x"yes"; then
216 dnl Check to see if the (stdlib function) argument passed is
217 dnl 1) declared when using the c++ compiler
218 dnl 2) has "C" linkage
220 dnl argument 1 is name of function to check
222 dnl ASSUMES argument is a math function with TWO parameters
224 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
225 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2], [
226 AC_MSG_CHECKING([for $1 declaration])
227 if test x${glibcxx_cv_func_$1_use+set} != xset; then
228 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
231 AC_TRY_COMPILE([#include <stdlib.h>],
233 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
237 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
238 if test x$glibcxx_cv_func_$1_use = x"yes"; then
245 dnl Check to see if the (stdlib function) argument passed is
246 dnl 1) declared when using the c++ compiler
247 dnl 2) has "C" linkage
249 dnl argument 1 is name of function to check
251 dnl ASSUMES argument is a function with THREE parameters
253 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3
254 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3], [
255 AC_MSG_CHECKING([for $1 declaration])
256 if test x${glibcxx_cv_func_$1_use+set} != xset; then
257 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
260 AC_TRY_COMPILE([#include <stdlib.h>],
262 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
266 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
267 if test x$glibcxx_cv_func_$1_use = x"yes"; then
273 dnl Because the builtins are picky picky picky about the arguments they take,
274 dnl do an explict linkage tests here.
275 dnl Check to see if the (math function) argument passed is
276 dnl 1) declared when using the c++ compiler
277 dnl 2) has "C" linkage
279 dnl Define HAVE_CARGF etc if "cargf" is declared and links
281 dnl argument 1 is name of function to check
283 dnl ASSUMES argument is a math function with ONE parameter
285 dnl GLIBCXX_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
286 AC_DEFUN([GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1], [
287 AC_MSG_CHECKING([for $1 declaration])
288 if test x${glibcxx_cv_func_$1_use+set} != xset; then
289 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
292 AC_TRY_COMPILE([#include <math.h>],
294 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
298 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
299 if test x$glibcxx_cv_func_$1_use = x"yes"; then
300 AC_MSG_CHECKING([for $1 linkage])
301 if test x${glibcxx_cv_func_$1_link+set} != xset; then
302 AC_CACHE_VAL(glibcxx_cv_func_$1_link, [
303 AC_TRY_LINK([#include <math.h>],
305 [glibcxx_cv_func_$1_link=yes], [glibcxx_cv_func_$1_link=no])
308 AC_MSG_RESULT($glibcxx_cv_func_$1_link)
309 define([NAME], [translit([$1],[abcdefghijklmnopqrstuvwxyz],
310 [ABCDEFGHIJKLMNOPQRSTUVWXYZ])])
311 if test x$glibcxx_cv_func_$1_link = x"yes"; then
312 AC_DEFINE([HAVE_]NAME, 1, [Define if the compiler/host combination has $1.])
320 dnl Check to see what builtin math functions are supported
322 dnl check for __builtin_abs
323 dnl check for __builtin_fabsf
324 dnl check for __builtin_fabs
325 dnl check for __builtin_fabl
326 dnl check for __builtin_labs
327 dnl check for __builtin_sqrtf
328 dnl check for __builtin_sqrtl
329 dnl check for __builtin_sqrt
330 dnl check for __builtin_sinf
331 dnl check for __builtin_sin
332 dnl check for __builtin_sinl
333 dnl check for __builtin_cosf
334 dnl check for __builtin_cos
335 dnl check for __builtin_cosl
337 dnl GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
338 AC_DEFUN([GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT], [
339 dnl Test for builtin math functions.
340 dnl These are made in gcc/c-common.c
341 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
342 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
343 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
344 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
345 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
347 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
348 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
349 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
351 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
352 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
353 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
355 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
356 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
357 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
361 dnl Check to see what the underlying c library is like
362 dnl These checks need to do two things:
363 dnl 1) make sure the name is declared when using the c++ compiler
364 dnl 2) make sure the name has "C" linkage
365 dnl This might seem like overkill but experience has shown that it's not...
367 dnl Define HAVE_STRTOLD if "strtold" is declared and links
368 dnl Define HAVE_STRTOF if "strtof" is declared and links
370 dnl GLIBCXX_CHECK_STDLIB_SUPPORT
371 AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [
372 ac_test_CXXFLAGS="${CXXFLAGS+set}"
373 ac_save_CXXFLAGS="$CXXFLAGS"
374 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
376 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
377 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
379 CXXFLAGS="$ac_save_CXXFLAGS"
383 dnl Check to see what the underlying c library or math library is like.
384 dnl These checks need to do two things:
385 dnl 1) make sure the name is declared when using the c++ compiler
386 dnl 2) make sure the name has "C" linkage
387 dnl This might seem like overkill but experience has shown that it's not...
389 dnl Define HAVE_CARGF etc if "cargf" is found.
391 dnl GLIBCXX_CHECK_MATH_SUPPORT
392 AC_DEFUN([GLIBCXX_CHECK_MATH_SUPPORT], [
393 ac_test_CXXFLAGS="${CXXFLAGS+set}"
394 ac_save_CXXFLAGS="$CXXFLAGS"
395 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
398 AC_CHECK_LIB(m, sin, libm="-lm")
402 dnl Check to see if certain C math functions exist.
403 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
404 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
405 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
406 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
407 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
408 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
409 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
410 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
412 dnl Check to see if basic C math functions have float versions.
413 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
418 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
421 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
422 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
423 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
424 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
425 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
426 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
427 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
428 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
429 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
430 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
431 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
432 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
433 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modf)
434 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
435 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
436 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
437 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
439 dnl Check to see if basic C math functions have long double versions.
440 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
445 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
448 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
449 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
450 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
451 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
452 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
453 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
454 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
455 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
456 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
457 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
458 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
459 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
460 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
461 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
462 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
463 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
464 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
466 dnl Some runtimes have these functions with a preceding underscore. Please
467 dnl keep this sync'd with the one above. And if you add any new symbol,
468 dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
469 dnl Check to see if certain C math functions exist.
471 CXXFLAGS="$ac_save_CXXFLAGS"
476 dnl Check to see if there is native support for complex
478 dnl Don't compile bits in math/* if native support exits.
480 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
482 dnl GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
483 AC_DEFUN([GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT], [
484 dnl Check for complex versions of math functions of platform. This will
485 dnl always pass if libm is available, and fail if it isn't. If it is
486 dnl available, we assume we'll need it later, so add it to LIBS.
487 AC_CHECK_LIB(m, main)
488 AC_REPLACE_MATHFUNCS(copysignf)
490 dnl For __signbit to signbit conversions.
491 dnl Not sure why this is done, as these will be macros mostly.
492 dnl Should probably coordinate this with std_cmath.h.
493 AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
495 AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
497 dnl Compile the long double complex functions only if the function
498 dnl provides the non-complex long double functions that are needed.
499 dnl Currently this includes copysignl, which should be
500 dnl cached from the GLIBCXX_CHECK_MATH_SUPPORT macro, above.
501 if test x$ac_cv_func_copysignl = x"yes"; then
502 AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
505 # Used in libmath/Makefile.am.
506 if test -n "$LIBMATHOBJS"; then
509 AC_SUBST(LIBMATHOBJS)
513 # Check for functions in math library.
514 # Ulrich Drepper <drepper@cygnus.com>, 1998.
516 # This file can be copied and used freely without restrictions. It can
517 # be used in projects which are not available under the GNU Public License
518 # but which still want to provide support for the GNU gettext functionality.
519 # Please note that the actual code is *not* freely available.
523 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
524 AC_DEFUN([AC_REPLACE_MATHFUNCS],
525 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])])