OSDN Git Service

2011-08-29 Robert Dewar <dewar@adacore.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  baseline_subdir_switch
594 dnl
595 AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
596   if $GLIBCXX_IS_NATIVE ; then
597     # Do checks for resource limit functions.
598     GLIBCXX_CHECK_SETRLIMIT
599
600     # Look for setenv, so that extended locale tests can be performed.
601     GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
602   fi
603
604   if $GLIBCXX_IS_NATIVE && test $is_hosted = yes &&
605      test $enable_symvers != no; then
606     case "$host" in
607       *-*-cygwin*)
608         enable_abi_check=no ;;
609       *)
610         enable_abi_check=yes ;;
611     esac
612   else
613     # Only build this as native, since automake does not understand
614     # CXX_FOR_BUILD.
615     enable_abi_check=no
616   fi
617
618   # Export file names for ABI checking.
619   baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}"
620   AC_SUBST(baseline_dir)
621   baseline_subdir_switch="$abi_baseline_subdir_switch"
622   AC_SUBST(baseline_subdir_switch)
623 ])
624
625
626 dnl
627 dnl Does any necessary configuration of the documentation directory.
628 dnl
629 dnl XSLTPROC must be set before this
630 dnl
631 dnl Sets:
632 dnl  glibcxx_stylesheets
633 dnl Substs:
634 dnl  XSL_STYLE_DIR
635 dnl
636 AC_DEFUN([GLIBCXX_CONFIGURE_DOCBOOK], [
637
638 AC_MSG_CHECKING([for stylesheets used in generation of documentation])
639 glibcxx_stylesheets=no
640 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
641   glibcxx_stylesheets=yes
642 fi
643 AC_MSG_RESULT($glibcxx_stylesheets)
644
645 AC_MSG_CHECKING([for local stylesheet directory])
646 glibcxx_local_stylesheets=no
647 if test x"$glibcxx_stylesheets" = x"yes"; then
648   if test -d /usr/share/sgml/docbook/xsl-ns-stylesheets; then
649     glibcxx_local_stylesheets=yes
650     XSL_STYLE_DIR=/usr/share/sgml/docbook/xsl-ns-stylesheets
651   fi
652   if test -d /usr/share/xml/docbook/stylesheet/docbook-xsl-ns; then
653     glibcxx_local_stylesheets=yes
654     XSL_STYLE_DIR=/usr/share/xml/docbook/stylesheet/docbook-xsl-ns
655   fi
656 fi
657 AC_MSG_RESULT($glibcxx_local_stylesheets)
658
659 if test x"$glibcxx_local_stylesheets" = x"yes"; then
660   AC_SUBST(XSL_STYLE_DIR)
661   AC_MSG_NOTICE($XSL_STYLE_DIR)
662 else
663   glibcxx_stylesheets=no
664 fi
665 ])
666
667
668 dnl
669 dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
670 dnl
671 dnl Substs:
672 dnl  GLIBCXX_INCLUDES
673 dnl  TOPLEVEL_INCLUDES
674 dnl
675 AC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [
676   # Used for every C++ compile we perform.
677   GLIBCXX_INCLUDES="\
678 -I$glibcxx_builddir/include/$host_alias \
679 -I$glibcxx_builddir/include \
680 -I$glibcxx_srcdir/libsupc++"
681
682   # For Canadian crosses, pick this up too.
683   if test $CANADIAN = yes; then
684     GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
685   fi
686
687   # Stuff in the actual top level.  Currently only used by libsupc++ to
688   # get unwind* headers from the libgcc dir.
689   #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc -I$(toplevel_srcdir)/include'
690   TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc'
691
692   # Now, export this to all the little Makefiles....
693   AC_SUBST(GLIBCXX_INCLUDES)
694   AC_SUBST(TOPLEVEL_INCLUDES)
695 ])
696
697
698 dnl
699 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
700 dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
701 dnl
702 dnl Substs:
703 dnl  OPTIMIZE_CXXFLAGS
704 dnl  WARN_FLAGS
705 dnl
706 AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
707   # Optimization flags that are probably a good idea for thrill-seekers. Just
708   # uncomment the lines below and make, everything else is ready to go...
709   # Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host.
710   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
711   AC_SUBST(OPTIMIZE_CXXFLAGS)
712
713   WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
714   AC_SUBST(WARN_FLAGS)
715 ])
716
717
718 dnl
719 dnl All installation directory information is determined here.
720 dnl
721 dnl Substs:
722 dnl  gxx_install_dir
723 dnl  glibcxx_prefixdir
724 dnl  glibcxx_toolexecdir
725 dnl  glibcxx_toolexeclibdir
726 dnl
727 dnl Assumes cross_compiling bits already done, and with_cross_host in
728 dnl particular.
729 dnl
730 dnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir.
731 dnl config/gxx-include-dir.m4 must be kept consistant with this as well.
732 AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
733   glibcxx_toolexecdir=no
734   glibcxx_toolexeclibdir=no
735   glibcxx_prefixdir=$prefix
736
737   AC_MSG_CHECKING([for gxx-include-dir])
738   AC_ARG_WITH([gxx-include-dir],
739     AC_HELP_STRING([--with-gxx-include-dir=DIR],
740                    [installation directory for include files]),
741     [case "$withval" in
742       yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
743       no)  gxx_include_dir=no ;;
744       *)   gxx_include_dir=$withval ;;
745      esac],
746     [gxx_include_dir=no])
747   AC_MSG_RESULT($gxx_include_dir)
748
749   AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
750   AC_ARG_ENABLE([version-specific-runtime-libs],
751     AC_HELP_STRING([--enable-version-specific-runtime-libs],
752                    [Specify that runtime libraries should be installed in a compiler-specific directory]),
753     [case "$enableval" in
754       yes) version_specific_libs=yes ;;
755       no)  version_specific_libs=no ;;
756       *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
757      esac],
758     [version_specific_libs=no])
759   AC_MSG_RESULT($version_specific_libs)
760
761   # Default case for install directory for include files.
762   if test $version_specific_libs = no && test $gxx_include_dir = no; then
763     gxx_include_dir='include/c++/${gcc_version}'
764     if test -n "$with_cross_host" &&
765        test x"$with_cross_host" != x"no"; then
766       gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir"
767     else
768       gxx_include_dir='${prefix}/'"$gxx_include_dir"
769     fi
770   fi
771
772   # Version-specific runtime libs processing.
773   if test $version_specific_libs = yes; then
774     # Need the gcc compiler version to know where to install libraries
775     # and header files if --enable-version-specific-runtime-libs option
776     # is selected.  FIXME: these variables are misnamed, there are
777     # no executables installed in _toolexecdir or _toolexeclibdir.
778     if test x"$gxx_include_dir" = x"no"; then
779       gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
780     fi
781     glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
782     glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
783   fi
784
785   # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
786   # Install a library built with a cross compiler in tooldir, not libdir.
787   if test x"$glibcxx_toolexecdir" = x"no"; then
788     if test -n "$with_cross_host" &&
789        test x"$with_cross_host" != x"no"; then
790       glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
791       glibcxx_toolexeclibdir='${toolexecdir}/lib'
792     else
793       glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
794       glibcxx_toolexeclibdir='${libdir}'
795     fi
796     multi_os_directory=`$CXX -print-multi-os-directory`
797     case $multi_os_directory in
798       .) ;; # Avoid trailing /.
799       *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
800     esac
801   fi
802
803   AC_MSG_CHECKING([for install location])
804   AC_MSG_RESULT($gxx_include_dir)
805
806   AC_SUBST(glibcxx_prefixdir)
807   AC_SUBST(gxx_include_dir)
808   AC_SUBST(glibcxx_toolexecdir)
809   AC_SUBST(glibcxx_toolexeclibdir)
810 ])
811
812
813 dnl
814 dnl GLIBCXX_ENABLE
815 dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
816 dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
817 dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
818 dnl
819 dnl See docs/html/17_intro/configury.html#enable for documentation.
820 dnl
821 m4_define([GLIBCXX_ENABLE],[dnl
822 m4_define([_g_switch],[--enable-$1])dnl
823 m4_define([_g_help],[AC_HELP_STRING([_g_switch$3],[$4 @<:@default=$2@:>@])])dnl
824  AC_ARG_ENABLE([$1],m4_dquote(_g_help),
825   m4_bmatch([$5],
826    [^permit ],
827      [[
828       case "$enableval" in
829        m4_bpatsubst([$5],[permit ])) ;;
830        *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
831           dnl Idea for future:  generate a URL pointing to
832           dnl "onlinedocs/configopts.html#whatever"
833       esac
834      ]],
835    [^$],
836      [[
837       case "$enableval" in
838        yes|no) ;;
839        *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
840       esac
841      ]],
842    [[$5]]),
843   [enable_]m4_bpatsubst([$1],-,_)[=][$2])
844 m4_undefine([_g_switch])dnl
845 m4_undefine([_g_help])dnl
846 ])
847
848
849 dnl
850 dnl Check for ISO/IEC 9899:1999 "C99" support.
851 dnl
852 dnl --enable-c99 defines _GLIBCXX_USE_C99
853 dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
854 dnl  +  Usage:  GLIBCXX_ENABLE_C99[(DEFAULT)]
855 dnl       Where DEFAULT is either `yes' or `no'.
856 dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
857 dnl
858 AC_DEFUN([GLIBCXX_ENABLE_C99], [
859   GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
860
861   if test x"$enable_c99" = x"yes"; then
862
863   AC_LANG_SAVE
864   AC_LANG_CPLUSPLUS
865
866   # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
867   # undefined and fake C99 facilities - like pre-standard snprintf - may be
868   # spuriously enabled.
869   # Long term, -std=c++0x could be even better, could manage to explicitely
870   # request C99 facilities to the underlying C headers.
871   ac_save_CXXFLAGS="$CXXFLAGS"
872   CXXFLAGS="$CXXFLAGS -std=c++98"
873   ac_save_LIBS="$LIBS"
874   ac_save_gcc_no_link="$gcc_no_link"
875
876   if test x$gcc_no_link != xyes; then
877     # Use -fno-exceptions to that the C driver can link these tests without
878     # hitting undefined references to personality routines.
879     CXXFLAGS="$CXXFLAGS -fno-exceptions"
880     AC_CHECK_LIB(m, sin, [
881       LIBS="$LIBS -lm"
882     ], [
883       # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
884       gcc_no_link=yes
885     ])
886   fi
887
888   # Check for the existence of <math.h> functions used if C99 is enabled.
889   AC_MSG_CHECKING([for ISO C99 support in <math.h>])
890   AC_CACHE_VAL(glibcxx_cv_c99_math, [
891   GCC_TRY_COMPILE_OR_LINK(
892      [#include <math.h>
893       volatile double d1, d2;
894       volatile int i;],
895      [i = fpclassify(d1);
896       i = isfinite(d1);
897       i = isinf(d1);
898       i = isnan(d1);
899       i = isnormal(d1);
900       i = signbit(d1);
901       i = isgreater(d1, d2);
902       i = isgreaterequal(d1, d2);
903       i = isless(d1, d2);
904       i = islessequal(d1, d2);
905       i = islessgreater(d1, d2);
906       i = islessgreater(d1, d2);
907       i = isunordered(d1, d2);
908      ],[glibcxx_cv_c99_math=yes], [glibcxx_cv_c99_math=no])
909   ])
910   AC_MSG_RESULT($glibcxx_cv_c99_math)
911   if test x"$glibcxx_cv_c99_math" = x"yes"; then
912     AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
913               [Define if C99 functions or macros in <math.h> should be imported
914               in <cmath> in namespace std.])
915   fi
916
917   # Check for the existence of <complex.h> complex math functions.
918   # This is necessary even though libstdc++ uses the builtin versions
919   # of these functions, because if the builtin cannot be used, a reference
920   # to the library function is emitted.
921   AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
922   AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
923   glibcxx_cv_c99_complex=no;
924   if test x"$ac_has_complex_h" = x"yes"; then
925     AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
926     GCC_TRY_COMPILE_OR_LINK(
927        [#include <complex.h>
928         typedef __complex__ float float_type;
929         typedef __complex__ double double_type;
930         typedef __complex__ long double ld_type;
931         volatile float_type tmpf;
932         volatile double_type tmpd;
933         volatile ld_type tmpld;
934         volatile float f;
935         volatile double d;
936         volatile long double ld;],
937        [f = cabsf(tmpf);
938         f = cargf(tmpf);
939         tmpf = ccosf(tmpf);
940         tmpf = ccoshf(tmpf);
941         tmpf = cexpf(tmpf);
942         tmpf = clogf(tmpf);
943         tmpf = csinf(tmpf);
944         tmpf = csinhf(tmpf);
945         tmpf = csqrtf(tmpf);
946         tmpf = ctanf(tmpf);
947         tmpf = ctanhf(tmpf);
948         tmpf = cpowf(tmpf, tmpf);
949         tmpf = cprojf(tmpf);
950         d = cabs(tmpd);
951         d = carg(tmpd);
952         tmpd = ccos(tmpd);
953         tmpd = ccosh(tmpd);
954         tmpd = cexp(tmpd);
955         tmpd = clog(tmpd);
956         tmpd = csin(tmpd);
957         tmpd = csinh(tmpd);
958         tmpd = csqrt(tmpd);
959         tmpd = ctan(tmpd);
960         tmpd = ctanh(tmpd);
961         tmpd = cpow(tmpd, tmpd);
962         tmpd = cproj(tmpd);
963         ld = cabsl(tmpld);
964         ld = cargl(tmpld);
965         tmpld = ccosl(tmpld);
966         tmpld = ccoshl(tmpld);
967         tmpld = cexpl(tmpld);
968         tmpld = clogl(tmpld);
969         tmpld = csinl(tmpld);
970         tmpld = csinhl(tmpld);
971         tmpld = csqrtl(tmpld);
972         tmpld = ctanl(tmpld);
973         tmpld = ctanhl(tmpld);
974         tmpld = cpowl(tmpld, tmpld);
975         tmpld = cprojl(tmpld);
976        ],[glibcxx_cv_c99_complex=yes], [glibcxx_cv_c99_complex=no])
977   fi
978   AC_MSG_RESULT($glibcxx_cv_c99_complex)
979   if test x"$glibcxx_cv_c99_complex" = x"yes"; then
980     AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
981               [Define if C99 functions in <complex.h> should be used in
982               <complex>. Using compiler builtins for these functions requires
983               corresponding C99 library functions to be present.])
984   fi
985
986   # Check for the existence in <stdio.h> of vscanf, et. al.
987   AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
988   AC_CACHE_VAL(glibcxx_cv_c99_stdio, [
989   GCC_TRY_COMPILE_OR_LINK(
990      [#include <stdio.h>
991       #include <stdarg.h>
992       void foo(char* fmt, ...)
993       {
994         va_list args; va_start(args, fmt);
995         vfscanf(stderr, "%i", args);
996         vscanf("%i", args);
997         vsnprintf(fmt, 0, "%i", args);
998         vsscanf(fmt, "%i", args);
999       }],
1000      [snprintf("12", 0, "%i");],
1001      [glibcxx_cv_c99_stdio=yes], [glibcxx_cv_c99_stdio=no])
1002   ])
1003   AC_MSG_RESULT($glibcxx_cv_c99_stdio)
1004
1005   # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1006   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1007   AC_CACHE_VAL(glibcxx_cv_c99_stdlib, [
1008   GCC_TRY_COMPILE_OR_LINK(
1009      [#include <stdlib.h>
1010       volatile float f;
1011       volatile long double ld;
1012       volatile unsigned long long ll;
1013       lldiv_t mydivt;],
1014      [char* tmp;
1015       f = strtof("gnu", &tmp);
1016       ld = strtold("gnu", &tmp);
1017       ll = strtoll("gnu", &tmp, 10);
1018       ll = strtoull("gnu", &tmp, 10);
1019       ll = llabs(10);
1020       mydivt = lldiv(10,1);
1021       ll = mydivt.quot;
1022       ll = mydivt.rem;
1023       ll = atoll("10");
1024       _Exit(0);
1025       ],[glibcxx_cv_c99_stdlib=yes], [glibcxx_cv_c99_stdlib=no])
1026   ])
1027   AC_MSG_RESULT($glibcxx_cv_c99_stdlib)
1028
1029   # Check for the existence in <wchar.h> of wcstold, etc.
1030   glibcxx_cv_c99_wchar=no;
1031   if test x"$ac_has_wchar_h" = xyes &&
1032      test x"$ac_has_wctype_h" = xyes; then
1033     AC_MSG_CHECKING([for ISO C99 support in <wchar.h>])
1034     AC_TRY_COMPILE([#include <wchar.h>
1035                     namespace test
1036                     {
1037                       using ::wcstold;
1038                       using ::wcstoll;
1039                       using ::wcstoull;
1040                     }
1041                    ],[],[glibcxx_cv_c99_wchar=yes], [glibcxx_cv_c99_wchar=no])
1042
1043     # Checks for wide character functions that may not be present.
1044     # Injection of these is wrapped with guard macros.
1045     # NB: only put functions here, instead of immediately above, if
1046     # absolutely necessary.
1047     AC_TRY_COMPILE([#include <wchar.h>
1048                     namespace test { using ::vfwscanf; } ], [],
1049                    [AC_DEFINE(HAVE_VFWSCANF,1,
1050                         [Defined if vfwscanf exists.])],[])
1051
1052     AC_TRY_COMPILE([#include <wchar.h>
1053                     namespace test { using ::vswscanf; } ], [],
1054                    [AC_DEFINE(HAVE_VSWSCANF,1,
1055                         [Defined if vswscanf exists.])],[])
1056
1057     AC_TRY_COMPILE([#include <wchar.h>
1058                     namespace test { using ::vwscanf; } ], [],
1059                    [AC_DEFINE(HAVE_VWSCANF,1,[Defined if vwscanf exists.])],[])
1060
1061     AC_TRY_COMPILE([#include <wchar.h>
1062                     namespace test { using ::wcstof; } ], [],
1063                    [AC_DEFINE(HAVE_WCSTOF,1,[Defined if wcstof exists.])],[])
1064
1065     AC_TRY_COMPILE([#include <wctype.h>],
1066                    [ wint_t t; int i = iswblank(t);],
1067                    [AC_DEFINE(HAVE_ISWBLANK,1,
1068                         [Defined if iswblank exists.])],[])
1069
1070     AC_MSG_RESULT($glibcxx_cv_c99_wchar)
1071   fi
1072
1073   # Option parsed, now set things appropriately.
1074   if test x"$glibcxx_cv_c99_math" = x"no" ||
1075      test x"$glibcxx_cv_c99_complex" = x"no" ||
1076      test x"$glibcxx_cv_c99_stdio" = x"no" ||
1077      test x"$glibcxx_cv_c99_stdlib" = x"no" ||
1078      test x"$glibcxx_cv_c99_wchar" = x"no"; then
1079     enable_c99=no;
1080   else
1081     AC_DEFINE(_GLIBCXX_USE_C99, 1,
1082     [Define if C99 functions or macros from <wchar.h>, <math.h>,
1083     <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed.])
1084   fi
1085
1086   gcc_no_link="$ac_save_gcc_no_link"
1087   LIBS="$ac_save_LIBS"
1088   CXXFLAGS="$ac_save_CXXFLAGS"
1089   AC_LANG_RESTORE
1090   fi
1091
1092   AC_MSG_CHECKING([for fully enabled ISO C99 support])
1093   AC_MSG_RESULT($enable_c99)
1094 ])
1095
1096
1097 dnl
1098 dnl Check for clock_gettime, nanosleep and sched_yield, used in the
1099 dnl implementation of 20.8.5 [time.clock], and 30.2.2 [thread.thread.this]
1100 dnl in the current C++0x working draft.
1101 dnl
1102 dnl --enable-libstdcxx-time
1103 dnl --enable-libstdcxx-time=yes
1104 dnl        checks for the availability of monotonic and realtime clocks,
1105 dnl        nanosleep and sched_yield in libc and libposix4 and, in case, links
1106 dnl       the latter
1107 dnl --enable-libstdcxx-time=rt
1108 dnl        also searches (and, in case, links) librt.  Note that this is
1109 dnl        not always desirable because, in glibc, for example, in turn it
1110 dnl        triggers the linking of libpthread too, which activates locking,
1111 dnl        a large overhead for single-thread programs.
1112 dnl --enable-libstdcxx-time=no
1113 dnl --disable-libstdcxx-time
1114 dnl        disables the checks completely
1115 dnl
1116 AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
1117
1118   AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield])
1119   GLIBCXX_ENABLE(libstdcxx-time,$1,[[[=KIND]]],
1120     [use KIND for check type],
1121     [permit yes|no|rt])
1122
1123   AC_LANG_SAVE
1124   AC_LANG_CPLUSPLUS
1125   ac_save_CXXFLAGS="$CXXFLAGS"
1126   CXXFLAGS="$CXXFLAGS -fno-exceptions"
1127   ac_save_LIBS="$LIBS"
1128
1129   ac_has_clock_monotonic=no
1130   ac_has_clock_realtime=no
1131   AC_MSG_RESULT($enable_libstdcxx_time)
1132
1133   if test x"$enable_libstdcxx_time" != x"no"; then
1134
1135     if test x"$enable_libstdcxx_time" = x"rt"; then
1136       AC_SEARCH_LIBS(clock_gettime, [rt posix4])
1137       AC_SEARCH_LIBS(nanosleep, [rt posix4])
1138     else
1139       AC_SEARCH_LIBS(clock_gettime, [posix4])
1140       AC_SEARCH_LIBS(nanosleep, [posix4])
1141     fi
1142
1143     case "$ac_cv_search_clock_gettime" in
1144       -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
1145       ;;
1146     esac
1147     case "$ac_cv_search_nanosleep" in
1148       -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
1149       ;;
1150     esac
1151
1152     AC_SEARCH_LIBS(sched_yield, [rt posix4])
1153
1154     case "$ac_cv_search_sched_yield" in
1155       -lposix4*)
1156       GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1157       AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1158                 [ Defined if sched_yield is available. ])
1159       ;;
1160       -lrt*)
1161       if test x"$enable_libstdcxx_time" = x"rt"; then
1162         GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1163         AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1164                   [ Defined if sched_yield is available. ])
1165       fi
1166       ;;
1167       *)
1168       AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1169                 [ Defined if sched_yield is available. ])
1170       ;;
1171     esac
1172
1173     AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
1174
1175     if test x"$ac_has_unistd_h" = x"yes"; then
1176       AC_MSG_CHECKING([for monotonic clock])
1177       AC_TRY_LINK(
1178         [#include <unistd.h>
1179          #include <time.h>
1180         ],
1181         [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
1182           timespec tp;
1183          #endif
1184           clock_gettime(CLOCK_MONOTONIC, &tp);
1185         ], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
1186
1187       AC_MSG_RESULT($ac_has_clock_monotonic)
1188
1189       AC_MSG_CHECKING([for realtime clock])
1190       AC_TRY_LINK(
1191         [#include <unistd.h>
1192          #include <time.h>
1193         ],
1194         [#if _POSIX_TIMERS > 0
1195           timespec tp;
1196          #endif
1197           clock_gettime(CLOCK_REALTIME, &tp);
1198         ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
1199
1200       AC_MSG_RESULT($ac_has_clock_realtime)
1201
1202       AC_MSG_CHECKING([for nanosleep])
1203       AC_TRY_LINK(
1204         [#include <unistd.h>
1205          #include <time.h>
1206         ],
1207         [#if _POSIX_TIMERS > 0
1208           timespec tp;
1209          #endif
1210           nanosleep(&tp, 0);
1211         ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
1212
1213       AC_MSG_RESULT($ac_has_nanosleep)
1214     fi
1215   fi
1216
1217   if test x"$ac_has_clock_monotonic" = x"yes"; then
1218     AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
1219       [ Defined if clock_gettime has monotonic clock support. ])
1220   fi
1221
1222   if test x"$ac_has_clock_realtime" = x"yes"; then
1223     AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1,
1224       [ Defined if clock_gettime has realtime clock support. ])
1225   fi
1226
1227   if test x"$ac_has_nanosleep" = x"yes"; then
1228     AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
1229       [ Defined if nanosleep is available. ])
1230   fi
1231
1232   AC_SUBST(GLIBCXX_LIBS)
1233
1234   CXXFLAGS="$ac_save_CXXFLAGS"
1235   LIBS="$ac_save_LIBS"
1236   AC_LANG_RESTORE
1237 ])
1238
1239 dnl
1240 dnl Check for gettimeofday, used in the implementation of 20.8.5
1241 dnl [time.clock] in the current C++0x working draft.
1242 dnl
1243 AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
1244
1245   AC_MSG_CHECKING([for gettimeofday])
1246
1247   AC_LANG_SAVE
1248   AC_LANG_CPLUSPLUS
1249   ac_save_CXXFLAGS="$CXXFLAGS"
1250   CXXFLAGS="$CXXFLAGS -fno-exceptions"
1251
1252   ac_has_gettimeofday=no;
1253   AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
1254   if test x"$ac_has_sys_time_h" = x"yes"; then
1255     AC_MSG_CHECKING([for gettimeofday])
1256     GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>],
1257       [timeval tv; gettimeofday(&tv, 0);],
1258       [ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])
1259
1260     AC_MSG_RESULT($ac_has_gettimeofday)
1261   fi
1262
1263   if test x"$ac_has_gettimeofday" = x"yes"; then
1264     AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1,
1265       [ Defined if gettimeofday is available. ])
1266   fi
1267
1268   CXXFLAGS="$ac_save_CXXFLAGS"
1269   AC_LANG_RESTORE
1270 ])
1271
1272 dnl
1273 dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
1274 dnl facilities in Chapter 8, "C compatibility".
1275 dnl
1276 AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
1277
1278   AC_LANG_SAVE
1279   AC_LANG_CPLUSPLUS
1280
1281   # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
1282   # undefined and fake C99 facilities may be spuriously enabled.
1283   ac_save_CXXFLAGS="$CXXFLAGS"
1284   CXXFLAGS="$CXXFLAGS -std=c++98"
1285
1286   # Check for the existence of <complex.h> complex math functions used
1287   # by tr1/complex.
1288   AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
1289   ac_c99_complex_tr1=no;
1290   if test x"$ac_has_complex_h" = x"yes"; then
1291     AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>])
1292     AC_TRY_COMPILE([#include <complex.h>],
1293                    [typedef __complex__ float float_type; float_type tmpf;
1294                     cacosf(tmpf);
1295                     casinf(tmpf);
1296                     catanf(tmpf);
1297                     cacoshf(tmpf);
1298                     casinhf(tmpf);
1299                     catanhf(tmpf);
1300                     typedef __complex__ double double_type; double_type tmpd;
1301                     cacos(tmpd);
1302                     casin(tmpd);
1303                     catan(tmpd);
1304                     cacosh(tmpd);
1305                     casinh(tmpd);
1306                     catanh(tmpd);
1307                     typedef __complex__ long double ld_type; ld_type tmpld;
1308                     cacosl(tmpld);
1309                     casinl(tmpld);
1310                     catanl(tmpld);
1311                     cacoshl(tmpld);
1312                     casinhl(tmpld);
1313                     catanhl(tmpld);
1314                    ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no])
1315   fi
1316   AC_MSG_RESULT($ac_c99_complex_tr1)
1317   if test x"$ac_c99_complex_tr1" = x"yes"; then
1318     AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1,
1319               [Define if C99 functions in <complex.h> should be used in
1320               <tr1/complex>. Using compiler builtins for these functions
1321               requires corresponding C99 library functions to be present.])
1322   fi
1323
1324   # Check for the existence of <ctype.h> functions.
1325   AC_MSG_CHECKING([for ISO C99 support to TR1 in <ctype.h>])
1326   AC_CACHE_VAL(glibcxx_cv_c99_ctype_tr1, [
1327   AC_TRY_COMPILE([#include <ctype.h>],
1328                  [int ch;
1329                   int ret;
1330                   ret = isblank(ch);
1331                  ],[glibcxx_cv_c99_ctype_tr1=yes],
1332                    [glibcxx_cv_c99_ctype_tr1=no])
1333   ])
1334   AC_MSG_RESULT($glibcxx_cv_c99_ctype_tr1)
1335   if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then
1336     AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
1337               [Define if C99 functions in <ctype.h> should be imported in
1338               <tr1/cctype> in namespace std::tr1.])
1339   fi
1340
1341   # Check for the existence of <fenv.h> functions.
1342   AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
1343   ac_c99_fenv_tr1=no;
1344   if test x"$ac_has_fenv_h" = x"yes"; then
1345     AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>])
1346     AC_TRY_COMPILE([#include <fenv.h>],
1347                    [int except, mode;
1348                     fexcept_t* pflag;
1349                     fenv_t* penv;
1350                     int ret;
1351                     ret = feclearexcept(except);
1352                     ret = fegetexceptflag(pflag, except);
1353                     ret = feraiseexcept(except);
1354                     ret = fesetexceptflag(pflag, except);
1355                     ret = fetestexcept(except);
1356                     ret = fegetround();
1357                     ret = fesetround(mode);
1358                     ret = fegetenv(penv);
1359                     ret = feholdexcept(penv);
1360                     ret = fesetenv(penv);
1361                     ret = feupdateenv(penv);
1362                    ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no])
1363   fi
1364   AC_MSG_RESULT($ac_c99_fenv_tr1)
1365   if test x"$ac_c99_fenv_tr1" = x"yes"; then
1366     AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1,
1367               [Define if C99 functions in <fenv.h> should be imported in
1368               <tr1/cfenv> in namespace std::tr1.])
1369   fi
1370
1371   # Check for the existence of <stdint.h> types.
1372   AC_MSG_CHECKING([for ISO C99 support to TR1 in <stdint.h>])
1373   AC_CACHE_VAL(glibcxx_cv_c99_stdint_tr1, [
1374   AC_TRY_COMPILE([#define __STDC_LIMIT_MACROS
1375                   #define __STDC_CONSTANT_MACROS
1376                   #include <stdint.h>],
1377                  [typedef int8_t          my_int8_t;
1378                   my_int8_t               i8 = INT8_MIN;
1379                   i8 = INT8_MAX;
1380                   typedef int16_t         my_int16_t;
1381                   my_int16_t              i16 = INT16_MIN;
1382                   i16 = INT16_MAX;
1383                   typedef int32_t         my_int32_t;
1384                   my_int32_t              i32 = INT32_MIN;
1385                   i32 = INT32_MAX;
1386                   typedef int64_t         my_int64_t;
1387                   my_int64_t              i64 = INT64_MIN;
1388                   i64 = INT64_MAX;
1389                   typedef int_fast8_t     my_int_fast8_t;
1390                   my_int_fast8_t          if8 = INT_FAST8_MIN;
1391                   if8 = INT_FAST8_MAX;
1392                   typedef int_fast16_t    my_int_fast16_t;
1393                   my_int_fast16_t         if16 = INT_FAST16_MIN;
1394                   if16 = INT_FAST16_MAX;
1395                   typedef int_fast32_t    my_int_fast32_t;
1396                   my_int_fast32_t         if32 = INT_FAST32_MIN;
1397                   if32 = INT_FAST32_MAX;
1398                   typedef int_fast64_t    my_int_fast64_t;
1399                   my_int_fast64_t         if64 = INT_FAST64_MIN;
1400                   if64 = INT_FAST64_MAX;
1401                   typedef int_least8_t    my_int_least8_t;
1402                   my_int_least8_t         il8 = INT_LEAST8_MIN;
1403                   il8 = INT_LEAST8_MAX;
1404                   typedef int_least16_t   my_int_least16_t;
1405                   my_int_least16_t        il16 = INT_LEAST16_MIN;
1406                   il16 = INT_LEAST16_MAX;
1407                   typedef int_least32_t   my_int_least32_t;
1408                   my_int_least32_t        il32 = INT_LEAST32_MIN;
1409                   il32 = INT_LEAST32_MAX;
1410                   typedef int_least64_t   my_int_least64_t;
1411                   my_int_least64_t        il64 = INT_LEAST64_MIN;
1412                   il64 = INT_LEAST64_MAX;
1413                   typedef intmax_t        my_intmax_t;
1414                   my_intmax_t             im = INTMAX_MAX;
1415                   im = INTMAX_MIN;
1416                   typedef intptr_t        my_intptr_t;
1417                   my_intptr_t             ip = INTPTR_MAX;
1418                   ip = INTPTR_MIN;
1419                   typedef uint8_t         my_uint8_t;
1420                   my_uint8_t              ui8 = UINT8_MAX;
1421                   ui8 = UINT8_MAX;
1422                   typedef uint16_t        my_uint16_t;
1423                   my_uint16_t             ui16 = UINT16_MAX;
1424                   ui16 = UINT16_MAX;
1425                   typedef uint32_t        my_uint32_t;
1426                   my_uint32_t             ui32 = UINT32_MAX;
1427                   ui32 = UINT32_MAX;
1428                   typedef uint64_t        my_uint64_t;
1429                   my_uint64_t             ui64 = UINT64_MAX;
1430                   ui64 = UINT64_MAX;
1431                   typedef uint_fast8_t    my_uint_fast8_t;
1432                   my_uint_fast8_t         uif8 = UINT_FAST8_MAX;
1433                   uif8 = UINT_FAST8_MAX;
1434                   typedef uint_fast16_t   my_uint_fast16_t;
1435                   my_uint_fast16_t        uif16 = UINT_FAST16_MAX;
1436                   uif16 = UINT_FAST16_MAX;
1437                   typedef uint_fast32_t   my_uint_fast32_t;
1438                   my_uint_fast32_t        uif32 = UINT_FAST32_MAX;
1439                   uif32 = UINT_FAST32_MAX;
1440                   typedef uint_fast64_t   my_uint_fast64_t;
1441                   my_uint_fast64_t        uif64 = UINT_FAST64_MAX;
1442                   uif64 = UINT_FAST64_MAX;
1443                   typedef uint_least8_t   my_uint_least8_t;
1444                   my_uint_least8_t        uil8 = UINT_LEAST8_MAX;
1445                   uil8 = UINT_LEAST8_MAX;
1446                   typedef uint_least16_t  my_uint_least16_t;
1447                   my_uint_least16_t       uil16 = UINT_LEAST16_MAX;
1448                   uil16 = UINT_LEAST16_MAX;
1449                   typedef uint_least32_t  my_uint_least32_t;
1450                   my_uint_least32_t       uil32 = UINT_LEAST32_MAX;
1451                   uil32 = UINT_LEAST32_MAX;
1452                   typedef uint_least64_t  my_uint_least64_t;
1453                   my_uint_least64_t       uil64 = UINT_LEAST64_MAX;
1454                   uil64 = UINT_LEAST64_MAX;
1455                   typedef uintmax_t       my_uintmax_t;
1456                   my_uintmax_t            uim = UINTMAX_MAX;
1457                   uim = UINTMAX_MAX;
1458                   typedef uintptr_t       my_uintptr_t;
1459                   my_uintptr_t            uip = UINTPTR_MAX;
1460                   uip = UINTPTR_MAX;
1461                  ],[glibcxx_cv_c99_stdint_tr1=yes],
1462                    [glibcxx_cv_c99_stdint_tr1=no])
1463   ])
1464   AC_MSG_RESULT($glibcxx_cv_c99_stdint_tr1)
1465   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1466     AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1,
1467               [Define if C99 types in <stdint.h> should be imported in
1468               <tr1/cstdint> in namespace std::tr1.])
1469   fi
1470
1471   # Check for the existence of <math.h> functions.
1472   AC_MSG_CHECKING([for ISO C99 support to TR1 in <math.h>])
1473   AC_CACHE_VAL(glibcxx_cv_c99_math_tr1, [
1474   AC_TRY_COMPILE([#include <math.h>],
1475                  [typedef double_t  my_double_t;
1476                   typedef float_t   my_float_t;
1477                   acosh(0.0);
1478                   acoshf(0.0f);
1479                   acoshl(0.0l);
1480                   asinh(0.0);
1481                   asinhf(0.0f);
1482                   asinhl(0.0l);
1483                   atanh(0.0);
1484                   atanhf(0.0f);
1485                   atanhl(0.0l);
1486                   cbrt(0.0);
1487                   cbrtf(0.0f);
1488                   cbrtl(0.0l);
1489                   copysign(0.0, 0.0);
1490                   copysignf(0.0f, 0.0f);
1491                   copysignl(0.0l, 0.0l);
1492                   erf(0.0);
1493                   erff(0.0f);
1494                   erfl(0.0l);
1495                   erfc(0.0);
1496                   erfcf(0.0f);
1497                   erfcl(0.0l);
1498                   exp2(0.0);
1499                   exp2f(0.0f);
1500                   exp2l(0.0l);
1501                   expm1(0.0);
1502                   expm1f(0.0f);
1503                   expm1l(0.0l);
1504                   fdim(0.0, 0.0);
1505                   fdimf(0.0f, 0.0f);
1506                   fdiml(0.0l, 0.0l);
1507                   fma(0.0, 0.0, 0.0);
1508                   fmaf(0.0f, 0.0f, 0.0f);
1509                   fmal(0.0l, 0.0l, 0.0l);
1510                   fmax(0.0, 0.0);
1511                   fmaxf(0.0f, 0.0f);
1512                   fmaxl(0.0l, 0.0l);
1513                   fmin(0.0, 0.0);
1514                   fminf(0.0f, 0.0f);
1515                   fminl(0.0l, 0.0l);
1516                   hypot(0.0, 0.0);
1517                   hypotf(0.0f, 0.0f);
1518                   hypotl(0.0l, 0.0l);
1519                   ilogb(0.0);
1520                   ilogbf(0.0f);
1521                   ilogbl(0.0l);
1522                   lgamma(0.0);
1523                   lgammaf(0.0f);
1524                   lgammal(0.0l);
1525                   llrint(0.0);
1526                   llrintf(0.0f);
1527                   llrintl(0.0l);
1528                   llround(0.0);
1529                   llroundf(0.0f);
1530                   llroundl(0.0l);
1531                   log1p(0.0);
1532                   log1pf(0.0f);
1533                   log1pl(0.0l);
1534                   log2(0.0);
1535                   log2f(0.0f);
1536                   log2l(0.0l);
1537                   logb(0.0);
1538                   logbf(0.0f);
1539                   logbl(0.0l);
1540                   lrint(0.0);
1541                   lrintf(0.0f);
1542                   lrintl(0.0l);
1543                   lround(0.0);
1544                   lroundf(0.0f);
1545                   lroundl(0.0l);
1546                   nan(0);
1547                   nanf(0);
1548                   nanl(0);
1549                   nearbyint(0.0);
1550                   nearbyintf(0.0f);
1551                   nearbyintl(0.0l);
1552                   nextafter(0.0, 0.0);
1553                   nextafterf(0.0f, 0.0f);
1554                   nextafterl(0.0l, 0.0l);
1555                   nexttoward(0.0, 0.0);
1556                   nexttowardf(0.0f, 0.0f);
1557                   nexttowardl(0.0l, 0.0l);
1558                   remainder(0.0, 0.0);
1559                   remainderf(0.0f, 0.0f);
1560                   remainderl(0.0l, 0.0l);
1561                   remquo(0.0, 0.0, 0);
1562                   remquof(0.0f, 0.0f, 0);
1563                   remquol(0.0l, 0.0l, 0);
1564                   rint(0.0);
1565                   rintf(0.0f);
1566                   rintl(0.0l);
1567                   round(0.0);
1568                   roundf(0.0f);
1569                   roundl(0.0l);
1570                   scalbln(0.0, 0l);
1571                   scalblnf(0.0f, 0l);
1572                   scalblnl(0.0l, 0l);
1573                   scalbn(0.0, 0);
1574                   scalbnf(0.0f, 0);
1575                   scalbnl(0.0l, 0);
1576                   tgamma(0.0);
1577                   tgammaf(0.0f);
1578                   tgammal(0.0l);
1579                   trunc(0.0);
1580                   truncf(0.0f);
1581                   truncl(0.0l);
1582                  ],[glibcxx_cv_c99_math_tr1=yes], [glibcxx_cv_c99_math_tr1=no])
1583   ])
1584   AC_MSG_RESULT($glibcxx_cv_c99_math_tr1)
1585   if test x"$glibcxx_cv_c99_math_tr1" = x"yes"; then
1586     AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1,
1587               [Define if C99 functions or macros in <math.h> should be imported
1588               in <tr1/cmath> in namespace std::tr1.])
1589   fi
1590
1591   # Check for the existence of <inttypes.h> functions (NB: doesn't make
1592   # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1593   ac_c99_inttypes_tr1=no;
1594   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1595     AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>])
1596     AC_TRY_COMPILE([#include <inttypes.h>],
1597                    [intmax_t i, numer, denom, base;
1598                     const char* s;
1599                     char** endptr;
1600                     intmax_t ret = imaxabs(i);
1601                     imaxdiv_t dret = imaxdiv(numer, denom);
1602                     ret = strtoimax(s, endptr, base);
1603                     uintmax_t uret = strtoumax(s, endptr, base);
1604                    ],[ac_c99_inttypes_tr1=yes], [ac_c99_inttypes_tr1=no])
1605   fi
1606   AC_MSG_RESULT($ac_c99_inttypes_tr1)
1607   if test x"$ac_c99_inttypes_tr1" = x"yes"; then
1608     AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_TR1, 1,
1609               [Define if C99 functions in <inttypes.h> should be imported in
1610               <tr1/cinttypes> in namespace std::tr1.])
1611   fi
1612
1613   # Check for the existence of whcar_t <inttypes.h> functions (NB: doesn't
1614   # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1615   ac_c99_inttypes_wchar_t_tr1=no;
1616   if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1617     AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>])
1618     AC_TRY_COMPILE([#include <inttypes.h>],
1619                    [intmax_t base;
1620                     const wchar_t* s;
1621                     wchar_t** endptr;
1622                     intmax_t ret = wcstoimax(s, endptr, base);
1623                     uintmax_t uret = wcstoumax(s, endptr, base);
1624                    ],[ac_c99_inttypes_wchar_t_tr1=yes],
1625                      [ac_c99_inttypes_wchar_t_tr1=no])
1626   fi
1627   AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1)
1628   if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then
1629     AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1,
1630               [Define if wchar_t C99 functions in <inttypes.h> should be
1631               imported in <tr1/cinttypes> in namespace std::tr1.])
1632   fi
1633
1634   # Check for the existence of the <stdbool.h> header.
1635   AC_CHECK_HEADERS(stdbool.h)
1636
1637   CXXFLAGS="$ac_save_CXXFLAGS"
1638   AC_LANG_RESTORE
1639 ])
1640
1641 dnl
1642 dnl Check whether "/dev/random" and "/dev/urandom" are available for the
1643 dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
1644 dnl
1645 AC_DEFUN([GLIBCXX_CHECK_RANDOM_TR1], [
1646
1647   AC_MSG_CHECKING([for "/dev/random" and "/dev/urandom" for TR1 random_device])
1648   AC_CACHE_VAL(glibcxx_cv_random_tr1, [
1649     if test -r /dev/random && test -r /dev/urandom; then
1650       glibcxx_cv_random_tr1=yes;
1651     else
1652       glibcxx_cv_random_tr1=no;
1653     fi
1654   ])
1655   AC_MSG_RESULT($glibcxx_cv_random_tr1)
1656
1657   if test x"$glibcxx_cv_random_tr1" = x"yes"; then
1658     AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1,
1659               [Define if /dev/random and /dev/urandom are available for
1660                the random_device of TR1 (Chapter 5.1).])
1661   fi
1662
1663 ])
1664
1665 dnl
1666 dnl Compute the EOF, SEEK_CUR, and SEEK_END integer constants.
1667 dnl
1668 AC_DEFUN([GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS], [
1669
1670   AC_CACHE_CHECK([for the value of EOF], glibcxx_cv_stdio_eof, [
1671   AC_COMPUTE_INT([glibcxx_cv_stdio_eof], [[EOF]],
1672                  [#include <stdio.h>],
1673                  [AC_MSG_ERROR([computing EOF failed])])
1674   ])
1675   AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_EOF, $glibcxx_cv_stdio_eof,
1676                      [Define to the value of the EOF integer constant.])
1677
1678   AC_CACHE_CHECK([for the value of SEEK_CUR], glibcxx_cv_stdio_seek_cur, [
1679   AC_COMPUTE_INT([glibcxx_cv_stdio_seek_cur], [[SEEK_CUR]],
1680                  [#include <stdio.h>],
1681                  [AC_MSG_ERROR([computing SEEK_CUR failed])])
1682   ])
1683   AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_CUR, $glibcxx_cv_stdio_seek_cur,
1684                      [Define to the value of the SEEK_CUR integer constant.])
1685
1686   AC_CACHE_CHECK([for the value of SEEK_END], glibcxx_cv_stdio_seek_end, [
1687   AC_COMPUTE_INT([glibcxx_cv_stdio_seek_end], [[SEEK_END]],
1688                  [#include <stdio.h>],
1689                  [AC_MSG_ERROR([computing SEEK_END failed])])
1690   ])
1691   AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_END, $glibcxx_cv_stdio_seek_end,
1692                      [Define to the value of the SEEK_END integer constant.])
1693 ])
1694
1695 dnl
1696 dnl Check whether required C++ overloads are present in <math.h>.
1697 dnl
1698
1699 AC_DEFUN([GLIBCXX_CHECK_MATH_PROTO], [
1700
1701   AC_LANG_SAVE
1702   AC_LANG_CPLUSPLUS
1703
1704   case "$host" in
1705     *-*-solaris2.*)
1706       # Solaris 8 FCS only had an overload for double std::abs(double) in
1707       # <iso/math_iso.h>.  Patches 111721-04 (SPARC) and 112757-01 (x86)
1708       # introduced the full set also found from Solaris 9 onwards.
1709       AC_MSG_CHECKING([for float std::abs(float) overload])
1710       AC_CACHE_VAL(glibcxx_cv_abs_float, [
1711         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1712           [#include <math.h>
1713            namespace std {
1714              inline float abs(float __x)
1715              {  return __builtin_fabsf(__x); }
1716            }
1717         ])],
1718         [glibcxx_cv_abs_float=no],
1719         [glibcxx_cv_abs_float=yes]
1720       )])
1721
1722       # autoheader cannot handle indented templates.
1723       AH_VERBATIM([__CORRECT_ISO_CPP_MATH_H_PROTO1],
1724         [/* Define if all C++ overloads are available in <math.h>.  */
1725 #if __cplusplus >= 199711L
1726 #undef __CORRECT_ISO_CPP_MATH_H_PROTO1
1727 #endif])
1728       AH_VERBATIM([__CORRECT_ISO_CPP_MATH_H_PROTO2],
1729         [/* Define if only double std::abs(double) is available in <math.h>.  */
1730 #if __cplusplus >= 199711L
1731 #undef __CORRECT_ISO_CPP_MATH_H_PROTO2
1732 #endif])
1733
1734       if test $glibcxx_cv_abs_float = yes; then
1735         AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO1)
1736       else
1737         AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO2)
1738       fi
1739       AC_MSG_RESULT($glibcxx_cv_abs_float)
1740       ;;
1741   esac
1742
1743   AC_LANG_RESTORE
1744 ])
1745
1746 dnl
1747 dnl Check whether required C++ overloads are present in <stdlib.h>.
1748 dnl
1749
1750 AC_DEFUN([GLIBCXX_CHECK_STDLIB_PROTO], [
1751
1752   AC_LANG_SAVE
1753   AC_LANG_CPLUSPLUS
1754
1755   case "$host" in
1756     *-*-solaris2.*)
1757       # Solaris 8 FCS lacked the overloads for long std::abs(long) and
1758       # ldiv_t std::div(long, long) in <iso/stdlib_iso.h>.  Patches 109607-02
1759       # (SPARC) and 109608-02 (x86) introduced them.
1760       AC_MSG_CHECKING([for long std::abs(long) overload])
1761       AC_CACHE_VAL(glibcxx_cv_abs_long, [
1762         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1763           [#include <stdlib.h>
1764            namespace std {
1765              inline long
1766              abs(long __i) { return labs(__i); }
1767            }
1768         ])],
1769         [glibcxx_cv_abs_long=no],
1770         [glibcxx_cv_abs_long=yes]
1771       )])
1772
1773       # autoheader cannot handle indented templates.
1774       AH_VERBATIM([__CORRECT_ISO_CPP_STDLIB_H_PROTO],
1775         [/* Define if all C++ overloads are available in <stdlib.h>.  */
1776 #if __cplusplus >= 199711L
1777 #undef __CORRECT_ISO_CPP_STDLIB_H_PROTO
1778 #endif])
1779       if test $glibcxx_cv_abs_long = yes; then
1780         AC_DEFINE(__CORRECT_ISO_CPP_STDLIB_H_PROTO, 1)
1781       fi
1782       AC_MSG_RESULT($glibcxx_cv_abs_long)
1783       ;;
1784   esac
1785
1786   AC_LANG_RESTORE
1787 ])
1788
1789 dnl
1790 dnl Check whether macros, etc are present for <system_error>
1791 dnl
1792 AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
1793
1794 m4_pushdef([n_syserr], [1])dnl
1795 m4_foreach([syserr], [EOWNERDEAD, ENOTRECOVERABLE, ENOLINK, EPROTO, ENODATA,
1796                       ENOSR, ENOSTR, ETIME, EBADMSG, ECANCELED,
1797                       EOVERFLOW, ENOTSUP, EIDRM, ETXTBSY],
1798 [m4_pushdef([SYSERR], m4_toupper(syserr))dnl
1799 AC_MSG_CHECKING([for syserr])
1800 AC_CACHE_VAL([glibcxx_cv_system_error[]n_syserr], [
1801 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]],
1802                                    [int i = syserr;])],
1803                   [glibcxx_cv_system_error[]n_syserr=yes],
1804                   [glibcxx_cv_system_error[]n_syserr=no])
1805 ])
1806 AC_MSG_RESULT([$glibcxx_cv_system_error[]n_syserr])
1807 if test x"$glibcxx_cv_system_error[]n_syserr" = x"yes"; then
1808   AC_DEFINE([HAVE_]SYSERR, 1, [Define if ]syserr[ exists.])
1809 fi
1810 m4_define([n_syserr], m4_incr(n_syserr))dnl
1811 m4_popdef([SYSERR])dnl
1812 ])
1813 m4_popdef([n_syserr])dnl
1814 ])
1815
1816 dnl
1817 dnl Check for what type of C headers to use.
1818 dnl
1819 dnl --enable-cheaders= [does stuff].
1820 dnl --disable-cheaders [does not do anything, really].
1821 dnl  +  Usage:  GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
1822 dnl       Where DEFAULT is either 'c' or 'c_std' or 'c_global'.
1823 dnl
1824 AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
1825   GLIBCXX_ENABLE(cheaders,$1,[[[=KIND]]],
1826     [construct "C" headers for g++], [permit c|c_std|c_global])
1827   AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
1828
1829   C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
1830
1831   # Allow overrides to configure.host here.
1832   if test $enable_cheaders = c_global; then
1833      c_compatibility=yes
1834   fi
1835
1836   AC_SUBST(C_INCLUDE_DIR)
1837   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
1838   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
1839   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global)
1840   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
1841 ])
1842
1843
1844 dnl
1845 dnl Check for which locale library to use.  The choice is mapped to
1846 dnl a subdirectory of config/locale.
1847 dnl
1848 dnl Default is generic.
1849 dnl
1850 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
1851   GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
1852     [use MODEL for target locale package],
1853     [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
1854
1855   # Deal with gettext issues.  Default to not using it (=no) until we detect
1856   # support for it later.  Let the user turn it off via --e/d, but let that
1857   # default to on for easier handling.
1858   USE_NLS=no
1859   AC_ARG_ENABLE(nls,
1860     AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
1861     [],
1862     [enable_nls=yes])
1863
1864   # Either a known package, or "auto"
1865   if test $enable_clocale = no || test $enable_clocale = yes; then
1866      enable_clocale=auto
1867   fi
1868   enable_clocale_flag=$enable_clocale
1869
1870   # Probe for locale model to use if none specified.
1871   # Default to "generic".
1872   if test $enable_clocale_flag = auto; then
1873     case ${target_os} in
1874       linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
1875         enable_clocale_flag=gnu
1876         ;;
1877       darwin* | freebsd*)
1878         enable_clocale_flag=darwin
1879         ;;
1880       *)
1881         if test x"$with_newlib" = x"yes"; then
1882           enable_clocale_flag=newlib
1883         else
1884           enable_clocale_flag=generic
1885         fi
1886         ;;
1887     esac
1888   fi
1889
1890   # Sanity check model, and test for special functionality.
1891   if test $enable_clocale_flag = gnu; then
1892     AC_EGREP_CPP([_GLIBCXX_ok], [
1893     #include <features.h>
1894     #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(__UCLIBC__)
1895       _GLIBCXX_ok
1896     #endif
1897     ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1898
1899     # Set it to scream when it hurts.
1900     ac_save_CFLAGS="$CFLAGS"
1901     CFLAGS="-Wimplicit-function-declaration -Werror"
1902
1903     # Use strxfrm_l if available.
1904     AC_TRY_COMPILE([#define _GNU_SOURCE 1
1905                     #include <string.h>
1906                     #include <locale.h>],
1907                     [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);],
1908                     AC_DEFINE(HAVE_STRXFRM_L, 1,
1909                     [Define if strxfrm_l is available in <string.h>.]),)
1910
1911     # Use strerror_l if available.
1912     AC_TRY_COMPILE([#define _GNU_SOURCE 1
1913                     #include <string.h>
1914                     #include <locale.h>],
1915                     [__locale_t loc; strerror_l(5, loc);],
1916                     AC_DEFINE(HAVE_STRERROR_L, 1,
1917                     [Define if strerror_l is available in <string.h>.]),)
1918
1919     CFLAGS="$ac_save_CFLAGS"
1920   fi
1921
1922   # Perhaps use strerror_r if available, and strerror_l isn't.
1923   ac_save_CFLAGS="$CFLAGS"
1924   CFLAGS="-Wimplicit-function-declaration -Werror"
1925   AC_TRY_COMPILE([#define _GNU_SOURCE 1
1926                   #include <string.h>
1927                   #include <locale.h>],
1928                   [char s[128]; strerror_r(5, s, 128);],
1929                   AC_DEFINE(HAVE_STRERROR_R, 1,
1930                   [Define if strerror_r is available in <string.h>.]),)
1931   CFLAGS="$ac_save_CFLAGS"
1932
1933   # Set configure bits for specified locale package
1934   AC_MSG_CHECKING([for C locale to use])
1935   case ${enable_clocale_flag} in
1936     generic)
1937       AC_MSG_RESULT(generic)
1938
1939       CLOCALE_H=config/locale/generic/c_locale.h
1940       CLOCALE_CC=config/locale/generic/c_locale.cc
1941       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1942       CCOLLATE_CC=config/locale/generic/collate_members.cc
1943       CCTYPE_CC=config/locale/generic/ctype_members.cc
1944       CMESSAGES_H=config/locale/generic/messages_members.h
1945       CMESSAGES_CC=config/locale/generic/messages_members.cc
1946       CMONEY_CC=config/locale/generic/monetary_members.cc
1947       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1948       CTIME_H=config/locale/generic/time_members.h
1949       CTIME_CC=config/locale/generic/time_members.cc
1950       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1951       ;;
1952     darwin)
1953       AC_MSG_RESULT(darwin or freebsd)
1954
1955       CLOCALE_H=config/locale/generic/c_locale.h
1956       CLOCALE_CC=config/locale/generic/c_locale.cc
1957       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1958       CCOLLATE_CC=config/locale/generic/collate_members.cc
1959       CCTYPE_CC=config/locale/darwin/ctype_members.cc
1960       CMESSAGES_H=config/locale/generic/messages_members.h
1961       CMESSAGES_CC=config/locale/generic/messages_members.cc
1962       CMONEY_CC=config/locale/generic/monetary_members.cc
1963       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1964       CTIME_H=config/locale/generic/time_members.h
1965       CTIME_CC=config/locale/generic/time_members.cc
1966       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1967       ;;
1968
1969     gnu)
1970       AC_MSG_RESULT(gnu)
1971
1972       # Declare intention to use gettext, and add support for specific
1973       # languages.
1974       # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
1975       ALL_LINGUAS="de fr"
1976
1977       # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
1978       AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1979       if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
1980         USE_NLS=yes
1981       fi
1982       # Export the build objects.
1983       for ling in $ALL_LINGUAS; do \
1984         glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
1985         glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
1986       done
1987       AC_SUBST(glibcxx_MOFILES)
1988       AC_SUBST(glibcxx_POFILES)
1989
1990       CLOCALE_H=config/locale/gnu/c_locale.h
1991       CLOCALE_CC=config/locale/gnu/c_locale.cc
1992       CCODECVT_CC=config/locale/gnu/codecvt_members.cc
1993       CCOLLATE_CC=config/locale/gnu/collate_members.cc
1994       CCTYPE_CC=config/locale/gnu/ctype_members.cc
1995       CMESSAGES_H=config/locale/gnu/messages_members.h
1996       CMESSAGES_CC=config/locale/gnu/messages_members.cc
1997       CMONEY_CC=config/locale/gnu/monetary_members.cc
1998       CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1999       CTIME_H=config/locale/gnu/time_members.h
2000       CTIME_CC=config/locale/gnu/time_members.cc
2001       CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
2002       ;;
2003     ieee_1003.1-2001)
2004       AC_MSG_RESULT(IEEE 1003.1)
2005
2006       CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
2007       CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
2008       CCODECVT_CC=config/locale/generic/codecvt_members.cc
2009       CCOLLATE_CC=config/locale/generic/collate_members.cc
2010       CCTYPE_CC=config/locale/generic/ctype_members.cc
2011       CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
2012       CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
2013       CMONEY_CC=config/locale/generic/monetary_members.cc
2014       CNUMERIC_CC=config/locale/generic/numeric_members.cc
2015       CTIME_H=config/locale/generic/time_members.h
2016       CTIME_CC=config/locale/generic/time_members.cc
2017       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2018       ;;
2019     newlib)
2020       AC_MSG_RESULT(newlib)
2021
2022       CLOCALE_H=config/locale/generic/c_locale.h
2023       CLOCALE_CC=config/locale/generic/c_locale.cc
2024       CCODECVT_CC=config/locale/generic/codecvt_members.cc
2025       CCOLLATE_CC=config/locale/generic/collate_members.cc
2026       CCTYPE_CC=config/locale/newlib/ctype_members.cc
2027       CMESSAGES_H=config/locale/generic/messages_members.h
2028       CMESSAGES_CC=config/locale/generic/messages_members.cc
2029       CMONEY_CC=config/locale/generic/monetary_members.cc
2030       CNUMERIC_CC=config/locale/generic/numeric_members.cc
2031       CTIME_H=config/locale/generic/time_members.h
2032       CTIME_CC=config/locale/generic/time_members.cc
2033       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2034       ;;
2035   esac
2036
2037   # This is where the testsuite looks for locale catalogs, using the
2038   # -DLOCALEDIR define during testsuite compilation.
2039   glibcxx_localedir=${glibcxx_builddir}/po/share/locale
2040   AC_SUBST(glibcxx_localedir)
2041
2042   # A standalone libintl (e.g., GNU libintl) may be in use.
2043   if test $USE_NLS = yes; then
2044     AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no)
2045     AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no)
2046   fi
2047   if test $USE_NLS = yes; then
2048     AC_DEFINE(_GLIBCXX_USE_NLS, 1,
2049               [Define if NLS translations are to be used.])
2050   fi
2051
2052   AC_SUBST(USE_NLS)
2053   AC_SUBST(CLOCALE_H)
2054   AC_SUBST(CMESSAGES_H)
2055   AC_SUBST(CCODECVT_CC)
2056   AC_SUBST(CCOLLATE_CC)
2057   AC_SUBST(CCTYPE_CC)
2058   AC_SUBST(CMESSAGES_CC)
2059   AC_SUBST(CMONEY_CC)
2060   AC_SUBST(CNUMERIC_CC)
2061   AC_SUBST(CTIME_H)
2062   AC_SUBST(CTIME_CC)
2063   AC_SUBST(CLOCALE_CC)
2064   AC_SUBST(CLOCALE_INTERNAL_H)
2065 ])
2066
2067
2068 dnl
2069 dnl Check for which std::allocator base class to use.  The choice is
2070 dnl mapped from a subdirectory of include/ext.
2071 dnl
2072 dnl Default is new.
2073 dnl
2074 AC_DEFUN([GLIBCXX_ENABLE_ALLOCATOR], [
2075   AC_MSG_CHECKING([for std::allocator base class])
2076   GLIBCXX_ENABLE(libstdcxx-allocator,auto,[[[=KIND]]],
2077     [use KIND for target std::allocator base],
2078     [permit new|malloc|mt|bitmap|pool|yes|no|auto])
2079
2080   # If they didn't use this option switch, or if they specified --enable
2081   # with no specific model, we'll have to look for one.  If they
2082   # specified --disable (???), do likewise.
2083   if test $enable_libstdcxx_allocator = no ||
2084      test $enable_libstdcxx_allocator = yes;
2085   then
2086      enable_libstdcxx_allocator=auto
2087   fi
2088
2089   # Either a known package, or "auto". Auto implies the default choice
2090   # for a particular platform.
2091   enable_libstdcxx_allocator_flag=$enable_libstdcxx_allocator
2092
2093   # Probe for host-specific support if no specific model is specified.
2094   # Default to "new".
2095   if test $enable_libstdcxx_allocator_flag = auto; then
2096     case ${target_os} in
2097       linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
2098         enable_libstdcxx_allocator_flag=new
2099         ;;
2100       *)
2101         enable_libstdcxx_allocator_flag=new
2102         ;;
2103     esac
2104   fi
2105   AC_MSG_RESULT($enable_libstdcxx_allocator_flag)
2106
2107
2108   # Set configure bits for specified locale package
2109   case ${enable_libstdcxx_allocator_flag} in
2110     bitmap)
2111       ALLOCATOR_H=config/allocator/bitmap_allocator_base.h
2112       ALLOCATOR_NAME=__gnu_cxx::bitmap_allocator
2113       ;;
2114     malloc)
2115       ALLOCATOR_H=config/allocator/malloc_allocator_base.h
2116       ALLOCATOR_NAME=__gnu_cxx::malloc_allocator
2117       ;;
2118     mt)
2119       ALLOCATOR_H=config/allocator/mt_allocator_base.h
2120       ALLOCATOR_NAME=__gnu_cxx::__mt_alloc
2121       ;;
2122     new)
2123       ALLOCATOR_H=config/allocator/new_allocator_base.h
2124       ALLOCATOR_NAME=__gnu_cxx::new_allocator
2125       ;;
2126     pool)
2127       ALLOCATOR_H=config/allocator/pool_allocator_base.h
2128       ALLOCATOR_NAME=__gnu_cxx::__pool_alloc
2129       ;;
2130   esac
2131
2132   AC_SUBST(ALLOCATOR_H)
2133   AC_SUBST(ALLOCATOR_NAME)
2134 ])
2135
2136
2137 dnl
2138 dnl Check for whether the Boost-derived checks should be turned on.
2139 dnl
2140 dnl --enable-concept-checks turns them on.
2141 dnl --disable-concept-checks leaves them off.
2142 dnl  +  Usage:  GLIBCXX_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2143 dnl       Where DEFAULT is either `yes' or `no'.
2144 dnl
2145 AC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [
2146   GLIBCXX_ENABLE(concept-checks,$1,,[use Boost-derived template checks])
2147   if test $enable_concept_checks = yes; then
2148     AC_DEFINE(_GLIBCXX_CONCEPT_CHECKS, 1,
2149               [Define to use concept checking code from the boost libraries.])
2150   fi
2151 ])
2152
2153 dnl
2154 dnl Use extern templates.
2155 dnl
2156 dnl --enable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 1
2157 dnl --disable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 0
2158
2159 dnl  +  Usage:  GLIBCXX_ENABLE_TEMPLATE[(DEFAULT)]
2160 dnl       Where DEFAULT is `yes' or `no'.
2161 dnl
2162 AC_DEFUN([GLIBCXX_ENABLE_EXTERN_TEMPLATE], [
2163
2164   GLIBCXX_ENABLE(extern-template,$1,,[enable extern template])
2165
2166   AC_MSG_CHECKING([for extern template support])
2167   AC_MSG_RESULT([$enable_extern_template])
2168
2169   GLIBCXX_CONDITIONAL(ENABLE_EXTERN_TEMPLATE, test $enable_extern_template = yes)
2170 ])
2171
2172 dnl
2173 dnl Check for parallel mode pre-requisites, including OpenMP support.
2174 dnl
2175 dnl  +  Usage:  GLIBCXX_ENABLE_PARALLEL
2176 dnl
2177 AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
2178
2179   enable_parallel=no;
2180
2181   # See if configured libgomp/omp.h exists. (libgomp may be in
2182   # noconfigdirs but not explicitly disabled.)
2183   if echo " ${TARGET_CONFIGDIRS} " | grep " libgomp " > /dev/null 2>&1 ; then
2184     enable_parallel=yes;
2185   else
2186     AC_MSG_NOTICE([target-libgomp not built])
2187   fi
2188
2189   AC_MSG_CHECKING([for parallel mode support])
2190   AC_MSG_RESULT([$enable_parallel])
2191   GLIBCXX_CONDITIONAL(ENABLE_PARALLEL, test $enable_parallel = yes)
2192 ])
2193
2194
2195 dnl
2196 dnl Check for which I/O library to use:  stdio, or something specific.
2197 dnl
2198 dnl Default is stdio.
2199 dnl
2200 AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
2201   AC_MSG_CHECKING([for underlying I/O to use])
2202   GLIBCXX_ENABLE(cstdio,stdio,[[[=PACKAGE]]],
2203     [use target-specific I/O package], [permit stdio])
2204
2205   # Now that libio has been removed, you can have any color you want as long
2206   # as it's black.  This is one big no-op until other packages are added, but
2207   # showing the framework never hurts.
2208   case ${enable_cstdio} in
2209     stdio)
2210       CSTDIO_H=config/io/c_io_stdio.h
2211       BASIC_FILE_H=config/io/basic_file_stdio.h
2212       BASIC_FILE_CC=config/io/basic_file_stdio.cc
2213       AC_MSG_RESULT(stdio)
2214       ;;
2215   esac
2216
2217   AC_SUBST(CSTDIO_H)
2218   AC_SUBST(BASIC_FILE_H)
2219   AC_SUBST(BASIC_FILE_CC)
2220 ])
2221
2222
2223 dnl
2224 dnl Check for "unusual" flags to pass to the compiler while building.
2225 dnl
2226 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
2227 dnl     experimental flags such as -fpch, -fIMI, -Dfloat=char, etc.
2228 dnl --disable-cxx-flags passes nothing.
2229 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
2230 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
2231 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
2232 dnl  +  Usage:  GLIBCXX_ENABLE_CXX_FLAGS(default flags)
2233 dnl       If "default flags" is an empty string, the effect is the same
2234 dnl       as --disable or --enable=no.
2235 dnl
2236 AC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl
2237   AC_MSG_CHECKING([for extra compiler flags for building])
2238   GLIBCXX_ENABLE(cxx-flags,$1,[=FLAGS],
2239     [pass compiler FLAGS when building library],
2240     [case "x$enable_cxx_flags" in
2241       xno | x)   enable_cxx_flags= ;;
2242       x-*)       ;;
2243       *)         AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2244      esac])
2245
2246   # Run through flags (either default or command-line) and set anything
2247   # extra (e.g., #defines) that must accompany particular g++ options.
2248   if test -n "$enable_cxx_flags"; then
2249     for f in $enable_cxx_flags; do
2250       case "$f" in
2251         -fhonor-std)  ;;
2252         -*)  ;;
2253         *)   # and we're trying to pass /what/ exactly?
2254              AC_MSG_ERROR([compiler flags start with a -]) ;;
2255       esac
2256     done
2257   fi
2258
2259   EXTRA_CXX_FLAGS="$enable_cxx_flags"
2260   AC_MSG_RESULT($EXTRA_CXX_FLAGS)
2261   AC_SUBST(EXTRA_CXX_FLAGS)
2262 ])
2263
2264
2265 dnl
2266 dnl Check to see if debugging libraries are to be built.
2267 dnl
2268 dnl --enable-libstdcxx-debug
2269 dnl builds a separate set of debugging libraries in addition to the
2270 dnl normal (shared, static) libstdc++ binaries.
2271 dnl
2272 dnl --disable-libstdcxx-debug
2273 dnl builds only one (non-debug) version of libstdc++.
2274 dnl
2275 dnl --enable-libstdcxx-debug-flags=FLAGS
2276 dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
2277 dnl
2278 dnl  +  Usage:  GLIBCXX_ENABLE_DEBUG[(DEFAULT)]
2279 dnl       Where DEFAULT is either `yes' or `no'.
2280 dnl
2281 AC_DEFUN([GLIBCXX_ENABLE_DEBUG], [
2282   AC_MSG_CHECKING([for additional debug build])
2283   GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library])
2284   AC_MSG_RESULT($enable_libstdcxx_debug)
2285   GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
2286 ])
2287
2288
2289 dnl
2290 dnl Check for explicit debug flags.
2291 dnl
2292 dnl --enable-libstdcxx-debug-flags='-O1'
2293 dnl is a general method for passing flags to be used when
2294 dnl building debug libraries with --enable-debug.
2295 dnl
2296 dnl --disable-libstdcxx-debug-flags does nothing.
2297 dnl  +  Usage:  GLIBCXX_ENABLE_DEBUG_FLAGS(default flags)
2298 dnl       If "default flags" is an empty string, the effect is the same
2299 dnl       as --disable or --enable=no.
2300 dnl
2301 AC_DEFUN([GLIBCXX_ENABLE_DEBUG_FLAGS], [
2302   GLIBCXX_ENABLE(libstdcxx-debug-flags,[$1],[=FLAGS],
2303     [pass compiler FLAGS when building debug library],
2304     [case "x$enable_libstdcxx_debug_flags" in
2305       xno | x)    enable_libstdcxx_debug_flags= ;;
2306       x-*)        ;;
2307       *)          AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2308      esac])
2309
2310   # Option parsed, now set things appropriately
2311   DEBUG_FLAGS="$enable_libstdcxx_debug_flags"
2312   AC_SUBST(DEBUG_FLAGS)
2313
2314   AC_MSG_NOTICE([Debug build flags set to $DEBUG_FLAGS])
2315 ])
2316
2317
2318 dnl
2319 dnl Check if the user only wants a freestanding library implementation.
2320 dnl
2321 dnl --disable-hosted-libstdcxx will turn off most of the library build,
2322 dnl installing only the headers required by [17.4.1.3] and the language
2323 dnl support library.  More than that will be built (to keep the Makefiles
2324 dnl conveniently clean), but not installed.
2325 dnl
2326 dnl Sets:
2327 dnl  is_hosted  (yes/no)
2328 dnl
2329 dnl Defines:
2330 dnl  _GLIBCXX_HOSTED   (always defined, either to 1 or 0)
2331 dnl
2332 AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [
2333   AC_ARG_ENABLE([hosted-libstdcxx],
2334     AC_HELP_STRING([--disable-hosted-libstdcxx],
2335                    [only build freestanding C++ runtime support]),,
2336     [case "$host" in
2337         arm*-*-symbianelf*)
2338             enable_hosted_libstdcxx=no
2339             ;;
2340         *)
2341             enable_hosted_libstdcxx=yes
2342             ;;
2343      esac])
2344   if test "$enable_hosted_libstdcxx" = no; then
2345     AC_MSG_NOTICE([Only freestanding libraries will be built])
2346     is_hosted=no
2347     hosted_define=0
2348     enable_abi_check=no
2349     enable_libstdcxx_pch=no
2350   else
2351     is_hosted=yes
2352     hosted_define=1
2353   fi
2354   GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
2355   AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
2356     [Define to 1 if a full hosted library is built, or 0 if freestanding.])
2357 ])
2358
2359
2360 dnl
2361 dnl Check for template specializations for the 'long long' type.
2362 dnl The result determines only whether 'long long' I/O is enabled; things
2363 dnl like numeric_limits<> specializations are always available.
2364 dnl
2365 dnl --enable-long-long defines _GLIBCXX_USE_LONG_LONG
2366 dnl --disable-long-long leaves _GLIBCXX_USE_LONG_LONG undefined
2367 dnl  +  Usage:  GLIBCXX_ENABLE_LONG_LONG[(DEFAULT)]
2368 dnl       Where DEFAULT is either `yes' or `no'.
2369 dnl
2370 AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
2371   GLIBCXX_ENABLE(long-long,$1,,[enable template specializations for 'long long'])
2372   if test $enable_long_long = yes; then
2373     AC_DEFINE(_GLIBCXX_USE_LONG_LONG, 1,
2374               [Define if code specialized for long long should be used.])
2375   fi
2376   AC_MSG_CHECKING([for enabled long long specializations])
2377   AC_MSG_RESULT([$enable_long_long])
2378 ])
2379
2380
2381 dnl
2382 dnl Check for decimal floating point.
2383 dnl See:
2384 dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
2385 dnl
2386 dnl This checks to see if the host supports decimal floating point types.
2387 dnl
2388 dnl Defines:
2389 dnl  _GLIBCXX_USE_DECIMAL_FLOAT
2390 dnl
2391 AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
2392
2393   # Fake what AC_TRY_COMPILE does, without linking as this is
2394   # unnecessary for this test.
2395
2396     cat > conftest.$ac_ext << EOF
2397 [#]line __oline__ "configure"
2398 int main()
2399 {
2400   _Decimal32 d1;
2401   _Decimal64 d2;
2402   _Decimal128 d3;
2403   return 0;
2404 }
2405 EOF
2406
2407     AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
2408     if AC_TRY_EVAL(ac_compile); then
2409       AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
2410       [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
2411       enable_dfp=yes
2412     else
2413       enable_dfp=no
2414     fi
2415     AC_MSG_RESULT($enable_dfp)
2416     rm -f conftest*
2417 ])
2418
2419 dnl
2420 dnl Check for template specializations for the 'wchar_t' type.
2421 dnl
2422 dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
2423 dnl --disable-wchar_t leaves _GLIBCXX_USE_WCHAR_T undefined
2424 dnl  +  Usage:  GLIBCXX_ENABLE_WCHAR_T[(DEFAULT)]
2425 dnl       Where DEFAULT is either `yes' or `no'.
2426 dnl
2427 dnl Necessary support must also be present.
2428 dnl
2429 AC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [
2430   GLIBCXX_ENABLE(wchar_t,$1,,[enable template specializations for 'wchar_t'])
2431
2432   # Test wchar.h for mbstate_t, which is needed for char_traits and fpos.
2433   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
2434   AC_MSG_CHECKING([for mbstate_t])
2435   AC_TRY_COMPILE([#include <wchar.h>],
2436   [mbstate_t teststate;],
2437   have_mbstate_t=yes, have_mbstate_t=no)
2438   AC_MSG_RESULT($have_mbstate_t)
2439   if test x"$have_mbstate_t" = xyes; then
2440     AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
2441   fi
2442
2443   # Test it always, for use in GLIBCXX_ENABLE_C99, together with
2444   # ac_has_wchar_h.
2445   AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
2446
2447   if test x"$enable_wchar_t" = x"yes"; then
2448
2449     AC_LANG_SAVE
2450     AC_LANG_CPLUSPLUS
2451
2452     if test x"$ac_has_wchar_h" = xyes &&
2453        test x"$ac_has_wctype_h" = xyes; then
2454       AC_TRY_COMPILE([#include <wchar.h>
2455                       #include <stddef.h>
2456                       wint_t i;
2457                       long l = WEOF;
2458                       long j = WCHAR_MIN;
2459                       long k = WCHAR_MAX;
2460                       namespace test
2461                       {
2462                         using ::btowc;
2463                         using ::fgetwc;
2464                         using ::fgetws;
2465                         using ::fputwc;
2466                         using ::fputws;
2467                         using ::fwide;
2468                         using ::fwprintf;
2469                         using ::fwscanf;
2470                         using ::getwc;
2471                         using ::getwchar;
2472                         using ::mbrlen;
2473                         using ::mbrtowc;
2474                         using ::mbsinit;
2475                         using ::mbsrtowcs;
2476                         using ::putwc;
2477                         using ::putwchar;
2478                         using ::swprintf;
2479                         using ::swscanf;
2480                         using ::ungetwc;
2481                         using ::vfwprintf;
2482                         using ::vswprintf;
2483                         using ::vwprintf;
2484                         using ::wcrtomb;
2485                         using ::wcscat;
2486                         using ::wcschr;
2487                         using ::wcscmp;
2488                         using ::wcscoll;
2489                         using ::wcscpy;
2490                         using ::wcscspn;
2491                         using ::wcsftime;
2492                         using ::wcslen;
2493                         using ::wcsncat;
2494                         using ::wcsncmp;
2495                         using ::wcsncpy;
2496                         using ::wcspbrk;
2497                         using ::wcsrchr;
2498                         using ::wcsrtombs;
2499                         using ::wcsspn;
2500                         using ::wcsstr;
2501                         using ::wcstod;
2502                         using ::wcstok;
2503                         using ::wcstol;
2504                         using ::wcstoul;
2505                         using ::wcsxfrm;
2506                         using ::wctob;
2507                         using ::wmemchr;
2508                         using ::wmemcmp;
2509                         using ::wmemcpy;
2510                         using ::wmemmove;
2511                         using ::wmemset;
2512                         using ::wprintf;
2513                         using ::wscanf;
2514                       }
2515                      ],[],[], [enable_wchar_t=no])
2516     else
2517       enable_wchar_t=no
2518     fi
2519
2520     AC_LANG_RESTORE
2521   fi
2522
2523   if test x"$enable_wchar_t" = x"yes"; then
2524     AC_DEFINE(_GLIBCXX_USE_WCHAR_T, 1,
2525               [Define if code specialized for wchar_t should be used.])
2526   fi
2527
2528   AC_MSG_CHECKING([for enabled wchar_t specializations])
2529   AC_MSG_RESULT([$enable_wchar_t])
2530 ])
2531
2532
2533 dnl
2534 dnl Check to see if building and using a C++ precompiled header can be done.
2535 dnl
2536 dnl --enable-libstdcxx-pch=yes
2537 dnl default, this shows intent to use stdc++.h.gch If it looks like it
2538 dnl may work, after some light-hearted attempts to puzzle out compiler
2539 dnl support, flip bits on in include/Makefile.am
2540 dnl
2541 dnl --disable-libstdcxx-pch
2542 dnl turns off attempts to use or build stdc++.h.gch.
2543 dnl
2544 dnl Substs:
2545 dnl  glibcxx_PCHFLAGS
2546 dnl
2547 AC_DEFUN([GLIBCXX_ENABLE_PCH], [
2548   GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers])
2549   if test $enable_libstdcxx_pch = yes; then
2550     AC_CACHE_CHECK([for compiler with PCH support],
2551       [glibcxx_cv_prog_CXX_pch],
2552       [ac_save_CXXFLAGS="$CXXFLAGS"
2553        CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated"
2554        AC_LANG_SAVE
2555        AC_LANG_CPLUSPLUS
2556        echo '#include <math.h>' > conftest.h
2557        if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \
2558                           -o conftest.h.gch 1>&5 2>&1 &&
2559                 echo '#error "pch failed"' > conftest.h &&
2560           echo '#include "conftest.h"' > conftest.cc &&
2561                $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ;
2562        then
2563          glibcxx_cv_prog_CXX_pch=yes
2564        else
2565          glibcxx_cv_prog_CXX_pch=no
2566        fi
2567        rm -f conftest*
2568        CXXFLAGS=$ac_save_CXXFLAGS
2569        AC_LANG_RESTORE
2570       ])
2571     enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch
2572   fi
2573
2574   AC_MSG_CHECKING([for enabled PCH])
2575   AC_MSG_RESULT([$enable_libstdcxx_pch])
2576
2577   GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
2578   if test $enable_libstdcxx_pch = yes; then
2579     glibcxx_PCHFLAGS="-include bits/stdc++.h"
2580   else
2581     glibcxx_PCHFLAGS=""
2582   fi
2583   AC_SUBST(glibcxx_PCHFLAGS)
2584 ])
2585
2586
2587 dnl
2588 dnl Check for atomic builtins.
2589 dnl See:
2590 dnl http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html#Atomic-Builtins
2591 dnl
2592 dnl This checks to see if the host supports the compiler-generated
2593 dnl builtins for atomic operations for various integral sizes. Note, this
2594 dnl is intended to be an all-or-nothing switch, so all the atomic operations
2595 dnl that are used should be checked.
2596 dnl
2597 dnl Note:
2598 dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
2599 dnl
2600 dnl Defines:
2601 dnl  _GLIBCXX_ATOMIC_BUILTINS_1
2602 dnl  _GLIBCXX_ATOMIC_BUILTINS_2
2603 dnl  _GLIBCXX_ATOMIC_BUILTINS_4
2604 dnl  _GLIBCXX_ATOMIC_BUILTINS_8
2605 dnl
2606 AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
2607   AC_LANG_SAVE
2608   AC_LANG_CPLUSPLUS
2609   old_CXXFLAGS="$CXXFLAGS"
2610
2611   # Do link tests if possible, instead asm tests, limited to some platforms
2612   # see discussion in PR target/40134, PR libstdc++/40133 and the thread
2613   # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
2614   atomic_builtins_link_tests=no
2615   if test x$gcc_no_link != xyes; then
2616     # Can do link tests. Limit to some tested platforms
2617     case "$host" in
2618       *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
2619         atomic_builtins_link_tests=yes
2620         ;;
2621     esac
2622   fi
2623
2624   if test x$atomic_builtins_link_tests = xyes; then
2625
2626   # Do link tests.
2627
2628   CXXFLAGS="$CXXFLAGS -fno-exceptions"
2629
2630   AC_MSG_CHECKING([for atomic builtins for bool])
2631   AC_CACHE_VAL(glibcxx_cv_atomic_bool, [
2632     AC_TRY_LINK(
2633       [ ],
2634       [typedef bool atomic_type;
2635        atomic_type c1;
2636        atomic_type c2;
2637        const atomic_type c3(0);
2638        __sync_fetch_and_add(&c1, c2);
2639        __sync_val_compare_and_swap(&c1, c3, c2);
2640        __sync_lock_test_and_set(&c1, c3);
2641        __sync_lock_release(&c1);
2642        __sync_synchronize();],
2643       [glibcxx_cv_atomic_bool=yes],
2644       [glibcxx_cv_atomic_bool=no])
2645   ])
2646   if test $glibcxx_cv_atomic_bool = yes; then
2647     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2648       [Define if builtin atomic operations for bool are supported on this host.])
2649   fi
2650   AC_MSG_RESULT($glibcxx_cv_atomic_bool)
2651
2652   AC_MSG_CHECKING([for atomic builtins for short])
2653   AC_CACHE_VAL(glibcxx_cv_atomic_short, [
2654     AC_TRY_LINK(
2655       [ ],
2656       [typedef short atomic_type;
2657        atomic_type c1;
2658        atomic_type c2;
2659        const atomic_type c3(0);
2660        __sync_fetch_and_add(&c1, c2);
2661        __sync_val_compare_and_swap(&c1, c3, c2);
2662        __sync_lock_test_and_set(&c1, c3);
2663        __sync_lock_release(&c1);
2664        __sync_synchronize();],
2665       [glibcxx_cv_atomic_short=yes],
2666       [glibcxx_cv_atomic_short=no])
2667   ])
2668   if test $glibcxx_cv_atomic_short = yes; then
2669     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2670       [Define if builtin atomic operations for short are supported on this host.])
2671   fi
2672   AC_MSG_RESULT($glibcxx_cv_atomic_short)
2673
2674   AC_MSG_CHECKING([for atomic builtins for int])
2675   AC_CACHE_VAL(glibcxx_cv_atomic_int, [
2676     AC_TRY_LINK(
2677       [ ],
2678       [typedef int atomic_type;
2679        atomic_type c1;
2680        atomic_type c2;
2681        const atomic_type c3(0);
2682        __sync_fetch_and_add(&c1, c2);
2683        __sync_val_compare_and_swap(&c1, c3, c2);
2684        __sync_lock_test_and_set(&c1, c3);
2685        __sync_lock_release(&c1);
2686        __sync_synchronize();],
2687       [glibcxx_cv_atomic_int=yes],
2688       [glibcxx_cv_atomic_int=no])
2689   ])
2690   if test $glibcxx_cv_atomic_int = yes; then
2691     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2692       [Define if builtin atomic operations for int are supported on this host.])
2693   fi
2694   AC_MSG_RESULT($glibcxx_cv_atomic_int)
2695
2696   AC_MSG_CHECKING([for atomic builtins for long long])
2697   AC_CACHE_VAL(glibcxx_cv_atomic_long_long, [
2698     AC_TRY_LINK(
2699       [ ],
2700       [typedef long long atomic_type;
2701        atomic_type c1;
2702        atomic_type c2;
2703        const atomic_type c3(0);
2704        __sync_fetch_and_add(&c1, c2);
2705        __sync_val_compare_and_swap(&c1, c3, c2);
2706        __sync_lock_test_and_set(&c1, c3);
2707        __sync_lock_release(&c1);
2708        __sync_synchronize();],
2709       [glibcxx_cv_atomic_long_long=yes],
2710       [glibcxx_cv_atomic_long_long=no])
2711   ])
2712   if test $glibcxx_cv_atomic_long_long = yes; then
2713     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2714       [Define if builtin atomic operations for long long are supported on this host.])
2715   fi
2716   AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
2717
2718   else
2719
2720   # Do asm tests.
2721
2722   # Compile unoptimized.
2723   CXXFLAGS='-O0 -S'
2724
2725   # Fake what AC_TRY_COMPILE does.
2726
2727     cat > conftest.$ac_ext << EOF
2728 [#]line __oline__ "configure"
2729 int main()
2730 {
2731   typedef bool atomic_type;
2732   atomic_type c1;
2733   atomic_type c2;
2734   const atomic_type c3(0);
2735   __sync_fetch_and_add(&c1, c2);
2736   __sync_val_compare_and_swap(&c1, c3, c2);
2737   __sync_lock_test_and_set(&c1, c3);
2738   __sync_lock_release(&c1);
2739   __sync_synchronize();
2740   return 0;
2741 }
2742 EOF
2743
2744     AC_MSG_CHECKING([for atomic builtins for bool])
2745     if AC_TRY_EVAL(ac_compile); then
2746       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2747         glibcxx_cv_atomic_bool=no
2748       else
2749       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2750       [Define if builtin atomic operations for bool are supported on this host.])
2751         glibcxx_cv_atomic_bool=yes
2752       fi
2753     fi
2754     AC_MSG_RESULT($glibcxx_cv_atomic_bool)
2755     rm -f conftest*
2756
2757     cat > conftest.$ac_ext << EOF
2758 [#]line __oline__ "configure"
2759 int main()
2760 {
2761   typedef short atomic_type;
2762   atomic_type c1;
2763   atomic_type c2;
2764   const atomic_type c3(0);
2765   __sync_fetch_and_add(&c1, c2);
2766   __sync_val_compare_and_swap(&c1, c3, c2);
2767   __sync_lock_test_and_set(&c1, c3);
2768   __sync_lock_release(&c1);
2769   __sync_synchronize();
2770   return 0;
2771 }
2772 EOF
2773
2774     AC_MSG_CHECKING([for atomic builtins for short])
2775     if AC_TRY_EVAL(ac_compile); then
2776       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2777         glibcxx_cv_atomic_short=no
2778       else
2779       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2780       [Define if builtin atomic operations for short are supported on this host.])
2781         glibcxx_cv_atomic_short=yes
2782       fi
2783     fi
2784     AC_MSG_RESULT($glibcxx_cv_atomic_short)
2785     rm -f conftest*
2786
2787     cat > conftest.$ac_ext << EOF
2788 [#]line __oline__ "configure"
2789 int main()
2790 {
2791   // NB: _Atomic_word not necessarily int.
2792   typedef int atomic_type;
2793   atomic_type c1;
2794   atomic_type c2;
2795   const atomic_type c3(0);
2796   __sync_fetch_and_add(&c1, c2);
2797   __sync_val_compare_and_swap(&c1, c3, c2);
2798   __sync_lock_test_and_set(&c1, c3);
2799   __sync_lock_release(&c1);
2800   __sync_synchronize();
2801   return 0;
2802 }
2803 EOF
2804
2805     AC_MSG_CHECKING([for atomic builtins for int])
2806     if AC_TRY_EVAL(ac_compile); then
2807       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2808         glibcxx_cv_atomic_int=no
2809       else
2810       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2811         [Define if builtin atomic operations for int are supported on this host.])
2812         glibcxx_cv_atomic_int=yes
2813       fi
2814     fi
2815     AC_MSG_RESULT($glibcxx_cv_atomic_int)
2816     rm -f conftest*
2817
2818     cat > conftest.$ac_ext << EOF
2819 [#]line __oline__ "configure"
2820 int main()
2821 {
2822   typedef long long atomic_type;
2823   atomic_type c1;
2824   atomic_type c2;
2825   const atomic_type c3(0);
2826   __sync_fetch_and_add(&c1, c2);
2827   __sync_val_compare_and_swap(&c1, c3, c2);
2828   __sync_lock_test_and_set(&c1, c3);
2829   __sync_lock_release(&c1);
2830   __sync_synchronize();
2831   return 0;
2832 }
2833 EOF
2834
2835     AC_MSG_CHECKING([for atomic builtins for long long])
2836     if AC_TRY_EVAL(ac_compile); then
2837       if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2838         glibcxx_cv_atomic_long_long=no
2839       else
2840       AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2841       [Define if builtin atomic operations for long long are supported on this host.])
2842         glibcxx_cv_atomic_long_long=yes
2843       fi
2844     fi
2845     AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
2846     rm -f conftest*
2847
2848   fi
2849
2850   CXXFLAGS="$old_CXXFLAGS"
2851   AC_LANG_RESTORE
2852
2853   # Set atomicity_dir to builtins if either of above tests pass.
2854   if test $glibcxx_cv_atomic_int = yes || test $glibcxx_cv_atomic_bool = yes ; then
2855     atomicity_dir=cpu/generic/atomicity_builtins
2856   fi
2857
2858   # If still generic, set to mutex.
2859   if test $atomicity_dir = "cpu/generic" ; then
2860     atomicity_dir=cpu/generic/atomicity_mutex
2861     AC_MSG_WARN([No native atomic operations are provided for this platform.])
2862       if test "x$target_thread_file" = xsingle; then
2863         AC_MSG_WARN([They cannot be faked when thread support is disabled.])
2864         AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
2865       else
2866         AC_MSG_WARN([They will be faked using a mutex.])
2867         AC_MSG_WARN([Performance of certain classes will degrade as a result.])
2868       fi
2869   fi
2870
2871 ])
2872
2873
2874 dnl
2875 dnl Check for exception handling support.  If an explicit enable/disable
2876 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
2877 dnl target may or may not support call frame exceptions.
2878 dnl
2879 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
2880 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
2881 dnl Neither one forces an attempt at detection.
2882 dnl
2883 dnl Defines:
2884 dnl  _GLIBCXX_SJLJ_EXCEPTIONS if the compiler is configured for it
2885 dnl
2886 AC_DEFUN([GLIBCXX_ENABLE_SJLJ_EXCEPTIONS], [
2887   AC_MSG_CHECKING([for exception model to use])
2888   AC_LANG_SAVE
2889   AC_LANG_CPLUSPLUS
2890   GLIBCXX_ENABLE(sjlj-exceptions,auto,,
2891     [force use of builtin_setjmp for exceptions],
2892     [permit yes|no|auto])
2893
2894   if test $enable_sjlj_exceptions = auto; then
2895     # Botheration.  Now we've got to detect the exception model.  Link tests
2896     # against libgcc.a are problematic since we've not been given proper -L
2897     # bits for single-tree newlib and libgloss.
2898     #
2899     # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
2900     cat > conftest.$ac_ext << EOF
2901 [#]line __oline__ "configure"
2902 struct S { ~S(); };
2903 void bar();
2904 void foo()
2905 {
2906   S s;
2907   bar();
2908 }
2909 EOF
2910     old_CXXFLAGS="$CXXFLAGS"
2911     CXXFLAGS=-S
2912     if AC_TRY_EVAL(ac_compile); then
2913       if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
2914         enable_sjlj_exceptions=yes
2915       elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
2916         enable_sjlj_exceptions=no
2917       elif grep __cxa_end_cleanup conftest.s >/dev/null 2>&1 ; then
2918         enable_sjlj_exceptions=no
2919       fi
2920     fi
2921     CXXFLAGS="$old_CXXFLAGS"
2922     rm -f conftest*
2923   fi
2924
2925   # This is a tad weird, for hysterical raisins.  We have to map
2926   # enable/disable to two different models.
2927   case $enable_sjlj_exceptions in
2928     yes)
2929       AC_DEFINE(_GLIBCXX_SJLJ_EXCEPTIONS, 1,
2930         [Define if the compiler is configured for setjmp/longjmp exceptions.])
2931       ac_exception_model_name=sjlj
2932       ;;
2933     no)
2934       ac_exception_model_name="call frame"
2935       ;;
2936     *)
2937       AC_MSG_ERROR([unable to detect exception model])
2938       ;;
2939   esac
2940  AC_LANG_RESTORE
2941  AC_MSG_RESULT($ac_exception_model_name)
2942 ])
2943
2944
2945 dnl
2946 dnl Allow visibility attributes to be used on namespaces, objects, etc.
2947 dnl
2948 dnl --enable-visibility enables attempt to use visibility attributes.
2949 dnl --disable-visibility turns off all use of visibility attributes.
2950 dnl  +  Usage:  GLIBCXX_ENABLE_VISIBILITY[(DEFAULT)]
2951 dnl       Where DEFAULT is 'yes'.
2952 dnl
2953 AC_DEFUN([GLIBCXX_ENABLE_VISIBILITY], [
2954 GLIBCXX_ENABLE(visibility,$1,,[enables visibility safe usage])
2955
2956 if test x$enable_visibility = xyes ; then
2957   dnl all hail libgfortran
2958   dnl Check whether the target supports hidden visibility.
2959   AC_CACHE_CHECK([whether the target supports hidden visibility],
2960                  glibcxx_cv_have_attribute_visibility, [
2961   save_CFLAGS="$CFLAGS"
2962   CFLAGS="$CFLAGS -Werror"
2963   AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
2964                  [], glibcxx_cv_have_attribute_visibility=yes,
2965                  glibcxx_cv_have_attribute_visibility=no)
2966   CFLAGS="$save_CFLAGS"])
2967   if test $glibcxx_cv_have_attribute_visibility = no; then
2968     enable_visibility=no
2969   fi
2970 fi
2971
2972 GLIBCXX_CONDITIONAL(ENABLE_VISIBILITY, test $enable_visibility = yes)
2973 AC_MSG_NOTICE([visibility supported: $enable_visibility])
2974 ])
2975
2976
2977 dnl
2978 dnl Add version tags to symbols in shared library (or not), additionally
2979 dnl marking other symbols as private/local (or not).
2980 dnl
2981 dnl --enable-symvers=style adds a version script to the linker call when
2982 dnl       creating the shared library.  The choice of version script is
2983 dnl       controlled by 'style'.
2984 dnl --disable-symvers does not.
2985 dnl  +  Usage:  GLIBCXX_ENABLE_SYMVERS[(DEFAULT)]
2986 dnl       Where DEFAULT is either 'yes' or 'no'.  Passing `yes' tries to
2987 dnl       choose a default style based on linker characteristics.  Passing
2988 dnl       'no' disables versioning.
2989 dnl
2990 AC_DEFUN([GLIBCXX_ENABLE_SYMVERS], [
2991
2992 GLIBCXX_ENABLE(symvers,$1,[[[=STYLE]]],
2993   [enables symbol versioning of the shared library],
2994   [permit yes|no|gnu|gnu-versioned-namespace|darwin|darwin-export|sun])
2995
2996 # If we never went through the GLIBCXX_CHECK_LINKER_FEATURES macro, then we
2997 # don't know enough about $LD to do tricks...
2998 AC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES])
2999 # Sun style symbol versions needs GNU c++filt for make_sunver.pl to work
3000 # with extern "C++" in version scripts.
3001 AC_REQUIRE([GCC_PROG_GNU_CXXFILT])
3002
3003 # Turn a 'yes' into a suitable default.
3004 if test x$enable_symvers = xyes ; then
3005   if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then
3006     enable_symvers=no
3007   else
3008     if test $with_gnu_ld = yes ; then
3009       case ${target_os} in
3010         hpux*)
3011           enable_symvers=no ;;
3012         *)
3013           enable_symvers=gnu ;;
3014       esac
3015     else
3016       case ${target_os} in
3017         darwin*)
3018           enable_symvers=darwin ;;
3019         # Sun symbol versioning exists since Solaris 2.5.
3020         solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
3021           # make_sunver.pl needs GNU c++filt to support extern "C++" in
3022           # version scripts, so disable symbol versioning if none can be
3023           # found.
3024           if test -z "$ac_cv_path_CXXFILT"; then
3025             AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
3026             AC_MSG_WARN([=== no GNU c++filt could  be found.])
3027             AC_MSG_WARN([=== Symbol versioning will be disabled.])
3028             enable_symvers=no
3029           else
3030             enable_symvers=sun
3031           fi
3032           ;;
3033         *)
3034           enable_symvers=no ;;
3035       esac
3036     fi
3037   fi
3038 fi
3039
3040 # Check to see if 'darwin' or 'darwin-export' can win.
3041 if test x$enable_symvers = xdarwin-export ; then
3042     enable_symvers=darwin
3043 fi
3044
3045 # Check if 'sun' was requested on non-Solaris 2 platforms.
3046 if test x$enable_symvers = xsun ; then
3047   case ${target_os} in
3048     solaris2*)
3049       # All fine.
3050       ;;
3051     *)
3052       # Unlikely to work.
3053       AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
3054       AC_MSG_WARN([=== you are not targetting Solaris 2.])
3055       AC_MSG_WARN([=== Symbol versioning will be disabled.])
3056       enable_symvers=no
3057       ;;
3058   esac
3059 fi
3060
3061 # Check to see if 'gnu' can win.
3062 if test $enable_symvers = gnu ||
3063   test $enable_symvers = gnu-versioned-namespace ||
3064   test $enable_symvers = sun; then
3065   # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
3066   AC_MSG_CHECKING([for shared libgcc])
3067   ac_save_CFLAGS="$CFLAGS"
3068   CFLAGS=' -lgcc_s'
3069   AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes, glibcxx_shared_libgcc=no)
3070   CFLAGS="$ac_save_CFLAGS"
3071   if test $glibcxx_shared_libgcc = no; then
3072     cat > conftest.c <<EOF
3073 int main (void) { return 0; }
3074 EOF
3075 changequote(,)dnl
3076     glibcxx_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
3077                              -shared -shared-libgcc -o conftest.so \
3078                              conftest.c -v 2>&1 >/dev/null \
3079                              | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
3080 changequote([,])dnl
3081     rm -f conftest.c conftest.so
3082     if test x${glibcxx_libgcc_s_suffix+set} = xset; then
3083       CFLAGS=" -lgcc_s$glibcxx_libgcc_s_suffix"
3084       AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes)
3085       CFLAGS="$ac_save_CFLAGS"
3086     fi
3087   fi
3088   AC_MSG_RESULT($glibcxx_shared_libgcc)
3089
3090   # For GNU ld, we need at least this version.  The format is described in
3091   # GLIBCXX_CHECK_LINKER_FEATURES above.
3092   glibcxx_min_gnu_ld_version=21400
3093
3094   # If no shared libgcc, can't win.
3095   if test $glibcxx_shared_libgcc != yes; then
3096       AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
3097       AC_MSG_WARN([=== you are not building a shared libgcc_s.])
3098       AC_MSG_WARN([=== Symbol versioning will be disabled.])
3099       enable_symvers=no
3100   elif test $with_gnu_ld != yes && test $enable_symvers = sun; then
3101     : All interesting versions of Sun ld support sun style symbol versioning.
3102   elif test $with_gnu_ld != yes ; then
3103     # just fail for now
3104     AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
3105     AC_MSG_WARN([=== you are not using the GNU linker.])
3106     AC_MSG_WARN([=== Symbol versioning will be disabled.])
3107     enable_symvers=no
3108   elif test $glibcxx_ld_is_gold = yes ; then
3109     : All versions of gold support symbol versioning.
3110   elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
3111     # The right tools, the right setup, but too old.  Fallbacks?
3112     AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for)
3113     AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
3114     AC_MSG_WARN(=== You would need to upgrade your binutils to version)
3115     AC_MSG_WARN(=== $glibcxx_min_gnu_ld_version or later and rebuild GCC.)
3116     AC_MSG_WARN([=== Symbol versioning will be disabled.])
3117     enable_symvers=no
3118   fi
3119 fi
3120
3121 # Everything parsed; figure out what file to use.
3122 case $enable_symvers in
3123   no)
3124     SYMVER_FILE=config/abi/pre/none.ver
3125     ;;
3126   gnu)
3127     SYMVER_FILE=config/abi/pre/gnu.ver
3128     AC_DEFINE(_GLIBCXX_SYMVER_GNU, 1,
3129               [Define to use GNU versioning in the shared library.])
3130     ;;
3131   gnu-versioned-namespace)
3132     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
3133     AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1,
3134               [Define to use GNU namespace versioning in the shared library.])
3135     ;;
3136   darwin)
3137     SYMVER_FILE=config/abi/pre/gnu.ver
3138     AC_DEFINE(_GLIBCXX_SYMVER_DARWIN, 1,
3139               [Define to use darwin versioning in the shared library.])
3140     ;;
3141   sun)
3142     SYMVER_FILE=config/abi/pre/gnu.ver
3143     AC_DEFINE(_GLIBCXX_SYMVER_SUN, 1,
3144               [Define to use Sun versioning in the shared library.])
3145     ;;
3146 esac
3147
3148 if test x$enable_symvers != xno ; then
3149   AC_DEFINE(_GLIBCXX_SYMVER, 1,
3150          [Define to use symbol versioning in the shared library.])
3151 fi
3152
3153 AC_CACHE_CHECK([whether the target supports .symver directive],
3154                glibcxx_cv_have_as_symver_directive, [
3155   AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
3156                  [], glibcxx_cv_have_as_symver_directive=yes,
3157                  glibcxx_cv_have_as_symver_directive=no)])
3158 if test $glibcxx_cv_have_as_symver_directive = yes; then
3159   AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
3160     [Define to 1 if the target assembler supports .symver directive.])
3161 fi
3162
3163 AC_SUBST(SYMVER_FILE)
3164 AC_SUBST(port_specific_symbol_files)
3165 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
3166 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU, test $enable_symvers = gnu)
3167 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU_NAMESPACE, test $enable_symvers = gnu-versioned-namespace)
3168 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_DARWIN, test $enable_symvers = darwin)
3169 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_SUN, test $enable_symvers = sun)
3170 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
3171
3172 if test $enable_symvers != no ; then
3173    case ${target_os} in
3174      # The Solaris 2 runtime linker doesn't support the GNU extension of
3175      # binding the same symbol to different versions
3176      solaris2*)
3177        symvers_renaming=no  ;;
3178      # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
3179      *)
3180        AC_DEFINE(HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, 1,
3181          [Define to 1 if the target runtime linker supports binding the same symbol to different versions.])
3182        symvers_renaming=yes  ;;
3183     esac
3184 else
3185     symvers_renaming=no
3186 fi
3187 GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_SOL2, test $symvers_renaming = no)
3188
3189 # Now, set up compatibility support, if any.
3190 # In addition, need this to deal with std::size_t mangling in
3191 # src/compatibility.cc.  In a perfect world, could use
3192 # typeid(std::size_t).name()[0] to do direct substitution.
3193 AC_MSG_CHECKING([for size_t as unsigned int])
3194 ac_save_CFLAGS="$CFLAGS"
3195 CFLAGS="-Werror"
3196 AC_TRY_COMPILE(, [__SIZE_TYPE__* stp; unsigned int* uip; stp = uip;],
3197                  [glibcxx_size_t_is_i=yes], [glibcxx_size_t_is_i=no])
3198 CFLAGS=$ac_save_CFLAGS
3199 if test "$glibcxx_size_t_is_i" = yes; then
3200   AC_DEFINE(_GLIBCXX_SIZE_T_IS_UINT, 1, [Define if size_t is unsigned int.])
3201 fi
3202 AC_MSG_RESULT([$glibcxx_size_t_is_i])
3203
3204 AC_MSG_CHECKING([for ptrdiff_t as int])
3205 ac_save_CFLAGS="$CFLAGS"
3206 CFLAGS="-Werror"
3207 AC_TRY_COMPILE(, [__PTRDIFF_TYPE__* ptp; int* ip; ptp = ip;],
3208                  [glibcxx_ptrdiff_t_is_i=yes], [glibcxx_ptrdiff_t_is_i=no])
3209 CFLAGS=$ac_save_CFLAGS
3210 if test "$glibcxx_ptrdiff_t_is_i" = yes; then
3211   AC_DEFINE(_GLIBCXX_PTRDIFF_T_IS_INT, 1, [Define if ptrdiff_t is int.])
3212 fi
3213 AC_MSG_RESULT([$glibcxx_ptrdiff_t_is_i])
3214 ])
3215
3216
3217 dnl
3218 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
3219 dnl We must stage the required headers so that they will be installed
3220 dnl with the library (unlike libgcc, the STL implementation is provided
3221 dnl solely within headers).  Since we must not inject random user-space
3222 dnl macro names into user-provided C++ code, we first stage into <file>-in
3223 dnl and process to <file> with an output command.  The reason for a two-
3224 dnl stage process here is to correctly handle $srcdir!=$objdir without
3225 dnl having to write complex code (the sed commands to clean the macro
3226 dnl namespace are complex and fragile enough as it is).  We must also
3227 dnl add a relative path so that -I- is supported properly.
3228 dnl
3229 dnl Substs:
3230 dnl  glibcxx_thread_h
3231 dnl
3232 dnl Defines:
3233 dnl  HAVE_GTHR_DEFAULT
3234 dnl
3235 AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
3236   AC_MSG_CHECKING([for thread model used by GCC])
3237   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
3238   AC_MSG_RESULT([$target_thread_file])
3239
3240   if test $target_thread_file != single; then
3241     AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
3242               [Define if gthr-default.h exists
3243               (meaning that threading support is enabled).])
3244   fi
3245
3246   glibcxx_thread_h=gthr-$target_thread_file.h
3247
3248   dnl Check for __GTHREADS define.
3249   gthread_file=${toplevel_srcdir}/gcc/${glibcxx_thread_h}
3250   if grep __GTHREADS $gthread_file >/dev/null 2>&1 ; then
3251     enable_thread=yes
3252   else
3253    enable_thread=no
3254   fi
3255
3256   AC_SUBST(glibcxx_thread_h)
3257 ])
3258
3259
3260 dnl
3261 dnl Check if gthread implementation defines the types and functions
3262 dnl required by the c++0x thread library.  Conforming gthread
3263 dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
3264 dnl
3265 AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
3266   AC_LANG_SAVE
3267   AC_LANG_CPLUSPLUS
3268
3269   ac_save_CXXFLAGS="$CXXFLAGS"
3270   CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc"
3271
3272   AC_MSG_CHECKING([check whether it can be safely assumed that mutex_timedlock is available])
3273
3274   AC_TRY_COMPILE([#include <unistd.h>],
3275     [
3276       #if !defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS < 0
3277       #error
3278       #endif
3279     ], [ac_gthread_use_mutex_timedlock=1], [ac_gthread_use_mutex_timedlock=0])
3280
3281   AC_DEFINE_UNQUOTED(_GTHREAD_USE_MUTEX_TIMEDLOCK, $ac_gthread_use_mutex_timedlock,
3282                      [Define to 1 if mutex_timedlock is available.])
3283
3284   if test $ac_gthread_use_mutex_timedlock = 1 ; then res_mutex_timedlock=yes ;
3285   else res_mutex_timedlock=no ; fi
3286   AC_MSG_RESULT([$res_mutex_timedlock])
3287
3288   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
3289   case $target_thread_file in
3290     posix)
3291       CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
3292   esac
3293
3294   AC_MSG_CHECKING([for gthreads library])
3295
3296   AC_TRY_COMPILE([
3297                   #include "gthr.h"
3298                   #include <unistd.h>
3299                  ],
3300     [
3301       #ifndef __GTHREADS_CXX0X
3302       #error
3303       #endif
3304
3305       // In case of POSIX threads check _POSIX_TIMEOUTS too.
3306       #if (defined(_PTHREADS) \
3307            && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
3308       #error
3309       #endif
3310     ], [ac_has_gthreads=yes], [ac_has_gthreads=no])
3311
3312   AC_MSG_RESULT([$ac_has_gthreads])
3313
3314   if test x"$ac_has_gthreads" = x"yes"; then
3315     AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
3316               [Define if gthreads library is available.])
3317   fi
3318
3319   CXXFLAGS="$ac_save_CXXFLAGS"
3320   AC_LANG_RESTORE
3321 ])
3322
3323
3324 # Check whether LC_MESSAGES is available in <locale.h>.
3325 # Ulrich Drepper <drepper@cygnus.com>, 1995.
3326 #
3327 # This file file be copied and used freely without restrictions.  It can
3328 # be used in projects which are not available under the GNU Public License
3329 # but which still want to provide support for the GNU gettext functionality.
3330 # Please note that the actual code is *not* freely available.
3331 AC_DEFUN([AC_LC_MESSAGES], [
3332   AC_CHECK_HEADER(locale.h, [
3333     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
3334       [AC_TRY_COMPILE([#include <locale.h>], [return LC_MESSAGES],
3335        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
3336     if test $ac_cv_val_LC_MESSAGES = yes; then
3337       AC_DEFINE(HAVE_LC_MESSAGES, 1,
3338                 [Define if LC_MESSAGES is available in <locale.h>.])
3339     fi
3340   ])
3341 ])
3342
3343 dnl
3344 dnl Check whether get_nprocs is available in <sys/sysinfo.h>, and define _GLIBCXX_USE_GET_NPROCS.
3345 dnl
3346 AC_DEFUN([GLIBCXX_CHECK_GET_NPROCS], [
3347
3348   AC_LANG_SAVE
3349   AC_LANG_CPLUSPLUS
3350   ac_save_CXXFLAGS="$CXXFLAGS"
3351   CXXFLAGS="$CXXFLAGS -fno-exceptions"
3352
3353   AC_MSG_CHECKING([for get_nprocs])
3354   AC_CACHE_VAL(glibcxx_cv_GET_NPROCS, [
3355     GCC_TRY_COMPILE_OR_LINK(
3356       [#include <sys/sysinfo.h>],
3357       [int n = get_nprocs();],
3358       [glibcxx_cv_GET_NPROCS=yes],
3359       [glibcxx_cv_GET_NPROCS=no])
3360   ])
3361   if test $glibcxx_cv_GET_NPROCS = yes; then
3362     AC_DEFINE(_GLIBCXX_USE_GET_NPROCS, 1, [Define if get_nprocs is available in <sys/sysinfo.h>.])
3363   fi
3364   AC_MSG_RESULT($glibcxx_cv_GET_NPROCS)
3365
3366   CXXFLAGS="$ac_save_CXXFLAGS"
3367   AC_LANG_RESTORE
3368 ])
3369
3370 dnl
3371 dnl Check whether sysconf(_SC_NPROCESSORS_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROCESSORS_ONLN.
3372 dnl
3373 AC_DEFUN([GLIBCXX_CHECK_SC_NPROCESSORS_ONLN], [
3374
3375   AC_LANG_SAVE
3376   AC_LANG_CPLUSPLUS
3377   ac_save_CXXFLAGS="$CXXFLAGS"
3378   CXXFLAGS="$CXXFLAGS -fno-exceptions"
3379
3380   AC_MSG_CHECKING([for _SC_NPROCESSORS_ONLN])
3381   AC_CACHE_VAL(glibcxx_cv_SC_NPROCESSORS_ONLN, [
3382     GCC_TRY_COMPILE_OR_LINK(
3383       [#include <unistd.h>],
3384       [int n = sysconf(_SC_NPROCESSORS_ONLN);],
3385       [glibcxx_cv_SC_NPROCESSORS_ONLN=yes],
3386       [glibcxx_cv_SC_NPROCESSORS_ONLN=no])
3387   ])
3388   if test $glibcxx_cv_SC_NPROCESSORS_ONLN = yes; then
3389     AC_DEFINE(_GLIBCXX_USE_SC_NPROCESSORS_ONLN, 1, [Define if _SC_NPROCESSORS_ONLN  is available in <unistd.h>.])
3390   fi
3391   AC_MSG_RESULT($glibcxx_cv_SC_NPROCESSORS_ONLN)
3392
3393   CXXFLAGS="$ac_save_CXXFLAGS"
3394   AC_LANG_RESTORE
3395 ])
3396
3397
3398 # Macros from the top-level gcc directory.
3399 m4_include([../config/gc++filt.m4])
3400 m4_include([../config/tls.m4])