2 dnl This file contains stuff.
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)
31 dnl Check to see if the (math function) argument passed is
32 dnl 1) declared when using the c++ compiler
33 dnl 2) has "C" linkage
34 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
36 dnl Define HAVE_CARGF etc if "cargf" is declared and links
38 dnl argument 1 is name of function to check
40 dnl ASSUMES argument is a math function with ONE parameter
42 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1
43 AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, [
44 GLIBCXX_CHECK_MATH_DECL_1($1)
45 if test x$glibcxx_cv_func_$1_use = x"yes"; then
48 GLIBCXX_CHECK_MATH_DECL_1(_$1)
49 if test x$glibcxx_cv_func__$1_use = x"yes"; then
57 dnl Like GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
58 dnl of functions at once. It's an all-or-nothing check -- either
59 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
60 dnl Doing it this way saves significant configure time.
61 AC_DEFUN(GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1, [
62 AC_MSG_CHECKING([for $1 functions])
63 AC_CACHE_VAL(glibcxx_cv_func_$2_use, [
66 AC_TRY_COMPILE([#include <math.h>],
67 [ `for x in $3; do echo "$x (0);"; done` ],
68 [glibcxx_cv_func_$2_use=yes],
69 [glibcxx_cv_func_$2_use=no])
71 AC_MSG_RESULT($glibcxx_cv_func_$2_use)
72 if test x$glibcxx_cv_func_$2_use = x"yes"; then
78 dnl Check to see if the (math function) argument passed is
79 dnl declared when using the c++ compiler
80 dnl ASSUMES argument is a math function with TWO parameters
82 dnl GLIBCXX_CHECK_MATH_DECL_2
83 AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_2, [
84 AC_MSG_CHECKING([for $1 declaration])
85 if test x${glibcxx_cv_func_$1_use+set} != xset; then
86 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
89 AC_TRY_COMPILE([#include <math.h>],
91 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
95 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
99 dnl Check to see if the (math function) argument passed is
100 dnl 1) declared when using the c++ compiler
101 dnl 2) has "C" linkage
103 dnl Define HAVE_CARGF etc if "cargf" is declared and links
105 dnl argument 1 is name of function to check
107 dnl ASSUMES argument is a math function with TWO parameters
109 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2
110 AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2, [
111 GLIBCXX_CHECK_MATH_DECL_2($1)
112 if test x$glibcxx_cv_func_$1_use = x"yes"; then
115 GLIBCXX_CHECK_MATH_DECL_2(_$1)
116 if test x$glibcxx_cv_func__$1_use = x"yes"; then
124 dnl Check to see if the (math function) argument passed is
125 dnl declared when using the c++ compiler
126 dnl ASSUMES argument is a math function with THREE parameters
128 dnl GLIBCXX_CHECK_MATH_DECL_3
129 AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_3, [
130 AC_MSG_CHECKING([for $1 declaration])
131 if test x${glibcxx_cv_func_$1_use+set} != xset; then
132 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
135 AC_TRY_COMPILE([#include <math.h>],
137 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
141 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
145 dnl Check to see if the (math function) argument passed is
146 dnl 1) declared when using the c++ compiler
147 dnl 2) has "C" linkage
149 dnl Define HAVE_CARGF etc if "cargf" is declared and links
151 dnl argument 1 is name of function to check
153 dnl ASSUMES argument is a math function with THREE parameters
155 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3
156 AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3, [
157 GLIBCXX_CHECK_MATH_DECL_3($1)
158 if test x$glibcxx_cv_func_$1_use = x"yes"; then
161 GLIBCXX_CHECK_MATH_DECL_3(_$1)
162 if test x$glibcxx_cv_func__$1_use = x"yes"; then
170 dnl Check to see if the (stdlib function) argument passed is
171 dnl 1) declared when using the c++ compiler
172 dnl 2) has "C" linkage
174 dnl argument 1 is name of function to check
176 dnl ASSUMES argument is a stdlib function without parameters
178 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0
179 AC_DEFUN(GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0, [
180 AC_MSG_CHECKING([for $1 declaration])
181 if test x${glibcxx_cv_func_$1_use+set} != xset; then
182 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
185 AC_TRY_COMPILE([#include <stdlib.h>],
187 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
191 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
192 if test x$glibcxx_cv_func_$1_use = x"yes"; then
199 dnl Check to see if the (stdlib function) argument passed is
200 dnl 1) declared when using the c++ compiler
201 dnl 2) has "C" linkage
203 dnl argument 1 is name of function to check
205 dnl ASSUMES argument is a math function with TWO parameters
207 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
208 AC_DEFUN(GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
209 AC_MSG_CHECKING([for $1 declaration])
210 if test x${glibcxx_cv_func_$1_use+set} != xset; then
211 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
214 AC_TRY_COMPILE([#include <stdlib.h>],
216 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
220 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
221 if test x$glibcxx_cv_func_$1_use = x"yes"; then
228 dnl Check to see if the (stdlib function) argument passed is
229 dnl 1) declared when using the c++ compiler
230 dnl 2) has "C" linkage
232 dnl argument 1 is name of function to check
234 dnl ASSUMES argument is a function with THREE parameters
236 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3
237 AC_DEFUN(GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
238 AC_MSG_CHECKING([for $1 declaration])
239 if test x${glibcxx_cv_func_$1_use+set} != xset; then
240 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
243 AC_TRY_COMPILE([#include <stdlib.h>],
245 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
249 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
250 if test x$glibcxx_cv_func_$1_use = x"yes"; then
256 dnl Because the builtins are picky picky picky about the arguments they take,
257 dnl do an explict linkage tests here.
258 dnl Check to see if the (math function) argument passed is
259 dnl 1) declared when using the c++ compiler
260 dnl 2) has "C" linkage
262 dnl Define HAVE_CARGF etc if "cargf" is declared and links
264 dnl argument 1 is name of function to check
266 dnl ASSUMES argument is a math function with ONE parameter
268 dnl GLIBCXX_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
269 AC_DEFUN(GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
270 AC_MSG_CHECKING([for $1 declaration])
271 if test x${glibcxx_cv_func_$1_use+set} != xset; then
272 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
275 AC_TRY_COMPILE([#include <math.h>],
277 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
281 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
282 if test x$glibcxx_cv_func_$1_use = x"yes"; then
283 AC_MSG_CHECKING([for $1 linkage])
284 if test x${glibcxx_cv_func_$1_link+set} != xset; then
285 AC_CACHE_VAL(glibcxx_cv_func_$1_link, [
286 AC_TRY_LINK([#include <math.h>],
288 [glibcxx_cv_func_$1_link=yes], [glibcxx_cv_func_$1_link=no])
291 AC_MSG_RESULT($glibcxx_cv_func_$1_link)
292 if test x$glibcxx_cv_func_$1_link = x"yes"; then
293 ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
294 AC_DEFINE_UNQUOTED(${ac_tr_func})
301 dnl Check to see what builtin math functions are supported
303 dnl check for __builtin_abs
304 dnl check for __builtin_fabsf
305 dnl check for __builtin_fabs
306 dnl check for __builtin_fabl
307 dnl check for __builtin_labs
308 dnl check for __builtin_sqrtf
309 dnl check for __builtin_sqrtl
310 dnl check for __builtin_sqrt
311 dnl check for __builtin_sinf
312 dnl check for __builtin_sin
313 dnl check for __builtin_sinl
314 dnl check for __builtin_cosf
315 dnl check for __builtin_cos
316 dnl check for __builtin_cosl
318 dnl GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
319 AC_DEFUN(GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT, [
320 dnl Test for builtin math functions.
321 dnl These are made in gcc/c-common.c
322 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
323 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
324 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
325 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
326 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
328 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
329 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
330 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
332 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
333 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
334 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
336 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
337 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
338 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
340 dnl There is, without a doubt, a more elegant way to have these
341 dnl names exported so that they won't be stripped out of acconfig.h by
342 dnl autoheader. I leave this as an exercise to somebody less frustrated
343 dnl than I.... please email the libstdc++ list if you can figure out a
344 dnl more elegant approach (see autoconf/acgen.m4 and specifically
345 dnl AC_CHECK_FUNC for things to steal.)
347 if test x$dummyvar = x"yes"; then
348 AC_DEFINE(HAVE___BUILTIN_ABS)
349 AC_DEFINE(HAVE___BUILTIN_LABS)
350 AC_DEFINE(HAVE___BUILTIN_COS)
351 AC_DEFINE(HAVE___BUILTIN_COSF)
352 AC_DEFINE(HAVE___BUILTIN_COSL)
353 AC_DEFINE(HAVE___BUILTIN_FABS)
354 AC_DEFINE(HAVE___BUILTIN_FABSF)
355 AC_DEFINE(HAVE___BUILTIN_FABSL)
356 AC_DEFINE(HAVE___BUILTIN_SIN)
357 AC_DEFINE(HAVE___BUILTIN_SINF)
358 AC_DEFINE(HAVE___BUILTIN_SINL)
359 AC_DEFINE(HAVE___BUILTIN_SQRT)
360 AC_DEFINE(HAVE___BUILTIN_SQRTF)
361 AC_DEFINE(HAVE___BUILTIN_SQRTL)
366 dnl Check to see what the underlying c library is like
367 dnl These checks need to do two things:
368 dnl 1) make sure the name is declared when using the c++ compiler
369 dnl 2) make sure the name has "C" linkage
370 dnl This might seem like overkill but experience has shown that it's not...
372 dnl Define HAVE_STRTOLD if "strtold" is declared and links
373 dnl Define HAVE_STRTOF if "strtof" is declared and links
374 dnl Define HAVE_LRAND48 if "lrand48" is declared and links
376 dnl GLIBCXX_CHECK_STDLIB_SUPPORT
377 AC_DEFUN(GLIBCXX_CHECK_STDLIB_SUPPORT, [
378 ac_test_CXXFLAGS="${CXXFLAGS+set}"
379 ac_save_CXXFLAGS="$CXXFLAGS"
380 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
382 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
383 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
384 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0(lrand48)
386 CXXFLAGS="$ac_save_CXXFLAGS"
390 dnl Check to see what the underlying c library or math library is like.
391 dnl These checks need to do two things:
392 dnl 1) make sure the name is declared when using the c++ compiler
393 dnl 2) make sure the name has "C" linkage
394 dnl This might seem like overkill but experience has shown that it's not...
396 dnl Define HAVE_CARGF etc if "cargf" is found.
398 dnl GLIBCXX_CHECK_MATH_SUPPORT
399 AC_DEFUN(GLIBCXX_CHECK_MATH_SUPPORT, [
400 ac_test_CXXFLAGS="${CXXFLAGS+set}"
401 ac_save_CXXFLAGS="$CXXFLAGS"
402 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
405 AC_CHECK_LIB(m, sin, libm="-lm")
409 dnl Check to see if certain C math functions exist.
410 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
411 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
412 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
413 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
414 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
415 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
416 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
417 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
419 dnl Check to see if basic C math functions have float versions.
420 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
425 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
428 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
429 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
430 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
431 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
432 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
433 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
434 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
435 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
436 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
437 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
438 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
439 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
440 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
441 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
442 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
443 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
445 dnl Check to see if basic C math functions have long double versions.
446 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
451 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
454 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
455 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
456 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
457 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
458 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
459 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
460 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
461 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
462 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
463 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
464 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
465 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
466 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
467 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
468 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
469 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
470 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
472 dnl Some runtimes have these functions with a preceding underscore. Please
473 dnl keep this sync'd with the one above. And if you add any new symbol,
474 dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
475 dnl Check to see if certain C math functions exist.
477 dnl Check to see if basic C math functions have float versions.
478 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
480 _acosf _asinf _atanf \
482 _coshf _sinhf _tanhf)
483 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
487 dnl Check to see if basic C math functions have long double versions.
488 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
490 _acosl _asinl _atanl \
492 _coshl _sinhl _tanhl)
493 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
498 CXXFLAGS="$ac_save_CXXFLAGS"
503 dnl Check to see if there is native support for complex
505 dnl Don't compile bits in math/* if native support exits.
507 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
509 dnl GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
510 AC_DEFUN(GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT, [
511 dnl Check for complex versions of math functions of platform. This will
512 dnl always pass if libm is available, and fail if it isn't. If it is
513 dnl available, we assume we'll need it later, so add it to LIBS.
514 AC_CHECK_LIB(m, main)
515 AC_REPLACE_MATHFUNCS(nan copysignf)
517 dnl For __signbit to signbit conversions.
518 AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
519 AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
521 dnl Compile the long double complex functions only if the function
522 dnl provides the non-complex long double functions that are needed.
523 dnl Currently this includes copysignl, which should be
524 dnl cached from the GLIBCXX_CHECK_MATH_SUPPORT macro, above.
525 if test x$ac_cv_func_copysignl = x"yes"; then
526 AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
529 # XXX Review this. Nothing uses it.
530 if test -n "$LIBMATHOBJS"; then
533 AC_SUBST(LIBMATHOBJS)
537 # Check for functions in math library.
538 # Ulrich Drepper <drepper@cygnus.com>, 1998.
540 # This file can be copied and used freely without restrictions. It can
541 # be used in projects which are not available under the GNU Public License
542 # but which still want to provide support for the GNU gettext functionality.
543 # Please note that the actual code is *not* freely available.
547 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
548 AC_DEFUN(AC_REPLACE_MATHFUNCS,
549 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])])