]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/acinclude.m4
* gcc.dg/20021018-1.c: Disable if the sizeof (int) < 4.
[thirdparty/gcc.git] / libstdc++-v3 / acinclude.m4
CommitLineData
b2dad0e3 1dnl
51122a42 2dnl Initialize basic configure bits, set toplevel_srcdir for Makefiles.
b2dad0e3 3dnl
3d7c150e
BK
4dnl GLIBCXX_TOPREL_CONFIGURE
5AC_DEFUN(GLIBCXX_TOPREL_CONFIGURE, [
2c839a4e
PE
6 dnl Default to --enable-multilib (this is also passed by default
7 dnl from the ubercommon-top-level configure)
b2dad0e3
BK
8 AC_ARG_ENABLE(multilib,
9 [ --enable-multilib build hella library versions (default)],
10 [case "${enableval}" in
11 yes) multilib=yes ;;
12 no) multilib=no ;;
13 *) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
14 esac], [multilib=yes])dnl
15
d2caef2e
PE
16 # When building with srcdir == objdir, links to the source files will
17 # be created in directories within the target_subdir. We have to
18 # adjust toplevel_srcdir accordingly, so that configure finds
19 # install-sh and other auxiliary files that live in the top-level
20 # source directory.
21 if test "${srcdir}" = "."; then
22 if test -z "${with_target_subdir}"; then
23 toprel=".."
33590f13 24 else
d2caef2e
PE
25 if test "${with_target_subdir}" != "."; then
26 toprel="${with_multisrctop}../.."
27 else
28 toprel="${with_multisrctop}.."
29 fi
33590f13 30 fi
d2caef2e
PE
31 else
32 toprel=".."
33590f13 33 fi
d2caef2e
PE
34 AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
35 toplevel_srcdir=\${top_srcdir}/$toprel
36 AC_SUBST(toplevel_srcdir)
aebb8c22
DD
37])
38
39dnl
51122a42 40dnl Initialize the rest of the library configury.
aebb8c22 41dnl
3d7c150e
BK
42dnl GLIBCXX_CONFIGURE
43AC_DEFUN(GLIBCXX_CONFIGURE, [
d2caef2e
PE
44 # Export build and source directories.
45 # These need to be absolute paths, yet at the same time need to
46 # canonicalize only relative paths, because then amd will not unmount
47 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
3d7c150e 48 glibcxx_builddir=`${PWDCMD-pwd}`
d2caef2e 49 case $srcdir in
3d7c150e
BK
50 [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
51 *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
d2caef2e 52 esac
3d7c150e
BK
53 AC_SUBST(glibcxx_builddir)
54 AC_SUBST(glibcxx_srcdir)
d2caef2e
PE
55
56 dnl This is here just to satisfy automake.
57 ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)])
58
59 AC_PROG_AWK
60 # Will set LN_S to either 'ln -s' or 'ln'. With autoconf 2.5x, can also
2c839a4e
PE
61 # be 'cp -p' if linking isn't available. Uncomment the next line to
62 # force a particular method.
d2caef2e
PE
63 #ac_cv_prog_LN_S='cp -p'
64 AC_PROG_LN_S
65
66 # We use these options to decide which functions to include.
67 AC_ARG_WITH(target-subdir,
68 [ --with-target-subdir=SUBDIR
69 configuring in a subdirectory])
70 AC_ARG_WITH(cross-host,
71 [ --with-cross-host=HOST configuring with a cross compiler])
33590f13 72
b731048b
BK
73 AC_ARG_WITH(newlib,
74 [ --with-newlib Configuring with newlib])
75
3d7c150e
BK
76 glibcxx_basedir=$srcdir/$toprel/$1/libstdc++-v3
77 AC_SUBST(glibcxx_basedir)
b2dad0e3 78
28861379
BK
79 # Never versions of autoconf add an underscore to these functions.
80 # Prevent future problems ...
81 ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
82 ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
83 ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
84 ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
5780a46b 85
d2caef2e
PE
86 # AC_PROG_CC
87 # FIXME: We temporarily define our own version of AC_PROG_CC. This is
88 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
89 # are probably using a cross compiler, which will not be able to fully
90 # link an executable. This is addressed in later versions of autoconf.
91
92 AC_DEFUN(LIB_AC_PROG_CC,
93 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
94 dnl Fool anybody using AC_PROG_CC.
95 AC_PROVIDE([AC_PROG_CC])
96 AC_CHECK_PROG(CC, gcc, gcc)
97 if test -z "$CC"; then
98 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
99 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
b2dad0e3 100 fi
b2dad0e3 101
d2caef2e
PE
102 AC_PROG_CC_GNU
103
104 if test $ac_cv_prog_gcc = yes; then
105 GCC=yes
106 dnl Check whether -g works, even if CFLAGS is set, in case the package
107 dnl plays around with CFLAGS (such as to build both debugging and
108 dnl normal versions of a library), tasteless as that idea is.
109 ac_test_CFLAGS="${CFLAGS+set}"
110 ac_save_CFLAGS="$CFLAGS"
111 CFLAGS=
112 AC_PROG_CC_G
113 if test "$ac_test_CFLAGS" = set; then
114 CFLAGS="$ac_save_CFLAGS"
115 elif test $ac_cv_prog_cc_g = yes; then
116 CFLAGS="-g -O2"
117 else
118 CFLAGS="-O2"
119 fi
b2dad0e3 120 else
d2caef2e
PE
121 GCC=
122 test "${CFLAGS+set}" = set || CFLAGS="-g"
b2dad0e3 123 fi
d2caef2e
PE
124 ])
125
126 LIB_AC_PROG_CC
127
128 # Likewise for AC_PROG_CXX. We can't just call it directly because g++
129 # will try to link in libstdc++.
130 AC_DEFUN(LIB_AC_PROG_CXX,
131 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
132 dnl Fool anybody using AC_PROG_CXX.
133 AC_PROVIDE([AC_PROG_CXX])
3d7c150e 134 # Use glibcxx_CXX so that we do not cause CXX to be cached with the
d2caef2e
PE
135 # flags that come in CXX while configuring libstdc++. They're different
136 # from those used for all other target libraries. If CXX is set in
137 # the environment, respect that here.
3d7c150e
BK
138 glibcxx_CXX=$CXX
139 AC_CHECK_PROGS(glibcxx_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
140 AC_SUBST(glibcxx_CXX)
141 CXX=$glibcxx_CXX
142 test -z "$glibcxx_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
d2caef2e
PE
143
144 AC_PROG_CXX_GNU
145
146 if test $ac_cv_prog_gxx = yes; then
147 GXX=yes
148 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
149 dnl plays around with CXXFLAGS (such as to build both debugging and
150 dnl normal versions of a library), tasteless as that idea is.
151 ac_test_CXXFLAGS="${CXXFLAGS+set}"
152 ac_save_CXXFLAGS="$CXXFLAGS"
153 CXXFLAGS=
154 AC_PROG_CXX_G
155 if test "$ac_test_CXXFLAGS" = set; then
156 CXXFLAGS="$ac_save_CXXFLAGS"
157 elif test $ac_cv_prog_cxx_g = yes; then
158 CXXFLAGS="-g -O2"
159 else
160 CXXFLAGS="-O2"
161 fi
162 else
163 GXX=
164 test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
165 fi
166 ])
b2dad0e3 167
d2caef2e 168 LIB_AC_PROG_CXX
b2dad0e3 169
2f235b6d
PE
170 # For directory versioning (e.g., headers) and other variables.
171 AC_MSG_CHECKING([for GCC version number])
3d7c150e 172 gcc_version=`$glibcxx_CXX -dumpversion`
2f235b6d
PE
173 AC_MSG_RESULT($gcc_version)
174
d2caef2e
PE
175 # For some reason, gettext needs this.
176 AC_ISC_POSIX
33590f13 177
5780a46b
BK
178 AC_CHECK_TOOL(AS, as)
179 AC_CHECK_TOOL(AR, ar)
46840bcd 180 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
5780a46b 181 AC_PROG_INSTALL
b2dad0e3 182
5780a46b 183 AM_MAINTAINER_MODE
b2dad0e3 184
5780a46b
BK
185 # We need AC_EXEEXT to keep automake happy in cygnus mode. However,
186 # at least currently, we never actually build a program, so we never
187 # need to use $(EXEEXT). Moreover, the test for EXEEXT normally
188 # fails, because we are probably configuring with a cross compiler
c5504edb
JM
189 # which can't create executables. So we include AC_EXEEXT to keep
190 # automake happy, but we don't execute it, since we don't care about
15bcd79a 191 # the result.
5780a46b 192 if false; then
4e0abb1d
AO
193 # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
194 # to nothing, so nothing would remain between `then' and `fi' if it
195 # were not for the `:' below.
196 :
5780a46b
BK
197 AC_EXEEXT
198 fi
b2dad0e3 199
3d7c150e
BK
200 case [$]{glibcxx_basedir} in
201 /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcxx_basedir} ;;
202 *) glibcxx_flagbasedir='[$](top_builddir)/'[$]{glibcxx_basedir} ;;
5780a46b 203 esac
b2dad0e3 204
16da539b
PE
205 # Set up safe default values for all subsequent AM_CONDITIONAL tests.
206 need_libmath=no
207 enable_wchar_t=no
208 #enable_debug=no
3d7c150e 209 #glibcxx_pch_comp=no
16da539b
PE
210 #enable_cheaders=c
211 #c_compatibility=no
c4c064e7 212 #enable_abi_check=no
16da539b
PE
213 #enable_symvers=no
214
2c839a4e 215 # Find platform-specific directories containing configuration info. In
5e3cbe0b 216 # addition to possibly modifying the same flags, it also sets up symlinks.
3d7c150e 217 GLIBCXX_CHECK_HOST
b2dad0e3
BK
218])
219
220
221dnl
8bd636c5 222dnl Check to see if g++ can compile this library, and if so, if any version-
37bc6ca2
PE
223dnl specific precautions need to be taken.
224dnl
3d7c150e
BK
225dnl GLIBCXX_CHECK_COMPILER_VERSION
226AC_DEFUN(GLIBCXX_CHECK_COMPILER_VERSION, [
44382959
BK
227if test ! -f stamp-sanity-compiler; then
228 AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
229 AC_LANG_SAVE
230 AC_LANG_CPLUSPLUS
1d855e87
BK
231 AC_TRY_COMPILE(, [
232 #if __GNUC__ < 3
233 not_ok
c470c17d 234 #endif
6a163d7c 235 ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
44382959 236 AC_LANG_RESTORE
c470c17d 237 AC_MSG_RESULT($gpp_satisfactory)
44382959
BK
238 touch stamp-sanity-compiler
239fi
c470c17d
BK
240])
241
242
243dnl
52b55e7d
PE
244dnl Tests for newer compiler features, or features that are present in newer
245dnl compiler versions but not older compiler versions still in use, should
246dnl be placed here.
b2dad0e3 247dnl
7f586614
BK
248dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
249dnl new inlining code or the new system_header pragma will die on -Werror.
250dnl Leave it out by default and use maint-mode to use it.
b2dad0e3 251dnl
c470c17d 252dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
c21b6f87
PE
253dnl compiler supports it and the user has not requested debug mode.
254dnl
3d7c150e
BK
255dnl GLIBCXX_CHECK_COMPILER_FEATURES
256AC_DEFUN(GLIBCXX_CHECK_COMPILER_FEATURES, [
a4e99046 257 # All these tests are for C++; save the language and the compiler flags.
52b55e7d 258 # The CXXFLAGS thing is suspicious, but based on similar bits previously
3d7c150e 259 # found in GLIBCXX_CONFIGURE.
a4e99046
PE
260 AC_LANG_SAVE
261 AC_LANG_CPLUSPLUS
262 ac_test_CXXFLAGS="${CXXFLAGS+set}"
263 ac_save_CXXFLAGS="$CXXFLAGS"
a4e99046 264
7f586614
BK
265 # Check for maintainer-mode bits.
266 if test x"$USE_MAINTAINER_MODE" = xno; then
267 WERROR=''
8bd636c5 268 else
7f586614 269 WERROR='-Werror'
8bd636c5
PE
270 fi
271
c470c17d
BK
272 # Check for -ffunction-sections -fdata-sections
273 AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
0517cb99 274 CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
c470c17d
BK
275 AC_TRY_COMPILE(, [int foo;
276 ], [ac_fdsections=yes], [ac_fdsections=no])
277 if test "$ac_test_CXXFLAGS" = set; then
278 CXXFLAGS="$ac_save_CXXFLAGS"
279 else
280 # this is the suspicious part
281 CXXFLAGS=''
282 fi
6aa43d99 283 if test x"$ac_fdsections" = x"yes"; then
c470c17d
BK
284 SECTION_FLAGS='-ffunction-sections -fdata-sections'
285 fi
286 AC_MSG_RESULT($ac_fdsections)
287
a4e99046 288 AC_LANG_RESTORE
8bd636c5 289 AC_SUBST(WERROR)
c470c17d 290 AC_SUBST(SECTION_FLAGS)
b2dad0e3
BK
291])
292
c470c17d
BK
293
294dnl
421173e6
PE
295dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
296dnl the native linker is in use, all variables will be defined to something
297dnl safe (like an empty string).
298dnl
299dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
300dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
3d7c150e 301dnl Define LD, with_gnu_ld, and (possibly) glibcxx_gnu_ld_version as
313dd504
PE
302dnl side-effects of testing. The last will be a single integer, e.g.,
303dnl version 1.23.45.0.67.89 will set glibcxx_gnu_ld_version to 12345.
c470c17d 304dnl
3d7c150e
BK
305dnl GLIBCXX_CHECK_LINKER_FEATURES
306AC_DEFUN(GLIBCXX_CHECK_LINKER_FEATURES, [
421173e6
PE
307 # If we're not using GNU ld, then there's no point in even trying these
308 # tests. Check for that first. We should have already tested for gld
309 # by now (in libtool), but require it now just to be safe...
654421eb
DE
310 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
311 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
421173e6 312 AC_REQUIRE([AC_PROG_LD])
5bd17d39 313
c98b201b
PE
314 # The name set by libtool depends on the version of libtool. Shame on us
315 # for depending on an impl detail, but c'est la vie. Older versions used
316 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
317 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
318 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
319 # set (hence we're using an older libtool), then set it.
320 if test x${with_gnu_ld+set} != xset; then
321 if test x${ac_cv_prog_gnu_ld+set} != xset; then
322 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
323 with_gnu_ld=no
324 else
325 with_gnu_ld=$ac_cv_prog_gnu_ld
326 fi
327 fi
328
329 # Start by getting the version number. I think the libtool test already
330 # does some of this, but throws away the result.
331 changequote(,)
332 ldver=`$LD --version 2>/dev/null | head -1 | \
333 sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
334 changequote([,])
3d7c150e 335 glibcxx_gnu_ld_version=`echo $ldver | \
c98b201b
PE
336 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
337
5bd17d39 338 # Set --gc-sections.
c98b201b 339 if test "$with_gnu_ld" = "notbroken"; then
a9117427 340 # GNU ld it is! Joy and bunny rabbits!
421173e6
PE
341
342 # All these tests are for C++; save the language and the compiler flags.
343 # Need to do this so that g++ won't try to link in libstdc++
344 ac_test_CFLAGS="${CFLAGS+set}"
345 ac_save_CFLAGS="$CFLAGS"
5bd17d39 346 CFLAGS='-x c++ -Wl,--gc-sections'
421173e6
PE
347
348 # Check for -Wl,--gc-sections
e466dc8a 349 # XXX This test is broken at the moment, as symbols required for
37bc6ca2 350 # linking are now in libsupc++ (not built yet.....). In addition,
a9117427
BK
351 # this test has cored on solaris in the past. In addition,
352 # --gc-sections doesn't really work at the moment (keeps on discarding
353 # used sections, first .eh_frame and now some of the glibc sections for
354 # iconv). Bzzzzt. Thanks for playing, maybe next time.
421173e6
PE
355 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
356 AC_TRY_RUN([
37bc6ca2 357 int main(void)
421173e6 358 {
a9117427
BK
359 try { throw 1; }
360 catch (...) { };
421173e6
PE
361 return 0;
362 }
c0abb59e 363 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
421173e6
PE
364 if test "$ac_test_CFLAGS" = set; then
365 CFLAGS="$ac_save_CFLAGS"
366 else
367 # this is the suspicious part
368 CFLAGS=''
369 fi
370 if test "$ac_sectionLDflags" = "yes"; then
654421eb 371 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
421173e6
PE
372 fi
373 AC_MSG_RESULT($ac_sectionLDflags)
5bd17d39 374 fi
a9117427 375
5bd17d39 376 # Set linker optimization flags.
6aa43d99 377 if test x"$with_gnu_ld" = x"yes"; then
654421eb 378 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
421173e6 379 fi
5bd17d39 380
c470c17d 381 AC_SUBST(SECTION_LDFLAGS)
421173e6 382 AC_SUBST(OPT_LDFLAGS)
c470c17d
BK
383])
384
385
b2dad0e3 386dnl
11fc1858 387dnl Check to see if the (math function) argument passed is
f8db4f20 388dnl declared when using the c++ compiler
38bd7296
BK
389dnl ASSUMES argument is a math function with ONE parameter
390dnl
3d7c150e
BK
391dnl GLIBCXX_CHECK_MATH_DECL_1
392AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_1, [
38bd7296 393 AC_MSG_CHECKING([for $1 declaration])
3d7c150e
BK
394 if test x${glibcxx_cv_func_$1_use+set} != xset; then
395 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
f84ef7fb
PE
396 AC_LANG_SAVE
397 AC_LANG_CPLUSPLUS
01a49191
RB
398 AC_TRY_COMPILE([#include <math.h>
399 #ifdef HAVE_IEEEFP_H
400 #include <ieeefp.h>
401 #endif
37bc6ca2
PE
402 ],
403 [ $1(0);],
3d7c150e 404 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
f84ef7fb
PE
405 AC_LANG_RESTORE
406 ])
407 fi
3d7c150e 408 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
f8db4f20
BK
409])
410
411dnl
412dnl Check to see if the (math function) argument passed is
413dnl 1) declared when using the c++ compiler
414dnl 2) has "C" linkage
415dnl 3) if not, see if 1) and 2) for argument prepended with '_'
416dnl
417dnl Define HAVE_CARGF etc if "cargf" is declared and links
418dnl
419dnl argument 1 is name of function to check
420dnl
421dnl ASSUMES argument is a math function with ONE parameter
422dnl
3d7c150e
BK
423dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1
424AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, [
425 GLIBCXX_CHECK_MATH_DECL_1($1)
426 if test x$glibcxx_cv_func_$1_use = x"yes"; then
37bc6ca2 427 AC_CHECK_FUNCS($1)
f8db4f20 428 else
3d7c150e
BK
429 GLIBCXX_CHECK_MATH_DECL_1(_$1)
430 if test x$glibcxx_cv_func__$1_use = x"yes"; then
37bc6ca2 431 AC_CHECK_FUNCS(_$1)
a0cb1aa7 432 fi
38bd7296
BK
433 fi
434])
435
f8db4f20 436
20b11783 437dnl
3d7c150e 438dnl Like GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
37bc6ca2 439dnl of functions at once. It's an all-or-nothing check -- either
9b8fd32c 440dnl HAVE_XYZ is defined for each of the functions, or for none of them.
20b11783 441dnl Doing it this way saves significant configure time.
3d7c150e 442AC_DEFUN(GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1, [
20b11783 443 AC_MSG_CHECKING([for $1 functions])
3d7c150e 444 AC_CACHE_VAL(glibcxx_cv_func_$2_use, [
20b11783
MM
445 AC_LANG_SAVE
446 AC_LANG_CPLUSPLUS
447 AC_TRY_COMPILE([#include <math.h>],
448 [ `for x in $3; do echo "$x (0);"; done` ],
3d7c150e
BK
449 [glibcxx_cv_func_$2_use=yes],
450 [glibcxx_cv_func_$2_use=no])
20b11783 451 AC_LANG_RESTORE])
3d7c150e
BK
452 AC_MSG_RESULT($glibcxx_cv_func_$2_use)
453 if test x$glibcxx_cv_func_$2_use = x"yes"; then
20b11783
MM
454 AC_CHECK_FUNCS($3)
455 fi
456])
38bd7296
BK
457
458dnl
11fc1858 459dnl Check to see if the (math function) argument passed is
f8db4f20 460dnl declared when using the c++ compiler
52b55e7d 461dnl ASSUMES argument is a math function with TWO parameters
38bd7296 462dnl
3d7c150e
BK
463dnl GLIBCXX_CHECK_MATH_DECL_2
464AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_2, [
38bd7296 465 AC_MSG_CHECKING([for $1 declaration])
3d7c150e
BK
466 if test x${glibcxx_cv_func_$1_use+set} != xset; then
467 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
f84ef7fb
PE
468 AC_LANG_SAVE
469 AC_LANG_CPLUSPLUS
37bc6ca2
PE
470 AC_TRY_COMPILE([#include <math.h>],
471 [ $1(0, 0);],
3d7c150e 472 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
f84ef7fb
PE
473 AC_LANG_RESTORE
474 ])
475 fi
3d7c150e 476 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
38bd7296
BK
477])
478
38bd7296 479dnl
11fc1858 480dnl Check to see if the (math function) argument passed is
38bd7296
BK
481dnl 1) declared when using the c++ compiler
482dnl 2) has "C" linkage
483dnl
484dnl Define HAVE_CARGF etc if "cargf" is declared and links
485dnl
486dnl argument 1 is name of function to check
487dnl
f8db4f20 488dnl ASSUMES argument is a math function with TWO parameters
38bd7296 489dnl
3d7c150e
BK
490dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2
491AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2, [
492 GLIBCXX_CHECK_MATH_DECL_2($1)
493 if test x$glibcxx_cv_func_$1_use = x"yes"; then
37bc6ca2 494 AC_CHECK_FUNCS($1)
f8db4f20 495 else
3d7c150e
BK
496 GLIBCXX_CHECK_MATH_DECL_2(_$1)
497 if test x$glibcxx_cv_func__$1_use = x"yes"; then
37bc6ca2 498 AC_CHECK_FUNCS(_$1)
a0cb1aa7 499 fi
f8db4f20
BK
500 fi
501])
502
503
504dnl
505dnl Check to see if the (math function) argument passed is
506dnl declared when using the c++ compiler
52b55e7d 507dnl ASSUMES argument is a math function with THREE parameters
f8db4f20 508dnl
3d7c150e
BK
509dnl GLIBCXX_CHECK_MATH_DECL_3
510AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_3, [
38bd7296 511 AC_MSG_CHECKING([for $1 declaration])
3d7c150e
BK
512 if test x${glibcxx_cv_func_$1_use+set} != xset; then
513 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
f84ef7fb
PE
514 AC_LANG_SAVE
515 AC_LANG_CPLUSPLUS
37bc6ca2
PE
516 AC_TRY_COMPILE([#include <math.h>],
517 [ $1(0, 0, 0);],
3d7c150e 518 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
f84ef7fb
PE
519 AC_LANG_RESTORE
520 ])
521 fi
3d7c150e 522 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
f8db4f20
BK
523])
524
525dnl
526dnl Check to see if the (math function) argument passed is
527dnl 1) declared when using the c++ compiler
528dnl 2) has "C" linkage
529dnl
530dnl Define HAVE_CARGF etc if "cargf" is declared and links
531dnl
532dnl argument 1 is name of function to check
533dnl
534dnl ASSUMES argument is a math function with THREE parameters
535dnl
3d7c150e
BK
536dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3
537AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3, [
538 GLIBCXX_CHECK_MATH_DECL_3($1)
539 if test x$glibcxx_cv_func_$1_use = x"yes"; then
37bc6ca2 540 AC_CHECK_FUNCS($1)
f8db4f20 541 else
3d7c150e
BK
542 GLIBCXX_CHECK_MATH_DECL_3(_$1)
543 if test x$glibcxx_cv_func__$1_use = x"yes"; then
37bc6ca2 544 AC_CHECK_FUNCS(_$1)
a0cb1aa7 545 fi
38bd7296
BK
546 fi
547])
548
549
5bd17d39
PE
550dnl
551dnl Check to see if the (stdlib function) argument passed is
552dnl 1) declared when using the c++ compiler
553dnl 2) has "C" linkage
554dnl
5bd17d39
PE
555dnl argument 1 is name of function to check
556dnl
557dnl ASSUMES argument is a math function with TWO parameters
558dnl
3d7c150e
BK
559dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
560AC_DEFUN(GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
5bd17d39 561 AC_MSG_CHECKING([for $1 declaration])
3d7c150e
BK
562 if test x${glibcxx_cv_func_$1_use+set} != xset; then
563 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
f84ef7fb
PE
564 AC_LANG_SAVE
565 AC_LANG_CPLUSPLUS
37bc6ca2
PE
566 AC_TRY_COMPILE([#include <stdlib.h>],
567 [ $1(0, 0);],
3d7c150e 568 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
f84ef7fb
PE
569 AC_LANG_RESTORE
570 ])
571 fi
3d7c150e
BK
572 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
573 if test x$glibcxx_cv_func_$1_use = x"yes"; then
37bc6ca2 574 AC_CHECK_FUNCS($1)
5bd17d39
PE
575 fi
576])
577
578
380f343b
RO
579dnl
580dnl Check to see if the (stdlib function) argument passed is
581dnl 1) declared when using the c++ compiler
582dnl 2) has "C" linkage
583dnl
584dnl argument 1 is name of function to check
585dnl
586dnl ASSUMES argument is a function with THREE parameters
587dnl
3d7c150e
BK
588dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3
589AC_DEFUN(GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
380f343b 590 AC_MSG_CHECKING([for $1 declaration])
3d7c150e
BK
591 if test x${glibcxx_cv_func_$1_use+set} != xset; then
592 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
380f343b
RO
593 AC_LANG_SAVE
594 AC_LANG_CPLUSPLUS
37bc6ca2
PE
595 AC_TRY_COMPILE([#include <stdlib.h>],
596 [ $1(0, 0, 0);],
3d7c150e 597 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
380f343b
RO
598 AC_LANG_RESTORE
599 ])
600 fi
3d7c150e
BK
601 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
602 if test x$glibcxx_cv_func_$1_use = x"yes"; then
37bc6ca2 603 AC_CHECK_FUNCS($1)
380f343b
RO
604 fi
605])
606
11fc1858 607dnl
37bc6ca2 608dnl Because the builtins are picky picky picky about the arguments they take,
11fc1858
BK
609dnl do an explict linkage tests here.
610dnl Check to see if the (math function) argument passed is
611dnl 1) declared when using the c++ compiler
612dnl 2) has "C" linkage
613dnl
614dnl Define HAVE_CARGF etc if "cargf" is declared and links
615dnl
616dnl argument 1 is name of function to check
617dnl
618dnl ASSUMES argument is a math function with ONE parameter
619dnl
3d7c150e
BK
620dnl GLIBCXX_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
621AC_DEFUN(GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
11fc1858 622 AC_MSG_CHECKING([for $1 declaration])
3d7c150e
BK
623 if test x${glibcxx_cv_func_$1_use+set} != xset; then
624 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
f84ef7fb
PE
625 AC_LANG_SAVE
626 AC_LANG_CPLUSPLUS
37bc6ca2
PE
627 AC_TRY_COMPILE([#include <math.h>],
628 [ $1(0);],
3d7c150e 629 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
f84ef7fb
PE
630 AC_LANG_RESTORE
631 ])
632 fi
3d7c150e
BK
633 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
634 if test x$glibcxx_cv_func_$1_use = x"yes"; then
11fc1858 635 AC_MSG_CHECKING([for $1 linkage])
3d7c150e
BK
636 if test x${glibcxx_cv_func_$1_link+set} != xset; then
637 AC_CACHE_VAL(glibcxx_cv_func_$1_link, [
37bc6ca2
PE
638 AC_TRY_LINK([#include <math.h>],
639 [ $1(0);],
3d7c150e 640 [glibcxx_cv_func_$1_link=yes], [glibcxx_cv_func_$1_link=no])
f84ef7fb
PE
641 ])
642 fi
3d7c150e
BK
643 AC_MSG_RESULT($glibcxx_cv_func_$1_link)
644 if test x$glibcxx_cv_func_$1_link = x"yes"; then
11fc1858
BK
645 ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
646 AC_DEFINE_UNQUOTED(${ac_tr_func})
647 fi
648 fi
649])
650
651
652dnl
653dnl Check to see what builtin math functions are supported
654dnl
655dnl check for __builtin_abs
656dnl check for __builtin_fabsf
657dnl check for __builtin_fabs
658dnl check for __builtin_fabl
659dnl check for __builtin_labs
660dnl check for __builtin_sqrtf
661dnl check for __builtin_sqrtl
dc6f4158 662dnl check for __builtin_sqrt
11fc1858
BK
663dnl check for __builtin_sinf
664dnl check for __builtin_sin
665dnl check for __builtin_sinl
666dnl check for __builtin_cosf
667dnl check for __builtin_cos
668dnl check for __builtin_cosl
669dnl
3d7c150e
BK
670dnl GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
671AC_DEFUN(GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT, [
11fc1858 672 dnl Test for builtin math functions.
37bc6ca2 673 dnl These are made in gcc/c-common.c
3d7c150e
BK
674 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
675 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
676 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
677 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
678 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
11fc1858 679
3d7c150e
BK
680 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
681 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
682 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
11fc1858 683
3d7c150e
BK
684 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
685 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
686 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
11fc1858 687
3d7c150e
BK
688 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
689 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
690 GLIBCXX_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
11fc1858
BK
691
692 dnl There is, without a doubt, a more elegant way to have these
693 dnl names exported so that they won't be stripped out of acconfig.h by
694 dnl autoheader. I leave this as an exercise to somebody less frustrated
695 dnl than I.... please email the libstdc++ list if you can figure out a
696 dnl more elegant approach (see autoconf/acgen.m4 and specifically
697 dnl AC_CHECK_FUNC for things to steal.)
698 dummyvar=no
699 if test x$dummyvar = x"yes"; then
700 AC_DEFINE(HAVE___BUILTIN_ABS)
701 AC_DEFINE(HAVE___BUILTIN_LABS)
702 AC_DEFINE(HAVE___BUILTIN_COS)
703 AC_DEFINE(HAVE___BUILTIN_COSF)
704 AC_DEFINE(HAVE___BUILTIN_COSL)
705 AC_DEFINE(HAVE___BUILTIN_FABS)
706 AC_DEFINE(HAVE___BUILTIN_FABSF)
707 AC_DEFINE(HAVE___BUILTIN_FABSL)
708 AC_DEFINE(HAVE___BUILTIN_SIN)
709 AC_DEFINE(HAVE___BUILTIN_SINF)
710 AC_DEFINE(HAVE___BUILTIN_SINL)
dc6f4158 711 AC_DEFINE(HAVE___BUILTIN_SQRT)
11fc1858
BK
712 AC_DEFINE(HAVE___BUILTIN_SQRTF)
713 AC_DEFINE(HAVE___BUILTIN_SQRTL)
714 fi
715])
716
5bd17d39 717dnl
74af99e5 718dnl Check to see what the underlying c library is like
37bc6ca2 719dnl These checks need to do two things:
5bd17d39
PE
720dnl 1) make sure the name is declared when using the c++ compiler
721dnl 2) make sure the name has "C" linkage
722dnl This might seem like overkill but experience has shown that it's not...
723dnl
7cda84dc
BK
724dnl Define HAVE_STRTOLD if "strtold" is declared and links
725dnl Define HAVE_STRTOF if "strtof" is declared and links
726dnl Define HAVE_DRAND48 if "drand48" is declared and links
5bd17d39 727dnl
3d7c150e
BK
728dnl GLIBCXX_CHECK_STDLIB_SUPPORT
729AC_DEFUN(GLIBCXX_CHECK_STDLIB_SUPPORT, [
5bd17d39
PE
730 ac_test_CXXFLAGS="${CXXFLAGS+set}"
731 ac_save_CXXFLAGS="$CXXFLAGS"
b7693a46 732 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
5bd17d39 733
3d7c150e
BK
734 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
735 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
7cda84dc 736 AC_CHECK_FUNCS(drand48)
5bd17d39
PE
737
738 CXXFLAGS="$ac_save_CXXFLAGS"
739])
740
2f103494
BK
741dnl
742dnl Check to see what the underlying c library or math library is like.
37bc6ca2 743dnl These checks need to do two things:
38bd7296
BK
744dnl 1) make sure the name is declared when using the c++ compiler
745dnl 2) make sure the name has "C" linkage
746dnl This might seem like overkill but experience has shown that it's not...
2f103494
BK
747dnl
748dnl Define HAVE_CARGF etc if "cargf" is found.
749dnl
3d7c150e
BK
750dnl GLIBCXX_CHECK_MATH_SUPPORT
751AC_DEFUN(GLIBCXX_CHECK_MATH_SUPPORT, [
38bd7296
BK
752 ac_test_CXXFLAGS="${CXXFLAGS+set}"
753 ac_save_CXXFLAGS="$CXXFLAGS"
b7693a46 754 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
aac350aa
BK
755
756 dnl Check libm
2f103494 757 AC_CHECK_LIB(m, sin, libm="-lm")
38bd7296 758 ac_save_LIBS="$LIBS"
2f103494
BK
759 LIBS="$LIBS $libm"
760
38bd7296 761 dnl Check to see if certain C math functions exist.
3d7c150e
BK
762 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
763 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
764 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
765 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
766 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
767 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
768 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
769 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
38bd7296
BK
770
771 dnl Check to see if basic C math functions have float versions.
3d7c150e 772 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
9b8fd32c
PE
773 float_trig,
774 acosf asinf atanf \
20b11783 775 cosf sinf tanf \
9b8fd32c 776 coshf sinhf tanhf)
3d7c150e 777 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
9b8fd32c 778 float_round,
20b11783 779 ceilf floorf)
3d7c150e
BK
780 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
781 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
782 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
783 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
784 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
785 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
786 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
787 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
788 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
789 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
790 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
791 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
792 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
793 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
794 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
795 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
38bd7296
BK
796
797 dnl Check to see if basic C math functions have long double versions.
3d7c150e 798 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
9b8fd32c
PE
799 long_double_trig,
800 acosl asinl atanl \
20b11783 801 cosl sinl tanl \
9b8fd32c 802 coshl sinhl tanhl)
3d7c150e 803 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
9b8fd32c 804 long_double_round,
20b11783 805 ceill floorl)
3d7c150e
BK
806 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
807 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
808 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
809 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
810 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
811 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
812 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
813 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
814 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
815 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
816 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
817 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
818 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
819 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
820 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
821 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
822 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
38bd7296
BK
823
824 dnl Some runtimes have these functions with a preceding underscore. Please
825 dnl keep this sync'd with the one above. And if you add any new symbol,
826 dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
827 dnl Check to see if certain C math functions exist.
38bd7296
BK
828
829 dnl Check to see if basic C math functions have float versions.
3d7c150e 830 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
9b8fd32c
PE
831 _float_trig,
832 _acosf _asinf _atanf \
20b11783 833 _cosf _sinf _tanf \
9b8fd32c 834 _coshf _sinhf _tanhf)
3d7c150e 835 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
9b8fd32c 836 _float_round,
20b11783 837 _ceilf _floorf)
38bd7296
BK
838
839 dnl Check to see if basic C math functions have long double versions.
3d7c150e 840 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
9b8fd32c
PE
841 _long_double_trig,
842 _acosl _asinl _atanl \
20b11783 843 _cosl _sinl _tanl \
9b8fd32c 844 _coshl _sinhl _tanhl)
3d7c150e 845 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
9b8fd32c 846 _long_double_round,
20b11783 847 _ceill _floorl)
38bd7296
BK
848
849 LIBS="$ac_save_LIBS"
850 CXXFLAGS="$ac_save_CXXFLAGS"
2f103494
BK
851])
852
853
854dnl
37bc6ca2 855dnl Check to see if there is native support for complex
2f103494
BK
856dnl
857dnl Don't compile bits in math/* if native support exits.
858dnl
d38cd8ae 859dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
2f103494 860dnl
3d7c150e
BK
861dnl GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
862AC_DEFUN(GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT, [
16da539b
PE
863 dnl Check for complex versions of math functions of platform. This will
864 dnl always pass if libm is available, and fail if it isn't. If it is
865 dnl available, we assume we'll need it later, so add it to LIBS.
b4b2a487 866 AC_CHECK_LIB(m, main)
d38cd8ae 867 AC_REPLACE_MATHFUNCS(nan copysignf)
11fc1858 868
34ff0b99
BK
869 dnl For __signbit to signbit conversions.
870 AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
871 AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
872
37bc6ca2 873 dnl Compile the long double complex functions only if the function
11fc1858 874 dnl provides the non-complex long double functions that are needed.
d38cd8ae 875 dnl Currently this includes copysignl, which should be
3d7c150e 876 dnl cached from the GLIBCXX_CHECK_MATH_SUPPORT macro, above.
d38cd8ae 877 if test x$ac_cv_func_copysignl = x"yes"; then
34ff0b99 878 AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
11fc1858
BK
879 fi
880
6aa43d99
BK
881 if test -n "$LIBMATHOBJS"; then
882 need_libmath=yes
883 fi
34ff0b99 884 AC_SUBST(LIBMATHOBJS)
2f103494
BK
885])
886
54fa7415 887
d0941a31
PE
888dnl Check to see what architecture and operating system we are compiling
889dnl for. Also, if architecture- or OS-specific flags are required for
890dnl compilation, pick them up here.
37bc6ca2 891dnl
3d7c150e
BK
892dnl GLIBCXX_CHECK_HOST
893AC_DEFUN(GLIBCXX_CHECK_HOST, [
894 . [$]{glibcxx_basedir}/configure.host
974e336b
PE
895 AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
896 AC_MSG_RESULT(OS config directory is $os_include_dir)
e974e9cc
BK
897])
898
899
b2dad0e3
BK
900dnl
901dnl Check to see if this target can enable the wchar_t parts of libstdc++.
8b8ab21c
BK
902dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled. (This
903dnl must have been previously checked.)
b2dad0e3 904dnl
3d7c150e 905dnl Define _GLIBCXX_USE_WCHAR_T if all the bits are found
7b331228 906dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
b2dad0e3 907dnl
3d7c150e
BK
908dnl GLIBCXX_CHECK_WCHAR_T_SUPPORT
909AC_DEFUN(GLIBCXX_CHECK_WCHAR_T_SUPPORT, [
6b543e86 910 dnl Wide characters disabled by default.
7b331228
BK
911
912 dnl Test wchar.h for mbstate_t, which is needed for char_traits and
913 dnl others even if wchar_t support is not on.
914 AC_MSG_CHECKING([for mbstate_t])
915 AC_TRY_COMPILE([#include <wchar.h>],
37bc6ca2 916 [mbstate_t teststate;],
7b331228
BK
917 have_mbstate_t=yes, have_mbstate_t=no)
918 AC_MSG_RESULT($have_mbstate_t)
919 if test x"$have_mbstate_t" = xyes; then
920 AC_DEFINE(HAVE_MBSTATE_T)
921 fi
922
923 dnl Sanity check for existence of ISO C99 headers for extended encoding.
924 AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
31f93f90 925 AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
37bc6ca2 926
7b331228 927 dnl Only continue checking if the ISO C99 headers exist and support is on.
a0cb1aa7
PE
928 if test x"$ac_has_wchar_h" = xyes &&
929 test x"$ac_has_wctype_h" = xyes &&
930 test x"$enable_c_mbchar" != xno; then
37bc6ca2 931
7b331228
BK
932 dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
933 dnl numeric_limits can instantiate type_traits<wchar_t>
934 AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
935 AC_TRY_COMPILE([#include <wchar.h>],
37bc6ca2 936 [int i = WCHAR_MIN; int j = WCHAR_MAX;],
7b331228
BK
937 has_wchar_minmax=yes, has_wchar_minmax=no)
938 AC_MSG_RESULT($has_wchar_minmax)
37bc6ca2 939
7b331228
BK
940 dnl Test wchar.h for WEOF, which is what we use to determine whether
941 dnl to specialize for char_traits<wchar_t> or not.
942 AC_MSG_CHECKING([for WEOF])
943 AC_TRY_COMPILE([
944 #include <wchar.h>
945 #include <stddef.h>],
946 [wint_t i = WEOF;],
947 has_weof=yes, has_weof=no)
948 AC_MSG_RESULT($has_weof)
37bc6ca2 949
7b331228 950 dnl Tests for wide character functions used in char_traits<wchar_t>.
68fe6226
BK
951 ac_wfuncs=yes
952 AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
953 ac_wfuncs=no)
37bc6ca2 954
68fe6226 955 dnl Checks for names injected into std:: by the c_std headers.
6b543e86 956 AC_CHECK_FUNCS(btowc wctob fgetwc fgetws fputwc fputws fwide \
68fe6226
BK
957 fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
958 vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
959 mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
960 wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
961 wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
962 ac_wfuncs=no)
df7b1359 963
7b331228 964 AC_MSG_CHECKING([for ISO C99 wchar_t support])
a0cb1aa7
PE
965 if test x"$has_weof" = xyes &&
966 test x"$has_wchar_minmax" = xyes &&
967 test x"$ac_wfuncs" = xyes; then
7b331228
BK
968 ac_isoC99_wchar_t=yes
969 else
970 ac_isoC99_wchar_t=no
971 fi
972 AC_MSG_RESULT($ac_isoC99_wchar_t)
37bc6ca2
PE
973
974 dnl Use iconv for wchar_t to char conversions. As such, check for
7b331228
BK
975 dnl X/Open Portability Guide, version 2 features (XPG2).
976 AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
977 AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
978
979 dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
980 AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
981 ac_save_LIBS="$LIBS"
982 LIBS="$LIBS $libiconv"
983
984 AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
985 ac_XPG2funcs=yes, ac_XPG2funcs=no)
37bc6ca2 986
7b331228 987 LIBS="$ac_save_LIBS"
5b20f7a0 988
7b331228 989 AC_MSG_CHECKING([for XPG2 wchar_t support])
a0cb1aa7
PE
990 if test x"$ac_has_iconv_h" = xyes &&
991 test x"$ac_has_langinfo_h" = xyes &&
992 test x"$ac_XPG2funcs" = xyes; then
7b331228
BK
993 ac_XPG2_wchar_t=yes
994 else
995 ac_XPG2_wchar_t=no
996 fi
997 AC_MSG_RESULT($ac_XPG2_wchar_t)
37bc6ca2 998
7b331228
BK
999 dnl At the moment, only enable wchar_t specializations if all the
1000 dnl above support is present.
6b543e86
BK
1001 if test x"$ac_isoC99_wchar_t" = xyes &&
1002 test x"$ac_XPG2_wchar_t" = xyes; then
3d7c150e 1003 AC_DEFINE(_GLIBCXX_USE_WCHAR_T)
6b543e86 1004 enable_wchar_t=yes
15bcd79a 1005 fi
b2dad0e3 1006 fi
6b543e86
BK
1007 AC_MSG_CHECKING([for enabled wchar_t specializations])
1008 AC_MSG_RESULT($enable_wchar_t)
b2dad0e3
BK
1009])
1010
1011
b2dad0e3 1012dnl
6aa43d99 1013dnl Check to see if debugging libraries are to be built.
b2dad0e3 1014dnl
3d7c150e 1015dnl GLIBCXX_ENABLE_DEBUG
6aa43d99 1016dnl
d8d81f62 1017dnl --enable-libstdcxx-debug
6aa43d99
BK
1018dnl builds a separate set of debugging libraries in addition to the
1019dnl normal (shared, static) libstdc++ binaries.
1020dnl
d8d81f62 1021dnl --disable-libstdcxx-debug
6aa43d99
BK
1022dnl builds only one (non-debug) version of libstdc++.
1023dnl
d8d81f62 1024dnl --enable-libstdcxx-debug-flags=FLAGS
6aa43d99
BK
1025dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
1026dnl
3d7c150e 1027dnl + Usage: GLIBCXX_ENABLE_DEBUG[(DEFAULT)]
b2dad0e3
BK
1028dnl Where DEFAULT is either `yes' or `no'. If ommitted, it
1029dnl defaults to `no'.
3d7c150e
BK
1030AC_DEFUN(GLIBCXX_ENABLE_DEBUG, [dnl
1031define([GLIBCXX_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
d8d81f62 1032AC_ARG_ENABLE(libstdcxx_debug,
b2dad0e3 1033changequote(<<, >>)dnl
3d7c150e 1034<< --enable-libstdcxx-debug build extra debug library [default=>>GLIBCXX_ENABLE_DEBUG_DEFAULT],
b2dad0e3 1035changequote([, ])dnl
5780a46b 1036[case "${enableval}" in
d8d81f62
BK
1037 yes) enable_libstdcxx_debug=yes ;;
1038 no) enable_libstdcxx_debug=no ;;
b2dad0e3
BK
1039 *) AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1040 esac],
3d7c150e 1041enable_libstdcxx_debug=GLIBCXX_ENABLE_DEBUG_DEFAULT)dnl
6aa43d99 1042AC_MSG_CHECKING([for additional debug build])
d8d81f62 1043AC_MSG_RESULT($enable_libstdcxx_debug)
3d7c150e 1044AM_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test "$enable_libstdcxx_debug" = yes)
6aa43d99
BK
1045])
1046
1047
1048dnl Check for explicit debug flags.
1049dnl
3d7c150e 1050dnl GLIBCXX_ENABLE_DEBUG_FLAGS
6aa43d99 1051dnl
d8d81f62 1052dnl --enable-libstdcxx-debug-flags='-O1'
37bc6ca2 1053dnl is a general method for passing flags to be used when
6aa43d99
BK
1054dnl building debug libraries with --enable-debug.
1055dnl
d8d81f62 1056dnl --disable-libstdcxx-debug-flags does nothing.
3d7c150e 1057dnl + Usage: GLIBCXX_ENABLE_DEBUG_FLAGS(default flags)
6aa43d99
BK
1058dnl If "default flags" is an empty string (or "none"), the effect is
1059dnl the same as --disable or --enable=no.
3d7c150e
BK
1060AC_DEFUN(GLIBCXX_ENABLE_DEBUG_FLAGS, [dnl
1061define([GLIBCXX_ENABLE_DEBUG_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
d8d81f62 1062AC_ARG_ENABLE(libstdcxx_debug_flags,
6aa43d99 1063changequote(<<, >>)dnl
d8d81f62
BK
1064<< --enable-libstdcxx-debug-flags=FLAGS pass compiler FLAGS when building
1065 debug library;
3d7c150e 1066 [default=>>GLIBCXX_ENABLE_DEBUG_FLAGS_DEFAULT],
6aa43d99
BK
1067changequote([, ])dnl
1068[case "${enableval}" in
1069 none) ;;
d8d81f62 1070 -*) enable_libstdcxx_debug_flags="${enableval}" ;;
6aa43d99
BK
1071 *) AC_MSG_ERROR([Unknown argument to extra debugging flags]) ;;
1072 esac],
3d7c150e 1073enable_libstdcxx_debug_flags=GLIBCXX_ENABLE_DEBUG_FLAGS_DEFAULT)dnl
5780a46b 1074
b2dad0e3 1075dnl Option parsed, now set things appropriately
d8d81f62 1076case x"$enable_libstdcxx_debug" in
37bc6ca2 1077 xyes)
d8d81f62 1078 case "$enable_libstdcxx_debug_flags" in
37bc6ca2 1079 none)
6aa43d99
BK
1080 DEBUG_FLAGS="-g3 -O0";;
1081 -*) #valid input
1082 DEBUG_FLAGS="${enableval}"
1083 esac
37bc6ca2
PE
1084 ;;
1085 xno)
6aa43d99 1086 DEBUG_FLAGS=""
f3b004d8 1087 ;;
b2dad0e3 1088esac
c470c17d 1089AC_SUBST(DEBUG_FLAGS)
6aa43d99
BK
1090
1091AC_MSG_CHECKING([for debug build flags])
1092AC_MSG_RESULT($DEBUG_FLAGS)
b2dad0e3
BK
1093])
1094
1095
dcfa0bc8
PE
1096dnl
1097dnl Check for "unusual" flags to pass to the compiler while building.
1098dnl
3d7c150e 1099dnl GLIBCXX_ENABLE_CXX_FLAGS
dcfa0bc8
PE
1100dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1101dnl experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1102dnl Somehow this same set of flags must be passed when [re]building
1103dnl libgcc.
1104dnl --disable-cxx-flags passes nothing.
a9ab8db1
JM
1105dnl + See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1106dnl http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1107dnl http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
3d7c150e 1108dnl + Usage: GLIBCXX_ENABLE_CXX_FLAGS(default flags)
32a4595e
PE
1109dnl If "default flags" is an empty string (or "none"), the effect is
1110dnl the same as --disable or --enable=no.
3d7c150e
BK
1111AC_DEFUN(GLIBCXX_ENABLE_CXX_FLAGS, [dnl
1112define([GLIBCXX_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
37bc6ca2 1113AC_MSG_CHECKING([for extra compiler flags for building])
6aa43d99 1114AC_ARG_ENABLE(cxx_flags,
dcfa0bc8 1115changequote(<<, >>)dnl
d8d81f62 1116<< --enable-cxx-flags=FLAGS pass compiler FLAGS when building library;
3d7c150e 1117 [default=>>GLIBCXX_ENABLE_CXX_FLAGS_DEFAULT],
dcfa0bc8 1118changequote([, ])dnl
37bc6ca2
PE
1119[case "x$enable_cxx_flags" in
1120 xyes)
1121 AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1122 xno | xnone | x)
1123 enable_cxx_flags='' ;;
1124 *)
1125 enable_cxx_flags="$enableval" ;;
1126esac],
3d7c150e 1127enable_cxx_flags=GLIBCXX_ENABLE_CXX_FLAGS_DEFAULT)
5780a46b 1128
32a4595e
PE
1129dnl Run through flags (either default or command-line) and set anything
1130dnl extra (e.g., #defines) that must accompany particular g++ options.
dcfa0bc8 1131if test -n "$enable_cxx_flags"; then
974e336b
PE
1132 for f in $enable_cxx_flags; do
1133 case "$f" in
1134 -fhonor-std) ;;
1135 -*) ;;
1136 *) # and we're trying to pass /what/ exactly?
1137 AC_MSG_ERROR([compiler flags start with a -]) ;;
1138 esac
1139 done
dcfa0bc8
PE
1140fi
1141EXTRA_CXX_FLAGS="$enable_cxx_flags"
37bc6ca2 1142AC_MSG_RESULT($EXTRA_CXX_FLAGS)
dcfa0bc8
PE
1143AC_SUBST(EXTRA_CXX_FLAGS)
1144])
1145
1146
0214010c
BK
1147dnl
1148dnl Check for which locale library to use: gnu or generic.
1149dnl
3d7c150e 1150dnl GLIBCXX_ENABLE_CLOCALE
33590f13
BK
1151dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1152dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
37bc6ca2 1153dnl
0214010c
BK
1154dnl default is generic
1155dnl
3d7c150e 1156AC_DEFUN(GLIBCXX_ENABLE_CLOCALE, [
0214010c
BK
1157 AC_MSG_CHECKING([for clocale to use])
1158 AC_ARG_ENABLE(clocale,
37bc6ca2 1159 [ --enable-clocale enable model for target locale package.
572051a2 1160 --enable-clocale=MODEL use MODEL target-speific locale package. [default=generic]
37bc6ca2 1161 ],
0214010c 1162 if test x$enable_clocale = xno; then
56deb74c 1163 enable_clocale=no
0214010c 1164 fi,
56deb74c 1165 enable_clocale=no)
0214010c
BK
1166
1167 enable_clocale_flag=$enable_clocale
1168
56deb74c
BK
1169 dnl Probe for locale support if no specific model is specified.
1170 dnl Default to "generic"
1171 if test x$enable_clocale_flag = xno; then
1172 case x${target_os} in
1173 xlinux* | xgnu*)
3d7c150e 1174 AC_EGREP_CPP([_GLIBCXX_ok], [
56deb74c 1175 #include <features.h>
37bc6ca2 1176 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
3d7c150e 1177 _GLIBCXX_ok
56deb74c
BK
1178 #endif
1179 ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1451a492
BK
1180
1181 # Test for bugs early in glibc-2.2.x series
1182 if test x$enable_clocale_flag = xgnu; then
1183 AC_TRY_RUN([
1184 #define _GNU_SOURCE 1
1185 #include <locale.h>
89671b70
JJ
1186 #include <string.h>
1187 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
1188 extern __typeof(newlocale) __newlocale;
1189 extern __typeof(duplocale) __duplocale;
1190 extern __typeof(strcoll_l) __strcoll_l;
1191 #endif
1451a492
BK
1192 int main()
1193 {
1194