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