moveable2.cc: Tweak Copyright years.
[gcc.git] / libstdc++-v3 / linkage.m4
1 dnl
2 dnl This file contains macros for testing linkage.
3 dnl
4
5 dnl
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
9 dnl
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, [
15 AC_LANG_SAVE
16 AC_LANG_CPLUSPLUS
17 AC_TRY_COMPILE([#include <math.h>
18 #ifdef HAVE_IEEEFP_H
19 #include <ieeefp.h>
20 #endif
21 ],
22 [ $1(0);],
23 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
24 AC_LANG_RESTORE
25 ])
26 fi
27 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
28 ])
29
30
31 dnl
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".
35 dnl
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[
43 #endif])])
44 ])
45
46
47 dnl
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 '_'
52 dnl
53 dnl Define HAVE_CARGF etc if "cargf" is declared and links
54 dnl
55 dnl argument 1 is name of function to check
56 dnl
57 dnl ASSUMES argument is a math function with ONE parameter
58 dnl
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
63 AC_CHECK_FUNCS($1)
64 else
65 GLIBCXX_CHECK_MATH_DECL_1(_$1)
66 if test x$glibcxx_cv_func__$1_use = x"yes"; then
67 AC_CHECK_FUNCS(_$1)
68 fi
69 fi
70 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
71 ])
72
73
74 dnl
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, [
83 AC_LANG_SAVE
84 AC_LANG_CPLUSPLUS
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])
89 AC_LANG_RESTORE])
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)
93 else
94 AC_MSG_CHECKING([for _$1 functions])
95 AC_CACHE_VAL(glibcxx_cv_func__$2_use, [
96 AC_LANG_SAVE
97 AC_LANG_CPLUSPLUS
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])
102 AC_LANG_RESTORE])
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+],[_\&]))
106 fi
107 fi
108 GLIBCXX_MAYBE_UNDERSCORED_FUNCS(funclist)
109 undefine([funclist])
110 ])
111
112 dnl
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
116 dnl
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, [
122 AC_LANG_SAVE
123 AC_LANG_CPLUSPLUS
124 AC_TRY_COMPILE([#include <math.h>],
125 [ $1(0, 0);],
126 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
127 AC_LANG_RESTORE
128 ])
129 fi
130 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
131 ])
132
133 dnl
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
137 dnl
138 dnl Define HAVE_CARGF etc if "cargf" is declared and links
139 dnl
140 dnl argument 1 is name of function to check
141 dnl
142 dnl ASSUMES argument is a math function with TWO parameters
143 dnl
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
148 AC_CHECK_FUNCS($1)
149 else
150 GLIBCXX_CHECK_MATH_DECL_2(_$1)
151 if test x$glibcxx_cv_func__$1_use = x"yes"; then
152 AC_CHECK_FUNCS(_$1)
153 fi
154 fi
155 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
156 ])
157
158
159 dnl
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
163 dnl
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, [
169 AC_LANG_SAVE
170 AC_LANG_CPLUSPLUS
171 AC_TRY_COMPILE([#include <math.h>],
172 [ $1(0, 0, 0);],
173 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
174 AC_LANG_RESTORE
175 ])
176 fi
177 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
178 ])
179
180 dnl
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
184 dnl
185 dnl Define HAVE_CARGF etc if "cargf" is declared and links
186 dnl
187 dnl argument 1 is name of function to check
188 dnl
189 dnl ASSUMES argument is a math function with THREE parameters
190 dnl
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
195 AC_CHECK_FUNCS($1)
196 else
197 GLIBCXX_CHECK_MATH_DECL_3(_$1)
198 if test x$glibcxx_cv_func__$1_use = x"yes"; then
199 AC_CHECK_FUNCS(_$1)
200 fi
201 fi
202 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
203 ])
204
205
206 dnl
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
210 dnl
211 dnl argument 1 is name of function to check
212 dnl
213 dnl ASSUMES argument is a stdlib function without parameters
214 dnl
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, [
220 AC_LANG_SAVE
221 AC_LANG_CPLUSPLUS
222 AC_TRY_COMPILE([#include <stdlib.h>],
223 [ $1();],
224 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
225 AC_LANG_RESTORE
226 ])
227 fi
228 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
229 if test x$glibcxx_cv_func_$1_use = x"yes"; then
230 AC_CHECK_FUNCS($1)
231 fi
232 ])
233
234
235 dnl
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
239 dnl
240 dnl argument 1 is name of function to check
241 dnl
242 dnl ASSUMES argument is a stdlib function with TWO parameters
243 dnl
244 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
245 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2], [
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, [
249 AC_LANG_SAVE
250 AC_LANG_CPLUSPLUS
251 AC_TRY_COMPILE([#include <stdlib.h>],
252 [ $1(0, 0);],
253 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
254 AC_LANG_RESTORE
255 ])
256 fi
257 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
258 if test x$glibcxx_cv_func_$1_use = x"yes"; then
259 AC_CHECK_FUNCS($1)
260 fi
261 GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1)
262 ])
263
264
265 dnl
266 dnl Check to see if the (stdlib function) argument passed is
267 dnl 1) declared when using the c++ compiler
268 dnl 2) has "C" linkage
269 dnl
270 dnl argument 1 is name of function to check
271 dnl
272 dnl ASSUMES argument is a stdlib function with THREE parameters
273 dnl
274 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3
275 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3], [
276 AC_MSG_CHECKING([for $1 declaration])
277 if test x${glibcxx_cv_func_$1_use+set} != xset; then
278 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
279 AC_LANG_SAVE
280 AC_LANG_CPLUSPLUS
281 AC_TRY_COMPILE([#include <stdlib.h>],
282 [ $1(0, 0, 0);],
283 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
284 AC_LANG_RESTORE
285 ])
286 fi
287 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
288 if test x$glibcxx_cv_func_$1_use = x"yes"; then
289 AC_CHECK_FUNCS($1)
290 fi
291 ])
292
293 dnl
294 dnl Check to see what the underlying c library is like
295 dnl These checks need to do two things:
296 dnl 1) make sure the name is declared when using the c++ compiler
297 dnl 2) make sure the name has "C" linkage
298 dnl This might seem like overkill but experience has shown that it's not...
299 dnl
300 dnl Define HAVE_STRTOLD if "strtold" is declared and links
301 dnl Define HAVE_STRTOF if "strtof" is declared and links
302 dnl
303 dnl GLIBCXX_CHECK_STDLIB_SUPPORT
304 AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [
305 ac_test_CXXFLAGS="${CXXFLAGS+set}"
306 ac_save_CXXFLAGS="$CXXFLAGS"
307 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
308
309 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
310 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
311
312 CXXFLAGS="$ac_save_CXXFLAGS"
313 ])
314
315 dnl
316 dnl Check to see what the underlying c library or math library is like.
317 dnl These checks need to do two things:
318 dnl 1) make sure the name is declared when using the c++ compiler
319 dnl 2) make sure the name has "C" linkage
320 dnl This might seem like overkill but experience has shown that it's not...
321 dnl
322 dnl Define HAVE_CARGF etc if "cargf" is found.
323 dnl
324 dnl GLIBCXX_CHECK_MATH_SUPPORT
325 AC_DEFUN([GLIBCXX_CHECK_MATH_SUPPORT], [
326 ac_test_CXXFLAGS="${CXXFLAGS+set}"
327 ac_save_CXXFLAGS="$CXXFLAGS"
328 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
329
330 dnl Check libm
331 AC_CHECK_LIB(m, sin, libm="-lm")
332 ac_save_LIBS="$LIBS"
333 LIBS="$LIBS $libm"
334
335 dnl Check to see if certain C math functions exist.
336 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
337 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
338 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
339 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
340 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
341 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
342 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
343
344 dnl Check to see if basic C math functions have float versions.
345 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
346 float_trig,
347 acosf asinf atanf \
348 cosf sinf tanf \
349 coshf sinhf tanhf)
350 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
351 float_round,
352 ceilf floorf)
353 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
354 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
355 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
356 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
357 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
358 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
359 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
360 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
361 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
362 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
363 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
364 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
365 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modf)
366 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
367 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
368 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
369 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
370
371 dnl Check to see if basic C math functions have long double versions.
372 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
373 long_double_trig,
374 acosl asinl atanl \
375 cosl sinl tanl \
376 coshl sinhl tanhl)
377 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
378 long_double_round,
379 ceill floorl)
380 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
381 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
382 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
383 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
384 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
385 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
386 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
387 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
388 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
389 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
390 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
391 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
392 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
393 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
394 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
395 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
396
397 LIBS="$ac_save_LIBS"
398 CXXFLAGS="$ac_save_CXXFLAGS"
399 ])