OSDN Git Service

2009-12-11 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
1
2 dnl
3 dnl GLIBCXX_CONDITIONAL (NAME, SHELL-TEST)
4 dnl
5 dnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the
6 dnl end of configure.  This lets tested variables be reassigned, and the
7 dnl conditional will depend on the final state of the variable.  For a simple
8 dnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED.
9 dnl
10 m4_define([_m4_divert(glibcxx_diversion)], 8000)dnl
11 AC_DEFUN([GLIBCXX_CONDITIONAL], [dnl
12   m4_divert_text([glibcxx_diversion],dnl
13    AM_CONDITIONAL([$1],[$2])
14   )dnl
15 ])dnl
16 AC_DEFUN([GLIBCXX_EVALUATE_CONDITIONALS], [m4_undivert([glibcxx_diversion])])dnl
17
18
19 dnl
20 dnl Check to see what architecture and operating system we are compiling
21 dnl for.  Also, if architecture- or OS-specific flags are required for
22 dnl compilation, pick them up here.
23 dnl
24 AC_DEFUN([GLIBCXX_CHECK_HOST], [
25   . $glibcxx_srcdir/configure.host
26   AC_MSG_NOTICE([CPU config directory is $cpu_include_dir])
27   AC_MSG_NOTICE([OS config directory is $os_include_dir])
28 ])
29
30 dnl
31 dnl Initialize the rest of the library configury.  At this point we have
32 dnl variables like $host.
33 dnl
34 dnl Sets:
35 dnl  SUBDIRS
36 dnl Substs:
37 dnl  glibcxx_builddir     (absolute path)
38 dnl  glibcxx_srcdir       (absolute path)
39 dnl  toplevel_srcdir      (absolute path)
40 dnl  with_cross_host
41 dnl  with_newlib
42 dnl  with_target_subdir
43 dnl plus
44 dnl  - the variables in GLIBCXX_CHECK_HOST / configure.host
45 dnl  - default settings for all AM_CONFITIONAL test variables
46 dnl  - lots of tools, like CC and CXX
47 dnl
48 AC_DEFUN([GLIBCXX_CONFIGURE], [
49   # Keep these sync'd with the list in Makefile.am.  The first provides an
50   # expandable list at autoconf time; the second provides an expandable list
51   # (i.e., shell variable) at configure time.
52   m4_define([glibcxx_SUBDIRS],[include libsupc++ python src doc po testsuite])
53   SUBDIRS='glibcxx_SUBDIRS'
54
55   # These need to be absolute paths, yet at the same time need to
56   # canonicalize only relative paths, because then amd will not unmount
57   # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
58   glibcxx_builddir=`${PWDCMD-pwd}`
59   case $srcdir in
60     [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
61     *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
62   esac
63   toplevel_srcdir=${glibcxx_srcdir}/..
64   AC_SUBST(glibcxx_builddir)
65   AC_SUBST(glibcxx_srcdir)
66   AC_SUBST(toplevel_srcdir)
67
68   # We use these options to decide which functions to include.  They are
69   # set from the top level.
70   AC_ARG_WITH([target-subdir],
71     AC_HELP_STRING([--with-target-subdir=SUBDIR],
72                    [configuring in a subdirectory]))
73
74   AC_ARG_WITH([cross-host],
75     AC_HELP_STRING([--with-cross-host=HOST],
76                    [configuring with a cross compiler]))
77
78   AC_ARG_WITH([newlib],
79     AC_HELP_STRING([--with-newlib],
80                    [assume newlib as a system C library]))
81
82   # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
83   # available).  Uncomment the next line to force a particular method.
84   AC_PROG_LN_S
85   #LN_S='cp -p'
86
87   AC_CHECK_TOOL(AS, as)
88   AC_CHECK_TOOL(AR, ar)
89   AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
90
91   AM_MAINTAINER_MODE
92
93   # Set up safe default values for all subsequent AM_CONDITIONAL tests
94   # which are themselves conditionally expanded.
95   ## (Right now, this only matters for enable_wchar_t, but nothing prevents
96   ## other macros from doing the same.  This should be automated.)  -pme
97
98   # Check for uClibc since Linux platforms use different configuration
99   # directories depending on the C library in use.
100   AC_EGREP_CPP([_using_uclibc], [
101   #include <stdio.h>
102   #if __UCLIBC__
103     _using_uclibc
104   #endif
105   ], uclibc=yes, uclibc=no)
106
107   # Find platform-specific directories containing configuration info.
108   # Also possibly modify flags used elsewhere, as needed by the platform.
109   GLIBCXX_CHECK_HOST
110 ])
111
112
113 dnl
114 dnl Tests for newer compiler features, or features that are present in newer
115 dnl compiler versions but not older compiler versions still in use, should
116 dnl be placed here.
117 dnl
118 dnl Defines:
119 dnl  WERROR='-Werror' if requested and possible; g++'s that lack the
120 dnl   new inlining code or the new system_header pragma will die on -Werror.
121 dnl   Leave it out by default and use maint-mode to use it.
122 dnl  SECTION_FLAGS='-ffunction-sections -fdata-sections' if
123 dnl   compiler supports it and the user has not requested debug mode.
124 dnl
125 AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [
126   # All these tests are for C++; save the language and the compiler flags.
127   # The CXXFLAGS thing is suspicious, but based on similar bits previously
128   # found in GLIBCXX_CONFIGURE.
129   AC_LANG_SAVE
130   AC_LANG_CPLUSPLUS
131   ac_test_CXXFLAGS="${CXXFLAGS+set}"
132   ac_save_CXXFLAGS="$CXXFLAGS"
133
134   # Check for maintainer-mode bits.
135   if test x"$USE_MAINTAINER_MODE" = xno; then
136     WERROR=''
137   else
138     WERROR='-Werror'
139   fi
140
141   # Check for -ffunction-sections -fdata-sections
142   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
143   CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
144   AC_TRY_COMPILE([int foo; void bar() { };],, [ac_fdsections=yes], [ac_fdsections=no])
145   if test "$ac_test_CXXFLAGS" = set; then
146     CXXFLAGS="$ac_save_CXXFLAGS"
147   else
148     # this is the suspicious part
149     CXXFLAGS=''
150   fi
151   if test x"$ac_fdsections" = x"yes"; then
152     SECTION_FLAGS='-ffunction-sections -fdata-sections'
153   fi
154   AC_MSG_RESULT($ac_fdsections)
155
156   AC_LANG_RESTORE
157   AC_SUBST(WERROR)
158   AC_SUBST(SECTION_FLAGS)
159 ])
160
161
162 dnl
163 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
164 dnl the native linker is in use, all variables will be defined to something
165 dnl safe (like an empty string).
166 dnl
167 dnl Defines:
168 dnl  SECTION_LDFLAGS='-Wl,--gc-sections' if possible
169 dnl  OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible
170 dnl  LD (as a side effect of testing)
171 dnl Sets:
172 dnl  with_gnu_ld
173 dnl  glibcxx_ld_is_gold (set to "no" or "yes")
174 dnl  glibcxx_gnu_ld_version (possibly)
175 dnl
176 dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
177 dnl set glibcxx_gnu_ld_version to 12345.  Zeros cause problems.
178 dnl
179 AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
180   # If we're not using GNU ld, then there's no point in even trying these
181   # tests.  Check for that first.  We should have already tested for gld
182   # by now (in libtool), but require it now just to be safe...
183   test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
184   test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
185   AC_REQUIRE([AC_PROG_LD])
186   AC_REQUIRE([AC_PROG_AWK])
187
188   # The name set by libtool depends on the version of libtool.  Shame on us
189   # for depending on an impl detail, but c'est la vie.  Older versions used
190   # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
191   # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
192   # makes sense).  We'll test with_gnu_ld everywhere else, so if that isn't
193   # set (hence we're using an older libtool), then set it.
194   if test x${with_gnu_ld+set} != xset; then
195     if test x${ac_cv_prog_gnu_ld+set} != xset; then
196       # We got through "ac_require(ac_prog_ld)" and still not set?  Huh?
197       with_gnu_ld=no
198     else
199       with_gnu_ld=$ac_cv_prog_gnu_ld
200     fi
201   fi
202
203   # Start by getting the version number.  I think the libtool test already
204   # does some of this, but throws away the result.
205   glibcxx_ld_is_gold=no
206   if test x"$with_gnu_ld" = x"yes"; then
207     AC_MSG_CHECKING([for ld version])
208     changequote(,)
209     if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
210       glibcxx_ld_is_gold=yes
211     fi
212     ldver=`$LD --version 2>/dev/null |
213            sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
214     changequote([,])
215     glibcxx_gnu_ld_version=`echo $ldver | \
216            $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
217     AC_MSG_RESULT($glibcxx_gnu_ld_version)
218   fi
219
220   # Set --gc-sections.
221   glibcxx_have_gc_sections=no
222   if test "$glibcxx_ld_is_gold" = "yes"; then
223     if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
224       glibcxx_have_gc_sections=yes
225     fi
226   else
227     glibcxx_gcsections_min_ld=21602
228     if test x"$with_gnu_ld" = x"yes" && 
229         test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
230       glibcxx_have_gc_sections=yes
231     fi
232   fi
233   if test "$glibcxx_have_gc_sections" = "yes"; then
234     # Sufficiently young GNU ld it is!  Joy and bunny rabbits!
235     # NB: This flag only works reliably after 2.16.1. Configure tests
236     # for this are difficult, so hard wire a value that should work.
237
238     ac_test_CFLAGS="${CFLAGS+set}"
239     ac_save_CFLAGS="$CFLAGS"
240     CFLAGS='-Wl,--gc-sections'
241
242     # Check for -Wl,--gc-sections
243     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
244     AC_TRY_LINK([ int one(void) { return 1; }
245      int two(void) { return 2; }
246         ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no])
247     if test "$ac_gcsections" = "yes"; then
248       rm -f conftest.c
249       touch conftest.c
250       if $CC -c conftest.c; then
251         if $LD --gc-sections -o conftest conftest.o 2>&1 | \
252            grep "Warning: gc-sections option ignored" > /dev/null; then
253           ac_gcsections=no
254         fi
255       fi
256       rm -f conftest.c conftest.o conftest
257     fi
258     if test "$ac_gcsections" = "yes"; then
259       SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
260     fi
261     AC_MSG_RESULT($ac_gcsections)
262
263     if test "$ac_test_CFLAGS" = set; then
264       CFLAGS="$ac_save_CFLAGS"
265     else
266       # this is the suspicious part
267       CFLAGS=''
268     fi
269   fi
270
271   # Set -z,relro.
272   # Note this is only for shared objects.
273   ac_ld_relro=no
274   if test x"$with_gnu_ld" = x"yes"; then
275     AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
276     cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
277     if test -n "$cxx_z_relo"; then
278       OPT_LDFLAGS="-Wl,-z,relro"
279       ac_ld_relro=yes
280     fi
281     AC_MSG_RESULT($ac_ld_relro)
282   fi
283
284   # Set linker optimization flags.
285   if test x"$with_gnu_ld" = x"yes"; then
286     OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
287   fi
288
289   AC_SUBST(SECTION_LDFLAGS)
290   AC_SUBST(OPT_LDFLAGS)
291 ])
292
293
294 dnl
295 dnl Check for headers for, and arguments to, the setrlimit() function.
296 dnl Used only in testsuite_hooks.h.  Called from GLIBCXX_CONFIGURE_TESTSUITE.
297 dnl
298 dnl Defines:
299 dnl  _GLIBCXX_RES_LIMITS if we can set artificial resource limits 
300 dnl  various HAVE_LIMIT_* for individual limit names
301 dnl
302 AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
303   AC_MSG_CHECKING([for RLIMIT_$1])
304   AC_TRY_COMPILE(
305     [#include <unistd.h>
306      #include <sys/time.h>
307      #include <sys/resource.h>
308     ],
309     [ int f = RLIMIT_$1 ; ],
310     [glibcxx_mresult=1], [glibcxx_mresult=0])
311   AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult,
312                      [Only used in build directory testsuite_hooks.h.])
313   if test $glibcxx_mresult = 1 ; then res=yes ; else res=no ; fi
314   AC_MSG_RESULT($res)
315 ])
316
317 AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
318   setrlimit_have_headers=yes
319   AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
320                    [],
321                    [setrlimit_have_headers=no])
322   # If don't have the headers, then we can't run the tests now, and we
323   # won't be seeing any of these during testsuite compilation.
324   if test $setrlimit_have_headers = yes; then
325     # Can't do these in a loop, else the resulting syntax is wrong.
326     GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA)
327     GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
328     GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
329     GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
330     GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE)
331
332     # Check for rlimit, setrlimit.
333     AC_CACHE_VAL(glibcxx_cv_setrlimit, [
334       AC_TRY_COMPILE(
335         [#include <unistd.h>
336          #include <sys/time.h>
337          #include <sys/resource.h>
338         ],
339         [struct rlimit r;
340          setrlimit(0, &r);],
341         [glibcxx_cv_setrlimit=yes], [glibcxx_cv_setrlimit=no])
342     ])
343   fi
344
345   AC_MSG_CHECKING([for testsuite resource limits support])
346   if test $setrlimit_have_headers = yes && test $glibcxx_cv_setrlimit = yes; then
347     ac_res_limits=yes
348     AC_DEFINE(_GLIBCXX_RES_LIMITS, 1,
349               [Define if using setrlimit to set resource limits during
350               "make check"])
351   else
352     ac_res_limits=no
353   fi
354   AC_MSG_RESULT($ac_res_limits)
355 ])
356
357
358 dnl
359 dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
360 dnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately.
361 dnl
362 AC_DEFUN([GLIBCXX_CHECK_S_ISREG_OR_S_IFREG], [
363
364   AC_LANG_SAVE
365   AC_LANG_CPLUSPLUS
366   ac_save_CXXFLAGS="$CXXFLAGS"
367   CXXFLAGS="$CXXFLAGS -fno-exceptions"
368
369   AC_MSG_CHECKING([for S_ISREG or S_IFREG])
370   AC_CACHE_VAL(glibcxx_cv_S_ISREG, [
371     GCC_TRY_COMPILE_OR_LINK(
372       [#include <sys/stat.h>],
373       [struct stat buffer;
374        fstat(0, &buffer);
375        S_ISREG(buffer.st_mode);],
376       [glibcxx_cv_S_ISREG=yes],
377       [glibcxx_cv_S_ISREG=no])
378   ])
379   AC_CACHE_VAL(glibcxx_cv_S_IFREG, [
380     GCC_TRY_COMPILE_OR_LINK(
381       [#include <sys/stat.h>],
382       [struct stat buffer;
383        fstat(0, &buffer);
384        S_IFREG & buffer.st_mode;],
385       [glibcxx_cv_S_IFREG=yes],
386       [glibcxx_cv_S_IFREG=no])
387   ])
388   res=no
389   if test $glibcxx_cv_S_ISREG = yes; then
390     AC_DEFINE(HAVE_S_ISREG, 1, 
391               [Define if S_IFREG is available in <sys/stat.h>.])
392     res=S_ISREG
393   elif test $glibcxx_cv_S_IFREG = yes; then
394     AC_DEFINE(HAVE_S_IFREG, 1,
395               [Define if S_IFREG is available in <sys/stat.h>.])
396     res=S_IFREG
397   fi
398   AC_MSG_RESULT($res)
399
400   CXXFLAGS="$ac_save_CXXFLAGS"
401   AC_LANG_RESTORE
402 ])
403
404
405 dnl
406 dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
407 dnl
408 AC_DEFUN([GLIBCXX_CHECK_POLL], [
409
410   AC_LANG_SAVE
411   AC_LANG_CPLUSPLUS
412   ac_save_CXXFLAGS="$CXXFLAGS"
413   CXXFLAGS="$CXXFLAGS -fno-exceptions"
414
415   AC_MSG_CHECKING([for poll])
416   AC_CACHE_VAL(glibcxx_cv_POLL, [
417     GCC_TRY_COMPILE_OR_LINK(
418       [#include <poll.h>],
419       [struct pollfd pfd[1];
420        pfd[0].events = POLLIN;
421        poll(pfd, 1, 0);],
422       [glibcxx_cv_POLL=yes],
423       [glibcxx_cv_POLL=no])
424   ])
425   if test $glibcxx_cv_POLL = yes; then
426     AC_DEFINE(HAVE_POLL, 1, [Define if poll is available in <poll.h>.])
427   fi
428   AC_MSG_RESULT($glibcxx_cv_POLL)
429
430   CXXFLAGS="$ac_save_CXXFLAGS"
431   AC_LANG_RESTORE
432 ])
433
434
435 dnl
436 dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
437 dnl
438 AC_DEFUN([GLIBCXX_CHECK_WRITEV], [
439
440   AC_LANG_SAVE
441   AC_LANG_CPLUSPLUS
442   ac_save_CXXFLAGS="$CXXFLAGS"
443   CXXFLAGS="$CXXFLAGS -fno-exceptions"
444
445   AC_MSG_CHECKING([for writev])
446   AC_CACHE_VAL(glibcxx_cv_WRITEV, [
447     GCC_TRY_COMPILE_OR_LINK(
448       [#include <sys/uio.h>],
449       [struct iovec iov[2];
450        writev(0, iov, 0);],
451       [glibcxx_cv_WRITEV=yes],
452       [glibcxx_cv_WRITEV=no])
453   ])
454   if test $glibcxx_cv_WRITEV = yes; then
455     AC_DEFINE(HAVE_WRITEV, 1, [Define if writev is available in <sys/uio.h>.])
456   fi
457   AC_MSG_RESULT($glibcxx_cv_WRITEV)
458
459   CXXFLAGS="$ac_save_CXXFLAGS"
460   AC_LANG_RESTORE
461 ])
462
463
464 dnl
465 dnl Check whether int64_t is available in <stdint.h>, and define HAVE_INT64_T.
466 dnl Also check whether int64_t is actually a typedef to long or long long.
467 dnl
468 AC_DEFUN([GLIBCXX_CHECK_INT64_T], [
469
470   AC_LANG_SAVE
471   AC_LANG_CPLUSPLUS
472
473   AC_MSG_CHECKING([for int64_t])
474   AC_CACHE_VAL(glibcxx_cv_INT64_T, [
475     AC_TRY_COMPILE(
476       [#include <stdint.h>],
477       [int64_t var;],
478       [glibcxx_cv_INT64_T=yes],
479       [glibcxx_cv_INT64_T=no])
480   ])
481
482   if test $glibcxx_cv_INT64_T = yes; then
483     AC_DEFINE(HAVE_INT64_T, 1, [Define if int64_t is available in <stdint.h>.])
484     AC_MSG_RESULT($glibcxx_cv_INT64_T)
485
486     AC_MSG_CHECKING([for int64_t as long])
487     AC_CACHE_VAL(glibcxx_cv_int64_t_long, [
488       AC_TRY_COMPILE(
489         [#include <stdint.h>
490         template<typename, typename> struct same { enum { value = -1 }; };
491         template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
492         int array[same<int64_t, long>::value];], [],
493         [glibcxx_cv_int64_t_long=yes], [glibcxx_cv_int64_t_long=no])
494     ])
495
496     if test $glibcxx_cv_int64_t_long = yes; then
497       AC_DEFINE(HAVE_INT64_T_LONG, 1, [Define if int64_t is a long.])
498       AC_MSG_RESULT($glibcxx_cv_int64_t_long)
499     fi
500
501     AC_MSG_CHECKING([for int64_t as long long])
502     AC_CACHE_VAL(glibcxx_cv_int64_t_long_long, [
503       AC_TRY_COMPILE(
504         [#include <stdint.h>
505         template<typename, typename> struct same { enum { value = -1 }; };
506         template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
507         int array[same<int64_t, long long>::value];], [],
508         [glibcxx_cv_int64_t_long_long=yes], [glibcxx_cv_int64_t_long_long=no])
509     ])
510
511     if test $glibcxx_cv_int64_t_long_long = yes; then
512       AC_DEFINE(HAVE_INT64_T_LONG_LONG, 1, [Define if int64_t is a long long.])
513       AC_MSG_RESULT($glibcxx_cv_int64_t_long_long)
514     fi
515   fi
516
517   AC_LANG_RESTORE
518 ])
519
520
521 dnl
522 dnl Check whether LFS support is available.
523 dnl
524 AC_DEFUN([GLIBCXX_CHECK_LFS], [
525   AC_LANG_SAVE
526   AC_LANG_CPLUSPLUS
527   ac_save_CXXFLAGS="$CXXFLAGS"
528   CXXFLAGS="$CXXFLAGS -fno-exceptions"  
529   AC_MSG_CHECKING([for LFS support])
530   AC_CACHE_VAL(glibcxx_cv_LFS, [
531     GCC_TRY_COMPILE_OR_LINK(
532       [#include <unistd.h>
533        #include <stdio.h>
534        #include <sys/stat.h>
535       ],
536       [FILE* fp;
537        fopen64("t", "w");
538        fseeko64(fp, 0, SEEK_CUR);
539        ftello64(fp);
540        lseek64(1, 0, SEEK_CUR);
541        struct stat64 buf;
542        fstat64(1, &buf);],
543       [glibcxx_cv_LFS=yes],
544       [glibcxx_cv_LFS=no])
545   ])
546   if test $glibcxx_cv_LFS = yes; then
547     AC_DEFINE(_GLIBCXX_USE_LFS, 1, [Define if LFS support is available.])
548   fi
549   AC_MSG_RESULT($glibcxx_cv_LFS)
550   CXXFLAGS="$ac_save_CXXFLAGS"
551   AC_LANG_RESTORE
552 ])
553
554
555 dnl
556 dnl Check for whether a fully dynamic basic_string implementation should
557 dnl be turned on, that does not put empty objects in per-process static
558 dnl memory (mostly useful together with shared memory allocators, see PR
559 dnl libstdc++/16612 for details).
560 dnl
561 dnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING
562 dnl --disable-fully-dynamic-string leaves _GLIBCXX_FULLY_DYNAMIC_STRING undefined
563 dnl  +  Usage:  GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
564 dnl       Where DEFAULT is either `yes' or `no'.
565 dnl
566 AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
567   GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory])
568   if test $enable_fully_dynamic_string = yes; then
569     AC_DEFINE(_GLIBCXX_FULLY_DYNAMIC_STRING, 1,
570               [Define if a fully dynamic basic_string is wanted.])
571   fi
572 ])
573
574
575 dnl
576 dnl Does any necessary configuration of the testsuite directory.  Generates
577 dnl the testsuite_hooks.h header.
578 dnl
579 dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this.
580 dnl
581 dnl Sets:
582 dnl  enable_abi_check 
583 dnl  GLIBCXX_TEST_WCHAR_T
584 dnl  GLIBCXX_TEST_THREAD
585 dnl Substs:
586 dnl  baseline_dir
587 dnl
588 AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
589   if $GLIBCXX_IS_NATIVE ; then
590     # Do checks for resource limit functions.
591     GLIBCXX_CHECK_SETRLIMIT
592
593     # Look for setenv, so that extended locale tests can be performed.
594     GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
595   fi
596
597   if $GLIBCXX_IS_NATIVE && test $is_hosted = yes &&
598      test $enable_symvers != no; then
599     case "$host" in
600       *-*-cygwin*)
601         enable_abi_check=no ;;
602       *)
603         enable_abi_check=yes ;;
604     esac
605   else
606     # Only build this as native, since automake does not understand
607     # CXX_FOR_BUILD.
608     enable_abi_check=no
609   fi
610   
611   # Export file names for ABI checking.
612   baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}"
613   AC_SUBST(baseline_dir)
614 ])
615
616
617 dnl
618 dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
619 dnl
620 dnl Substs:
621 dnl  GLIBCXX_INCLUDES
622 dnl  TOPLEVEL_INCLUDES
623 dnl
624 AC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [
625   # Used for every C++ compile we perform.
626   GLIBCXX_INCLUDES="\
627 -I$glibcxx_builddir/include/$host_alias \
628 -I$glibcxx_builddir/include \
629 -I$glibcxx_srcdir/libsupc++"
630
631   # For Canadian crosses, pick this up too.
632   if test $CANADIAN = yes; then
633     GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
634   fi
635
636   # Stuff in the actual top level.  Currently only used by libsupc++ to
637   # get unwind* headers from the gcc dir.
638   #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include'
639   TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc'
640
641   # Now, export this to all the little Makefiles....
642   AC_SUBST(GLIBCXX_INCLUDES)
643   AC_SUBST(TOPLEVEL_INCLUDES)
644 ])
645
646
647 dnl
648 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
649 dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
650 dnl
651 dnl Substs:
652 dnl  OPTIMIZE_CXXFLAGS
653 dnl  WARN_FLAGS
654 dnl
655 AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
656   # Optimization flags that are probably a good idea for thrill-seekers. Just
657   # uncomment the lines below and make, everything else is ready to go...
658   # Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host.
659   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
660   AC_SUBST(OPTIMIZE_CXXFLAGS)
661
662   WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
663   AC_SUBST(WARN_FLAGS)
664 ])
665
666
667 dnl
668 dnl All installation directory information is determined here.
669 dnl
670 dnl Substs:
671 dnl  gxx_install_dir
672 dnl  glibcxx_prefixdir
673 dnl  glibcxx_toolexecdir
674 dnl  glibcxx_toolexeclibdir
675 dnl
676 dnl Assumes cross_compiling bits already done, and with_cross_host in
677 dnl particular.
678 dnl
679 dnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir.
680 dnl config/gxx-include-dir.m4 must be kept consistant with this as well.
681 AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
682   glibcxx_toolexecdir=no
683   glibcxx_toolexeclibdir=no
684   glibcxx_prefixdir=$prefix
685
686   AC_MSG_CHECKING([for gxx-include-dir])
687   AC_ARG_WITH([gxx-include-dir],
688     AC_HELP_STRING([--with-gxx-include-dir=DIR],
689                    [installation directory for include files]),
690     [case "$withval" in
691       yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
692       no)  gxx_include_dir=no ;;
693       *)   gxx_include_dir=$withval ;;
694      esac],
695     [gxx_include_dir=no])
696   AC_MSG_RESULT($gxx_include_dir)
697
698   AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
699   AC_ARG_ENABLE([version-specific-runtime-libs],
700     AC_HELP_STRING([--enable-version-specific-runtime-libs],
701                    [Specify that runtime libraries should be installed in a compiler-specific directory]),
702     [case "$enableval" in
703       yes) version_specific_libs=yes ;;
704       no)  version_specific_libs=no ;;
705       *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
706      esac],
707     [version_specific_libs=no])
708   AC_MSG_RESULT($version_specific_libs)
709
710   # Default case for install directory for include files.
711   if test $version_specific_libs = no && test $gxx_include_dir = no; then
712     gxx_include_dir='include/c++/${gcc_version}'
713     if test -n "$with_cross_host" && 
714        test x"$with_cross_host" != x"no"; then  
715       gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir"
716     else
717       gxx_include_dir='${prefix}/'"$gxx_include_dir"
718     fi
719   fi
720
721   # Version-specific runtime libs processing.
722   if test $version_specific_libs = yes; then
723     # Need the gcc compiler version to know where to install libraries
724     # and header files if --enable-version-specific-runtime-libs option
725     # is selected.  FIXME: these variables are misnamed, there are
726     # no executables installed in _toolexecdir or _toolexeclibdir.
727     if test x"$gxx_include_dir" = x"no"; then
728       gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
729     fi
730     glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
731     glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
732   fi
733
734   # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
735   # Install a library built with a cross compiler in tooldir, not libdir.
736   if test x"$glibcxx_toolexecdir" = x"no"; then
737     if test -n "$with_cross_host" &&
738        test x"$with_cross_host" != x"no"; then
739       glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
740       glibcxx_toolexeclibdir='${toolexecdir}/lib'
741     else
742       glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
743       glibcxx_toolexeclibdir='${libdir}'
744     fi
745     multi_os_directory=`$CXX -print-multi-os-directory`
746     case $multi_os_directory in
747       .) ;; # Avoid trailing /.
748       *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
749     esac
750   fi
751
752   AC_MSG_CHECKING([for install location])
753   AC_MSG_RESULT($gxx_include_dir)
754
755   AC_SUBST(glibcxx_prefixdir)
756   AC_SUBST(gxx_include_dir)
757   AC_SUBST(glibcxx_toolexecdir)
758   AC_SUBST(glibcxx_toolexeclibdir)
759 ])
760
761
762 dnl
763 dnl GLIBCXX_ENABLE
764 dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
765 dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
766 dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
767 dnl
768 dnl See docs/html/17_intro/configury.html#enable for documentation.
769 dnl
770 m4_define([GLIBCXX_ENABLE],[dnl
771 m4_define([_g_switch],[--enable-$1])dnl
772 m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
773  AC_ARG_ENABLE($1,_g_help,
774   m4_bmatch([$5],
775    [^permit ],
776      [[
777       case "$enableval" in
778        m4_bpatsubst([$5],[permit ])) ;;
779        *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
780           dnl Idea for future:  generate a URL pointing to
781           dnl "onlinedocs/configopts.html#whatever"
782       esac
783      ]],
784    [^$],
785      [[
786       case "$enableval" in
787        yes|no) ;;
788        *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
789       esac
790      ]],
791    [[$5]]),
792   [enable_]m4_bpatsubst([$1],-,_)[=][$2])
793 m4_undefine([_g_switch])dnl
794 m4_undefine([_g_help])dnl
795 ])
796
797
798 dnl
799 dnl Check for ISO/IEC 9899:1999 "C99" support.
800 dnl
801 dnl --enable-c99 defines _GLIBCXX_USE_C99
802 dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
803 dnl  +  Usage:  GLIBCXX_ENABLE_C99[(DEFAULT)]
804 dnl       Where DEFAULT is either `yes' or `no'.
805 dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
806 dnl
807 AC_DEFUN([GLIBCXX_ENABLE_C99], [
808   GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
809
810   if test x"$enable_c99" = x"yes"; then
811
812   AC_LANG_SAVE
813   AC_LANG_CPLUSPLUS
814
815   # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
816   # undefined and fake C99 facilities - like pre-standard snprintf - may be
817   # spuriously enabled.
818   # Long term, -std=c++0x could be even better, could manage to explicitely
819   # request C99 facilities to the underlying C headers.
820   ac_save_CXXFLAGS="$CXXFLAGS"
821   CXXFLAGS="$CXXFLAGS -std=c++98"
822   ac_save_LIBS="$LIBS"
823   ac_save_gcc_no_link="$gcc_no_link"
824
825   if test x$gcc_no_link != xyes; then
826     # Use -fno-exceptions to that the C driver can link these tests without
827     # hitting undefined references to personality routines.
828     CXXFLAGS="$CXXFLAGS -fno-exceptions"
829     AC_CHECK_LIB(m, sin, [
830       LIBS="$LIBS -lm"
831     ], [
832       # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
833       gcc_no_link=yes
834     ])
835   fi
836
837   # Check for the existence of <math.h> functions used if C99 is enabled.
838   AC_MSG_CHECKING([for ISO C99 support in <math.h>])
839   AC_CACHE_VAL(glibcxx_cv_c99_math, [
840   GCC_TRY_COMPILE_OR_LINK(
841      [#include <math.h>
842       volatile double d1, d2;
843       volatile int i;],
844      [i = fpclassify(d1);
845       i = isfinite(d1);
846       i = isinf(d1);
847       i = isnan(d1);
848       i = isnormal(d1);
849       i = signbit(d1);
850       i = isgreater(d1, d2);
851       i = isgreaterequal(d1, d2);
852       i = isless(d1, d2);
853       i = islessequal(d1, d2);
854       i = islessgreater(d1, d2);
855       i = islessgreater(d1, d2);
856       i = isunordered(d1, d2);
857      ],[glibcxx_cv_c99_math=yes], [glibcxx_cv_c99_math=no])
858   ])
859   AC_MSG_RESULT($glibcxx_cv_c99_math)
860   if test x"$glibcxx_cv_c99_math" = x"yes"; then
861     AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
862               [Define if C99 functions or macros in <math.h> should be imported
863               in <cmath> in namespace std.])
864   fi
865
866   # Check for the existence of <complex.h> complex math functions.
867   # This is necessary even though libstdc++ uses the builtin versions
868   # of these functions, because if the builtin cannot be used, a reference
869   # to the library function is emitted.
870   AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
871   AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
872   glibcxx_cv_c99_complex=no;
873   if test x"$ac_has_complex_h" = x"yes"; then
874     AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
875     GCC_TRY_COMPILE_OR_LINK(
876        [#include <complex.h>
877         typedef __complex__ float float_type;
878         typedef __complex__ double double_type;
879         typedef __complex__ long double ld_type;
880         volatile float_type tmpf;
881         volatile double_type tmpd;
882         volatile ld_type tmpld;
883         volatile float f;
884         volatile double d;
885         volatile long double ld;],
886        [f = cabsf(tmpf);
887         f = cargf(tmpf);
888         tmpf = ccosf(tmpf);
889         tmpf = ccoshf(tmpf);
890         tmpf = cexpf(tmpf);
891         tmpf = clogf(tmpf);
892         tmpf = csinf(tmpf);
893         tmpf = csinhf(tmpf);
894         tmpf = csqrtf(tmpf);
895         tmpf = ctanf(tmpf);
896         tmpf = ctanhf(tmpf);
897         tmpf = cpowf(tmpf, tmpf);
898         tmpf = cprojf(tmpf);
899         d = cabs(tmpd);
900         d = carg(tmpd);
901         tmpd = ccos(tmpd);
902         tmpd = ccosh(tmpd);
903         tmpd = cexp(tmpd);
904         tmpd = clog(tmpd);
905         tmpd = csin(tmpd);
906         tmpd = csinh(tmpd);
907         tmpd = csqrt(tmpd);
908         tmpd = ctan(tmpd);
909         tmpd = ctanh(tmpd);
910         tmpd = cpow(tmpd, tmpd);
911         tmpd = cproj(tmpd);
912         ld = cabsl(tmpld);
913         ld = cargl(tmpld);
914         tmpld = ccosl(tmpld);
915         tmpld = ccoshl(tmpld);
916         tmpld = cexpl(tmpld);
917         tmpld = clogl(tmpld);
918         tmpld = csinl(tmpld);
919         tmpld = csinhl(tmpld);
920         tmpld = csqrtl(tmpld);
921         tmpld = ctanl(tmpld);
922         tmpld = ctanhl(tmpld);
923         tmpld = cpowl(tmpld, tmpld);
924         tmpld = cprojl(tmpld);
925        ],[glibcxx_cv_c99_complex=yes], [glibcxx_cv_c99_complex=no])
926   fi
927   AC_MSG_RESULT($glibcxx_cv_c99_complex)
928   if test x"$glibcxx_cv_c99_complex" = x"yes"; then
929     AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
930               [Define if C99 functions in <complex.h> should be used in
931               <complex>. Using compiler builtins for these functions requires
932               corresponding C99 library functions to be present.])
933   fi
934
935   # Check for the existence in <stdio.h> of vscanf, et. al.
936   AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
937   AC_CACHE_VAL(glibcxx_cv_c99_stdio, [
938   GCC_TRY_COMPILE_OR_LINK(
939      [#include <stdio.h>
940       #include <stdarg.h>
941       void foo(char* fmt, ...)
942       {
943         va_list args; va_start(args, fmt);
944         vfscanf(stderr, "%i", args); 
945         vscanf("%i", args);
946         vsnprintf(fmt, 0, "%i", args);
947         vsscanf(fmt, "%i", args);
948       }],
949      [snprintf("12", 0, "%i");],
950      [glibcxx_cv_c99_stdio=yes], [glibcxx_cv_c99_stdio=no])
951   ])
952   AC_MSG_RESULT($glibcxx_cv_c99_stdio)
953
954   # Check for the existence in <stdlib.h> of lldiv_t, et. al.
955   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
956   AC_CACHE_VAL(glibcxx_cv_c99_stdlib, [
957   GCC_TRY_COMPILE_OR_LINK(
958      [#include <stdlib.h>
959       volatile float f;
960       volatile long double ld;
961       volatile unsigned long long ll;
962       lldiv_t mydivt;],
963      [char* tmp;
964       f = strtof("gnu", &tmp);
965       ld = strtold("gnu", &tmp);
966       ll = strtoll("gnu", &tmp, 10);
967       ll = strtoull("gnu", &tmp, 10);
968       ll = llabs(10);
969       mydivt = lldiv(10,1);
970       ll = mydivt.quot;
971       ll = mydivt.rem;
972       ll = atoll("10");
973       _Exit(0);
974       ],[glibcxx_cv_c99_stdlib=yes], [glibcxx_cv_c99_stdlib=no])
975   ])
976   AC_MSG_RESULT($glibcxx_cv_c99_stdlib)
977
978   # Check for the existence in <wchar.h> of wcstold, etc.
979   glibcxx_cv_c99_wchar=no;
980   if test x"$ac_has_wchar_h" = xyes &&
981      test x"$ac_has_wctype_h" = xyes; then
982     AC_MSG_CHECKING([for ISO C99 support in <wchar.h>]) 
983     AC_TRY_COMPILE([#include <wchar.h>
984                     namespace test
985                     {
986                       using ::wcstold;
987                       using ::wcstoll;
988                       using ::wcstoull;
989                     }
990                    ],[],[glibcxx_cv_c99_wchar=yes], [glibcxx_cv_c99_wchar=no])
991
992     # Checks for wide character functions that may not be present.
993     # Injection of these is wrapped with guard macros.
994     # NB: only put functions here, instead of immediately above, if
995     # absolutely necessary.
996     AC_TRY_COMPILE([#include <wchar.h>
997                     namespace test { using ::vfwscanf; } ], [],
998                    [AC_DEFINE(HAVE_VFWSCANF,1,
999                         [Defined if vfwscanf exists.])],[])
1000
1001     AC_TRY_COMPILE([#include <wchar.h>
1002                     namespace test { using ::vswscanf; } ], [],
1003                    [AC_DEFINE(HAVE_VSWSCANF,1,
1004                         [Defined if vswscanf exists.])],[])
1005
1006     AC_TRY_COMPILE([#include <wchar.h>
1007                     namespace test { using ::vwscanf; } ], [],
1008                    [AC_DEFINE(HAVE_VWSCANF,1,[Defined if vwscanf exists.])],[])
1009
1010     AC_TRY_COMPILE([#include <wchar.h>
1011                     namespace test { using ::wcstof; } ], [],
1012                    [AC_DEFINE(HAVE_WCSTOF,1,[Defined if wcstof exists.])],[])
1013
1014     AC_TRY_COMPILE([#include <wctype.h>],
1015                    [ wint_t t; int i = iswblank(t);], 
1016                    [AC_DEFINE(HAVE_ISWBLANK,1,
1017                         [Defined if iswblank exists.])],[])
1018
1019     AC_MSG_RESULT($glibcxx_cv_c99_wchar)
1020   fi
1021
1022   # Option parsed, now set things appropriately.
1023   if test x"$glibcxx_cv_c99_math" = x"no" ||
1024      test x"$glibcxx_cv_c99_complex" = x"no" ||
1025      test x"$glibcxx_cv_c99_stdio" = x"no" ||
1026      test x"$glibcxx_cv_c99_stdlib" = x"no" ||
1027      test x"$glibcxx_cv_c99_wchar" = x"no"; then
1028     enable_c99=no;
1029   else
1030     AC_DEFINE(_GLIBCXX_USE_C99, 1,
1031     [Define if C99 functions or macros from <wchar.h>, <math.h>,
1032     <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed.])
1033   fi
1034
1035   gcc_no_link="$ac_save_gcc_no_link"
1036   LIBS="$ac_save_LIBS"
1037   CXXFLAGS="$ac_save_CXXFLAGS"
1038   AC_LANG_RESTORE
1039   fi    
1040
1041   AC_MSG_CHECKING([for fully enabled ISO C99 support])
1042   AC_MSG_RESULT($enable_c99)
1043 ])
1044
1045
1046 dnl
1047 dnl Check for clock_gettime, nanosleep and sched_yield, used in the
1048 dnl implementation of 20.8.5 [time.clock], and 30.2.2 [thread.thread.this]
1049 dnl in the current C++0x working draft.
1050 dnl
1051 dnl --enable-libstdcxx-time
1052 dnl --enable-libstdcxx-time=yes
1053 dnl        checks for the availability of monotonic and realtime clocks,
1054 dnl        nanosleep and sched_yield in libc and libposix4 and, in case, links
1055 dnl       the latter
1056 dnl --enable-libstdcxx-time=rt
1057 dnl        also searches (and, in case, links) librt.  Note that this is
1058 dnl        not always desirable because, in glibc, for example, in turn it
1059 dnl        triggers the linking of libpthread too, which activates locking,
1060 dnl        a large overhead for single-thread programs.
1061 dnl --enable-libstdcxx-time=no
1062 dnl --disable-libstdcxx-time
1063 dnl        disables the checks completely
1064 dnl
1065 AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
1066
1067   AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield])
1068   GLIBCXX_ENABLE(libstdcxx-time,$1,[=KIND],
1069     [use KIND for check type],
1070     [permit yes|no|rt])
1071
1072   AC_LANG_SAVE
1073   AC_LANG_CPLUSPLUS
1074   ac_save_CXXFLAGS="$CXXFLAGS"
1075   CXXFLAGS="$CXXFLAGS -fno-exceptions"
1076   ac_save_LIBS="$LIBS"
1077
1078   ac_has_clock_monotonic=no;
1079   ac_has_clock_realtime=no;
1080
1081   if test x"$enable_libstdcxx_time" != x"no"; then
1082
1083     if test x"$enable_libstdcxx_time" = x"rt"; then
1084       AC_SEARCH_LIBS(clock_gettime, [rt posix4])
1085       AC_SEARCH_LIBS(nanosleep, [rt posix4])
1086     else
1087       AC_SEARCH_LIBS(clock_gettime, [posix4])
1088       AC_SEARCH_LIBS(nanosleep, [posix4])
1089     fi
1090
1091     case "$ac_cv_search_clock_gettime" in
1092       -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
1093       ;;
1094     esac
1095     case "$ac_cv_search_nanosleep" in
1096       -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
1097       ;;
1098     esac
1099
1100     AC_SEARCH_LIBS(sched_yield, [rt posix4])
1101
1102     case "$ac_cv_search_sched_yield" in
1103       -lposix4*)
1104       GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1105       AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1106                 [ Defined if sched_yield is available. ])
1107       ;;
1108       -lrt*)
1109       if test x"$enable_libstdcxx_time" = x"rt"; then
1110         GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1111         AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, 
1112                   [ Defined if sched_yield is available. ])
1113       fi
1114       ;;
1115       *)
1116       AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1117                 [ Defined if sched_yield is available. ])
1118       ;;
1119     esac
1120
1121     AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
1122
1123     if test x"$ac_has_unistd_h" = x"yes"; then
1124       AC_MSG_CHECKING([for monotonic clock])
1125       AC_TRY_LINK(
1126         [#include <unistd.h>
1127          #include <time.h>
1128         ],
1129         [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
1130           timespec tp;     
1131          #endif
1132           clock_gettime(CLOCK_MONOTONIC, &tp);
1133         ], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
1134
1135       AC_MSG_RESULT($ac_has_clock_monotonic)   
1136     
1137       AC_MSG_CHECKING([for realtime clock])
1138       AC_TRY_LINK(
1139         [#include <unistd.h>
1140          #include <time.h>
1141         ],
1142         [#if _POSIX_TIMERS > 0
1143           timespec tp;      
1144          #endif
1145           clock_gettime(CLOCK_REALTIME, &tp);
1146         ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
1147
1148       AC_MSG_RESULT($ac_has_clock_realtime)
1149
1150       AC_MSG_CHECKING([for nanosleep])
1151       AC_TRY_LINK(
1152         [#include <unistd.h>
1153          #include <time.h>
1154         ],
1155         [#if _POSIX_TIMERS > 0
1156           timespec tp;
1157          #endif
1158           nanosleep(&tp, 0);
1159         ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
1160
1161       AC_MSG_RESULT($ac_has_nanosleep)
1162     fi
1163   fi
1164
1165   if test x"$ac_has_clock_monotonic" = x"yes"; then
1166     AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
1167       [ Defined if clock_gettime has monotonic clock support. ])
1168   fi
1169
1170   if test x"$ac_has_clock_realtime" = x"yes"; then
1171     AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1,
1172       [ Defined if clock_gettime has realtime clock support. ])
1173   fi
1174
1175   if test x"$ac_has_nanosleep" = x"yes"; then
1176     AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
1177       [ Defined if nanosleep is available. ])
1178   fi
1179
1180   AC_SUBST(GLIBCXX_LIBS)
1181
1182   CXXFLAGS="$ac_save_CXXFLAGS"
1183   LIBS="$ac_save_LIBS"
1184   AC_LANG_RESTORE
1185 ])
1186
1187 dnl
1188 dnl Check for gettimeofday, used in the implementation of 20.8.5
1189 dnl [time.clock] in the current C++0x working draft.
1190 dnl
1191 AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
1192   
1193   AC_MSG_CHECKING([for gettimeofday])
1194
1195   AC_LANG_SAVE
1196   AC_LANG_CPLUSPLUS
1197   ac_save_CXXFLAGS="$CXXFLAGS"
1198   CXXFLAGS="$CXXFLAGS -fno-exceptions"
1199   
1200   ac_has_gettimeofday=no;
1201   AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
1202   if test x"$ac_has_sys_time_h" = x"yes"; then
1203     AC_MSG_CHECKING([for gettimeofday])
1204     GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>],
1205       [timeval tv; gettimeofday(&tv, 0);],
1206       [ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])
1207     
1208     AC_MSG_RESULT($ac_has_gettimeofday)
1209   fi
1210   
1211   if test x"$ac_has_gettimeofday" = x"yes"; then
1212     AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1,
1213       [ Defined if gettimeofday is available. ])
1214   fi
1215   
1216   CXXFLAGS="$ac_save_CXXFLAGS"
1217   AC_LANG_RESTORE
1218 ])
1219
1220 dnl
1221 dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
1222 dnl facilities in Chapter 8, "C compatibility".
1223 dnl
1224 AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
1225
1226   AC_LANG_SAVE
1227   AC_LANG_CPLUSPLUS
1228
1229   # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
1230   # undefined and fake C99 facilities may be spuriously enabled.
1231   ac_save_CXXFLAGS="$CXXFLAGS"
1232   CXXFLAGS="$CXXFLAGS -std=c++98"
1233
1234   # Check for the existence of <complex.h> complex math functions used
1235   # by tr1/complex.
1236   AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
1237   ac_c99_complex_tr1=no;
1238   if test x"$ac_has_complex_h" = x"yes"; then
1239     AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>])
1240     AC_TRY_COMPILE([#include <complex.h>],
1241                    [typedef __complex__ float float_type; float_type tmpf;
1242                     cacosf(tmpf);
1243                     casinf(tmpf);
1244                     catanf(tmpf);
1245                     cacoshf(tmpf);
1246                     casinhf(tmpf);
1247                     catanhf(tmpf);
1248                     typedef __complex__ double double_type; double_type tmpd;
1249                     cacos(tmpd);
1250                     casin(tmpd);
1251                     catan(tmpd);
1252                     cacosh(tmpd);
1253                     casinh(tmpd);
1254                     catanh(tmpd);
1255                     typedef __complex__ long double ld_type; ld_type tmpld;
1256                     cacosl(tmpld);
1257                     casinl(tmpld);
1258                     catanl(tmpld);
1259                     cacoshl(tmpld);
1260                     casinhl(tmpld);
1261                     catanhl(tmpld);
1262                    ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no])
1263   fi
1264   AC_MSG_RESULT($ac_c99_complex_tr1)
1265   if test x"$ac_c99_complex_tr1" = x"yes"; then
1266     AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1,
1267               [Define if C99 functions in <complex.h> should be used in
1268               <tr1/complex>. Using compiler builtins for these functions
1269               requires corresponding C99 library functions to be present.])
1270   fi
1271
1272   # Check for the existence of <ctype.h> functions.
1273   AC_MSG_CHECKING([for ISO C99 support to TR1 in <ctype.h>])
1274   AC_CACHE_VAL(glibcxx_cv_c99_ctype_tr1, [
1275   AC_TRY_COMPILE([#include <ctype.h>],
1276                  [int ch;
1277                   int ret;
1278                   ret = isblank(ch);
1279                  ],[glibcxx_cv_c99_ctype_tr1=yes],
1280                    [glibcxx_cv_c99_ctype_tr1=no])
1281   ])
1282   AC_MSG_RESULT($glibcxx_cv_c99_ctype_tr1)
1283   if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then
1284     AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
1285               [Define if C99 functions in <ctype.h> should be imported in
1286               <tr1/cctype> in namespace std::tr1.])
1287   fi
1288
1289   # Check for the existence of <fenv.h> functions.
1290   AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
1291   ac_c99_fenv_tr1=no;
1292   if test x"$ac_has_fenv_h" = x"yes"; then
1293     AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>])
1294     AC_TRY_COMPILE([#include <fenv.h>],
1295                    [int except, mode;
1296                     fexcept_t* pflag;
1297                     fenv_t* penv;
1298                     int ret;
1299                     ret = feclearexcept(except);
1300                     ret = fegetexceptflag(pflag, except);
1301                     ret = feraiseexcept(except);
1302                     ret = fesetexceptflag(pflag, except);
1303                     ret = fetestexcept(except);
1304                     ret = fegetround();
1305                     ret = fesetround(mode);
1306                     ret = fegetenv(penv);
1307                     ret = feholdexcept(penv);
1308                     ret = fesetenv(penv);
1309                     ret = feupdateenv(penv);
1310                    ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no])
1311   fi
1312   AC_MSG_RESULT($ac_c99_fenv_tr1)
1313   if test x"$ac_c99_fenv_tr1" = x"yes"; then
1314     AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1,
1315               [Define if C99 functions in <fenv.h> should be imported in
1316               <tr1/cfenv> in namespace std::tr1.])
1317   fi
1318
1319   # Check for the existence of <stdint.h> types.
1320   AC_MSG_CHECKING([for ISO C99 support to TR1 in <stdint.h>])
1321   AC_CACHE_VAL(glibcxx_cv_c99_stdint_tr1, [
1322   AC_TRY_COMPILE([#define __STDC_LIMIT_MACROS
1323                   #define __STDC_CONSTANT_MACROS
1324                   #include <stdint.h>],
1325                  [typedef int8_t          my_int8_t;
1326                   my_int8_t               i8 = INT8_MIN;
1327                   i8 = INT8_MAX;
1328                   typedef int16_t         my_int16_t;
1329                   my_int16_t              i16 = INT16_MIN;
1330                   i16 = INT16_MAX;
1331                   typedef int32_t         my_int32_t;
1332                   my_int32_t              i32 = INT32_MIN;
1333                   i32 = INT32_MAX;
1334                   typedef int64_t         my_int64_t;
1335                   my_int64_t              i64 = INT64_MIN;
1336                   i64 = INT64_MAX;
1337                   typedef int_fast8_t     my_int_fast8_t;
1338                   my_int_fast8_t          if8 = INT_FAST8_MIN;
1339                   if8 = INT_FAST8_MAX;
1340                   typedef int_fast16_t    my_int_fast16_t;
1341                   my_int_fast16_t         if16 = INT_FAST16_MIN;
1342                   if16 = INT_FAST16_MAX;
1343                   typedef int_fast32_t    my_int_fast32_t;
1344                   my_int_fast32_t         if32 = INT_FAST32_MIN;
1345                   if32 = INT_FAST32_MAX;
1346                   typedef int_fast64_t    my_int_fast64_t;
1347                   my_int_fast64_t         if64 = INT_FAST64_MIN;
1348                   if64 = INT_FAST64_MAX;
1349                   typedef int_least8_t    my_int_least8_t;
1350                   my_int_least8_t         il8 = INT_LEAST8_MIN;
1351                   il8 = INT_LEAST8_MAX;
1352                   typedef int_least16_t   my_int_least16_t;
1353                   my_int_least16_t        il16 = INT_LEAST16_MIN;
1354                   il16 = INT_LEAST16_MAX;
1355                   typedef int_least32_t   my_int_least32_t;
1356                   my_int_least32_t        il32 = INT_LEAST32_MIN;
1357                   il32 = INT_LEAST32_MAX;
1358                   typedef int_least64_t   my_int_least64_t;
1359                   my_int_least64_t        il64 = INT_LEAST64_MIN;
1360                   il64 = INT_LEAST64_MAX;
1361                   typedef intmax_t        my_intmax_t;
1362                   my_intmax_t             im = INTMAX_MAX;
1363                   im = INTMAX_MIN;
1364                   typedef intptr_t        my_intptr_t;
1365                   my_intptr_t             ip = INTPTR_MAX;
1366                   ip = INTPTR_MIN;
1367                   typedef uint8_t         my_uint8_t;
1368                   my_uint8_t              ui8 = UINT8_MAX;
1369                   ui8 = UINT8_MAX;
1370                   typedef uint16_t        my_uint16_t;
1371                   my_uint16_t             ui16 = UINT16_MAX;
1372                   ui16 = UINT16_MAX;
1373                   typedef uint32_t        my_uint32_t;
1374                   my_uint32_t             ui32 = UINT32_MAX;
1375                   ui32 = UINT32_MAX;
1376                   typedef uint64_t        my_uint64_t;
1377                   my_uint64_t             ui64 = UINT64_MAX;
1378                   ui64 = UINT64_MAX;
1379                   typedef uint_fast8_t    my_uint_fast8_t;
1380                   my_uint_fast8_t         uif8 = UINT_FAST8_MAX;
1381                   uif8 = UINT_FAST8_MAX;
1382                   typedef uint_fast16_t   my_uint_fast16_t;
1383                   my_uint_fast16_t        uif16 = UINT_FAST16_MAX;
1384                   uif16 = UINT_FAST16_MAX;
1385                   typedef uint_fast32_t   my_uint_fast32_t;
1386                   my_uint_fast32_t        uif32 = UINT_FAST32_MAX;
1387                   uif32 = UINT_FAST32_MAX;
1388                   typedef uint_fast64_t   my_uint_fast64_t;
1389                   my_uint_fast64_t        uif64 = UINT_FAST64_MAX;
1390                   uif64 = UINT_FAST64_MAX;
1391                   typedef uint_least8_t   my_uint_least8_t;
1392                   my_uint_least8_t        uil8 = UINT_LEAST8_MAX;
1393                   uil8 = UINT_LEAST8_MAX;
1394                   typedef uint_least16_t  my_uint_least16_t;
1395                   my_uint_least16_t       uil16 = UINT_LEAST16_MAX;
1396                   uil16 = UINT_LEAST16_MAX;
1397                   typedef uint_least32_t  my_uint_least32_t;
1398                   my_uint_least32_t       uil32 = UINT_LEAST32_MAX;
1399                   uil32 = UINT_LEAST32_MAX;
1400                   typedef uint_least64_t  my_uint_least64_t;
1401                   my_uint_least64_t       uil64 = UINT_LEAST64_MAX;
1402                   uil64 = UINT_LEAST64_MAX;
1403                   typedef uintmax_t       my_uintmax_t;
1404                   my_uintmax_t            uim = UINTMAX_MAX;
1405                   uim = UINTMAX_MAX;
1406                   typedef uintptr_t       my_uintptr_t;
1407                   my_uintptr_t            uip = UINTPTR_MAX;
1408                   uip = UINTPTR_MAX;
1409                  ],[glibcxx_cv_c99_stdint_tr1=yes],
1410                    [glibcxx_cv_c99_stdint_tr1=no])
1411   ])
1412   AC_MSG_RESULT($glibcxx_cv_c99_stdint_tr1)
1413   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1414     AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1,
1415               [Define if C99 types in <stdint.h> should be imported in
1416               <tr1/cstdint> in namespace std::tr1.])
1417   fi
1418
1419   # Check for the existence of <math.h> functions.
1420   AC_MSG_CHECKING([for ISO C99 support to TR1 in <math.h>])
1421   AC_CACHE_VAL(glibcxx_cv_c99_math_tr1, [
1422   AC_TRY_COMPILE([#include <math.h>],
1423                  [typedef double_t  my_double_t;
1424                   typedef float_t   my_float_t;
1425                   acosh(0.0);
1426                   acoshf(0.0f);
1427                   acoshl(0.0l);
1428                   asinh(0.0);
1429                   asinhf(0.0f);
1430                   asinhl(0.0l);
1431                   atanh(0.0);
1432                   atanhf(0.0f);
1433                   atanhl(0.0l);
1434                   cbrt(0.0);
1435                   cbrtf(0.0f);
1436                   cbrtl(0.0l);
1437                   copysign(0.0, 0.0);
1438                   copysignf(0.0f, 0.0f);
1439                   copysignl(0.0l, 0.0l);
1440                   erf(0.0);
1441                   erff(0.0f);
1442                   erfl(0.0l);
1443                   erfc(0.0);
1444                   erfcf(0.0f);
1445                   erfcl(0.0l);
1446                   exp2(0.0);
1447                   exp2f(0.0f);
1448                   exp2l(0.0l);
1449                   expm1(0.0);
1450                   expm1f(0.0f);
1451                   expm1l(0.0l);
1452                   fdim(0.0, 0.0);
1453                   fdimf(0.0f, 0.0f);
1454                   fdiml(0.0l, 0.0l);
1455                   fma(0.0, 0.0, 0.0);
1456                   fmaf(0.0f, 0.0f, 0.0f);
1457                   fmal(0.0l, 0.0l, 0.0l);
1458                   fmax(0.0, 0.0);
1459                   fmaxf(0.0f, 0.0f);
1460                   fmaxl(0.0l, 0.0l);
1461                   fmin(0.0, 0.0);
1462                   fminf(0.0f, 0.0f);
1463                   fminl(0.0l, 0.0l);
1464                   hypot(0.0, 0.0);
1465                   hypotf(0.0f, 0.0f);
1466                   hypotl(0.0l, 0.0l);
1467                   ilogb(0.0);
1468                   ilogbf(0.0f);
1469                   ilogbl(0.0l);
1470                   lgamma(0.0);
1471                   lgammaf(0.0f);
1472                   lgammal(0.0l);
1473                   llrint(0.0);
1474                   llrintf(0.0f);
1475                   llrintl(0.0l);
1476                   llround(0.0);
1477                   llroundf(0.0f);
1478                   llroundl(0.0l);
1479                   log1p(0.0);
1480                   log1pf(0.0f);
1481                   log1pl(0.0l);
1482                   log2(0.0);
1483                   log2f(0.0f);
1484                   log2l(0.0l);
1485                   logb(0.0);
1486                   logbf(0.0f);
1487                   logbl(0.0l);
1488                   lrint(0.0);
1489                   lrintf(0.0f);
1490                   lrintl(0.0l);
1491                   lround(0.0);
1492                   lroundf(0.0f);
1493                   lroundl(0.0l);
1494                   nan(0);
1495                   nanf(0);
1496                   nanl(0);
1497                   nearbyint(0.0);
1498                   nearbyintf(0.0f);
1499                   nearbyintl(0.0l);
1500                   nextafter(0.0, 0.0);
1501                   nextafterf(0.0f, 0.0f);
1502                   nextafterl(0.0l, 0.0l);
1503                   nexttoward(0.0, 0.0);
1504                   nexttowardf(0.0f, 0.0f);
1505                   nexttowardl(0.0l, 0.0l);
1506                   remainder(0.0, 0.0);
1507                   remainderf(0.0f, 0.0f);
1508                   remainderl(0.0l, 0.0l);
1509                   remquo(0.0, 0.0, 0);
1510                   remquof(0.0f, 0.0f, 0);
1511                   remquol(0.0l, 0.0l, 0);
1512                   rint(0.0);
1513                   rintf(0.0f);
1514                   rintl(0.0l);
1515                   round(0.0);
1516                   roundf(0.0f);
1517                   roundl(0.0l);
1518                   scalbln(0.0, 0l);
1519                   scalblnf(0.0f, 0l);
1520                   scalblnl(0.0l, 0l);
1521                   scalbn(0.0, 0);
1522                   scalbnf(0.0f, 0);
1523                   scalbnl(0.0l, 0);
1524                   tgamma(0.0);
1525                   tgammaf(0.0f);
1526                   tgammal(0.0l);
1527                   trunc(0.0);
1528                   truncf(0.0f);
1529                   truncl(0.0l);
1530                  ],[glibcxx_cv_c99_math_tr1=yes], [glibcxx_cv_c99_math_tr1=no])
1531   ])
1532   AC_MSG_RESULT($glibcxx_cv_c99_math_tr1)
1533   if test x"$glibcxx_cv_c99_math_tr1" = x"yes"; then
1534     AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1,
1535               [Define if C99 functions or macros in <math.h> should be imported
1536               in <tr1/cmath> in namespace std::tr1.])
1537   fi
1538
1539   # Check for the existence of <inttypes.h> functions (NB: doesn't make
1540   # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1541   ac_c99_inttypes_tr1=no;
1542   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1543     AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>])
1544     AC_TRY_COMPILE([#include <inttypes.h>],
1545                    [intmax_t i, numer, denom, base;
1546                     const char* s;
1547                     char** endptr;
1548                     intmax_t ret = imaxabs(i);
1549                     imaxdiv_t dret = imaxdiv(numer, denom);
1550                     ret = strtoimax(s, endptr, base);
1551                     uintmax_t uret = strtoumax(s, endptr, base);
1552                    ],[ac_c99_inttypes_tr1=yes], [ac_c99_inttypes_tr1=no])
1553   fi
1554   AC_MSG_RESULT($ac_c99_inttypes_tr1)
1555   if test x"$ac_c99_inttypes_tr1" = x"yes"; then
1556     AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_TR1, 1,
1557               [Define if C99 functions in <inttypes.h> should be imported in
1558               <tr1/cinttypes> in namespace std::tr1.])
1559   fi
1560
1561   # Check for the existence of whcar_t <inttypes.h> functions (NB: doesn't
1562   # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1563   ac_c99_inttypes_wchar_t_tr1=no;
1564   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1565     AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>])
1566     AC_TRY_COMPILE([#include <inttypes.h>],
1567                    [intmax_t base;
1568                     const wchar_t* s;
1569                     wchar_t** endptr;
1570                     intmax_t ret = wcstoimax(s, endptr, base);
1571                     uintmax_t uret = wcstoumax(s, endptr, base);
1572                    ],[ac_c99_inttypes_wchar_t_tr1=yes],
1573                      [ac_c99_inttypes_wchar_t_tr1=no])
1574   fi
1575   AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1)
1576   if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then
1577     AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1,
1578               [Define if wchar_t C99 functions in <inttypes.h> should be
1579               imported in <tr1/cinttypes> in namespace std::tr1.])
1580   fi
1581
1582   # Check for the existence of the <stdbool.h> header.  
1583   AC_CHECK_HEADERS(stdbool.h)
1584
1585   CXXFLAGS="$ac_save_CXXFLAGS"
1586   AC_LANG_RESTORE
1587 ])
1588
1589 dnl
1590 dnl Check whether "/dev/random" and "/dev/urandom" are available for the
1591 dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
1592 dnl
1593 AC_DEFUN([GLIBCXX_CHECK_RANDOM_TR1], [
1594
1595   AC_MSG_CHECKING([for "/dev/random" and "/dev/urandom" for TR1 random_device])
1596   AC_CACHE_VAL(glibcxx_cv_random_tr1, [
1597     if test -r /dev/random && test -r /dev/urandom; then
1598       glibcxx_cv_random_tr1=yes;
1599     else
1600       glibcxx_cv_random_tr1=no;
1601     fi
1602   ])
1603   AC_MSG_RESULT($glibcxx_cv_random_tr1)
1604
1605   if test x"$glibcxx_cv_random_tr1" = x"yes"; then
1606     AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1,
1607               [Define if /dev/random and /dev/urandom are available for
1608                the random_device of TR1 (Chapter 5.1).])
1609   fi
1610
1611 ])
1612
1613 dnl
1614 dnl Check whether EOF, SEEK_CUR, and SEEK_END have the most common values:
1615 dnl in that case including <cstdio> in some C++ headers can be avoided.
1616 dnl
1617 AC_DEFUN([GLIBCXX_CHECK_STDIO_MACROS], [
1618
1619   AC_MSG_CHECKING([for EOF == -1, SEEK_CUR == 1, SEEK_END == 2])
1620   AC_CACHE_VAL(glibcxx_cv_stdio_macros, [
1621   AC_TRY_COMPILE([#include <stdio.h>],
1622                  [#if ((EOF != -1) || (SEEK_CUR != 1) || (SEEK_END != 2))
1623                     unusual values...
1624                   #endif
1625                  ], [glibcxx_cv_stdio_macros=yes],
1626                     [glibcxx_cv_stdio_macros=no])
1627   ])
1628   AC_MSG_RESULT($glibcxx_cv_stdio_macros)
1629   if test x"$glibcxx_cv_stdio_macros" = x"yes"; then
1630     AC_DEFINE(_GLIBCXX_STDIO_MACROS, 1,
1631               [Define if EOF == -1, SEEK_CUR == 1, SEEK_END == 2.])
1632   fi
1633
1634 ])
1635
1636 dnl
1637 dnl Check whether macros, etc are present for <system_error>
1638 dnl
1639 AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
1640
1641 m4_pushdef([n_syserr], [1])dnl
1642 m4_foreach([syserr], [EOWNERDEAD, ENOTRECOVERABLE, ENOLINK, EPROTO, ENODATA,
1643                       ENOSR, ENOSTR, ETIME, EBADMSG, ECANCELED,
1644                       EOVERFLOW, ENOTSUP, EIDRM, ETXTBSY],
1645 [m4_pushdef([SYSERR], m4_toupper(syserr))dnl
1646 AC_MSG_CHECKING([for syserr])
1647 AC_CACHE_VAL([glibcxx_cv_system_error[]n_syserr], [
1648 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]],
1649                                    [int i = syserr;])],
1650                   [glibcxx_cv_system_error[]n_syserr=yes],
1651                   [glibcxx_cv_system_error[]n_syserr=no])
1652 ])
1653 AC_MSG_RESULT([$glibcxx_cv_system_error[]n_syserr])
1654 if test x"$glibcxx_cv_system_error[]n_syserr" = x"yes"; then
1655   AC_DEFINE([HAVE_]SYSERR, 1, [Define if ]syserr[ exists.])
1656 fi
1657 m4_define([n_syserr], m4_incr(n_syserr))dnl
1658 m4_popdef([SYSERR])dnl
1659 ])
1660 m4_popdef([n_syserr])dnl
1661 ])
1662
1663 dnl
1664 dnl Check for what type of C headers to use.
1665 dnl
1666 dnl --enable-cheaders= [does stuff].
1667 dnl --disable-cheaders [does not do anything, really].
1668 dnl  +  Usage:  GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
1669 dnl       Where DEFAULT is either 'c' or 'c_std' or 'c_global'.
1670 dnl
1671 AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
1672   GLIBCXX_ENABLE(cheaders,$1,[=KIND],
1673     [construct "C" headers for g++], [permit c|c_std|c_global])
1674   AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
1675
1676   C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
1677
1678   # Allow overrides to configure.host here.
1679   if test $enable_cheaders = c_global; then
1680      c_compatibility=yes
1681   fi
1682
1683   if test $enable_cheaders = c_global || test $enable_cheaders = c_std; then
1684      c_extra=yes
1685   fi
1686
1687   AC_SUBST(C_INCLUDE_DIR)
1688   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
1689   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
1690   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global)
1691   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
1692   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_EXTRA, test $c_extra = yes)
1693 ])
1694
1695
1696 dnl
1697 dnl Check for which locale library to use.  The choice is mapped to
1698 dnl a subdirectory of config/locale.
1699 dnl
1700 dnl Default is generic.
1701 dnl
1702 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
1703   GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
1704     [use MODEL for target locale package],
1705     [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
1706
1707   # Deal with gettext issues.  Default to not using it (=no) until we detect
1708   # support for it later.  Let the user turn it off via --e/d, but let that
1709   # default to on for easier handling.
1710   USE_NLS=no
1711   AC_ARG_ENABLE(nls,
1712     AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
1713     [],
1714     [enable_nls=yes])
1715   
1716   # Either a known packaage, or "auto"
1717   if test $enable_clocale = no || test $enable_clocale = yes; then
1718      enable_clocale=auto
1719   fi
1720   enable_clocale_flag=$enable_clocale
1721
1722   # Probe for locale model to use if none specified.
1723   # Default to "generic".
1724   if test $enable_clocale_flag = auto; then
1725     case ${target_os} in
1726       linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
1727         enable_clocale_flag=gnu 
1728         ;;
1729       darwin* | freebsd*)
1730         enable_clocale_flag=darwin
1731         ;;
1732       *)
1733         enable_clocale_flag=generic
1734         ;;
1735     esac
1736   fi
1737
1738   # Sanity check model, and test for special functionality.
1739   if test $enable_clocale_flag = gnu; then
1740     AC_EGREP_CPP([_GLIBCXX_ok], [
1741     #include <features.h>
1742     #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
1743       _GLIBCXX_ok
1744     #endif
1745     ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1746
1747     if test $enable_clocale = auto; then
1748       # Test for bugs early in glibc-2.2.x series
1749       AC_TRY_RUN([
1750       #define _GNU_SOURCE 1
1751       #include <locale.h>
1752       #include <string.h>
1753       #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
1754       extern __typeof(newlocale) __newlocale;
1755       extern __typeof(duplocale) __duplocale;
1756       extern __typeof(strcoll_l) __strcoll_l;
1757       #endif
1758       int main()
1759       {
1760         const char __one[] = "Äuglein Augmen";
1761         const char __two[] = "Äuglein";
1762         int i;
1763         int j;
1764         __locale_t        loc;
1765         __locale_t        loc_dup;
1766         loc = __newlocale(1 << LC_ALL, "de_DE", 0);
1767         loc_dup = __duplocale(loc);
1768         i = __strcoll_l(__one, __two, loc);
1769         j = __strcoll_l(__one, __two, loc_dup);
1770         return 0;
1771       }
1772       ],
1773       [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
1774       [enable_clocale_flag=generic])
1775     fi
1776
1777     # Set it to scream when it hurts.
1778     ac_save_CFLAGS="$CFLAGS"    
1779     CFLAGS="-Wimplicit-function-declaration -Werror"
1780
1781     # Use strxfrm_l if available.
1782     AC_TRY_COMPILE([#define _GNU_SOURCE 1
1783                     #include <string.h>
1784                     #include <locale.h>],
1785                     [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);], 
1786                     AC_DEFINE(HAVE_STRXFRM_L, 1, 
1787                     [Define if strxfrm_l is available in <string.h>.]),)
1788     
1789     # Use strerror_l if available.
1790     AC_TRY_COMPILE([#define _GNU_SOURCE 1
1791                     #include <string.h>
1792                     #include <locale.h>],
1793                     [__locale_t loc; strerror_l(5, loc);], 
1794                     AC_DEFINE(HAVE_STRERROR_L, 1, 
1795                     [Define if strerror_l is available in <string.h>.]),)
1796
1797     CFLAGS="$ac_save_CFLAGS"
1798   fi
1799
1800   # Perhaps use strerror_r if available, and strerror_l isn't.
1801   ac_save_CFLAGS="$CFLAGS"      
1802   CFLAGS="-Wimplicit-function-declaration -Werror"
1803   AC_TRY_COMPILE([#define _GNU_SOURCE 1
1804                   #include <string.h>
1805                   #include <locale.h>],
1806                   [char s[128]; strerror_r(5, s, 128);], 
1807                   AC_DEFINE(HAVE_STRERROR_R, 1, 
1808                   [Define if strerror_r is available in <string.h>.]),)
1809   CFLAGS="$ac_save_CFLAGS"
1810
1811   # Set configure bits for specified locale package
1812   AC_MSG_CHECKING([for C locale to use])
1813   case ${enable_clocale_flag} in
1814     generic)
1815       AC_MSG_RESULT(generic)
1816
1817       CLOCALE_H=config/locale/generic/c_locale.h
1818       CLOCALE_CC=config/locale/generic/c_locale.cc
1819       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1820       CCOLLATE_CC=config/locale/generic/collate_members.cc
1821       CCTYPE_CC=config/locale/generic/ctype_members.cc
1822       CMESSAGES_H=config/locale/generic/messages_members.h
1823       CMESSAGES_CC=config/locale/generic/messages_members.cc
1824       CMONEY_CC=config/locale/generic/monetary_members.cc
1825       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1826       CTIME_H=config/locale/generic/time_members.h
1827       CTIME_CC=config/locale/generic/time_members.cc
1828       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1829       ;;
1830     darwin)
1831       AC_MSG_RESULT(darwin or freebsd)
1832
1833       CLOCALE_H=config/locale/generic/c_locale.h
1834       CLOCALE_CC=config/locale/generic/c_locale.cc
1835       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1836       CCOLLATE_CC=config/locale/generic/collate_members.cc
1837       CCTYPE_CC=config/locale/darwin/ctype_members.cc
1838       CMESSAGES_H=config/locale/generic/messages_members.h
1839       CMESSAGES_CC=config/locale/generic/messages_members.cc
1840       CMONEY_CC=config/locale/generic/monetary_members.cc
1841       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1842       CTIME_H=config/locale/generic/time_members.h
1843       CTIME_CC=config/locale/generic/time_members.cc
1844       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1845       ;;
1846         
1847     gnu)
1848       AC_MSG_RESULT(gnu)
1849
1850       # Declare intention to use gettext, and add support for specific
1851       # languages.
1852       # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
1853       ALL_LINGUAS="de fr"
1854
1855       # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
1856       AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1857       if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
1858         USE_NLS=yes
1859       fi
1860       # Export the build objects.
1861       for ling in $ALL_LINGUAS; do \
1862         glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
1863         glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
1864       done
1865       AC_SUBST(glibcxx_MOFILES)
1866       AC_SUBST(glibcxx_POFILES)
1867
1868       CLOCALE_H=config/locale/gnu/c_locale.h
1869       CLOCALE_CC=config/locale/gnu/c_locale.cc
1870       CCODECVT_CC=config/locale/gnu/codecvt_members.cc
1871       CCOLLATE_CC=config/locale/gnu/collate_members.cc
1872       CCTYPE_CC=config/locale/gnu/ctype_members.cc
1873       CMESSAGES_H=config/locale/gnu/messages_members.h
1874       CMESSAGES_CC=config/locale/gnu/messages_members.cc
1875       CMONEY_CC=config/locale/gnu/monetary_members.cc
1876       CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1877       CTIME_H=config/locale/gnu/time_members.h
1878       CTIME_CC=config/locale/gnu/time_members.cc
1879       CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
1880       ;;
1881     ieee_1003.1-2001)
1882       AC_MSG_RESULT(IEEE 1003.1)
1883
1884       CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1885       CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
1886       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1887       CCOLLATE_CC=config/locale/generic/collate_members.cc
1888       CCTYPE_CC=config/locale/generic/ctype_members.cc
1889       CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1890       CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1891       CMONEY_CC=config/locale/generic/monetary_members.cc
1892       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1893       CTIME_H=config/locale/generic/time_members.h
1894       CTIME_CC=config/locale/generic/time_members.cc
1895       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1896       ;;
1897   esac
1898
1899   # This is where the testsuite looks for locale catalogs, using the
1900   # -DLOCALEDIR define during testsuite compilation.
1901   glibcxx_localedir=${glibcxx_builddir}/po/share/locale
1902   AC_SUBST(glibcxx_localedir)
1903
1904   # A standalone libintl (e.g., GNU libintl) may be in use.
1905   if test $USE_NLS = yes; then
1906     AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no)
1907     AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no)
1908   fi
1909   if test $USE_NLS = yes; then
1910     AC_DEFINE(_GLIBCXX_USE_NLS, 1, 
1911               [Define if NLS translations are to be used.])
1912   fi
1913
1914   AC_SUBST(USE_NLS)
1915   AC_SUBST(CLOCALE_H)
1916   AC_SUBST(CMESSAGES_H)
1917   AC_SUBST(CCODECVT_CC)
1918   AC_SUBST(CCOLLATE_CC)
1919   AC_SUBST(CCTYPE_CC)
1920   AC_SUBST(CMESSAGES_CC)
1921   AC_SUBST(CMONEY_CC)
1922   AC_SUBST(CNUMERIC_CC)
1923   AC_SUBST(CTIME_H)
1924   AC_SUBST(CTIME_CC)
1925   AC_SUBST(CLOCALE_CC)
1926   AC_SUBST(CLOCALE_INTERNAL_H)
1927 ])
1928
1929
1930 dnl
1931 dnl Check for which std::allocator base class to use.  The choice is
1932 dnl mapped from a subdirectory of include/ext.
1933 dnl
1934 dnl Default is new.
1935 dnl
1936 AC_DEFUN([GLIBCXX_ENABLE_ALLOCATOR], [
1937   AC_MSG_CHECKING([for std::allocator base class])
1938   GLIBCXX_ENABLE(libstdcxx-allocator,auto,[=KIND],
1939     [use KIND for target std::allocator base],
1940     [permit new|malloc|mt|bitmap|pool|yes|no|auto])
1941
1942   # If they didn't use this option switch, or if they specified --enable
1943   # with no specific model, we'll have to look for one.  If they
1944   # specified --disable (???), do likewise.
1945   if test $enable_libstdcxx_allocator = no ||
1946      test $enable_libstdcxx_allocator = yes;
1947   then
1948      enable_libstdcxx_allocator=auto
1949   fi
1950
1951   # Either a known package, or "auto". Auto implies the default choice
1952   # for a particular platform.
1953   enable_libstdcxx_allocator_flag=$enable_libstdcxx_allocator
1954
1955   # Probe for host-specific support if no specific model is specified.
1956   # Default to "new".
1957   if test $enable_libstdcxx_allocator_flag = auto; then
1958     case ${target_os} in
1959       linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
1960         enable_libstdcxx_allocator_flag=new
1961         ;;
1962       *)
1963         enable_libstdcxx_allocator_flag=new
1964         ;;
1965     esac
1966   fi
1967   AC_MSG_RESULT($enable_libstdcxx_allocator_flag)
1968   
1969
1970   # Set configure bits for specified locale package
1971   case ${enable_libstdcxx_allocator_flag} in
1972     bitmap)
1973       ALLOCATOR_H=config/allocator/bitmap_allocator_base.h
1974       ALLOCATOR_NAME=__gnu_cxx::bitmap_allocator
1975       ;;
1976     malloc)
1977       ALLOCATOR_H=config/allocator/malloc_allocator_base.h
1978       ALLOCATOR_NAME=__gnu_cxx::malloc_allocator
1979       ;;
1980     mt)
1981       ALLOCATOR_H=config/allocator/mt_allocator_base.h
1982       ALLOCATOR_NAME=__gnu_cxx::__mt_alloc
1983       ;;
1984     new)
1985       ALLOCATOR_H=config/allocator/new_allocator_base.h
1986       ALLOCATOR_NAME=__gnu_cxx::new_allocator
1987       ;;
1988     pool)
1989       ALLOCATOR_H=config/allocator/pool_allocator_base.h
1990       ALLOCATOR_NAME=__gnu_cxx::__pool_alloc
1991       ;;        
1992   esac
1993
1994   AC_SUBST(ALLOCATOR_H)
1995   AC_SUBST(ALLOCATOR_NAME)
1996 ])
1997
1998
1999 dnl
2000 dnl Check for whether the Boost-derived checks should be turned on.
2001 dnl
2002 dnl --enable-concept-checks turns them on.
2003 dnl --disable-concept-checks leaves them off.
2004 dnl  +  Usage:  GLIBCXX_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2005 dnl       Where DEFAULT is either `yes' or `no'.
2006 dnl
2007 AC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [
2008   GLIBCXX_ENABLE(concept-checks,$1,,[use Boost-derived template checks])
2009   if test $enable_concept_checks = yes; then
2010     AC_DEFINE(_GLIBCXX_CONCEPT_CHECKS, 1,
2011               [Define to use concept checking code from the boost libraries.])
2012   fi
2013 ])
2014
2015 dnl
2016 dnl Check for parallel mode pre-requisites, including OpenMP support.
2017 dnl
2018 dnl  +  Usage:  GLIBCXX_ENABLE_PARALLEL
2019 dnl
2020 AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
2021
2022   enable_parallel=no;
2023
2024   # See if configured libgomp/omp.h exists. (libgomp may be in
2025   # noconfigdirs but not explicitly disabled.)
2026   if test -f $glibcxx_builddir/../libgomp/omp.h; then
2027     enable_parallel=yes;
2028   else
2029     AC_MSG_NOTICE([$glibcxx_builddir/../libgomp/omp.h not found])
2030   fi
2031
2032   AC_MSG_CHECKING([for parallel mode support])
2033   AC_MSG_RESULT([$enable_parallel])
2034   GLIBCXX_CONDITIONAL(ENABLE_PARALLEL, test $enable_parallel = yes)
2035 ])
2036
2037
2038 dnl
2039 dnl Check for which I/O library to use:  stdio, or something specific.
2040 dnl
2041 dnl Default is stdio.
2042 dnl
2043 AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
2044   AC_MSG_CHECKING([for underlying I/O to use])
2045   GLIBCXX_ENABLE(cstdio,stdio,[=PACKAGE],
2046     [use target-specific I/O package], [permit stdio])
2047
2048   # Now that libio has been removed, you can have any color you want as long
2049   # as it's black.  This is one big no-op until other packages are added, but
2050   # showing the framework never hurts.
2051   case ${enable_cstdio} in
2052     stdio)
2053       CSTDIO_H=config/io/c_io_stdio.h
2054       BASIC_FILE_H=config/io/basic_file_stdio.h
2055       BASIC_FILE_CC=config/io/basic_file_stdio.cc
2056       AC_MSG_RESULT(stdio)
2057       ;;
2058   esac
2059
2060   AC_SUBST(CSTDIO_H)
2061   AC_SUBST(BASIC_FILE_H)
2062   AC_SUBST(BASIC_FILE_CC)
2063 ])
2064
2065
2066 dnl
2067 dnl Check for "unusual" flags to pass to the compiler while building.
2068 dnl
2069 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
2070 dnl     experimental flags such as -fpch, -fIMI, -Dfloat=char, etc.
2071 dnl --disable-cxx-flags passes nothing.
2072 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
2073 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
2074 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
2075 dnl  +  Usage:  GLIBCXX_ENABLE_CXX_FLAGS(default flags)
2076 dnl       If "default flags" is an empty string, the effect is the same
2077 dnl       as --disable or --enable=no.
2078 dnl
2079 AC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl
2080   AC_MSG_CHECKING([for extra compiler flags for building])
2081   GLIBCXX_ENABLE(cxx-flags,$1,[=FLAGS],
2082     [pass compiler FLAGS when building library],
2083     [case "x$enable_cxx_flags" in
2084       xno | x)   enable_cxx_flags= ;;
2085       x-*)       ;;
2086       *)         AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2087      esac])
2088
2089   # Run through flags (either default or command-line) and set anything
2090   # extra (e.g., #defines) that must accompany particular g++ options.
2091   if test -n "$enable_cxx_flags"; then
2092     for f in $enable_cxx_flags; do
2093       case "$f" in
2094         -fhonor-std)  ;;
2095         -*)  ;;
2096         *)   # and we're trying to pass /what/ exactly?
2097              AC_MSG_ERROR([compiler flags start with a -]) ;;
2098       esac
2099     done
2100   fi
2101
2102   EXTRA_CXX_FLAGS="$enable_cxx_flags"
2103   AC_MSG_RESULT($EXTRA_CXX_FLAGS)
2104   AC_SUBST(EXTRA_CXX_FLAGS)
2105 ])
2106
2107
2108 dnl
2109 dnl Check to see if debugging libraries are to be built.
2110 dnl
2111 dnl --enable-libstdcxx-debug
2112 dnl builds a separate set of debugging libraries in addition to the
2113 dnl normal (shared, static) libstdc++ binaries.
2114 dnl
2115 dnl --disable-libstdcxx-debug
2116 dnl builds only one (non-debug) version of libstdc++.
2117 dnl
2118 dnl --enable-libstdcxx-debug-flags=FLAGS
2119 dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
2120 dnl
2121 dnl  +  Usage:  GLIBCXX_ENABLE_DEBUG[(DEFAULT)]
2122 dnl       Where DEFAULT is either `yes' or `no'.
2123 dnl
2124 AC_DEFUN([GLIBCXX_ENABLE_DEBUG], [
2125   AC_MSG_CHECKING([for additional debug build])
2126   GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library])
2127   AC_MSG_RESULT($enable_libstdcxx_debug)
2128   GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
2129 ])
2130
2131
2132 dnl
2133 dnl Check for explicit debug flags.
2134 dnl
2135 dnl --enable-libstdcxx-debug-flags='-O1'
2136 dnl is a general method for passing flags to be used when
2137 dnl building debug libraries with --enable-debug.
2138 dnl
2139 dnl --disable-libstdcxx-debug-flags does nothing.
2140 dnl  +  Usage:  GLIBCXX_ENABLE_DEBUG_FLAGS(default flags)
2141 dnl       If "default flags" is an empty string, the effect is the same
2142 dnl       as --disable or --enable=no.
2143 dnl
2144 AC_DEFUN([GLIBCXX_ENABLE_DEBUG_FLAGS], [
2145   GLIBCXX_ENABLE(libstdcxx-debug-flags,[$1],[=FLAGS],
2146     [pass compiler FLAGS when building debug library],
2147     [case "x$enable_libstdcxx_debug_flags" in
2148       xno | x)    enable_libstdcxx_debug_flags= ;;
2149       x-*)        ;;
2150       *)          AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2151      esac])
2152
2153   # Option parsed, now set things appropriately
2154   DEBUG_FLAGS="$enable_libstdcxx_debug_flags"
2155   AC_SUBST(DEBUG_FLAGS)
2156
2157   AC_MSG_NOTICE([Debug build flags set to $DEBUG_FLAGS])
2158 ])
2159
2160
2161 dnl
2162 dnl Check if the user only wants a freestanding library implementation.
2163 dnl
2164 dnl --disable-hosted-libstdcxx will turn off most of the library build,
2165 dnl installing only the headers required by [17.4.1.3] and the language
2166 dnl support library.  More than that will be built (to keep the Makefiles
2167 dnl conveniently clean), but not installed.
2168 dnl
2169 dnl Sets:
2170 dnl  is_hosted  (yes/no)
2171 dnl
2172 dnl Defines:
2173 dnl  _GLIBCXX_HOSTED   (always defined, either to 1 or 0)
2174 dnl
2175 AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [
2176   AC_ARG_ENABLE([hosted-libstdcxx],
2177     AC_HELP_STRING([--disable-hosted-libstdcxx],
2178                    [only build freestanding C++ runtime support]),,
2179     [case "$host" in
2180         arm*-*-symbianelf*) 
2181             enable_hosted_libstdcxx=no
2182             ;;
2183         *) 
2184             enable_hosted_libstdcxx=yes
2185             ;;
2186      esac])
2187   if test "$enable_hosted_libstdcxx" = no; then
2188     AC_MSG_NOTICE([Only freestanding libraries will be built])
2189     is_hosted=no
2190     hosted_define=0
2191     enable_abi_check=no
2192     enable_libstdcxx_pch=no
2193   else
2194     is_hosted=yes
2195     hosted_define=1
2196   fi
2197   GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
2198   AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
2199     [Define to 1 if a full hosted library is built, or 0 if freestanding.])
2200 ])
2201
2202
2203 dnl
2204 dnl Check for template specializations for the 'long long' type.
2205 dnl The result determines only whether 'long long' I/O is enabled; things
2206 dnl like numeric_limits<> specializations are always available.
2207 dnl
2208 dnl --enable-long-long defines _GLIBCXX_USE_LONG_LONG
2209 dnl --disable-long-long leaves _GLIBCXX_USE_LONG_LONG undefined
2210 dnl  +  Usage:  GLIBCXX_ENABLE_LONG_LONG[(DEFAULT)]
2211 dnl       Where DEFAULT is either `yes' or `no'.
2212 dnl
2213 AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
2214   GLIBCXX_ENABLE(long-long,$1,,[enable template specializations for 'long long'])
2215   if test $enable_long_long = yes; then
2216     AC_DEFINE(_GLIBCXX_USE_LONG_LONG, 1, 
2217               [Define if code specialized for long long should be used.])
2218   fi
2219   AC_MSG_CHECKING([for enabled long long specializations])
2220   AC_MSG_RESULT([$enable_long_long])
2221 ])
2222
2223
2224 dnl
2225 dnl Check for decimal floating point.
2226 dnl See:
2227 dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
2228 dnl
2229 dnl This checks to see if the host supports decimal floating point types.
2230 dnl
2231 dnl Defines:
2232 dnl  _GLIBCXX_USE_DECIMAL_FLOAT
2233 dnl
2234 AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
2235
2236   # Fake what AC_TRY_COMPILE does, without linking as this is
2237   # unnecessary for this test.
2238
2239     cat > conftest.$ac_ext << EOF
2240 [#]line __oline__ "configure"
2241 int main()
2242 {
2243   _Decimal32 d1;
2244   _Decimal64 d2;
2245   _Decimal128 d3;
2246   return 0;
2247 }
2248 EOF
2249
2250     AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
2251     if AC_TRY_EVAL(ac_compile); then
2252       AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
2253       [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
2254       enable_dfp=yes
2255     else
2256       enable_dfp=no
2257     fi
2258     AC_MSG_RESULT($enable_dfp)
2259     rm -f conftest*
2260 ])
2261
2262 dnl
2263 dnl Check for template specializations for the 'wchar_t' type.
2264 dnl
2265 dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
2266 dnl --disable-wchar_t leaves _GLIBCXX_USE_WCHAR_T undefined
2267 dnl  +  Usage:  GLIBCXX_ENABLE_WCHAR_T[(DEFAULT)]
2268 dnl       Where DEFAULT is either `yes' or `no'.
2269 dnl
2270 dnl Necessary support must also be present.
2271 dnl
2272 AC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [
2273   GLIBCXX_ENABLE(wchar_t,$1,,[enable template specializations for 'wchar_t'])
2274
2275   # Test wchar.h for mbstate_t, which is needed for char_traits and fpos.
2276   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
2277   AC_MSG_CHECKING([for mbstate_t])
2278   AC_TRY_COMPILE([#include <wchar.h>],
2279   [mbstate_t teststate;],
2280   have_mbstate_t=yes, have_mbstate_t=no)
2281   AC_MSG_RESULT($have_mbstate_t)
2282   if test x"$have_mbstate_t" = xyes; then
2283     AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
2284   fi
2285
2286   # Test it always, for use in GLIBCXX_ENABLE_C99, together with
2287   # ac_has_wchar_h.
2288   AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
2289   
2290   if test x"$enable_wchar_t" = x"yes"; then
2291
2292     AC_LANG_SAVE
2293     AC_LANG_CPLUSPLUS
2294     
2295     if test x"$ac_has_wchar_h" = xyes &&
2296        test x"$ac_has_wctype_h" = xyes; then
2297       AC_TRY_COMPILE([#include <wchar.h>
2298                       #include <stddef.h>
2299                       wint_t i;
2300                       long l = WEOF;
2301                       long j = WCHAR_MIN;
2302                       long k = WCHAR_MAX;
2303                       namespace test
2304                       {
2305                         using ::btowc;
2306                         using ::fgetwc;
2307                         using ::fgetws;
2308                         using ::fputwc;
2309                         using ::fputws;
2310                         using ::fwide;
2311                         using ::fwprintf; 
2312                         using ::fwscanf;
2313                         using ::getwc;
2314                         using ::getwchar;
2315                         using ::mbrlen; 
2316                         using ::mbrtowc; 
2317                         using ::mbsinit; 
2318                         using ::mbsrtowcs; 
2319                         using ::putwc;
2320                         using ::putwchar;
2321                         using ::swprintf; 
2322                         using ::swscanf; 
2323                         using ::ungetwc;
2324                         using ::vfwprintf; 
2325                         using ::vswprintf; 
2326                         using ::vwprintf; 
2327                         using ::wcrtomb; 
2328                         using ::wcscat; 
2329                         using ::wcschr; 
2330                         using ::wcscmp; 
2331                         using ::wcscoll; 
2332                         using ::wcscpy; 
2333                         using ::wcscspn; 
2334                         using ::wcsftime; 
2335                         using ::wcslen;
2336                         using ::wcsncat; 
2337                         using ::wcsncmp; 
2338                         using ::wcsncpy; 
2339                         using ::wcspbrk;
2340                         using ::wcsrchr; 
2341                         using ::wcsrtombs; 
2342                         using ::wcsspn; 
2343                         using ::wcsstr;
2344                         using ::wcstod; 
2345                         using ::wcstok; 
2346                         using ::wcstol;
2347                         using ::wcstoul; 
2348                         using ::wcsxfrm; 
2349                         using ::wctob; 
2350                         using ::wmemchr;
2351                         using ::wmemcmp;
2352                         using ::wmemcpy;
2353                         using ::wmemmove;
2354                         using ::wmemset;
2355                         using ::wprintf; 
2356                         using ::wscanf; 
2357                       }
2358                      ],[],[], [enable_wchar_t=no])
2359     else
2360       enable_wchar_t=no
2361     fi
2362
2363     AC_LANG_RESTORE
2364   fi
2365
2366   if test x"$enable_wchar_t" = x"yes"; then
2367     AC_DEFINE(_GLIBCXX_USE_WCHAR_T, 1,
2368               [Define if code specialized for wchar_t should be used.])
2369   fi
2370
2371   AC_MSG_CHECKING([for enabled wchar_t specializations])
2372   AC_MSG_RESULT([$enable_wchar_t])
2373 ])
2374
2375
2376 dnl
2377 dnl Check to see if building and using a C++ precompiled header can be done.
2378 dnl
2379 dnl --enable-libstdcxx-pch=yes
2380 dnl default, this shows intent to use stdc++.h.gch If it looks like it
2381 dnl may work, after some light-hearted attempts to puzzle out compiler
2382 dnl support, flip bits on in include/Makefile.am
2383 dnl
2384 dnl --disable-libstdcxx-pch
2385 dnl turns off attempts to use or build stdc++.h.gch.
2386 dnl
2387 dnl Substs:
2388 dnl  glibcxx_PCHFLAGS
2389 dnl
2390 AC_DEFUN([GLIBCXX_ENABLE_PCH], [
2391   GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers])
2392   if test $enable_libstdcxx_pch = yes; then
2393     AC_CACHE_CHECK([for compiler with PCH support],
2394       [glibcxx_cv_prog_CXX_pch],
2395       [ac_save_CXXFLAGS="$CXXFLAGS"
2396        CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated"
2397        AC_LANG_SAVE
2398        AC_LANG_CPLUSPLUS
2399        echo '#include <math.h>' > conftest.h
2400        if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \
2401                           -o conftest.h.gch 1>&5 2>&1 &&
2402                 echo '#error "pch failed"' > conftest.h &&
2403           echo '#include "conftest.h"' > conftest.cc &&
2404                $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ;
2405        then
2406          glibcxx_cv_prog_CXX_pch=yes
2407        else
2408          glibcxx_cv_prog_CXX_pch=no
2409        fi
2410        rm -f conftest*
2411        CXXFLAGS=$ac_save_CXXFLAGS
2412        AC_LANG_RESTORE
2413       ])
2414     enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch
2415   fi
2416
2417   AC_MSG_CHECKING([for enabled PCH])
2418   AC_MSG_RESULT([$enable_libstdcxx_pch])
2419
2420   GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
2421   if test $enable_libstdcxx_pch = yes; then
2422     glibcxx_PCHFLAGS="-include bits/stdc++.h"
2423   else
2424     glibcxx_PCHFLAGS=""
2425   fi
2426   AC_SUBST(glibcxx_PCHFLAGS)
2427 ])
2428
2429
2430 dnl
2431 dnl Check for atomic builtins.
2432 dnl See:
2433 dnl http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html#Atomic-Builtins
2434 dnl
2435 dnl This checks to see if the host supports the compiler-generated
2436 dnl builtins for atomic operations for various integral sizes. Note, this 
2437 dnl is intended to be an all-or-nothing switch, so all the atomic operations
2438 dnl that are used should be checked.
2439 dnl
2440 dnl Note:
2441 dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
2442 dnl
2443 dnl Defines:
2444 dnl  _GLIBCXX_ATOMIC_BUILTINS_1 
2445 dnl  _GLIBCXX_ATOMIC_BUILTINS_2
2446 dnl  _GLIBCXX_ATOMIC_BUILTINS_4
2447 dnl  _GLIBCXX_ATOMIC_BUILTINS_8
2448 dnl
2449 AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
2450   AC_LANG_SAVE
2451   AC_LANG_CPLUSPLUS
2452   old_CXXFLAGS="$CXXFLAGS"
2453
2454   # Do link tests if possible, instead asm tests, limited to some platforms
2455   # see discussion in PR target/40134, PR libstdc++/40133 and the thread
2456   # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
2457   atomic_builtins_link_tests=no
2458   if test x$gcc_no_link != xyes; then
2459     # Can do link tests. Limit to some tested platforms
2460     case "$host" in
2461       *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
2462         atomic_builtins_link_tests=yes
2463         ;;
2464     esac
2465   fi
2466
2467   if test x$atomic_builtins_link_tests = xyes; then
2468
2469   # Do link tests.
2470
2471   CXXFLAGS="$CXXFLAGS -fno-exceptions"
2472
2473   AC_MSG_CHECKING([for atomic builtins for bool])
2474   AC_CACHE_VAL(glibcxx_cv_atomic_bool, [
2475     AC_TRY_LINK(
2476       [ ],
2477       [typedef bool atomic_type;
2478        atomic_type c1;
2479        atomic_type c2;
2480        const atomic_type c3(0);
2481        __sync_fetch_and_add(&c1, c2);
2482        __sync_val_compare_and_swap(&c1, c3, c2);
2483        __sync_lock_test_and_set(&c1, c3);
2484        __sync_lock_release(&c1);
2485        __sync_synchronize();],
2486       [glibcxx_cv_atomic_bool=yes],
2487       [glibcxx_cv_atomic_bool=no])
2488   ])    
2489   if test $glibcxx_cv_atomic_bool = yes; then
2490     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2491       [Define if builtin atomic operations for bool are supported on this host.])
2492   fi
2493   AC_MSG_RESULT($glibcxx_cv_atomic_bool)
2494
2495   AC_MSG_CHECKING([for atomic builtins for short])
2496   AC_CACHE_VAL(glibcxx_cv_atomic_short, [
2497     AC_TRY_LINK(
2498       [ ],
2499       [typedef short atomic_type;
2500        atomic_type c1;
2501        atomic_type c2;
2502        const atomic_type c3(0);
2503        __sync_fetch_and_add(&c1, c2);
2504        __sync_val_compare_and_swap(&c1, c3, c2);
2505        __sync_lock_test_and_set(&c1, c3);
2506        __sync_lock_release(&c1);
2507        __sync_synchronize();],
2508       [glibcxx_cv_atomic_short=yes],
2509       [glibcxx_cv_atomic_short=no])
2510   ])    
2511   if test $glibcxx_cv_atomic_short = yes; then
2512     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2513       [Define if builtin atomic operations for short are supported on this host.])
2514   fi
2515   AC_MSG_RESULT($glibcxx_cv_atomic_short)
2516
2517   AC_MSG_CHECKING([for atomic builtins for int])
2518   AC_CACHE_VAL(glibcxx_cv_atomic_int, [
2519     AC_TRY_LINK(
2520       [ ],
2521       [typedef int atomic_type;
2522        atomic_type c1;
2523        atomic_type c2;
2524        const atomic_type c3(0);
2525        __sync_fetch_and_add(&c1, c2);
2526        __sync_val_compare_and_swap(&c1, c3, c2);
2527        __sync_lock_test_and_set(&c1, c3);
2528        __sync_lock_release(&c1);
2529        __sync_synchronize();],
2530       [glibcxx_cv_atomic_int=yes],
2531       [glibcxx_cv_atomic_int=no])
2532   ])    
2533   if test $glibcxx_cv_atomic_int = yes; then
2534     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2535       [Define if builtin atomic operations for int are supported on this host.])
2536   fi
2537   AC_MSG_RESULT($glibcxx_cv_atomic_int)
2538
2539   AC_MSG_CHECKING([for atomic builtins for long long])
2540   AC_CACHE_VAL(glibcxx_cv_atomic_long_long, [
2541     AC_TRY_LINK(
2542       [ ],
2543       [typedef long long atomic_type;
2544        atomic_type c1;
2545        atomic_type c2;
2546        const atomic_type c3(0);
2547        __sync_fetch_and_add(&c1, c2);
2548        __sync_val_compare_and_swap(&c1, c3, c2);
2549        __sync_lock_test_and_set(&c1, c3);
2550        __sync_lock_release(&c1);
2551        __sync_synchronize();],
2552       [glibcxx_cv_atomic_long_long=yes],
2553       [glibcxx_cv_atomic_long_long=no])
2554   ])    
2555   if test $glibcxx_cv_atomic_long_long = yes; then
2556     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2557       [Define if builtin atomic operations for long long are supported on this host.])
2558   fi
2559   AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
2560
2561   else
2562
2563   # Do asm tests.
2564
2565   # Compile unoptimized.
2566   CXXFLAGS='-O0 -S'
2567
2568   # Fake what AC_TRY_COMPILE does.
2569
2570     cat > conftest.$ac_ext << EOF
2571 [#]line __oline__ "configure"
2572 int main()
2573 {
2574   typedef bool atomic_type;
2575   atomic_type c1;
2576   atomic_type c2;
2577   const atomic_type c3(0);
2578   __sync_fetch_and_add(&c1, c2);
2579   __sync_val_compare_and_swap(&c1, c3, c2);
2580   __sync_lock_test_and_set(&c1, c3);
2581   __sync_lock_release(&c1);
2582   __sync_synchronize();
2583   return 0;
2584 }
2585 EOF
2586
2587     AC_MSG_CHECKING([for atomic builtins for bool])
2588     if AC_TRY_EVAL(ac_compile); then
2589       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2590         glibcxx_cv_atomic_bool=no
2591       else
2592       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2593       [Define if builtin atomic operations for bool are supported on this host.])
2594         glibcxx_cv_atomic_bool=yes
2595       fi
2596     fi
2597     AC_MSG_RESULT($glibcxx_cv_atomic_bool)
2598     rm -f conftest*
2599
2600     cat > conftest.$ac_ext << EOF
2601 [#]line __oline__ "configure"
2602 int main()
2603 {
2604   typedef short atomic_type;
2605   atomic_type c1;
2606   atomic_type c2;
2607   const atomic_type c3(0);
2608   __sync_fetch_and_add(&c1, c2);
2609   __sync_val_compare_and_swap(&c1, c3, c2);
2610   __sync_lock_test_and_set(&c1, c3);
2611   __sync_lock_release(&c1);
2612   __sync_synchronize();
2613   return 0;
2614 }
2615 EOF
2616
2617     AC_MSG_CHECKING([for atomic builtins for short])
2618     if AC_TRY_EVAL(ac_compile); then
2619       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2620         glibcxx_cv_atomic_short=no
2621       else
2622       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2623       [Define if builtin atomic operations for short are supported on this host.])
2624         glibcxx_cv_atomic_short=yes
2625       fi
2626     fi
2627     AC_MSG_RESULT($glibcxx_cv_atomic_short)
2628     rm -f conftest*
2629
2630     cat > conftest.$ac_ext << EOF
2631 [#]line __oline__ "configure"
2632 int main()
2633 {
2634   // NB: _Atomic_word not necessarily int. 
2635   typedef int atomic_type;
2636   atomic_type c1;
2637   atomic_type c2;
2638   const atomic_type c3(0);
2639   __sync_fetch_and_add(&c1, c2);
2640   __sync_val_compare_and_swap(&c1, c3, c2);
2641   __sync_lock_test_and_set(&c1, c3);
2642   __sync_lock_release(&c1);
2643   __sync_synchronize();
2644   return 0;
2645 }
2646 EOF
2647
2648     AC_MSG_CHECKING([for atomic builtins for int])
2649     if AC_TRY_EVAL(ac_compile); then
2650       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2651         glibcxx_cv_atomic_int=no
2652       else
2653       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2654         [Define if builtin atomic operations for int are supported on this host.])
2655         glibcxx_cv_atomic_int=yes
2656       fi
2657     fi
2658     AC_MSG_RESULT($glibcxx_cv_atomic_int)
2659     rm -f conftest*
2660
2661     cat > conftest.$ac_ext << EOF
2662 [#]line __oline__ "configure"
2663 int main()
2664 {
2665   typedef long long atomic_type;
2666   atomic_type c1;
2667   atomic_type c2;
2668   const atomic_type c3(0);
2669   __sync_fetch_and_add(&c1, c2);
2670   __sync_val_compare_and_swap(&c1, c3, c2);
2671   __sync_lock_test_and_set(&c1, c3);
2672   __sync_lock_release(&c1);
2673   __sync_synchronize();
2674   return 0;
2675 }
2676 EOF
2677
2678     AC_MSG_CHECKING([for atomic builtins for long long])
2679     if AC_TRY_EVAL(ac_compile); then
2680       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2681         glibcxx_cv_atomic_long_long=no
2682       else
2683       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2684       [Define if builtin atomic operations for long long are supported on this host.])
2685         glibcxx_cv_atomic_long_long=yes
2686       fi
2687     fi
2688     AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
2689     rm -f conftest*
2690
2691   fi
2692
2693   CXXFLAGS="$old_CXXFLAGS"
2694   AC_LANG_RESTORE
2695
2696   # Set atomicity_dir to builtins if either of above tests pass.
2697   if test $glibcxx_cv_atomic_int = yes || test $glibcxx_cv_atomic_bool = yes ; then
2698     atomicity_dir=cpu/generic/atomicity_builtins
2699   fi
2700
2701   # If still generic, set to mutex.
2702   if test $atomicity_dir = "cpu/generic" ; then
2703     atomicity_dir=cpu/generic/atomicity_mutex
2704     AC_MSG_WARN([No native atomic operations are provided for this platform.])
2705       if test "x$target_thread_file" = xsingle; then
2706         AC_MSG_WARN([They cannot be faked when thread support is disabled.])
2707         AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
2708       else
2709         AC_MSG_WARN([They will be faked using a mutex.])
2710         AC_MSG_WARN([Performance of certain classes will degrade as a result.])
2711       fi
2712   fi
2713
2714 ])
2715
2716
2717 dnl
2718 dnl Check for exception handling support.  If an explicit enable/disable
2719 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
2720 dnl target may or may not support call frame exceptions.
2721 dnl
2722 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
2723 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
2724 dnl Neither one forces an attempt at detection.
2725 dnl
2726 dnl Defines:
2727 dnl  _GLIBCXX_SJLJ_EXCEPTIONS if the compiler is configured for it
2728 dnl
2729 AC_DEFUN([GLIBCXX_ENABLE_SJLJ_EXCEPTIONS], [
2730   AC_MSG_CHECKING([for exception model to use])
2731   AC_LANG_SAVE
2732   AC_LANG_CPLUSPLUS
2733   GLIBCXX_ENABLE(sjlj-exceptions,auto,,
2734     [force use of builtin_setjmp for exceptions],
2735     [permit yes|no|auto])
2736
2737   if test $enable_sjlj_exceptions = auto; then
2738     # Botheration.  Now we've got to detect the exception model.  Link tests
2739     # against libgcc.a are problematic since we've not been given proper -L
2740     # bits for single-tree newlib and libgloss.
2741     #
2742     # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
2743     cat > conftest.$ac_ext << EOF
2744 [#]line __oline__ "configure"
2745 struct S { ~S(); };
2746 void bar();
2747 void foo()
2748 {
2749   S s;
2750   bar();
2751 }
2752 EOF
2753     old_CXXFLAGS="$CXXFLAGS"
2754     CXXFLAGS=-S
2755     if AC_TRY_EVAL(ac_compile); then
2756       if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
2757         enable_sjlj_exceptions=yes
2758       elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
2759         enable_sjlj_exceptions=no
2760       elif grep __cxa_end_cleanup conftest.s >/dev/null 2>&1 ; then
2761         enable_sjlj_exceptions=no
2762       fi
2763     fi
2764     CXXFLAGS="$old_CXXFLAGS"
2765     rm -f conftest*
2766   fi
2767
2768   # This is a tad weird, for hysterical raisins.  We have to map
2769   # enable/disable to two different models.
2770   case $enable_sjlj_exceptions in
2771     yes)
2772       AC_DEFINE(_GLIBCXX_SJLJ_EXCEPTIONS, 1,
2773         [Define if the compiler is configured for setjmp/longjmp exceptions.])
2774       ac_exception_model_name=sjlj
2775       ;;
2776     no)
2777       ac_exception_model_name="call frame"
2778       ;;
2779     *)
2780       AC_MSG_ERROR([unable to detect exception model])
2781       ;;
2782   esac
2783  AC_LANG_RESTORE
2784  AC_MSG_RESULT($ac_exception_model_name)
2785 ])
2786
2787
2788 dnl
2789 dnl Allow visibility attributes to be used on namespaces, objects, etc.
2790 dnl
2791 dnl --enable-visibility enables attempt to use visibility attributes.
2792 dnl --disable-visibility turns off all use of visibility attributes.
2793 dnl  +  Usage:  GLIBCXX_ENABLE_VISIBILITY[(DEFAULT)]
2794 dnl       Where DEFAULT is 'yes'.
2795 dnl
2796 AC_DEFUN([GLIBCXX_ENABLE_VISIBILITY], [
2797 GLIBCXX_ENABLE(visibility,$1,,[enables visibility safe usage])
2798
2799 if test x$enable_visibility = xyes ; then
2800   dnl all hail libgfortran
2801   dnl Check whether the target supports hidden visibility.
2802   AC_CACHE_CHECK([whether the target supports hidden visibility],
2803                  glibcxx_cv_have_attribute_visibility, [
2804   save_CFLAGS="$CFLAGS"
2805   CFLAGS="$CFLAGS -Werror"
2806   AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
2807                  [], glibcxx_cv_have_attribute_visibility=yes,
2808                  glibcxx_cv_have_attribute_visibility=no)
2809   CFLAGS="$save_CFLAGS"])
2810   if test $glibcxx_cv_have_attribute_visibility = no; then
2811     enable_visibility=no
2812   fi
2813 fi
2814
2815 GLIBCXX_CONDITIONAL(ENABLE_VISIBILITY, test $enable_visibility = yes)
2816 AC_MSG_NOTICE([visibility supported: $enable_visibility])
2817 ])
2818
2819
2820 dnl
2821 dnl Add version tags to symbols in shared library (or not), additionally
2822 dnl marking other symbols as private/local (or not).
2823 dnl
2824 dnl --enable-symvers=style adds a version script to the linker call when
2825 dnl       creating the shared library.  The choice of version script is
2826 dnl       controlled by 'style'.
2827 dnl --disable-symvers does not.
2828 dnl  +  Usage:  GLIBCXX_ENABLE_SYMVERS[(DEFAULT)]
2829 dnl       Where DEFAULT is either 'yes' or 'no'.  Passing `yes' tries to
2830 dnl       choose a default style based on linker characteristics.  Passing
2831 dnl       'no' disables versioning.
2832 dnl
2833 AC_DEFUN([GLIBCXX_ENABLE_SYMVERS], [
2834
2835 GLIBCXX_ENABLE(symvers,$1,[=STYLE],
2836   [enables symbol versioning of the shared library],
2837   [permit yes|no|gnu|gnu-versioned-namespace|darwin|darwin-export])
2838
2839 # If we never went through the GLIBCXX_CHECK_LINKER_FEATURES macro, then we
2840 # don't know enough about $LD to do tricks...
2841 AC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES])
2842
2843 # Turn a 'yes' into a suitable default.
2844 if test x$enable_symvers = xyes ; then
2845   if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then
2846     enable_symvers=no
2847   else
2848     if test $with_gnu_ld = yes ; then
2849       case ${target_os} in
2850         hpux*)
2851           enable_symvers=no ;;
2852         *)
2853           enable_symvers=gnu ;;
2854       esac
2855     else
2856       case ${target_os} in
2857         darwin*)
2858           enable_symvers=darwin ;;
2859         *)
2860           enable_symvers=no ;;
2861       esac
2862     fi
2863   fi
2864 fi
2865
2866 # Check to see if 'darwin' or 'darwin-export' can win.
2867 if test x$enable_symvers = xdarwin-export ; then
2868     enable_symvers=darwin
2869 fi
2870
2871 # Check to see if 'gnu' can win.
2872 if test $enable_symvers = gnu || test $enable_symvers = gnu-versioned-namespace; then
2873   # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2874   AC_MSG_CHECKING([for shared libgcc])
2875   ac_save_CFLAGS="$CFLAGS"
2876   CFLAGS=' -lgcc_s'
2877   AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes, glibcxx_shared_libgcc=no)
2878   CFLAGS="$ac_save_CFLAGS"
2879   if test $glibcxx_shared_libgcc = no; then
2880     cat > conftest.c <<EOF
2881 int main (void) { return 0; }
2882 EOF
2883 changequote(,)dnl
2884     glibcxx_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
2885                              -shared -shared-libgcc -o conftest.so \
2886                              conftest.c -v 2>&1 >/dev/null \
2887                              | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
2888 changequote([,])dnl
2889     rm -f conftest.c conftest.so
2890     if test x${glibcxx_libgcc_s_suffix+set} = xset; then
2891       CFLAGS=" -lgcc_s$glibcxx_libgcc_s_suffix"
2892       AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes)
2893       CFLAGS="$ac_save_CFLAGS"
2894     fi
2895   fi
2896   AC_MSG_RESULT($glibcxx_shared_libgcc)
2897
2898   # For GNU ld, we need at least this version.  The format is described in
2899   # GLIBCXX_CHECK_LINKER_FEATURES above.
2900   glibcxx_min_gnu_ld_version=21400
2901
2902   # If no shared libgcc, can't win.
2903   if test $glibcxx_shared_libgcc != yes; then
2904       AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
2905       AC_MSG_WARN([=== you are not building a shared libgcc_s.])
2906       AC_MSG_WARN([=== Symbol versioning will be disabled.])
2907       enable_symvers=no
2908   elif test $with_gnu_ld != yes ; then
2909     # just fail for now
2910     AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
2911     AC_MSG_WARN([=== you are not using the GNU linker.])
2912     AC_MSG_WARN([=== Symbol versioning will be disabled.])
2913     enable_symvers=no
2914   elif test $glibcxx_ld_is_gold = yes ; then
2915     : All versions of gold support symbol versioning.
2916   elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
2917     # The right tools, the right setup, but too old.  Fallbacks?
2918     AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for)
2919     AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
2920     AC_MSG_WARN(=== You would need to upgrade your binutils to version)
2921     AC_MSG_WARN(=== $glibcxx_min_gnu_ld_version or later and rebuild GCC.)
2922     AC_MSG_WARN([=== Symbol versioning will be disabled.])
2923     enable_symvers=no
2924   fi
2925 fi
2926
2927 # Everything parsed; figure out what file to use.
2928 case $enable_symvers in
2929   no)
2930     SYMVER_FILE=config/abi/pre/none.ver
2931     ;;
2932   gnu)
2933     SYMVER_FILE=config/abi/pre/gnu.ver
2934     AC_DEFINE(_GLIBCXX_SYMVER_GNU, 1, 
2935               [Define to use GNU versioning in the shared library.])
2936     ;;
2937   gnu-versioned-namespace)
2938     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
2939     AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1, 
2940               [Define to use GNU namespace versioning in the shared library.])
2941     ;;
2942   darwin)
2943     SYMVER_FILE=config/abi/pre/gnu.ver
2944     AC_DEFINE(_GLIBCXX_SYMVER_DARWIN, 1, 
2945               [Define to use darwin versioning in the shared library.])
2946     ;;
2947 esac
2948
2949 if test x$enable_symvers != xno ; then
2950   AC_DEFINE(_GLIBCXX_SYMVER, 1,
2951          [Define to use symbol versioning in the shared library.])
2952 fi
2953
2954 AC_CACHE_CHECK([whether the target supports .symver directive],
2955                glibcxx_cv_have_as_symver_directive, [
2956   AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
2957                  [], glibcxx_cv_have_as_symver_directive=yes,
2958                  glibcxx_cv_have_as_symver_directive=no)])
2959 if test $glibcxx_cv_have_as_symver_directive = yes; then
2960   AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
2961     [Define to 1 if the target assembler supports .symver directive.])
2962 fi
2963
2964 AC_SUBST(SYMVER_FILE)
2965 AC_SUBST(port_specific_symbol_files)
2966 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
2967 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU, test $enable_symvers = gnu)
2968 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU_NAMESPACE, test $enable_symvers = gnu-versioned-namespace)
2969 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_DARWIN, test $enable_symvers = darwin)
2970 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
2971
2972 # Now, set up compatibility support, if any.
2973 # In addition, need this to deal with std::size_t mangling in
2974 # src/compatibility.cc.  In a perfect world, could use
2975 # typeid(std::size_t).name()[0] to do direct substitution.
2976 AC_MSG_CHECKING([for size_t as unsigned int])
2977 ac_save_CFLAGS="$CFLAGS"
2978 CFLAGS="-Werror"
2979 AC_TRY_COMPILE(, [__SIZE_TYPE__* stp; unsigned int* uip; stp = uip;], 
2980                  [glibcxx_size_t_is_i=yes], [glibcxx_size_t_is_i=no])
2981 CFLAGS=$ac_save_CFLAGS
2982 if test "$glibcxx_size_t_is_i" = yes; then
2983   AC_DEFINE(_GLIBCXX_SIZE_T_IS_UINT, 1, [Define if size_t is unsigned int.])
2984 fi
2985 AC_MSG_RESULT([$glibcxx_size_t_is_i])
2986
2987 AC_MSG_CHECKING([for ptrdiff_t as int])
2988 ac_save_CFLAGS="$CFLAGS"
2989 CFLAGS="-Werror"
2990 AC_TRY_COMPILE(, [__PTRDIFF_TYPE__* ptp; int* ip; ptp = ip;], 
2991                  [glibcxx_ptrdiff_t_is_i=yes], [glibcxx_ptrdiff_t_is_i=no])
2992 CFLAGS=$ac_save_CFLAGS
2993 if test "$glibcxx_ptrdiff_t_is_i" = yes; then
2994   AC_DEFINE(_GLIBCXX_PTRDIFF_T_IS_INT, 1, [Define if ptrdiff_t is int.])
2995 fi
2996 AC_MSG_RESULT([$glibcxx_ptrdiff_t_is_i])
2997 ])
2998
2999
3000 dnl
3001 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
3002 dnl We must stage the required headers so that they will be installed
3003 dnl with the library (unlike libgcc, the STL implementation is provided
3004 dnl solely within headers).  Since we must not inject random user-space
3005 dnl macro names into user-provided C++ code, we first stage into <file>-in
3006 dnl and process to <file> with an output command.  The reason for a two-
3007 dnl stage process here is to correctly handle $srcdir!=$objdir without
3008 dnl having to write complex code (the sed commands to clean the macro
3009 dnl namespace are complex and fragile enough as it is).  We must also
3010 dnl add a relative path so that -I- is supported properly.
3011 dnl
3012 dnl Substs:
3013 dnl  glibcxx_thread_h
3014 dnl
3015 dnl Defines:
3016 dnl  HAVE_GTHR_DEFAULT
3017 dnl
3018 AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
3019   AC_MSG_CHECKING([for thread model used by GCC])
3020   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
3021   AC_MSG_RESULT([$target_thread_file])
3022
3023   if test $target_thread_file != single; then
3024     AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
3025               [Define if gthr-default.h exists 
3026               (meaning that threading support is enabled).])
3027   fi
3028
3029   glibcxx_thread_h=gthr-$target_thread_file.h
3030
3031   dnl Check for __GTHREADS define.
3032   gthread_file=${toplevel_srcdir}/gcc/${glibcxx_thread_h}
3033   if grep __GTHREADS $gthread_file >/dev/null 2>&1 ; then
3034     enable_thread=yes
3035   else
3036    enable_thread=no
3037   fi
3038
3039   AC_SUBST(glibcxx_thread_h)
3040 ])
3041
3042
3043 dnl
3044 dnl Check if gthread implementation defines the types and functions
3045 dnl required by the c++0x thread library.  Conforming gthread
3046 dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
3047 dnl
3048 AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
3049   AC_LANG_SAVE
3050   AC_LANG_CPLUSPLUS
3051
3052   ac_save_CXXFLAGS="$CXXFLAGS"
3053   CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc"
3054
3055   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
3056   case $target_thread_file in
3057     posix)
3058       CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
3059   esac
3060
3061   AC_MSG_CHECKING([for gthreads library])
3062
3063   AC_TRY_COMPILE([#include "gthr.h"],
3064     [
3065       #ifndef __GTHREADS_CXX0X
3066       #error
3067       #endif
3068
3069       // In case of POSIX threads check _POSIX_TIMEOUTS too.
3070       #if (defined(_PTHREADS) \
3071            && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
3072       #error
3073       #endif
3074     ], [ac_has_gthreads=yes], [ac_has_gthreads=no])
3075
3076   AC_MSG_RESULT([$ac_has_gthreads])
3077
3078   if test x"$ac_has_gthreads" = x"yes"; then
3079     AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
3080               [Define if gthreads library is available.])
3081   fi
3082
3083   CXXFLAGS="$ac_save_CXXFLAGS"
3084   AC_LANG_RESTORE
3085 ])
3086
3087
3088 # Check whether LC_MESSAGES is available in <locale.h>.
3089 # Ulrich Drepper <drepper@cygnus.com>, 1995.
3090 #
3091 # This file file be copied and used freely without restrictions.  It can
3092 # be used in projects which are not available under the GNU Public License
3093 # but which still want to provide support for the GNU gettext functionality.
3094 # Please note that the actual code is *not* freely available.
3095 AC_DEFUN([AC_LC_MESSAGES], [
3096   AC_CHECK_HEADER(locale.h, [
3097     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
3098       [AC_TRY_COMPILE([#include <locale.h>], [return LC_MESSAGES],
3099        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
3100     if test $ac_cv_val_LC_MESSAGES = yes; then
3101       AC_DEFINE(HAVE_LC_MESSAGES, 1, 
3102                 [Define if LC_MESSAGES is available in <locale.h>.])
3103     fi
3104   ])
3105 ])
3106
3107 # Macros from the top-level gcc directory.
3108 m4_include([../config/tls.m4])
3109