OSDN Git Service

PR c++/42844
[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   AC_MSG_RESULT($enable_libstdcxx_time)
1081
1082   if test x"$enable_libstdcxx_time" != x"no"; then
1083
1084     if test x"$enable_libstdcxx_time" = x"rt"; then
1085       AC_SEARCH_LIBS(clock_gettime, [rt posix4])
1086       AC_SEARCH_LIBS(nanosleep, [rt posix4])
1087     else
1088       AC_SEARCH_LIBS(clock_gettime, [posix4])
1089       AC_SEARCH_LIBS(nanosleep, [posix4])
1090     fi
1091
1092     case "$ac_cv_search_clock_gettime" in
1093       -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
1094       ;;
1095     esac
1096     case "$ac_cv_search_nanosleep" in
1097       -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
1098       ;;
1099     esac
1100
1101     AC_SEARCH_LIBS(sched_yield, [rt posix4])
1102
1103     case "$ac_cv_search_sched_yield" in
1104       -lposix4*)
1105       GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1106       AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1107                 [ Defined if sched_yield is available. ])
1108       ;;
1109       -lrt*)
1110       if test x"$enable_libstdcxx_time" = x"rt"; then
1111         GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1112         AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, 
1113                   [ Defined if sched_yield is available. ])
1114       fi
1115       ;;
1116       *)
1117       AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1118                 [ Defined if sched_yield is available. ])
1119       ;;
1120     esac
1121
1122     AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
1123
1124     if test x"$ac_has_unistd_h" = x"yes"; then
1125       AC_MSG_CHECKING([for monotonic clock])
1126       AC_TRY_LINK(
1127         [#include <unistd.h>
1128          #include <time.h>
1129         ],
1130         [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
1131           timespec tp;     
1132          #endif
1133           clock_gettime(CLOCK_MONOTONIC, &tp);
1134         ], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
1135
1136       AC_MSG_RESULT($ac_has_clock_monotonic)   
1137     
1138       AC_MSG_CHECKING([for realtime clock])
1139       AC_TRY_LINK(
1140         [#include <unistd.h>
1141          #include <time.h>
1142         ],
1143         [#if _POSIX_TIMERS > 0
1144           timespec tp;      
1145          #endif
1146           clock_gettime(CLOCK_REALTIME, &tp);
1147         ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
1148
1149       AC_MSG_RESULT($ac_has_clock_realtime)
1150
1151       AC_MSG_CHECKING([for nanosleep])
1152       AC_TRY_LINK(
1153         [#include <unistd.h>
1154          #include <time.h>
1155         ],
1156         [#if _POSIX_TIMERS > 0
1157           timespec tp;
1158          #endif
1159           nanosleep(&tp, 0);
1160         ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
1161
1162       AC_MSG_RESULT($ac_has_nanosleep)
1163     fi
1164   fi
1165
1166   if test x"$ac_has_clock_monotonic" = x"yes"; then
1167     AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
1168       [ Defined if clock_gettime has monotonic clock support. ])
1169   fi
1170
1171   if test x"$ac_has_clock_realtime" = x"yes"; then
1172     AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1,
1173       [ Defined if clock_gettime has realtime clock support. ])
1174   fi
1175
1176   if test x"$ac_has_nanosleep" = x"yes"; then
1177     AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
1178       [ Defined if nanosleep is available. ])
1179   fi
1180
1181   AC_SUBST(GLIBCXX_LIBS)
1182
1183   CXXFLAGS="$ac_save_CXXFLAGS"
1184   LIBS="$ac_save_LIBS"
1185   AC_LANG_RESTORE
1186 ])
1187
1188 dnl
1189 dnl Check for gettimeofday, used in the implementation of 20.8.5
1190 dnl [time.clock] in the current C++0x working draft.
1191 dnl
1192 AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
1193   
1194   AC_MSG_CHECKING([for gettimeofday])
1195
1196   AC_LANG_SAVE
1197   AC_LANG_CPLUSPLUS
1198   ac_save_CXXFLAGS="$CXXFLAGS"
1199   CXXFLAGS="$CXXFLAGS -fno-exceptions"
1200   
1201   ac_has_gettimeofday=no;
1202   AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
1203   if test x"$ac_has_sys_time_h" = x"yes"; then
1204     AC_MSG_CHECKING([for gettimeofday])
1205     GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>],
1206       [timeval tv; gettimeofday(&tv, 0);],
1207       [ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])
1208     
1209     AC_MSG_RESULT($ac_has_gettimeofday)
1210   fi
1211   
1212   if test x"$ac_has_gettimeofday" = x"yes"; then
1213     AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1,
1214       [ Defined if gettimeofday is available. ])
1215   fi
1216   
1217   CXXFLAGS="$ac_save_CXXFLAGS"
1218   AC_LANG_RESTORE
1219 ])
1220
1221 dnl
1222 dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
1223 dnl facilities in Chapter 8, "C compatibility".
1224 dnl
1225 AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
1226
1227   AC_LANG_SAVE
1228   AC_LANG_CPLUSPLUS
1229
1230   # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
1231   # undefined and fake C99 facilities may be spuriously enabled.
1232   ac_save_CXXFLAGS="$CXXFLAGS"
1233   CXXFLAGS="$CXXFLAGS -std=c++98"
1234
1235   # Check for the existence of <complex.h> complex math functions used
1236   # by tr1/complex.
1237   AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
1238   ac_c99_complex_tr1=no;
1239   if test x"$ac_has_complex_h" = x"yes"; then
1240     AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>])
1241     AC_TRY_COMPILE([#include <complex.h>],
1242                    [typedef __complex__ float float_type; float_type tmpf;
1243                     cacosf(tmpf);
1244                     casinf(tmpf);
1245                     catanf(tmpf);
1246                     cacoshf(tmpf);
1247                     casinhf(tmpf);
1248                     catanhf(tmpf);
1249                     typedef __complex__ double double_type; double_type tmpd;
1250                     cacos(tmpd);
1251                     casin(tmpd);
1252                     catan(tmpd);
1253                     cacosh(tmpd);
1254                     casinh(tmpd);
1255                     catanh(tmpd);
1256                     typedef __complex__ long double ld_type; ld_type tmpld;
1257                     cacosl(tmpld);
1258                     casinl(tmpld);
1259                     catanl(tmpld);
1260                     cacoshl(tmpld);
1261                     casinhl(tmpld);
1262                     catanhl(tmpld);
1263                    ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no])
1264   fi
1265   AC_MSG_RESULT($ac_c99_complex_tr1)
1266   if test x"$ac_c99_complex_tr1" = x"yes"; then
1267     AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1,
1268               [Define if C99 functions in <complex.h> should be used in
1269               <tr1/complex>. Using compiler builtins for these functions
1270               requires corresponding C99 library functions to be present.])
1271   fi
1272
1273   # Check for the existence of <ctype.h> functions.
1274   AC_MSG_CHECKING([for ISO C99 support to TR1 in <ctype.h>])
1275   AC_CACHE_VAL(glibcxx_cv_c99_ctype_tr1, [
1276   AC_TRY_COMPILE([#include <ctype.h>],
1277                  [int ch;
1278                   int ret;
1279                   ret = isblank(ch);
1280                  ],[glibcxx_cv_c99_ctype_tr1=yes],
1281                    [glibcxx_cv_c99_ctype_tr1=no])
1282   ])
1283   AC_MSG_RESULT($glibcxx_cv_c99_ctype_tr1)
1284   if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then
1285     AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
1286               [Define if C99 functions in <ctype.h> should be imported in
1287               <tr1/cctype> in namespace std::tr1.])
1288   fi
1289
1290   # Check for the existence of <fenv.h> functions.
1291   AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
1292   ac_c99_fenv_tr1=no;
1293   if test x"$ac_has_fenv_h" = x"yes"; then
1294     AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>])
1295     AC_TRY_COMPILE([#include <fenv.h>],
1296                    [int except, mode;
1297                     fexcept_t* pflag;
1298                     fenv_t* penv;
1299                     int ret;
1300                     ret = feclearexcept(except);
1301                     ret = fegetexceptflag(pflag, except);
1302                     ret = feraiseexcept(except);
1303                     ret = fesetexceptflag(pflag, except);
1304                     ret = fetestexcept(except);
1305                     ret = fegetround();
1306                     ret = fesetround(mode);
1307                     ret = fegetenv(penv);
1308                     ret = feholdexcept(penv);
1309                     ret = fesetenv(penv);
1310                     ret = feupdateenv(penv);
1311                    ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no])
1312   fi
1313   AC_MSG_RESULT($ac_c99_fenv_tr1)
1314   if test x"$ac_c99_fenv_tr1" = x"yes"; then
1315     AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1,
1316               [Define if C99 functions in <fenv.h> should be imported in
1317               <tr1/cfenv> in namespace std::tr1.])
1318   fi
1319
1320   # Check for the existence of <stdint.h> types.
1321   AC_MSG_CHECKING([for ISO C99 support to TR1 in <stdint.h>])
1322   AC_CACHE_VAL(glibcxx_cv_c99_stdint_tr1, [
1323   AC_TRY_COMPILE([#define __STDC_LIMIT_MACROS
1324                   #define __STDC_CONSTANT_MACROS
1325                   #include <stdint.h>],
1326                  [typedef int8_t          my_int8_t;
1327                   my_int8_t               i8 = INT8_MIN;
1328                   i8 = INT8_MAX;
1329                   typedef int16_t         my_int16_t;
1330                   my_int16_t              i16 = INT16_MIN;
1331                   i16 = INT16_MAX;
1332                   typedef int32_t         my_int32_t;
1333                   my_int32_t              i32 = INT32_MIN;
1334                   i32 = INT32_MAX;
1335                   typedef int64_t         my_int64_t;
1336                   my_int64_t              i64 = INT64_MIN;
1337                   i64 = INT64_MAX;
1338                   typedef int_fast8_t     my_int_fast8_t;
1339                   my_int_fast8_t          if8 = INT_FAST8_MIN;
1340                   if8 = INT_FAST8_MAX;
1341                   typedef int_fast16_t    my_int_fast16_t;
1342                   my_int_fast16_t         if16 = INT_FAST16_MIN;
1343                   if16 = INT_FAST16_MAX;
1344                   typedef int_fast32_t    my_int_fast32_t;
1345                   my_int_fast32_t         if32 = INT_FAST32_MIN;
1346                   if32 = INT_FAST32_MAX;
1347                   typedef int_fast64_t    my_int_fast64_t;
1348                   my_int_fast64_t         if64 = INT_FAST64_MIN;
1349                   if64 = INT_FAST64_MAX;
1350                   typedef int_least8_t    my_int_least8_t;
1351                   my_int_least8_t         il8 = INT_LEAST8_MIN;
1352                   il8 = INT_LEAST8_MAX;
1353                   typedef int_least16_t   my_int_least16_t;
1354                   my_int_least16_t        il16 = INT_LEAST16_MIN;
1355                   il16 = INT_LEAST16_MAX;
1356                   typedef int_least32_t   my_int_least32_t;
1357                   my_int_least32_t        il32 = INT_LEAST32_MIN;
1358                   il32 = INT_LEAST32_MAX;
1359                   typedef int_least64_t   my_int_least64_t;
1360                   my_int_least64_t        il64 = INT_LEAST64_MIN;
1361                   il64 = INT_LEAST64_MAX;
1362                   typedef intmax_t        my_intmax_t;
1363                   my_intmax_t             im = INTMAX_MAX;
1364                   im = INTMAX_MIN;
1365                   typedef intptr_t        my_intptr_t;
1366                   my_intptr_t             ip = INTPTR_MAX;
1367                   ip = INTPTR_MIN;
1368                   typedef uint8_t         my_uint8_t;
1369                   my_uint8_t              ui8 = UINT8_MAX;
1370                   ui8 = UINT8_MAX;
1371                   typedef uint16_t        my_uint16_t;
1372                   my_uint16_t             ui16 = UINT16_MAX;
1373                   ui16 = UINT16_MAX;
1374                   typedef uint32_t        my_uint32_t;
1375                   my_uint32_t             ui32 = UINT32_MAX;
1376                   ui32 = UINT32_MAX;
1377                   typedef uint64_t        my_uint64_t;
1378                   my_uint64_t             ui64 = UINT64_MAX;
1379                   ui64 = UINT64_MAX;
1380                   typedef uint_fast8_t    my_uint_fast8_t;
1381                   my_uint_fast8_t         uif8 = UINT_FAST8_MAX;
1382                   uif8 = UINT_FAST8_MAX;
1383                   typedef uint_fast16_t   my_uint_fast16_t;
1384                   my_uint_fast16_t        uif16 = UINT_FAST16_MAX;
1385                   uif16 = UINT_FAST16_MAX;
1386                   typedef uint_fast32_t   my_uint_fast32_t;
1387                   my_uint_fast32_t        uif32 = UINT_FAST32_MAX;
1388                   uif32 = UINT_FAST32_MAX;
1389                   typedef uint_fast64_t   my_uint_fast64_t;
1390                   my_uint_fast64_t        uif64 = UINT_FAST64_MAX;
1391                   uif64 = UINT_FAST64_MAX;
1392                   typedef uint_least8_t   my_uint_least8_t;
1393                   my_uint_least8_t        uil8 = UINT_LEAST8_MAX;
1394                   uil8 = UINT_LEAST8_MAX;
1395                   typedef uint_least16_t  my_uint_least16_t;
1396                   my_uint_least16_t       uil16 = UINT_LEAST16_MAX;
1397                   uil16 = UINT_LEAST16_MAX;
1398                   typedef uint_least32_t  my_uint_least32_t;
1399                   my_uint_least32_t       uil32 = UINT_LEAST32_MAX;
1400                   uil32 = UINT_LEAST32_MAX;
1401                   typedef uint_least64_t  my_uint_least64_t;
1402                   my_uint_least64_t       uil64 = UINT_LEAST64_MAX;
1403                   uil64 = UINT_LEAST64_MAX;
1404                   typedef uintmax_t       my_uintmax_t;
1405                   my_uintmax_t            uim = UINTMAX_MAX;
1406                   uim = UINTMAX_MAX;
1407                   typedef uintptr_t       my_uintptr_t;
1408                   my_uintptr_t            uip = UINTPTR_MAX;
1409                   uip = UINTPTR_MAX;
1410                  ],[glibcxx_cv_c99_stdint_tr1=yes],
1411                    [glibcxx_cv_c99_stdint_tr1=no])
1412   ])
1413   AC_MSG_RESULT($glibcxx_cv_c99_stdint_tr1)
1414   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1415     AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1,
1416               [Define if C99 types in <stdint.h> should be imported in
1417               <tr1/cstdint> in namespace std::tr1.])
1418   fi
1419
1420   # Check for the existence of <math.h> functions.
1421   AC_MSG_CHECKING([for ISO C99 support to TR1 in <math.h>])
1422   AC_CACHE_VAL(glibcxx_cv_c99_math_tr1, [
1423   AC_TRY_COMPILE([#include <math.h>],
1424                  [typedef double_t  my_double_t;
1425                   typedef float_t   my_float_t;
1426                   acosh(0.0);
1427                   acoshf(0.0f);
1428                   acoshl(0.0l);
1429                   asinh(0.0);
1430                   asinhf(0.0f);
1431                   asinhl(0.0l);
1432                   atanh(0.0);
1433                   atanhf(0.0f);
1434                   atanhl(0.0l);
1435                   cbrt(0.0);
1436                   cbrtf(0.0f);
1437                   cbrtl(0.0l);
1438                   copysign(0.0, 0.0);
1439                   copysignf(0.0f, 0.0f);
1440                   copysignl(0.0l, 0.0l);
1441                   erf(0.0);
1442                   erff(0.0f);
1443                   erfl(0.0l);
1444                   erfc(0.0);
1445                   erfcf(0.0f);
1446                   erfcl(0.0l);
1447                   exp2(0.0);
1448                   exp2f(0.0f);
1449                   exp2l(0.0l);
1450                   expm1(0.0);
1451                   expm1f(0.0f);
1452                   expm1l(0.0l);
1453                   fdim(0.0, 0.0);
1454                   fdimf(0.0f, 0.0f);
1455                   fdiml(0.0l, 0.0l);
1456                   fma(0.0, 0.0, 0.0);
1457                   fmaf(0.0f, 0.0f, 0.0f);
1458                   fmal(0.0l, 0.0l, 0.0l);
1459                   fmax(0.0, 0.0);
1460                   fmaxf(0.0f, 0.0f);
1461                   fmaxl(0.0l, 0.0l);
1462                   fmin(0.0, 0.0);
1463                   fminf(0.0f, 0.0f);
1464                   fminl(0.0l, 0.0l);
1465                   hypot(0.0, 0.0);
1466                   hypotf(0.0f, 0.0f);
1467                   hypotl(0.0l, 0.0l);
1468                   ilogb(0.0);
1469                   ilogbf(0.0f);
1470                   ilogbl(0.0l);
1471                   lgamma(0.0);
1472                   lgammaf(0.0f);
1473                   lgammal(0.0l);
1474                   llrint(0.0);
1475                   llrintf(0.0f);
1476                   llrintl(0.0l);
1477                   llround(0.0);
1478                   llroundf(0.0f);
1479                   llroundl(0.0l);
1480                   log1p(0.0);
1481                   log1pf(0.0f);
1482                   log1pl(0.0l);
1483                   log2(0.0);
1484                   log2f(0.0f);
1485                   log2l(0.0l);
1486                   logb(0.0);
1487                   logbf(0.0f);
1488                   logbl(0.0l);
1489                   lrint(0.0);
1490                   lrintf(0.0f);
1491                   lrintl(0.0l);
1492                   lround(0.0);
1493                   lroundf(0.0f);
1494                   lroundl(0.0l);
1495                   nan(0);
1496                   nanf(0);
1497                   nanl(0);
1498                   nearbyint(0.0);
1499                   nearbyintf(0.0f);
1500                   nearbyintl(0.0l);
1501                   nextafter(0.0, 0.0);
1502                   nextafterf(0.0f, 0.0f);
1503                   nextafterl(0.0l, 0.0l);
1504                   nexttoward(0.0, 0.0);
1505                   nexttowardf(0.0f, 0.0f);
1506                   nexttowardl(0.0l, 0.0l);
1507                   remainder(0.0, 0.0);
1508                   remainderf(0.0f, 0.0f);
1509                   remainderl(0.0l, 0.0l);
1510                   remquo(0.0, 0.0, 0);
1511                   remquof(0.0f, 0.0f, 0);
1512                   remquol(0.0l, 0.0l, 0);
1513                   rint(0.0);
1514                   rintf(0.0f);
1515                   rintl(0.0l);
1516                   round(0.0);
1517                   roundf(0.0f);
1518                   roundl(0.0l);
1519                   scalbln(0.0, 0l);
1520                   scalblnf(0.0f, 0l);
1521                   scalblnl(0.0l, 0l);
1522                   scalbn(0.0, 0);
1523                   scalbnf(0.0f, 0);
1524                   scalbnl(0.0l, 0);
1525                   tgamma(0.0);
1526                   tgammaf(0.0f);
1527                   tgammal(0.0l);
1528                   trunc(0.0);
1529                   truncf(0.0f);
1530                   truncl(0.0l);
1531                  ],[glibcxx_cv_c99_math_tr1=yes], [glibcxx_cv_c99_math_tr1=no])
1532   ])
1533   AC_MSG_RESULT($glibcxx_cv_c99_math_tr1)
1534   if test x"$glibcxx_cv_c99_math_tr1" = x"yes"; then
1535     AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1,
1536               [Define if C99 functions or macros in <math.h> should be imported
1537               in <tr1/cmath> in namespace std::tr1.])
1538   fi
1539
1540   # Check for the existence of <inttypes.h> functions (NB: doesn't make
1541   # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1542   ac_c99_inttypes_tr1=no;
1543   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1544     AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>])
1545     AC_TRY_COMPILE([#include <inttypes.h>],
1546                    [intmax_t i, numer, denom, base;
1547                     const char* s;
1548                     char** endptr;
1549                     intmax_t ret = imaxabs(i);
1550                     imaxdiv_t dret = imaxdiv(numer, denom);
1551                     ret = strtoimax(s, endptr, base);
1552                     uintmax_t uret = strtoumax(s, endptr, base);
1553                    ],[ac_c99_inttypes_tr1=yes], [ac_c99_inttypes_tr1=no])
1554   fi
1555   AC_MSG_RESULT($ac_c99_inttypes_tr1)
1556   if test x"$ac_c99_inttypes_tr1" = x"yes"; then
1557     AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_TR1, 1,
1558               [Define if C99 functions in <inttypes.h> should be imported in
1559               <tr1/cinttypes> in namespace std::tr1.])
1560   fi
1561
1562   # Check for the existence of whcar_t <inttypes.h> functions (NB: doesn't
1563   # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1564   ac_c99_inttypes_wchar_t_tr1=no;
1565   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1566     AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>])
1567     AC_TRY_COMPILE([#include <inttypes.h>],
1568                    [intmax_t base;
1569                     const wchar_t* s;
1570                     wchar_t** endptr;
1571                     intmax_t ret = wcstoimax(s, endptr, base);
1572                     uintmax_t uret = wcstoumax(s, endptr, base);
1573                    ],[ac_c99_inttypes_wchar_t_tr1=yes],
1574                      [ac_c99_inttypes_wchar_t_tr1=no])
1575   fi
1576   AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1)
1577   if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then
1578     AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1,
1579               [Define if wchar_t C99 functions in <inttypes.h> should be
1580               imported in <tr1/cinttypes> in namespace std::tr1.])
1581   fi
1582
1583   # Check for the existence of the <stdbool.h> header.  
1584   AC_CHECK_HEADERS(stdbool.h)
1585
1586   CXXFLAGS="$ac_save_CXXFLAGS"
1587   AC_LANG_RESTORE
1588 ])
1589
1590 dnl
1591 dnl Check whether "/dev/random" and "/dev/urandom" are available for the
1592 dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
1593 dnl
1594 AC_DEFUN([GLIBCXX_CHECK_RANDOM_TR1], [
1595
1596   AC_MSG_CHECKING([for "/dev/random" and "/dev/urandom" for TR1 random_device])
1597   AC_CACHE_VAL(glibcxx_cv_random_tr1, [
1598     if test -r /dev/random && test -r /dev/urandom; then
1599       glibcxx_cv_random_tr1=yes;
1600     else
1601       glibcxx_cv_random_tr1=no;
1602     fi
1603   ])
1604   AC_MSG_RESULT($glibcxx_cv_random_tr1)
1605
1606   if test x"$glibcxx_cv_random_tr1" = x"yes"; then
1607     AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1,
1608               [Define if /dev/random and /dev/urandom are available for
1609                the random_device of TR1 (Chapter 5.1).])
1610   fi
1611
1612 ])
1613
1614 dnl
1615 dnl Check whether EOF, SEEK_CUR, and SEEK_END have the most common values:
1616 dnl in that case including <cstdio> in some C++ headers can be avoided.
1617 dnl
1618 AC_DEFUN([GLIBCXX_CHECK_STDIO_MACROS], [
1619
1620   AC_MSG_CHECKING([for EOF == -1, SEEK_CUR == 1, SEEK_END == 2])
1621   AC_CACHE_VAL(glibcxx_cv_stdio_macros, [
1622   AC_TRY_COMPILE([#include <stdio.h>],
1623                  [#if ((EOF != -1) || (SEEK_CUR != 1) || (SEEK_END != 2))
1624                     unusual values...
1625                   #endif
1626                  ], [glibcxx_cv_stdio_macros=yes],
1627                     [glibcxx_cv_stdio_macros=no])
1628   ])
1629   AC_MSG_RESULT($glibcxx_cv_stdio_macros)
1630   if test x"$glibcxx_cv_stdio_macros" = x"yes"; then
1631     AC_DEFINE(_GLIBCXX_STDIO_MACROS, 1,
1632               [Define if EOF == -1, SEEK_CUR == 1, SEEK_END == 2.])
1633   fi
1634
1635 ])
1636
1637 dnl
1638 dnl Check whether macros, etc are present for <system_error>
1639 dnl
1640 AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
1641
1642 m4_pushdef([n_syserr], [1])dnl
1643 m4_foreach([syserr], [EOWNERDEAD, ENOTRECOVERABLE, ENOLINK, EPROTO, ENODATA,
1644                       ENOSR, ENOSTR, ETIME, EBADMSG, ECANCELED,
1645                       EOVERFLOW, ENOTSUP, EIDRM, ETXTBSY],
1646 [m4_pushdef([SYSERR], m4_toupper(syserr))dnl
1647 AC_MSG_CHECKING([for syserr])
1648 AC_CACHE_VAL([glibcxx_cv_system_error[]n_syserr], [
1649 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]],
1650                                    [int i = syserr;])],
1651                   [glibcxx_cv_system_error[]n_syserr=yes],
1652                   [glibcxx_cv_system_error[]n_syserr=no])
1653 ])
1654 AC_MSG_RESULT([$glibcxx_cv_system_error[]n_syserr])
1655 if test x"$glibcxx_cv_system_error[]n_syserr" = x"yes"; then
1656   AC_DEFINE([HAVE_]SYSERR, 1, [Define if ]syserr[ exists.])
1657 fi
1658 m4_define([n_syserr], m4_incr(n_syserr))dnl
1659 m4_popdef([SYSERR])dnl
1660 ])
1661 m4_popdef([n_syserr])dnl
1662 ])
1663
1664 dnl
1665 dnl Check for what type of C headers to use.
1666 dnl
1667 dnl --enable-cheaders= [does stuff].
1668 dnl --disable-cheaders [does not do anything, really].
1669 dnl  +  Usage:  GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
1670 dnl       Where DEFAULT is either 'c' or 'c_std' or 'c_global'.
1671 dnl
1672 AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
1673   GLIBCXX_ENABLE(cheaders,$1,[=KIND],
1674     [construct "C" headers for g++], [permit c|c_std|c_global])
1675   AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
1676
1677   C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
1678
1679   # Allow overrides to configure.host here.
1680   if test $enable_cheaders = c_global; then
1681      c_compatibility=yes
1682   fi
1683
1684   if test $enable_cheaders = c_global || test $enable_cheaders = c_std; then
1685      c_extra=yes
1686   fi
1687
1688   AC_SUBST(C_INCLUDE_DIR)
1689   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
1690   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
1691   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global)
1692   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
1693   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_EXTRA, test $c_extra = yes)
1694 ])
1695
1696
1697 dnl
1698 dnl Check for which locale library to use.  The choice is mapped to
1699 dnl a subdirectory of config/locale.
1700 dnl
1701 dnl Default is generic.
1702 dnl
1703 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
1704   GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
1705     [use MODEL for target locale package],
1706     [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
1707
1708   # Deal with gettext issues.  Default to not using it (=no) until we detect
1709   # support for it later.  Let the user turn it off via --e/d, but let that
1710   # default to on for easier handling.
1711   USE_NLS=no
1712   AC_ARG_ENABLE(nls,
1713     AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
1714     [],
1715     [enable_nls=yes])
1716   
1717   # Either a known packaage, or "auto"
1718   if test $enable_clocale = no || test $enable_clocale = yes; then
1719      enable_clocale=auto
1720   fi
1721   enable_clocale_flag=$enable_clocale
1722
1723   # Probe for locale model to use if none specified.
1724   # Default to "generic".
1725   if test $enable_clocale_flag = auto; then
1726     case ${target_os} in
1727       linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
1728         enable_clocale_flag=gnu 
1729         ;;
1730       darwin* | freebsd*)
1731         enable_clocale_flag=darwin
1732         ;;
1733       *)
1734         enable_clocale_flag=generic
1735         ;;
1736     esac
1737   fi
1738
1739   # Sanity check model, and test for special functionality.
1740   if test $enable_clocale_flag = gnu; then
1741     AC_EGREP_CPP([_GLIBCXX_ok], [
1742     #include <features.h>
1743     #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(__UCLIBC__)
1744       _GLIBCXX_ok
1745     #endif
1746     ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1747
1748     # Set it to scream when it hurts.
1749     ac_save_CFLAGS="$CFLAGS"    
1750     CFLAGS="-Wimplicit-function-declaration -Werror"
1751
1752     # Use strxfrm_l if available.
1753     AC_TRY_COMPILE([#define _GNU_SOURCE 1
1754                     #include <string.h>
1755                     #include <locale.h>],
1756                     [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);], 
1757                     AC_DEFINE(HAVE_STRXFRM_L, 1, 
1758                     [Define if strxfrm_l is available in <string.h>.]),)
1759     
1760     # Use strerror_l if available.
1761     AC_TRY_COMPILE([#define _GNU_SOURCE 1
1762                     #include <string.h>
1763                     #include <locale.h>],
1764                     [__locale_t loc; strerror_l(5, loc);], 
1765                     AC_DEFINE(HAVE_STRERROR_L, 1, 
1766                     [Define if strerror_l is available in <string.h>.]),)
1767
1768     CFLAGS="$ac_save_CFLAGS"
1769   fi
1770
1771   # Perhaps use strerror_r if available, and strerror_l isn't.
1772   ac_save_CFLAGS="$CFLAGS"      
1773   CFLAGS="-Wimplicit-function-declaration -Werror"
1774   AC_TRY_COMPILE([#define _GNU_SOURCE 1
1775                   #include <string.h>
1776                   #include <locale.h>],
1777                   [char s[128]; strerror_r(5, s, 128);], 
1778                   AC_DEFINE(HAVE_STRERROR_R, 1, 
1779                   [Define if strerror_r is available in <string.h>.]),)
1780   CFLAGS="$ac_save_CFLAGS"
1781
1782   # Set configure bits for specified locale package
1783   AC_MSG_CHECKING([for C locale to use])
1784   case ${enable_clocale_flag} in
1785     generic)
1786       AC_MSG_RESULT(generic)
1787
1788       CLOCALE_H=config/locale/generic/c_locale.h
1789       CLOCALE_CC=config/locale/generic/c_locale.cc
1790       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1791       CCOLLATE_CC=config/locale/generic/collate_members.cc
1792       CCTYPE_CC=config/locale/generic/ctype_members.cc
1793       CMESSAGES_H=config/locale/generic/messages_members.h
1794       CMESSAGES_CC=config/locale/generic/messages_members.cc
1795       CMONEY_CC=config/locale/generic/monetary_members.cc
1796       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1797       CTIME_H=config/locale/generic/time_members.h
1798       CTIME_CC=config/locale/generic/time_members.cc
1799       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1800       ;;
1801     darwin)
1802       AC_MSG_RESULT(darwin or freebsd)
1803
1804       CLOCALE_H=config/locale/generic/c_locale.h
1805       CLOCALE_CC=config/locale/generic/c_locale.cc
1806       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1807       CCOLLATE_CC=config/locale/generic/collate_members.cc
1808       CCTYPE_CC=config/locale/darwin/ctype_members.cc
1809       CMESSAGES_H=config/locale/generic/messages_members.h
1810       CMESSAGES_CC=config/locale/generic/messages_members.cc
1811       CMONEY_CC=config/locale/generic/monetary_members.cc
1812       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1813       CTIME_H=config/locale/generic/time_members.h
1814       CTIME_CC=config/locale/generic/time_members.cc
1815       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1816       ;;
1817         
1818     gnu)
1819       AC_MSG_RESULT(gnu)
1820
1821       # Declare intention to use gettext, and add support for specific
1822       # languages.
1823       # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
1824       ALL_LINGUAS="de fr"
1825
1826       # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
1827       AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1828       if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
1829         USE_NLS=yes
1830       fi
1831       # Export the build objects.
1832       for ling in $ALL_LINGUAS; do \
1833         glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
1834         glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
1835       done
1836       AC_SUBST(glibcxx_MOFILES)
1837       AC_SUBST(glibcxx_POFILES)
1838
1839       CLOCALE_H=config/locale/gnu/c_locale.h
1840       CLOCALE_CC=config/locale/gnu/c_locale.cc
1841       CCODECVT_CC=config/locale/gnu/codecvt_members.cc
1842       CCOLLATE_CC=config/locale/gnu/collate_members.cc
1843       CCTYPE_CC=config/locale/gnu/ctype_members.cc
1844       CMESSAGES_H=config/locale/gnu/messages_members.h
1845       CMESSAGES_CC=config/locale/gnu/messages_members.cc
1846       CMONEY_CC=config/locale/gnu/monetary_members.cc
1847       CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1848       CTIME_H=config/locale/gnu/time_members.h
1849       CTIME_CC=config/locale/gnu/time_members.cc
1850       CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
1851       ;;
1852     ieee_1003.1-2001)
1853       AC_MSG_RESULT(IEEE 1003.1)
1854
1855       CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1856       CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
1857       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1858       CCOLLATE_CC=config/locale/generic/collate_members.cc
1859       CCTYPE_CC=config/locale/generic/ctype_members.cc
1860       CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1861       CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1862       CMONEY_CC=config/locale/generic/monetary_members.cc
1863       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1864       CTIME_H=config/locale/generic/time_members.h
1865       CTIME_CC=config/locale/generic/time_members.cc
1866       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1867       ;;
1868   esac
1869
1870   # This is where the testsuite looks for locale catalogs, using the
1871   # -DLOCALEDIR define during testsuite compilation.
1872   glibcxx_localedir=${glibcxx_builddir}/po/share/locale
1873   AC_SUBST(glibcxx_localedir)
1874
1875   # A standalone libintl (e.g., GNU libintl) may be in use.
1876   if test $USE_NLS = yes; then
1877     AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no)
1878     AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no)
1879   fi
1880   if test $USE_NLS = yes; then
1881     AC_DEFINE(_GLIBCXX_USE_NLS, 1, 
1882               [Define if NLS translations are to be used.])
1883   fi
1884
1885   AC_SUBST(USE_NLS)
1886   AC_SUBST(CLOCALE_H)
1887   AC_SUBST(CMESSAGES_H)
1888   AC_SUBST(CCODECVT_CC)
1889   AC_SUBST(CCOLLATE_CC)
1890   AC_SUBST(CCTYPE_CC)
1891   AC_SUBST(CMESSAGES_CC)
1892   AC_SUBST(CMONEY_CC)
1893   AC_SUBST(CNUMERIC_CC)
1894   AC_SUBST(CTIME_H)
1895   AC_SUBST(CTIME_CC)
1896   AC_SUBST(CLOCALE_CC)
1897   AC_SUBST(CLOCALE_INTERNAL_H)
1898 ])
1899
1900
1901 dnl
1902 dnl Check for which std::allocator base class to use.  The choice is
1903 dnl mapped from a subdirectory of include/ext.
1904 dnl
1905 dnl Default is new.
1906 dnl
1907 AC_DEFUN([GLIBCXX_ENABLE_ALLOCATOR], [
1908   AC_MSG_CHECKING([for std::allocator base class])
1909   GLIBCXX_ENABLE(libstdcxx-allocator,auto,[=KIND],
1910     [use KIND for target std::allocator base],
1911     [permit new|malloc|mt|bitmap|pool|yes|no|auto])
1912
1913   # If they didn't use this option switch, or if they specified --enable
1914   # with no specific model, we'll have to look for one.  If they
1915   # specified --disable (???), do likewise.
1916   if test $enable_libstdcxx_allocator = no ||
1917      test $enable_libstdcxx_allocator = yes;
1918   then
1919      enable_libstdcxx_allocator=auto
1920   fi
1921
1922   # Either a known package, or "auto". Auto implies the default choice
1923   # for a particular platform.
1924   enable_libstdcxx_allocator_flag=$enable_libstdcxx_allocator
1925
1926   # Probe for host-specific support if no specific model is specified.
1927   # Default to "new".
1928   if test $enable_libstdcxx_allocator_flag = auto; then
1929     case ${target_os} in
1930       linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
1931         enable_libstdcxx_allocator_flag=new
1932         ;;
1933       *)
1934         enable_libstdcxx_allocator_flag=new
1935         ;;
1936     esac
1937   fi
1938   AC_MSG_RESULT($enable_libstdcxx_allocator_flag)
1939   
1940
1941   # Set configure bits for specified locale package
1942   case ${enable_libstdcxx_allocator_flag} in
1943     bitmap)
1944       ALLOCATOR_H=config/allocator/bitmap_allocator_base.h
1945       ALLOCATOR_NAME=__gnu_cxx::bitmap_allocator
1946       ;;
1947     malloc)
1948       ALLOCATOR_H=config/allocator/malloc_allocator_base.h
1949       ALLOCATOR_NAME=__gnu_cxx::malloc_allocator
1950       ;;
1951     mt)
1952       ALLOCATOR_H=config/allocator/mt_allocator_base.h
1953       ALLOCATOR_NAME=__gnu_cxx::__mt_alloc
1954       ;;
1955     new)
1956       ALLOCATOR_H=config/allocator/new_allocator_base.h
1957       ALLOCATOR_NAME=__gnu_cxx::new_allocator
1958       ;;
1959     pool)
1960       ALLOCATOR_H=config/allocator/pool_allocator_base.h
1961       ALLOCATOR_NAME=__gnu_cxx::__pool_alloc
1962       ;;        
1963   esac
1964
1965   AC_SUBST(ALLOCATOR_H)
1966   AC_SUBST(ALLOCATOR_NAME)
1967 ])
1968
1969
1970 dnl
1971 dnl Check for whether the Boost-derived checks should be turned on.
1972 dnl
1973 dnl --enable-concept-checks turns them on.
1974 dnl --disable-concept-checks leaves them off.
1975 dnl  +  Usage:  GLIBCXX_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
1976 dnl       Where DEFAULT is either `yes' or `no'.
1977 dnl
1978 AC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [
1979   GLIBCXX_ENABLE(concept-checks,$1,,[use Boost-derived template checks])
1980   if test $enable_concept_checks = yes; then
1981     AC_DEFINE(_GLIBCXX_CONCEPT_CHECKS, 1,
1982               [Define to use concept checking code from the boost libraries.])
1983   fi
1984 ])
1985
1986 dnl
1987 dnl Check for parallel mode pre-requisites, including OpenMP support.
1988 dnl
1989 dnl  +  Usage:  GLIBCXX_ENABLE_PARALLEL
1990 dnl
1991 AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
1992
1993   enable_parallel=no;
1994
1995   # See if configured libgomp/omp.h exists. (libgomp may be in
1996   # noconfigdirs but not explicitly disabled.)
1997   if echo " ${TARGET_CONFIGDIRS} " | grep " libgomp " > /dev/null 2>&1 ; then
1998     enable_parallel=yes;
1999   else
2000     AC_MSG_NOTICE([target-libgomp not built])
2001   fi
2002
2003   AC_MSG_CHECKING([for parallel mode support])
2004   AC_MSG_RESULT([$enable_parallel])
2005   GLIBCXX_CONDITIONAL(ENABLE_PARALLEL, test $enable_parallel = yes)
2006 ])
2007
2008
2009 dnl
2010 dnl Check for which I/O library to use:  stdio, or something specific.
2011 dnl
2012 dnl Default is stdio.
2013 dnl
2014 AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
2015   AC_MSG_CHECKING([for underlying I/O to use])
2016   GLIBCXX_ENABLE(cstdio,stdio,[=PACKAGE],
2017     [use target-specific I/O package], [permit stdio])
2018
2019   # Now that libio has been removed, you can have any color you want as long
2020   # as it's black.  This is one big no-op until other packages are added, but
2021   # showing the framework never hurts.
2022   case ${enable_cstdio} in
2023     stdio)
2024       CSTDIO_H=config/io/c_io_stdio.h
2025       BASIC_FILE_H=config/io/basic_file_stdio.h
2026       BASIC_FILE_CC=config/io/basic_file_stdio.cc
2027       AC_MSG_RESULT(stdio)
2028       ;;
2029   esac
2030
2031   AC_SUBST(CSTDIO_H)
2032   AC_SUBST(BASIC_FILE_H)
2033   AC_SUBST(BASIC_FILE_CC)
2034 ])
2035
2036
2037 dnl
2038 dnl Check for "unusual" flags to pass to the compiler while building.
2039 dnl
2040 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
2041 dnl     experimental flags such as -fpch, -fIMI, -Dfloat=char, etc.
2042 dnl --disable-cxx-flags passes nothing.
2043 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
2044 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
2045 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
2046 dnl  +  Usage:  GLIBCXX_ENABLE_CXX_FLAGS(default flags)
2047 dnl       If "default flags" is an empty string, the effect is the same
2048 dnl       as --disable or --enable=no.
2049 dnl
2050 AC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl
2051   AC_MSG_CHECKING([for extra compiler flags for building])
2052   GLIBCXX_ENABLE(cxx-flags,$1,[=FLAGS],
2053     [pass compiler FLAGS when building library],
2054     [case "x$enable_cxx_flags" in
2055       xno | x)   enable_cxx_flags= ;;
2056       x-*)       ;;
2057       *)         AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2058      esac])
2059
2060   # Run through flags (either default or command-line) and set anything
2061   # extra (e.g., #defines) that must accompany particular g++ options.
2062   if test -n "$enable_cxx_flags"; then
2063     for f in $enable_cxx_flags; do
2064       case "$f" in
2065         -fhonor-std)  ;;
2066         -*)  ;;
2067         *)   # and we're trying to pass /what/ exactly?
2068              AC_MSG_ERROR([compiler flags start with a -]) ;;
2069       esac
2070     done
2071   fi
2072
2073   EXTRA_CXX_FLAGS="$enable_cxx_flags"
2074   AC_MSG_RESULT($EXTRA_CXX_FLAGS)
2075   AC_SUBST(EXTRA_CXX_FLAGS)
2076 ])
2077
2078
2079 dnl
2080 dnl Check to see if debugging libraries are to be built.
2081 dnl
2082 dnl --enable-libstdcxx-debug
2083 dnl builds a separate set of debugging libraries in addition to the
2084 dnl normal (shared, static) libstdc++ binaries.
2085 dnl
2086 dnl --disable-libstdcxx-debug
2087 dnl builds only one (non-debug) version of libstdc++.
2088 dnl
2089 dnl --enable-libstdcxx-debug-flags=FLAGS
2090 dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
2091 dnl
2092 dnl  +  Usage:  GLIBCXX_ENABLE_DEBUG[(DEFAULT)]
2093 dnl       Where DEFAULT is either `yes' or `no'.
2094 dnl
2095 AC_DEFUN([GLIBCXX_ENABLE_DEBUG], [
2096   AC_MSG_CHECKING([for additional debug build])
2097   GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library])
2098   AC_MSG_RESULT($enable_libstdcxx_debug)
2099   GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
2100 ])
2101
2102
2103 dnl
2104 dnl Check for explicit debug flags.
2105 dnl
2106 dnl --enable-libstdcxx-debug-flags='-O1'
2107 dnl is a general method for passing flags to be used when
2108 dnl building debug libraries with --enable-debug.
2109 dnl
2110 dnl --disable-libstdcxx-debug-flags does nothing.
2111 dnl  +  Usage:  GLIBCXX_ENABLE_DEBUG_FLAGS(default flags)
2112 dnl       If "default flags" is an empty string, the effect is the same
2113 dnl       as --disable or --enable=no.
2114 dnl
2115 AC_DEFUN([GLIBCXX_ENABLE_DEBUG_FLAGS], [
2116   GLIBCXX_ENABLE(libstdcxx-debug-flags,[$1],[=FLAGS],
2117     [pass compiler FLAGS when building debug library],
2118     [case "x$enable_libstdcxx_debug_flags" in
2119       xno | x)    enable_libstdcxx_debug_flags= ;;
2120       x-*)        ;;
2121       *)          AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2122      esac])
2123
2124   # Option parsed, now set things appropriately
2125   DEBUG_FLAGS="$enable_libstdcxx_debug_flags"
2126   AC_SUBST(DEBUG_FLAGS)
2127
2128   AC_MSG_NOTICE([Debug build flags set to $DEBUG_FLAGS])
2129 ])
2130
2131
2132 dnl
2133 dnl Check if the user only wants a freestanding library implementation.
2134 dnl
2135 dnl --disable-hosted-libstdcxx will turn off most of the library build,
2136 dnl installing only the headers required by [17.4.1.3] and the language
2137 dnl support library.  More than that will be built (to keep the Makefiles
2138 dnl conveniently clean), but not installed.
2139 dnl
2140 dnl Sets:
2141 dnl  is_hosted  (yes/no)
2142 dnl
2143 dnl Defines:
2144 dnl  _GLIBCXX_HOSTED   (always defined, either to 1 or 0)
2145 dnl
2146 AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [
2147   AC_ARG_ENABLE([hosted-libstdcxx],
2148     AC_HELP_STRING([--disable-hosted-libstdcxx],
2149                    [only build freestanding C++ runtime support]),,
2150     [case "$host" in
2151         arm*-*-symbianelf*) 
2152             enable_hosted_libstdcxx=no
2153             ;;
2154         *) 
2155             enable_hosted_libstdcxx=yes
2156             ;;
2157      esac])
2158   if test "$enable_hosted_libstdcxx" = no; then
2159     AC_MSG_NOTICE([Only freestanding libraries will be built])
2160     is_hosted=no
2161     hosted_define=0
2162     enable_abi_check=no
2163     enable_libstdcxx_pch=no
2164   else
2165     is_hosted=yes
2166     hosted_define=1
2167   fi
2168   GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
2169   AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
2170     [Define to 1 if a full hosted library is built, or 0 if freestanding.])
2171 ])
2172
2173
2174 dnl
2175 dnl Check for template specializations for the 'long long' type.
2176 dnl The result determines only whether 'long long' I/O is enabled; things
2177 dnl like numeric_limits<> specializations are always available.
2178 dnl
2179 dnl --enable-long-long defines _GLIBCXX_USE_LONG_LONG
2180 dnl --disable-long-long leaves _GLIBCXX_USE_LONG_LONG undefined
2181 dnl  +  Usage:  GLIBCXX_ENABLE_LONG_LONG[(DEFAULT)]
2182 dnl       Where DEFAULT is either `yes' or `no'.
2183 dnl
2184 AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
2185   GLIBCXX_ENABLE(long-long,$1,,[enable template specializations for 'long long'])
2186   if test $enable_long_long = yes; then
2187     AC_DEFINE(_GLIBCXX_USE_LONG_LONG, 1, 
2188               [Define if code specialized for long long should be used.])
2189   fi
2190   AC_MSG_CHECKING([for enabled long long specializations])
2191   AC_MSG_RESULT([$enable_long_long])
2192 ])
2193
2194
2195 dnl
2196 dnl Check for decimal floating point.
2197 dnl See:
2198 dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
2199 dnl
2200 dnl This checks to see if the host supports decimal floating point types.
2201 dnl
2202 dnl Defines:
2203 dnl  _GLIBCXX_USE_DECIMAL_FLOAT
2204 dnl
2205 AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
2206
2207   # Fake what AC_TRY_COMPILE does, without linking as this is
2208   # unnecessary for this test.
2209
2210     cat > conftest.$ac_ext << EOF
2211 [#]line __oline__ "configure"
2212 int main()
2213 {
2214   _Decimal32 d1;
2215   _Decimal64 d2;
2216   _Decimal128 d3;
2217   return 0;
2218 }
2219 EOF
2220
2221     AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
2222     if AC_TRY_EVAL(ac_compile); then
2223       AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
2224       [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
2225       enable_dfp=yes
2226     else
2227       enable_dfp=no
2228     fi
2229     AC_MSG_RESULT($enable_dfp)
2230     rm -f conftest*
2231 ])
2232
2233 dnl
2234 dnl Check for template specializations for the 'wchar_t' type.
2235 dnl
2236 dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
2237 dnl --disable-wchar_t leaves _GLIBCXX_USE_WCHAR_T undefined
2238 dnl  +  Usage:  GLIBCXX_ENABLE_WCHAR_T[(DEFAULT)]
2239 dnl       Where DEFAULT is either `yes' or `no'.
2240 dnl
2241 dnl Necessary support must also be present.
2242 dnl
2243 AC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [
2244   GLIBCXX_ENABLE(wchar_t,$1,,[enable template specializations for 'wchar_t'])
2245
2246   # Test wchar.h for mbstate_t, which is needed for char_traits and fpos.
2247   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
2248   AC_MSG_CHECKING([for mbstate_t])
2249   AC_TRY_COMPILE([#include <wchar.h>],
2250   [mbstate_t teststate;],
2251   have_mbstate_t=yes, have_mbstate_t=no)
2252   AC_MSG_RESULT($have_mbstate_t)
2253   if test x"$have_mbstate_t" = xyes; then
2254     AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
2255   fi
2256
2257   # Test it always, for use in GLIBCXX_ENABLE_C99, together with
2258   # ac_has_wchar_h.
2259   AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
2260   
2261   if test x"$enable_wchar_t" = x"yes"; then
2262
2263     AC_LANG_SAVE
2264     AC_LANG_CPLUSPLUS
2265     
2266     if test x"$ac_has_wchar_h" = xyes &&
2267        test x"$ac_has_wctype_h" = xyes; then
2268       AC_TRY_COMPILE([#include <wchar.h>
2269                       #include <stddef.h>
2270                       wint_t i;
2271                       long l = WEOF;
2272                       long j = WCHAR_MIN;
2273                       long k = WCHAR_MAX;
2274                       namespace test
2275                       {
2276                         using ::btowc;
2277                         using ::fgetwc;
2278                         using ::fgetws;
2279                         using ::fputwc;
2280                         using ::fputws;
2281                         using ::fwide;
2282                         using ::fwprintf; 
2283                         using ::fwscanf;
2284                         using ::getwc;
2285                         using ::getwchar;
2286                         using ::mbrlen; 
2287                         using ::mbrtowc; 
2288                         using ::mbsinit; 
2289                         using ::mbsrtowcs; 
2290                         using ::putwc;
2291                         using ::putwchar;
2292                         using ::swprintf; 
2293                         using ::swscanf; 
2294                         using ::ungetwc;
2295                         using ::vfwprintf; 
2296                         using ::vswprintf; 
2297                         using ::vwprintf; 
2298                         using ::wcrtomb; 
2299                         using ::wcscat; 
2300                         using ::wcschr; 
2301                         using ::wcscmp; 
2302                         using ::wcscoll; 
2303                         using ::wcscpy; 
2304                         using ::wcscspn; 
2305                         using ::wcsftime; 
2306                         using ::wcslen;
2307                         using ::wcsncat; 
2308                         using ::wcsncmp; 
2309                         using ::wcsncpy; 
2310                         using ::wcspbrk;
2311                         using ::wcsrchr; 
2312                         using ::wcsrtombs; 
2313                         using ::wcsspn; 
2314                         using ::wcsstr;
2315                         using ::wcstod; 
2316                         using ::wcstok; 
2317                         using ::wcstol;
2318                         using ::wcstoul; 
2319                         using ::wcsxfrm; 
2320                         using ::wctob; 
2321                         using ::wmemchr;
2322                         using ::wmemcmp;
2323                         using ::wmemcpy;
2324                         using ::wmemmove;
2325                         using ::wmemset;
2326                         using ::wprintf; 
2327                         using ::wscanf; 
2328                       }
2329                      ],[],[], [enable_wchar_t=no])
2330     else
2331       enable_wchar_t=no
2332     fi
2333
2334     AC_LANG_RESTORE
2335   fi
2336
2337   if test x"$enable_wchar_t" = x"yes"; then
2338     AC_DEFINE(_GLIBCXX_USE_WCHAR_T, 1,
2339               [Define if code specialized for wchar_t should be used.])
2340   fi
2341
2342   AC_MSG_CHECKING([for enabled wchar_t specializations])
2343   AC_MSG_RESULT([$enable_wchar_t])
2344 ])
2345
2346
2347 dnl
2348 dnl Check to see if building and using a C++ precompiled header can be done.
2349 dnl
2350 dnl --enable-libstdcxx-pch=yes
2351 dnl default, this shows intent to use stdc++.h.gch If it looks like it
2352 dnl may work, after some light-hearted attempts to puzzle out compiler
2353 dnl support, flip bits on in include/Makefile.am
2354 dnl
2355 dnl --disable-libstdcxx-pch
2356 dnl turns off attempts to use or build stdc++.h.gch.
2357 dnl
2358 dnl Substs:
2359 dnl  glibcxx_PCHFLAGS
2360 dnl
2361 AC_DEFUN([GLIBCXX_ENABLE_PCH], [
2362   GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers])
2363   if test $enable_libstdcxx_pch = yes; then
2364     AC_CACHE_CHECK([for compiler with PCH support],
2365       [glibcxx_cv_prog_CXX_pch],
2366       [ac_save_CXXFLAGS="$CXXFLAGS"
2367        CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated"
2368        AC_LANG_SAVE
2369        AC_LANG_CPLUSPLUS
2370        echo '#include <math.h>' > conftest.h
2371        if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \
2372                           -o conftest.h.gch 1>&5 2>&1 &&
2373                 echo '#error "pch failed"' > conftest.h &&
2374           echo '#include "conftest.h"' > conftest.cc &&
2375                $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ;
2376        then
2377          glibcxx_cv_prog_CXX_pch=yes
2378        else
2379          glibcxx_cv_prog_CXX_pch=no
2380        fi
2381        rm -f conftest*
2382        CXXFLAGS=$ac_save_CXXFLAGS
2383        AC_LANG_RESTORE
2384       ])
2385     enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch
2386   fi
2387
2388   AC_MSG_CHECKING([for enabled PCH])
2389   AC_MSG_RESULT([$enable_libstdcxx_pch])
2390
2391   GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
2392   if test $enable_libstdcxx_pch = yes; then
2393     glibcxx_PCHFLAGS="-include bits/stdc++.h"
2394   else
2395     glibcxx_PCHFLAGS=""
2396   fi
2397   AC_SUBST(glibcxx_PCHFLAGS)
2398 ])
2399
2400
2401 dnl
2402 dnl Check for atomic builtins.
2403 dnl See:
2404 dnl http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html#Atomic-Builtins
2405 dnl
2406 dnl This checks to see if the host supports the compiler-generated
2407 dnl builtins for atomic operations for various integral sizes. Note, this 
2408 dnl is intended to be an all-or-nothing switch, so all the atomic operations
2409 dnl that are used should be checked.
2410 dnl
2411 dnl Note:
2412 dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
2413 dnl
2414 dnl Defines:
2415 dnl  _GLIBCXX_ATOMIC_BUILTINS_1 
2416 dnl  _GLIBCXX_ATOMIC_BUILTINS_2
2417 dnl  _GLIBCXX_ATOMIC_BUILTINS_4
2418 dnl  _GLIBCXX_ATOMIC_BUILTINS_8
2419 dnl
2420 AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
2421   AC_LANG_SAVE
2422   AC_LANG_CPLUSPLUS
2423   old_CXXFLAGS="$CXXFLAGS"
2424
2425   # Do link tests if possible, instead asm tests, limited to some platforms
2426   # see discussion in PR target/40134, PR libstdc++/40133 and the thread
2427   # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
2428   atomic_builtins_link_tests=no
2429   if test x$gcc_no_link != xyes; then
2430     # Can do link tests. Limit to some tested platforms
2431     case "$host" in
2432       *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
2433         atomic_builtins_link_tests=yes
2434         ;;
2435     esac
2436   fi
2437
2438   if test x$atomic_builtins_link_tests = xyes; then
2439
2440   # Do link tests.
2441
2442   CXXFLAGS="$CXXFLAGS -fno-exceptions"
2443
2444   AC_MSG_CHECKING([for atomic builtins for bool])
2445   AC_CACHE_VAL(glibcxx_cv_atomic_bool, [
2446     AC_TRY_LINK(
2447       [ ],
2448       [typedef bool atomic_type;
2449        atomic_type c1;
2450        atomic_type c2;
2451        const atomic_type c3(0);
2452        __sync_fetch_and_add(&c1, c2);
2453        __sync_val_compare_and_swap(&c1, c3, c2);
2454        __sync_lock_test_and_set(&c1, c3);
2455        __sync_lock_release(&c1);
2456        __sync_synchronize();],
2457       [glibcxx_cv_atomic_bool=yes],
2458       [glibcxx_cv_atomic_bool=no])
2459   ])    
2460   if test $glibcxx_cv_atomic_bool = yes; then
2461     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2462       [Define if builtin atomic operations for bool are supported on this host.])
2463   fi
2464   AC_MSG_RESULT($glibcxx_cv_atomic_bool)
2465
2466   AC_MSG_CHECKING([for atomic builtins for short])
2467   AC_CACHE_VAL(glibcxx_cv_atomic_short, [
2468     AC_TRY_LINK(
2469       [ ],
2470       [typedef short atomic_type;
2471        atomic_type c1;
2472        atomic_type c2;
2473        const atomic_type c3(0);
2474        __sync_fetch_and_add(&c1, c2);
2475        __sync_val_compare_and_swap(&c1, c3, c2);
2476        __sync_lock_test_and_set(&c1, c3);
2477        __sync_lock_release(&c1);
2478        __sync_synchronize();],
2479       [glibcxx_cv_atomic_short=yes],
2480       [glibcxx_cv_atomic_short=no])
2481   ])    
2482   if test $glibcxx_cv_atomic_short = yes; then
2483     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2484       [Define if builtin atomic operations for short are supported on this host.])
2485   fi
2486   AC_MSG_RESULT($glibcxx_cv_atomic_short)
2487
2488   AC_MSG_CHECKING([for atomic builtins for int])
2489   AC_CACHE_VAL(glibcxx_cv_atomic_int, [
2490     AC_TRY_LINK(
2491       [ ],
2492       [typedef int atomic_type;
2493        atomic_type c1;
2494        atomic_type c2;
2495        const atomic_type c3(0);
2496        __sync_fetch_and_add(&c1, c2);
2497        __sync_val_compare_and_swap(&c1, c3, c2);
2498        __sync_lock_test_and_set(&c1, c3);
2499        __sync_lock_release(&c1);
2500        __sync_synchronize();],
2501       [glibcxx_cv_atomic_int=yes],
2502       [glibcxx_cv_atomic_int=no])
2503   ])    
2504   if test $glibcxx_cv_atomic_int = yes; then
2505     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2506       [Define if builtin atomic operations for int are supported on this host.])
2507   fi
2508   AC_MSG_RESULT($glibcxx_cv_atomic_int)
2509
2510   AC_MSG_CHECKING([for atomic builtins for long long])
2511   AC_CACHE_VAL(glibcxx_cv_atomic_long_long, [
2512     AC_TRY_LINK(
2513       [ ],
2514       [typedef long long atomic_type;
2515        atomic_type c1;
2516        atomic_type c2;
2517        const atomic_type c3(0);
2518        __sync_fetch_and_add(&c1, c2);
2519        __sync_val_compare_and_swap(&c1, c3, c2);
2520        __sync_lock_test_and_set(&c1, c3);
2521        __sync_lock_release(&c1);
2522        __sync_synchronize();],
2523       [glibcxx_cv_atomic_long_long=yes],
2524       [glibcxx_cv_atomic_long_long=no])
2525   ])    
2526   if test $glibcxx_cv_atomic_long_long = yes; then
2527     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2528       [Define if builtin atomic operations for long long are supported on this host.])
2529   fi
2530   AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
2531
2532   else
2533
2534   # Do asm tests.
2535
2536   # Compile unoptimized.
2537   CXXFLAGS='-O0 -S'
2538
2539   # Fake what AC_TRY_COMPILE does.
2540
2541     cat > conftest.$ac_ext << EOF
2542 [#]line __oline__ "configure"
2543 int main()
2544 {
2545   typedef bool atomic_type;
2546   atomic_type c1;
2547   atomic_type c2;
2548   const atomic_type c3(0);
2549   __sync_fetch_and_add(&c1, c2);
2550   __sync_val_compare_and_swap(&c1, c3, c2);
2551   __sync_lock_test_and_set(&c1, c3);
2552   __sync_lock_release(&c1);
2553   __sync_synchronize();
2554   return 0;
2555 }
2556 EOF
2557
2558     AC_MSG_CHECKING([for atomic builtins for bool])
2559     if AC_TRY_EVAL(ac_compile); then
2560       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2561         glibcxx_cv_atomic_bool=no
2562       else
2563       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2564       [Define if builtin atomic operations for bool are supported on this host.])
2565         glibcxx_cv_atomic_bool=yes
2566       fi
2567     fi
2568     AC_MSG_RESULT($glibcxx_cv_atomic_bool)
2569     rm -f conftest*
2570
2571     cat > conftest.$ac_ext << EOF
2572 [#]line __oline__ "configure"
2573 int main()
2574 {
2575   typedef short atomic_type;
2576   atomic_type c1;
2577   atomic_type c2;
2578   const atomic_type c3(0);
2579   __sync_fetch_and_add(&c1, c2);
2580   __sync_val_compare_and_swap(&c1, c3, c2);
2581   __sync_lock_test_and_set(&c1, c3);
2582   __sync_lock_release(&c1);
2583   __sync_synchronize();
2584   return 0;
2585 }
2586 EOF
2587
2588     AC_MSG_CHECKING([for atomic builtins for short])
2589     if AC_TRY_EVAL(ac_compile); then
2590       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2591         glibcxx_cv_atomic_short=no
2592       else
2593       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2594       [Define if builtin atomic operations for short are supported on this host.])
2595         glibcxx_cv_atomic_short=yes
2596       fi
2597     fi
2598     AC_MSG_RESULT($glibcxx_cv_atomic_short)
2599     rm -f conftest*
2600
2601     cat > conftest.$ac_ext << EOF
2602 [#]line __oline__ "configure"
2603 int main()
2604 {
2605   // NB: _Atomic_word not necessarily int. 
2606   typedef int atomic_type;
2607   atomic_type c1;
2608   atomic_type c2;
2609   const atomic_type c3(0);
2610   __sync_fetch_and_add(&c1, c2);
2611   __sync_val_compare_and_swap(&c1, c3, c2);
2612   __sync_lock_test_and_set(&c1, c3);
2613   __sync_lock_release(&c1);
2614   __sync_synchronize();
2615   return 0;
2616 }
2617 EOF
2618
2619     AC_MSG_CHECKING([for atomic builtins for int])
2620     if AC_TRY_EVAL(ac_compile); then
2621       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2622         glibcxx_cv_atomic_int=no
2623       else
2624       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2625         [Define if builtin atomic operations for int are supported on this host.])
2626         glibcxx_cv_atomic_int=yes
2627       fi
2628     fi
2629     AC_MSG_RESULT($glibcxx_cv_atomic_int)
2630     rm -f conftest*
2631
2632     cat > conftest.$ac_ext << EOF
2633 [#]line __oline__ "configure"
2634 int main()
2635 {
2636   typedef long long atomic_type;
2637   atomic_type c1;
2638   atomic_type c2;
2639   const atomic_type c3(0);
2640   __sync_fetch_and_add(&c1, c2);
2641   __sync_val_compare_and_swap(&c1, c3, c2);
2642   __sync_lock_test_and_set(&c1, c3);
2643   __sync_lock_release(&c1);
2644   __sync_synchronize();
2645   return 0;
2646 }
2647 EOF
2648
2649     AC_MSG_CHECKING([for atomic builtins for long long])
2650     if AC_TRY_EVAL(ac_compile); then
2651       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2652         glibcxx_cv_atomic_long_long=no
2653       else
2654       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2655       [Define if builtin atomic operations for long long are supported on this host.])
2656         glibcxx_cv_atomic_long_long=yes
2657       fi
2658     fi
2659     AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
2660     rm -f conftest*
2661
2662   fi
2663
2664   CXXFLAGS="$old_CXXFLAGS"
2665   AC_LANG_RESTORE
2666
2667   # Set atomicity_dir to builtins if either of above tests pass.
2668   if test $glibcxx_cv_atomic_int = yes || test $glibcxx_cv_atomic_bool = yes ; then
2669     atomicity_dir=cpu/generic/atomicity_builtins
2670   fi
2671
2672   # If still generic, set to mutex.
2673   if test $atomicity_dir = "cpu/generic" ; then
2674     atomicity_dir=cpu/generic/atomicity_mutex
2675     AC_MSG_WARN([No native atomic operations are provided for this platform.])
2676       if test "x$target_thread_file" = xsingle; then
2677         AC_MSG_WARN([They cannot be faked when thread support is disabled.])
2678         AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
2679       else
2680         AC_MSG_WARN([They will be faked using a mutex.])
2681         AC_MSG_WARN([Performance of certain classes will degrade as a result.])
2682       fi
2683   fi
2684
2685 ])
2686
2687
2688 dnl
2689 dnl Check for exception handling support.  If an explicit enable/disable
2690 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
2691 dnl target may or may not support call frame exceptions.
2692 dnl
2693 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
2694 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
2695 dnl Neither one forces an attempt at detection.
2696 dnl
2697 dnl Defines:
2698 dnl  _GLIBCXX_SJLJ_EXCEPTIONS if the compiler is configured for it
2699 dnl
2700 AC_DEFUN([GLIBCXX_ENABLE_SJLJ_EXCEPTIONS], [
2701   AC_MSG_CHECKING([for exception model to use])
2702   AC_LANG_SAVE
2703   AC_LANG_CPLUSPLUS
2704   GLIBCXX_ENABLE(sjlj-exceptions,auto,,
2705     [force use of builtin_setjmp for exceptions],
2706     [permit yes|no|auto])
2707
2708   if test $enable_sjlj_exceptions = auto; then
2709     # Botheration.  Now we've got to detect the exception model.  Link tests
2710     # against libgcc.a are problematic since we've not been given proper -L
2711     # bits for single-tree newlib and libgloss.
2712     #
2713     # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
2714     cat > conftest.$ac_ext << EOF
2715 [#]line __oline__ "configure"
2716 struct S { ~S(); };
2717 void bar();
2718 void foo()
2719 {
2720   S s;
2721   bar();
2722 }
2723 EOF
2724     old_CXXFLAGS="$CXXFLAGS"
2725     CXXFLAGS=-S
2726     if AC_TRY_EVAL(ac_compile); then
2727       if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
2728         enable_sjlj_exceptions=yes
2729       elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
2730         enable_sjlj_exceptions=no
2731       elif grep __cxa_end_cleanup conftest.s >/dev/null 2>&1 ; then
2732         enable_sjlj_exceptions=no
2733       fi
2734     fi
2735     CXXFLAGS="$old_CXXFLAGS"
2736     rm -f conftest*
2737   fi
2738
2739   # This is a tad weird, for hysterical raisins.  We have to map
2740   # enable/disable to two different models.
2741   case $enable_sjlj_exceptions in
2742     yes)
2743       AC_DEFINE(_GLIBCXX_SJLJ_EXCEPTIONS, 1,
2744         [Define if the compiler is configured for setjmp/longjmp exceptions.])
2745       ac_exception_model_name=sjlj
2746       ;;
2747     no)
2748       ac_exception_model_name="call frame"
2749       ;;
2750     *)
2751       AC_MSG_ERROR([unable to detect exception model])
2752       ;;
2753   esac
2754  AC_LANG_RESTORE
2755  AC_MSG_RESULT($ac_exception_model_name)
2756 ])
2757
2758
2759 dnl
2760 dnl Allow visibility attributes to be used on namespaces, objects, etc.
2761 dnl
2762 dnl --enable-visibility enables attempt to use visibility attributes.
2763 dnl --disable-visibility turns off all use of visibility attributes.
2764 dnl  +  Usage:  GLIBCXX_ENABLE_VISIBILITY[(DEFAULT)]
2765 dnl       Where DEFAULT is 'yes'.
2766 dnl
2767 AC_DEFUN([GLIBCXX_ENABLE_VISIBILITY], [
2768 GLIBCXX_ENABLE(visibility,$1,,[enables visibility safe usage])
2769
2770 if test x$enable_visibility = xyes ; then
2771   dnl all hail libgfortran
2772   dnl Check whether the target supports hidden visibility.
2773   AC_CACHE_CHECK([whether the target supports hidden visibility],
2774                  glibcxx_cv_have_attribute_visibility, [
2775   save_CFLAGS="$CFLAGS"
2776   CFLAGS="$CFLAGS -Werror"
2777   AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
2778                  [], glibcxx_cv_have_attribute_visibility=yes,
2779                  glibcxx_cv_have_attribute_visibility=no)
2780   CFLAGS="$save_CFLAGS"])
2781   if test $glibcxx_cv_have_attribute_visibility = no; then
2782     enable_visibility=no
2783   fi
2784 fi
2785
2786 GLIBCXX_CONDITIONAL(ENABLE_VISIBILITY, test $enable_visibility = yes)
2787 AC_MSG_NOTICE([visibility supported: $enable_visibility])
2788 ])
2789
2790
2791 dnl
2792 dnl Add version tags to symbols in shared library (or not), additionally
2793 dnl marking other symbols as private/local (or not).
2794 dnl
2795 dnl --enable-symvers=style adds a version script to the linker call when
2796 dnl       creating the shared library.  The choice of version script is
2797 dnl       controlled by 'style'.
2798 dnl --disable-symvers does not.
2799 dnl  +  Usage:  GLIBCXX_ENABLE_SYMVERS[(DEFAULT)]
2800 dnl       Where DEFAULT is either 'yes' or 'no'.  Passing `yes' tries to
2801 dnl       choose a default style based on linker characteristics.  Passing
2802 dnl       'no' disables versioning.
2803 dnl
2804 AC_DEFUN([GLIBCXX_ENABLE_SYMVERS], [
2805
2806 GLIBCXX_ENABLE(symvers,$1,[=STYLE],
2807   [enables symbol versioning of the shared library],
2808   [permit yes|no|gnu|gnu-versioned-namespace|darwin|darwin-export])
2809
2810 # If we never went through the GLIBCXX_CHECK_LINKER_FEATURES macro, then we
2811 # don't know enough about $LD to do tricks...
2812 AC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES])
2813
2814 # Turn a 'yes' into a suitable default.
2815 if test x$enable_symvers = xyes ; then
2816   if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then
2817     enable_symvers=no
2818   else
2819     if test $with_gnu_ld = yes ; then
2820       case ${target_os} in
2821         hpux*)
2822           enable_symvers=no ;;
2823         *)
2824           enable_symvers=gnu ;;
2825       esac
2826     else
2827       case ${target_os} in
2828         darwin*)
2829           enable_symvers=darwin ;;
2830         *)
2831           enable_symvers=no ;;
2832       esac
2833     fi
2834   fi
2835 fi
2836
2837 # Check to see if 'darwin' or 'darwin-export' can win.
2838 if test x$enable_symvers = xdarwin-export ; then
2839     enable_symvers=darwin
2840 fi
2841
2842 # Check to see if 'gnu' can win.
2843 if test $enable_symvers = gnu || test $enable_symvers = gnu-versioned-namespace; then
2844   # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2845   AC_MSG_CHECKING([for shared libgcc])
2846   ac_save_CFLAGS="$CFLAGS"
2847   CFLAGS=' -lgcc_s'
2848   AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes, glibcxx_shared_libgcc=no)
2849   CFLAGS="$ac_save_CFLAGS"
2850   if test $glibcxx_shared_libgcc = no; then
2851     cat > conftest.c <<EOF
2852 int main (void) { return 0; }
2853 EOF
2854 changequote(,)dnl
2855     glibcxx_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
2856                              -shared -shared-libgcc -o conftest.so \
2857                              conftest.c -v 2>&1 >/dev/null \
2858                              | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
2859 changequote([,])dnl
2860     rm -f conftest.c conftest.so
2861     if test x${glibcxx_libgcc_s_suffix+set} = xset; then
2862       CFLAGS=" -lgcc_s$glibcxx_libgcc_s_suffix"
2863       AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes)
2864       CFLAGS="$ac_save_CFLAGS"
2865     fi
2866   fi
2867   AC_MSG_RESULT($glibcxx_shared_libgcc)
2868
2869   # For GNU ld, we need at least this version.  The format is described in
2870   # GLIBCXX_CHECK_LINKER_FEATURES above.
2871   glibcxx_min_gnu_ld_version=21400
2872
2873   # If no shared libgcc, can't win.
2874   if test $glibcxx_shared_libgcc != yes; then
2875       AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
2876       AC_MSG_WARN([=== you are not building a shared libgcc_s.])
2877       AC_MSG_WARN([=== Symbol versioning will be disabled.])
2878       enable_symvers=no
2879   elif test $with_gnu_ld != yes ; then
2880     # just fail for now
2881     AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
2882     AC_MSG_WARN([=== you are not using the GNU linker.])
2883     AC_MSG_WARN([=== Symbol versioning will be disabled.])
2884     enable_symvers=no
2885   elif test $glibcxx_ld_is_gold = yes ; then
2886     : All versions of gold support symbol versioning.
2887   elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
2888     # The right tools, the right setup, but too old.  Fallbacks?
2889     AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for)
2890     AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
2891     AC_MSG_WARN(=== You would need to upgrade your binutils to version)
2892     AC_MSG_WARN(=== $glibcxx_min_gnu_ld_version or later and rebuild GCC.)
2893     AC_MSG_WARN([=== Symbol versioning will be disabled.])
2894     enable_symvers=no
2895   fi
2896 fi
2897
2898 # Everything parsed; figure out what file to use.
2899 case $enable_symvers in
2900   no)
2901     SYMVER_FILE=config/abi/pre/none.ver
2902     ;;
2903   gnu)
2904     SYMVER_FILE=config/abi/pre/gnu.ver
2905     AC_DEFINE(_GLIBCXX_SYMVER_GNU, 1, 
2906               [Define to use GNU versioning in the shared library.])
2907     ;;
2908   gnu-versioned-namespace)
2909     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
2910     AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1, 
2911               [Define to use GNU namespace versioning in the shared library.])
2912     ;;
2913   darwin)
2914     SYMVER_FILE=config/abi/pre/gnu.ver
2915     AC_DEFINE(_GLIBCXX_SYMVER_DARWIN, 1, 
2916               [Define to use darwin versioning in the shared library.])
2917     ;;
2918 esac
2919
2920 if test x$enable_symvers != xno ; then
2921   AC_DEFINE(_GLIBCXX_SYMVER, 1,
2922          [Define to use symbol versioning in the shared library.])
2923 fi
2924
2925 AC_CACHE_CHECK([whether the target supports .symver directive],
2926                glibcxx_cv_have_as_symver_directive, [
2927   AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
2928                  [], glibcxx_cv_have_as_symver_directive=yes,
2929                  glibcxx_cv_have_as_symver_directive=no)])
2930 if test $glibcxx_cv_have_as_symver_directive = yes; then
2931   AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
2932     [Define to 1 if the target assembler supports .symver directive.])
2933 fi
2934
2935 AC_SUBST(SYMVER_FILE)
2936 AC_SUBST(port_specific_symbol_files)
2937 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
2938 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU, test $enable_symvers = gnu)
2939 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU_NAMESPACE, test $enable_symvers = gnu-versioned-namespace)
2940 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_DARWIN, test $enable_symvers = darwin)
2941 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
2942
2943 # Now, set up compatibility support, if any.
2944 # In addition, need this to deal with std::size_t mangling in
2945 # src/compatibility.cc.  In a perfect world, could use
2946 # typeid(std::size_t).name()[0] to do direct substitution.
2947 AC_MSG_CHECKING([for size_t as unsigned int])
2948 ac_save_CFLAGS="$CFLAGS"
2949 CFLAGS="-Werror"
2950 AC_TRY_COMPILE(, [__SIZE_TYPE__* stp; unsigned int* uip; stp = uip;], 
2951                  [glibcxx_size_t_is_i=yes], [glibcxx_size_t_is_i=no])
2952 CFLAGS=$ac_save_CFLAGS
2953 if test "$glibcxx_size_t_is_i" = yes; then
2954   AC_DEFINE(_GLIBCXX_SIZE_T_IS_UINT, 1, [Define if size_t is unsigned int.])
2955 fi
2956 AC_MSG_RESULT([$glibcxx_size_t_is_i])
2957
2958 AC_MSG_CHECKING([for ptrdiff_t as int])
2959 ac_save_CFLAGS="$CFLAGS"
2960 CFLAGS="-Werror"
2961 AC_TRY_COMPILE(, [__PTRDIFF_TYPE__* ptp; int* ip; ptp = ip;], 
2962                  [glibcxx_ptrdiff_t_is_i=yes], [glibcxx_ptrdiff_t_is_i=no])
2963 CFLAGS=$ac_save_CFLAGS
2964 if test "$glibcxx_ptrdiff_t_is_i" = yes; then
2965   AC_DEFINE(_GLIBCXX_PTRDIFF_T_IS_INT, 1, [Define if ptrdiff_t is int.])
2966 fi
2967 AC_MSG_RESULT([$glibcxx_ptrdiff_t_is_i])
2968 ])
2969
2970
2971 dnl
2972 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
2973 dnl We must stage the required headers so that they will be installed
2974 dnl with the library (unlike libgcc, the STL implementation is provided
2975 dnl solely within headers).  Since we must not inject random user-space
2976 dnl macro names into user-provided C++ code, we first stage into <file>-in
2977 dnl and process to <file> with an output command.  The reason for a two-
2978 dnl stage process here is to correctly handle $srcdir!=$objdir without
2979 dnl having to write complex code (the sed commands to clean the macro
2980 dnl namespace are complex and fragile enough as it is).  We must also
2981 dnl add a relative path so that -I- is supported properly.
2982 dnl
2983 dnl Substs:
2984 dnl  glibcxx_thread_h
2985 dnl
2986 dnl Defines:
2987 dnl  HAVE_GTHR_DEFAULT
2988 dnl
2989 AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
2990   AC_MSG_CHECKING([for thread model used by GCC])
2991   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
2992   AC_MSG_RESULT([$target_thread_file])
2993
2994   if test $target_thread_file != single; then
2995     AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
2996               [Define if gthr-default.h exists 
2997               (meaning that threading support is enabled).])
2998   fi
2999
3000   glibcxx_thread_h=gthr-$target_thread_file.h
3001
3002   dnl Check for __GTHREADS define.
3003   gthread_file=${toplevel_srcdir}/gcc/${glibcxx_thread_h}
3004   if grep __GTHREADS $gthread_file >/dev/null 2>&1 ; then
3005     enable_thread=yes
3006   else
3007    enable_thread=no
3008   fi
3009
3010   AC_SUBST(glibcxx_thread_h)
3011 ])
3012
3013
3014 dnl
3015 dnl Check if gthread implementation defines the types and functions
3016 dnl required by the c++0x thread library.  Conforming gthread
3017 dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
3018 dnl
3019 AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
3020   AC_LANG_SAVE
3021   AC_LANG_CPLUSPLUS
3022
3023   ac_save_CXXFLAGS="$CXXFLAGS"
3024   CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc"
3025
3026   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
3027   case $target_thread_file in
3028     posix)
3029       CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
3030   esac
3031
3032   AC_MSG_CHECKING([for gthreads library])
3033
3034   AC_TRY_COMPILE([#include "gthr.h"],
3035     [
3036       #ifndef __GTHREADS_CXX0X
3037       #error
3038       #endif
3039
3040       // In case of POSIX threads check _POSIX_TIMEOUTS too.
3041       #if (defined(_PTHREADS) \
3042            && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
3043       #error
3044       #endif
3045     ], [ac_has_gthreads=yes], [ac_has_gthreads=no])
3046
3047   AC_MSG_RESULT([$ac_has_gthreads])
3048
3049   if test x"$ac_has_gthreads" = x"yes"; then
3050     AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
3051               [Define if gthreads library is available.])
3052   fi
3053
3054   CXXFLAGS="$ac_save_CXXFLAGS"
3055   AC_LANG_RESTORE
3056 ])
3057
3058
3059 # Check whether LC_MESSAGES is available in <locale.h>.
3060 # Ulrich Drepper <drepper@cygnus.com>, 1995.
3061 #
3062 # This file file be copied and used freely without restrictions.  It can
3063 # be used in projects which are not available under the GNU Public License
3064 # but which still want to provide support for the GNU gettext functionality.
3065 # Please note that the actual code is *not* freely available.
3066 AC_DEFUN([AC_LC_MESSAGES], [
3067   AC_CHECK_HEADER(locale.h, [
3068     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
3069       [AC_TRY_COMPILE([#include <locale.h>], [return LC_MESSAGES],
3070        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
3071     if test $ac_cv_val_LC_MESSAGES = yes; then
3072       AC_DEFINE(HAVE_LC_MESSAGES, 1, 
3073                 [Define if LC_MESSAGES is available in <locale.h>.])
3074     fi
3075   ])
3076 ])
3077
3078 # Macros from the top-level gcc directory.
3079 m4_include([../config/tls.m4])
3080