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 Define autoheader template for using the underscore functions
33 dnl For each parameter, create a macro where if func doesn't exist,
34 dnl but _func does, then it will "#define func _func".
36 dnl GLIBCXX_MAYBE_UNDERSCORED_FUNCS
37 AC_DEFUN([GLIBCXX_MAYBE_UNDERSCORED_FUNCS],
38 [AC_FOREACH([glibcxx_ufunc], [$1],
39 [AH_VERBATIM(_[]glibcxx_ufunc,
40 [#if defined (]AS_TR_CPP(HAVE__[]glibcxx_ufunc)[) && ! defined (]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[)
41 # define ]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[ 1
42 # define ]glibcxx_ufunc[ _]glibcxx_ufunc[
48 dnl Check to see if the (math function) argument passed is
49 dnl 1) declared when using the c++ compiler
50 dnl 2) has "C" linkage
51 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
53 dnl Define HAVE_CARGF etc if "cargf" is declared and links
55 dnl argument 1 is name of function to check
57 dnl ASSUMES argument is a math function with ONE parameter
59 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1
60 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1], [
61 GLIBCXX_CHECK_MATH_DECL_1($1)
62 if test x$glibcxx_cv_func_$1_use = x"yes"; then
65 GLIBCXX_CHECK_MATH_DECL_1(_$1)
66 if test x$glibcxx_cv_func__$1_use = x"yes"; then
70 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
75 dnl Like GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
76 dnl of functions at once. It's an all-or-nothing check -- either
77 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
78 dnl Doing it this way saves significant configure time.
79 AC_DEFUN([GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1], [
80 define([funclist],patsubst($3,\(\w+\)\(\W*\),\1 ))dnl
81 AC_MSG_CHECKING([for $1 functions])
82 AC_CACHE_VAL(glibcxx_cv_func_$2_use, [
85 AC_TRY_COMPILE([#include <math.h>],
86 patsubst(funclist,[\w+],[\& (0);]),
87 [glibcxx_cv_func_$2_use=yes],
88 [glibcxx_cv_func_$2_use=no])
90 AC_MSG_RESULT($glibcxx_cv_func_$2_use)
91 if test x$glibcxx_cv_func_$2_use = x"yes"; then
92 AC_CHECK_FUNCS(funclist)
94 AC_MSG_CHECKING([for _$1 functions])
95 AC_CACHE_VAL(glibcxx_cv_func__$2_use, [
98 AC_TRY_COMPILE([#include <math.h>],
99 patsubst(funclist,[\w+],[_\& (0);]),
100 [glibcxx_cv_func__$2_use=yes],
101 [glibcxx_cv_func__$2_use=no])
103 AC_MSG_RESULT($glibcxx_cv_func__$2_use)
104 if test x$glibcxx_cv_func__$2_use = x"yes"; then
105 AC_CHECK_FUNCS(patsubst(funclist,[\w+],[_\&]))
108 GLIBCXX_MAYBE_UNDERSCORED_FUNCS(funclist)
113 dnl Check to see if the (math function) argument passed is
114 dnl declared when using the c++ compiler
115 dnl ASSUMES argument is a math function with TWO parameters
117 dnl GLIBCXX_CHECK_MATH_DECL_2
118 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_2], [
119 AC_MSG_CHECKING([for $1 declaration])
120 if test x${glibcxx_cv_func_$1_use+set} != xset; then
121 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
124 AC_TRY_COMPILE([#include <math.h>],
126 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
130 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
134 dnl Check to see if the (math function) argument passed is
135 dnl 1) declared when using the c++ compiler
136 dnl 2) has "C" linkage
138 dnl Define HAVE_CARGF etc if "cargf" is declared and links
140 dnl argument 1 is name of function to check
142 dnl ASSUMES argument is a math function with TWO parameters
144 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2
145 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2], [
146 GLIBCXX_CHECK_MATH_DECL_2($1)
147 if test x$glibcxx_cv_func_$1_use = x"yes"; then
150 GLIBCXX_CHECK_MATH_DECL_2(_$1)
151 if test x$glibcxx_cv_func__$1_use = x"yes"; then
155 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
160 dnl Check to see if the (math function) argument passed is
161 dnl declared when using the c++ compiler
162 dnl ASSUMES argument is a math function with THREE parameters
164 dnl GLIBCXX_CHECK_MATH_DECL_3
165 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_3], [
166 AC_MSG_CHECKING([for $1 declaration])
167 if test x${glibcxx_cv_func_$1_use+set} != xset; then
168 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
171 AC_TRY_COMPILE([#include <math.h>],
173 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
177 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
181 dnl Check to see if the (math function) argument passed is
182 dnl 1) declared when using the c++ compiler
183 dnl 2) has "C" linkage
185 dnl Define HAVE_CARGF etc if "cargf" is declared and links
187 dnl argument 1 is name of function to check
189 dnl ASSUMES argument is a math function with THREE parameters
191 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3
192 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3], [
193 GLIBCXX_CHECK_MATH_DECL_3($1)
194 if test x$glibcxx_cv_func_$1_use = x"yes"; then
197 GLIBCXX_CHECK_MATH_DECL_3(_$1)
198 if test x$glibcxx_cv_func__$1_use = x"yes"; then
202 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
207 dnl Check to see if the (stdlib function) argument passed is
208 dnl 1) declared when using the c++ compiler
209 dnl 2) has "C" linkage
211 dnl argument 1 is name of function to check
213 dnl ASSUMES argument is a stdlib function without parameters
215 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0
216 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0], [
217 AC_MSG_CHECKING([for $1 declaration])
218 if test x${glibcxx_cv_func_$1_use+set} != xset; then
219 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
222 AC_TRY_COMPILE([#include <stdlib.h>],
224 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
228 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
229 if test x$glibcxx_cv_func_$1_use = x"yes"; then
236 dnl Check to see if the (stdlib function) argument passed is
237 dnl 1) declared when using the c++ compiler
238 dnl 2) has "C" linkage
240 dnl argument 1 is name of function to check
242 dnl ASSUMES argument is a stdlib function with ONE parameter
244 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1
245 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1], [
246 AC_MSG_CHECKING([for $1 declaration])
247 if test x${glibcxx_cv_func_$1_use+set} != xset; then
248 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
251 AC_TRY_COMPILE([#include <stdlib.h>],
253 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
257 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
258 if test x$glibcxx_cv_func_$1_use = x"yes"; then
265 dnl Check to see if the (stdlib function) argument passed is
266 dnl 1) declared when using the c++ compiler
267 dnl 2) has "C" linkage
269 dnl argument 1 is name of function to check
271 dnl ASSUMES argument is a stdlib function with TWO parameters
273 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
274 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2], [
275 AC_MSG_CHECKING([for $1 declaration])
276 if test x${glibcxx_cv_func_$1_use+set} != xset; then
277 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
280 AC_TRY_COMPILE([#include <stdlib.h>],
282 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
286 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
287 if test x$glibcxx_cv_func_$1_use = x"yes"; then
290 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
295 dnl Check to see if the (stdlib function) argument passed is
296 dnl 1) declared when using the c++ compiler
297 dnl 2) has "C" linkage
299 dnl argument 1 is name of function to check
301 dnl ASSUMES argument is a stdlib function with THREE parameters
303 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3
304 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3], [
305 AC_MSG_CHECKING([for $1 declaration])
306 if test x${glibcxx_cv_func_$1_use+set} != xset; then
307 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
310 AC_TRY_COMPILE([#include <stdlib.h>],
312 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
316 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
317 if test x$glibcxx_cv_func_$1_use = x"yes"; then
323 dnl Check to see what the underlying c 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...
329 dnl Define HAVE_STRTOLD if "strtold" is declared and links
330 dnl Define HAVE_STRTOF if "strtof" is declared and links
332 dnl GLIBCXX_CHECK_STDLIB_SUPPORT
333 AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [
334 ac_test_CXXFLAGS="${CXXFLAGS+set}"
335 ac_save_CXXFLAGS="$CXXFLAGS"
336 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
338 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(at_quick_exit)
339 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(quick_exit)
340 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
341 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
343 CXXFLAGS="$ac_save_CXXFLAGS"
347 dnl Check to see what the underlying c library or math library is like.
348 dnl These checks need to do two things:
349 dnl 1) make sure the name is declared when using the c++ compiler
350 dnl 2) make sure the name has "C" linkage
351 dnl This might seem like overkill but experience has shown that it's not...
353 dnl Define HAVE_CARGF etc if "cargf" is found.
355 dnl GLIBCXX_CHECK_MATH_SUPPORT
356 AC_DEFUN([GLIBCXX_CHECK_MATH_SUPPORT], [
357 ac_test_CXXFLAGS="${CXXFLAGS+set}"
358 ac_save_CXXFLAGS="$CXXFLAGS"
359 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
362 AC_CHECK_LIB(m, sin, libm="-lm")
366 dnl Check to see if certain C math functions exist.
367 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
368 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
369 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
370 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
371 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
372 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
373 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
375 dnl Check to see if basic C math functions have float versions.
376 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
381 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
384 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
385 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
386 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
387 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
388 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
389 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
390 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
391 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
392 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
393 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
394 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
395 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
396 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modf)
397 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
398 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
399 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
400 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
402 dnl Check to see if basic C math functions have long double versions.
403 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
408 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
411 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
412 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
413 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
414 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
415 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
416 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
417 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
418 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
419 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
420 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
421 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
422 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
423 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
424 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
425 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
426 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
429 CXXFLAGS="$ac_save_CXXFLAGS"