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