OSDN Git Service

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