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