OSDN Git Service

2003-07-04 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
1 dnl
2 dnl Initialize basic configure bits, set toplevel_srcdir for Makefiles.
3 dnl
4 dnl GLIBCPP_TOPREL_CONFIGURE
5 AC_DEFUN(GLIBCPP_TOPREL_CONFIGURE, [
6   dnl Default to --enable-multilib (this is also passed by default
7   dnl from the ubercommon-top-level configure)
8   AC_ARG_ENABLE(multilib,
9   [  --enable-multilib       build hella library versions (default)],
10   [case "${enableval}" in
11     yes) multilib=yes ;;
12     no)  multilib=no ;;
13     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
14    esac], [multilib=yes])dnl
15
16   # When building with srcdir == objdir, links to the source files will
17   # be created in directories within the target_subdir.  We have to
18   # adjust toplevel_srcdir accordingly, so that configure finds
19   # install-sh and other auxiliary files that live in the top-level
20   # source directory.
21   if test "${srcdir}" = "."; then
22     if test -z "${with_target_subdir}"; then
23       toprel=".."
24     else
25       if test "${with_target_subdir}" != "."; then
26         toprel="${with_multisrctop}../.."
27       else
28         toprel="${with_multisrctop}.."
29       fi
30     fi
31   else
32     toprel=".."
33   fi
34   AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
35   toplevel_srcdir=\${top_srcdir}/$toprel
36   AC_SUBST(toplevel_srcdir)
37 ])
38
39 dnl
40 dnl Initialize the rest of the library configury.
41 dnl
42 dnl GLIBCPP_CONFIGURE
43 AC_DEFUN(GLIBCPP_CONFIGURE, [
44   # Export build and source directories.
45   # These need to be absolute paths, yet at the same time need to
46   # canonicalize only relative paths, because then amd will not unmount
47   # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
48   glibcpp_builddir=`${PWDCMD-pwd}`
49   case $srcdir in
50   [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
51   *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
52   esac
53   AC_SUBST(glibcpp_builddir)
54   AC_SUBST(glibcpp_srcdir)
55
56   dnl This is here just to satisfy automake.
57   ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)])
58
59   AC_PROG_AWK
60   # Will set LN_S to either 'ln -s' or 'ln'.  With autoconf 2.5x, can also
61   # be 'cp -p' if linking isn't available.  Uncomment the next line to
62   # force a particular method.
63   #ac_cv_prog_LN_S='cp -p'
64   AC_PROG_LN_S
65
66   # We use these options to decide which functions to include.
67   AC_ARG_WITH(target-subdir,
68   [  --with-target-subdir=SUBDIR
69                           configuring in a subdirectory])
70   AC_ARG_WITH(cross-host,
71   [  --with-cross-host=HOST  configuring with a cross compiler])
72
73   AC_ARG_WITH(newlib,
74   [  --with-newlib                    Configuring with newlib])
75
76   glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
77   AC_SUBST(glibcpp_basedir)
78
79   # Never versions of autoconf add an underscore to these functions.
80   # Prevent future problems ...
81   ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
82   ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
83   ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
84   ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
85
86   # AC_PROG_CC
87   # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
88   # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
89   # are probably using a cross compiler, which will not be able to fully
90   # link an executable.  This is addressed in later versions of autoconf.
91
92   AC_DEFUN(LIB_AC_PROG_CC,
93   [AC_BEFORE([$0], [AC_PROG_CPP])dnl
94   dnl Fool anybody using AC_PROG_CC.
95   AC_PROVIDE([AC_PROG_CC])
96   AC_CHECK_PROG(CC, gcc, gcc)
97   if test -z "$CC"; then
98     AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
99     test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
100   fi
101
102   AC_PROG_CC_GNU
103
104   if test $ac_cv_prog_gcc = yes; then
105     GCC=yes
106   dnl Check whether -g works, even if CFLAGS is set, in case the package
107   dnl plays around with CFLAGS (such as to build both debugging and
108   dnl normal versions of a library), tasteless as that idea is.
109     ac_test_CFLAGS="${CFLAGS+set}"
110     ac_save_CFLAGS="$CFLAGS"
111     CFLAGS=
112     AC_PROG_CC_G
113     if test "$ac_test_CFLAGS" = set; then
114       CFLAGS="$ac_save_CFLAGS"
115     elif test $ac_cv_prog_cc_g = yes; then
116       CFLAGS="-g -O2"
117     else
118       CFLAGS="-O2"
119     fi
120   else
121     GCC=
122     test "${CFLAGS+set}" = set || CFLAGS="-g"
123   fi
124   ])
125
126   LIB_AC_PROG_CC
127
128   # Likewise for AC_PROG_CXX.  We can't just call it directly because g++
129   # will try to link in libstdc++.
130   AC_DEFUN(LIB_AC_PROG_CXX,
131   [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
132   dnl Fool anybody using AC_PROG_CXX.
133   AC_PROVIDE([AC_PROG_CXX])
134   # Use glibcpp_CXX so that we do not cause CXX to be cached with the
135   # flags that come in CXX while configuring libstdc++.  They're different
136   # from those used for all other target libraries.  If CXX is set in
137   # the environment, respect that here.
138   glibcpp_CXX=$CXX
139   AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
140   AC_SUBST(glibcpp_CXX)
141   CXX=$glibcpp_CXX
142   test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
143
144   AC_PROG_CXX_GNU
145
146   if test $ac_cv_prog_gxx = yes; then
147     GXX=yes
148     dnl Check whether -g works, even if CXXFLAGS is set, in case the package
149     dnl plays around with CXXFLAGS (such as to build both debugging and
150     dnl normal versions of a library), tasteless as that idea is.
151     ac_test_CXXFLAGS="${CXXFLAGS+set}"
152     ac_save_CXXFLAGS="$CXXFLAGS"
153     CXXFLAGS=
154     AC_PROG_CXX_G
155     if test "$ac_test_CXXFLAGS" = set; then
156       CXXFLAGS="$ac_save_CXXFLAGS"
157     elif test $ac_cv_prog_cxx_g = yes; then
158       CXXFLAGS="-g -O2"
159     else
160       CXXFLAGS="-O2"
161     fi
162   else
163     GXX=
164     test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
165   fi
166   ])
167
168   LIB_AC_PROG_CXX
169
170   # For directory versioning (e.g., headers) and other variables.
171   AC_MSG_CHECKING([for GCC version number])
172   gcc_version=`$glibcpp_CXX -dumpversion`
173   AC_MSG_RESULT($gcc_version)
174
175   # For some reason, gettext needs this.
176   AC_ISC_POSIX
177
178   AC_CHECK_TOOL(AS, as)
179   AC_CHECK_TOOL(AR, ar)
180   AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
181   AC_PROG_INSTALL
182
183   AM_MAINTAINER_MODE
184
185   # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
186   # at least currently, we never actually build a program, so we never
187   # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
188   # fails, because we are probably configuring with a cross compiler
189   # which can't create executables.  So we include AC_EXEEXT to keep
190   # automake happy, but we don't execute it, since we don't care about
191   # the result.
192   if false; then
193     # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
194     # to nothing, so nothing would remain between `then' and `fi' if it
195     # were not for the `:' below.
196     :
197     AC_EXEEXT
198   fi
199
200   case [$]{glibcpp_basedir} in
201     /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
202     *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
203   esac
204
205   # Set up safe default values for all subsequent AM_CONDITIONAL tests.
206   need_libmath=no
207   enable_wchar_t=no
208   #enable_debug=no
209   #glibcpp_pch_comp=no
210   #enable_cheaders=c
211   #c_compatibility=no
212   #enable_abi_check=no
213   #enable_symvers=no
214
215   # Find platform-specific directories containing configuration info.  In
216   # addition to possibly modifying the same flags, it also sets up symlinks.
217   GLIBCPP_CHECK_HOST
218 ])
219
220
221 dnl
222 dnl Check to see if g++ can compile this library, and if so, if any version-
223 dnl specific precautions need to be taken.
224 dnl
225 dnl GLIBCPP_CHECK_COMPILER_VERSION
226 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
227 if test ! -f stamp-sanity-compiler; then
228   AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
229   AC_LANG_SAVE
230   AC_LANG_CPLUSPLUS
231   AC_TRY_COMPILE(, [
232   #if __GNUC__ < 3
233     not_ok
234   #endif
235   ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
236   AC_LANG_RESTORE
237   AC_MSG_RESULT($gpp_satisfactory)
238   touch stamp-sanity-compiler
239 fi
240 ])
241
242
243 dnl
244 dnl Tests for newer compiler features, or features that are present in newer
245 dnl compiler versions but not older compiler versions still in use, should
246 dnl be placed here.
247 dnl
248 dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
249 dnl new inlining code or the new system_header pragma will die on -Werror.
250 dnl Leave it out by default and use maint-mode to use it.
251 dnl
252 dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
253 dnl compiler supports it and the user has not requested debug mode.
254 dnl
255 dnl GLIBCPP_CHECK_COMPILER_FEATURES
256 AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
257   # All these tests are for C++; save the language and the compiler flags.
258   # The CXXFLAGS thing is suspicious, but based on similar bits previously
259   # found in GLIBCPP_CONFIGURE.
260   AC_LANG_SAVE
261   AC_LANG_CPLUSPLUS
262   ac_test_CXXFLAGS="${CXXFLAGS+set}"
263   ac_save_CXXFLAGS="$CXXFLAGS"
264
265   # Check for maintainer-mode bits.
266   if test x"$USE_MAINTAINER_MODE" = xno; then
267     WERROR=''
268   else
269     WERROR='-Werror'
270   fi
271
272   # Check for -ffunction-sections -fdata-sections
273   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
274   CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
275   AC_TRY_COMPILE(, [int foo;
276   ], [ac_fdsections=yes], [ac_fdsections=no])
277   if test "$ac_test_CXXFLAGS" = set; then
278     CXXFLAGS="$ac_save_CXXFLAGS"
279   else
280     # this is the suspicious part
281     CXXFLAGS=''
282   fi
283   if test x"$ac_fdsections" = x"yes"; then
284     SECTION_FLAGS='-ffunction-sections -fdata-sections'
285   fi
286   AC_MSG_RESULT($ac_fdsections)
287
288   AC_LANG_RESTORE
289   AC_SUBST(WERROR)
290   AC_SUBST(SECTION_FLAGS)
291 ])
292
293
294 dnl
295 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
296 dnl the native linker is in use, all variables will be defined to something
297 dnl safe (like an empty string).
298 dnl
299 dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
300 dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
301 dnl Define LD, with_gnu_ld, and (possibly) glibcpp_gnu_ld_version as
302 dnl side-effects of testing.
303 dnl
304 dnl GLIBCPP_CHECK_LINKER_FEATURES
305 AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
306   # If we're not using GNU ld, then there's no point in even trying these
307   # tests.  Check for that first.  We should have already tested for gld
308   # by now (in libtool), but require it now just to be safe...
309   test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
310   test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
311   AC_REQUIRE([AC_PROG_LD])
312
313   # The name set by libtool depends on the version of libtool.  Shame on us
314   # for depending on an impl detail, but c'est la vie.  Older versions used
315   # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
316   # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
317   # makes sense).  We'll test with_gnu_ld everywhere else, so if that isn't
318   # set (hence we're using an older libtool), then set it.
319   if test x${with_gnu_ld+set} != xset; then
320     if test x${ac_cv_prog_gnu_ld+set} != xset; then
321       # We got through "ac_require(ac_prog_ld)" and still not set?  Huh?
322       with_gnu_ld=no
323     else
324       with_gnu_ld=$ac_cv_prog_gnu_ld
325     fi
326   fi
327
328   # Start by getting the version number.  I think the libtool test already
329   # does some of this, but throws away the result.
330   changequote(,)
331   ldver=`$LD --version 2>/dev/null | head -1 | \
332          sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
333   changequote([,])
334   glibcpp_gnu_ld_version=`echo $ldver | \
335          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
336
337   # Set --gc-sections.
338   if test "$with_gnu_ld" = "notbroken"; then
339     # GNU ld it is!  Joy and bunny rabbits!
340
341     # All these tests are for C++; save the language and the compiler flags.
342     # Need to do this so that g++ won't try to link in libstdc++
343     ac_test_CFLAGS="${CFLAGS+set}"
344     ac_save_CFLAGS="$CFLAGS"
345     CFLAGS='-x c++  -Wl,--gc-sections'
346
347     # Check for -Wl,--gc-sections
348     # XXX This test is broken at the moment, as symbols required for
349     # linking are now in libsupc++ (not built yet.....). In addition,
350     # this test has cored on solaris in the past. In addition,
351     # --gc-sections doesn't really work at the moment (keeps on discarding
352     # used sections, first .eh_frame and now some of the glibc sections for
353     # iconv). Bzzzzt. Thanks for playing, maybe next time.
354     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
355     AC_TRY_RUN([
356      int main(void)
357      {
358        try { throw 1; }
359        catch (...) { };
360        return 0;
361      }
362     ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
363     if test "$ac_test_CFLAGS" = set; then
364       CFLAGS="$ac_save_CFLAGS"
365     else
366       # this is the suspicious part
367       CFLAGS=''
368     fi
369     if test "$ac_sectionLDflags" = "yes"; then
370       SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
371     fi
372     AC_MSG_RESULT($ac_sectionLDflags)
373   fi
374
375   # Set linker optimization flags.
376   if test x"$with_gnu_ld" = x"yes"; then
377     OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
378   fi
379
380   AC_SUBST(SECTION_LDFLAGS)
381   AC_SUBST(OPT_LDFLAGS)
382 ])
383
384
385 dnl
386 dnl Check to see if the (math function) argument passed is
387 dnl declared when using the c++ compiler
388 dnl ASSUMES argument is a math function with ONE parameter
389 dnl
390 dnl GLIBCPP_CHECK_MATH_DECL_1
391 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
392   AC_MSG_CHECKING([for $1 declaration])
393   if test x${glibcpp_cv_func_$1_use+set} != xset; then
394     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
395       AC_LANG_SAVE
396       AC_LANG_CPLUSPLUS
397       AC_TRY_COMPILE([#include <math.h>
398                       #ifdef HAVE_IEEEFP_H
399                       #include <ieeefp.h>
400                       #endif
401                      ],
402                      [ $1(0);],
403                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
404       AC_LANG_RESTORE
405     ])
406   fi
407   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
408 ])
409
410 dnl
411 dnl Check to see if the (math function) argument passed is
412 dnl 1) declared when using the c++ compiler
413 dnl 2) has "C" linkage
414 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
415 dnl
416 dnl Define HAVE_CARGF etc if "cargf" is declared and links
417 dnl
418 dnl argument 1 is name of function to check
419 dnl
420 dnl ASSUMES argument is a math function with ONE parameter
421 dnl
422 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
423 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
424   GLIBCPP_CHECK_MATH_DECL_1($1)
425   if test x$glibcpp_cv_func_$1_use = x"yes"; then
426     AC_CHECK_FUNCS($1)
427   else
428     GLIBCPP_CHECK_MATH_DECL_1(_$1)
429     if test x$glibcpp_cv_func__$1_use = x"yes"; then
430       AC_CHECK_FUNCS(_$1)
431     fi
432   fi
433 ])
434
435
436 dnl
437 dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
438 dnl of functions at once.  It's an all-or-nothing check -- either
439 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
440 dnl Doing it this way saves significant configure time.
441 AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
442   AC_MSG_CHECKING([for $1 functions])
443   AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
444     AC_LANG_SAVE
445     AC_LANG_CPLUSPLUS
446     AC_TRY_COMPILE([#include <math.h>],
447                    [ `for x in $3; do echo "$x (0);"; done` ],
448                    [glibcpp_cv_func_$2_use=yes],
449                    [glibcpp_cv_func_$2_use=no])
450     AC_LANG_RESTORE])
451   AC_MSG_RESULT($glibcpp_cv_func_$2_use)
452   if test x$glibcpp_cv_func_$2_use = x"yes"; then
453     AC_CHECK_FUNCS($3)
454   fi
455 ])
456
457 dnl
458 dnl Check to see if the (math function) argument passed is
459 dnl declared when using the c++ compiler
460 dnl ASSUMES argument is a math function with TWO parameters
461 dnl
462 dnl GLIBCPP_CHECK_MATH_DECL_2
463 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
464   AC_MSG_CHECKING([for $1 declaration])
465   if test x${glibcpp_cv_func_$1_use+set} != xset; then
466     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
467       AC_LANG_SAVE
468       AC_LANG_CPLUSPLUS
469       AC_TRY_COMPILE([#include <math.h>],
470                      [ $1(0, 0);],
471                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
472       AC_LANG_RESTORE
473     ])
474   fi
475   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
476 ])
477
478 dnl
479 dnl Check to see if the (math function) argument passed is
480 dnl 1) declared when using the c++ compiler
481 dnl 2) has "C" linkage
482 dnl
483 dnl Define HAVE_CARGF etc if "cargf" is declared and links
484 dnl
485 dnl argument 1 is name of function to check
486 dnl
487 dnl ASSUMES argument is a math function with TWO parameters
488 dnl
489 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
490 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
491   GLIBCPP_CHECK_MATH_DECL_2($1)
492   if test x$glibcpp_cv_func_$1_use = x"yes"; then
493     AC_CHECK_FUNCS($1)
494   else
495     GLIBCPP_CHECK_MATH_DECL_2(_$1)
496     if test x$glibcpp_cv_func__$1_use = x"yes"; then
497       AC_CHECK_FUNCS(_$1)
498     fi
499   fi
500 ])
501
502
503 dnl
504 dnl Check to see if the (math function) argument passed is
505 dnl declared when using the c++ compiler
506 dnl ASSUMES argument is a math function with THREE parameters
507 dnl
508 dnl GLIBCPP_CHECK_MATH_DECL_3
509 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
510   AC_MSG_CHECKING([for $1 declaration])
511   if test x${glibcpp_cv_func_$1_use+set} != xset; then
512     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
513       AC_LANG_SAVE
514       AC_LANG_CPLUSPLUS
515       AC_TRY_COMPILE([#include <math.h>],
516                      [ $1(0, 0, 0);],
517                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
518       AC_LANG_RESTORE
519     ])
520   fi
521   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
522 ])
523
524 dnl
525 dnl Check to see if the (math function) argument passed is
526 dnl 1) declared when using the c++ compiler
527 dnl 2) has "C" linkage
528 dnl
529 dnl Define HAVE_CARGF etc if "cargf" is declared and links
530 dnl
531 dnl argument 1 is name of function to check
532 dnl
533 dnl ASSUMES argument is a math function with THREE parameters
534 dnl
535 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
536 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
537   GLIBCPP_CHECK_MATH_DECL_3($1)
538   if test x$glibcpp_cv_func_$1_use = x"yes"; then
539     AC_CHECK_FUNCS($1)
540   else
541     GLIBCPP_CHECK_MATH_DECL_3(_$1)
542     if test x$glibcpp_cv_func__$1_use = x"yes"; then
543       AC_CHECK_FUNCS(_$1)
544     fi
545   fi
546 ])
547
548
549 dnl
550 dnl Check to see if the (stdlib function) argument passed is
551 dnl 1) declared when using the c++ compiler
552 dnl 2) has "C" linkage
553 dnl
554 dnl argument 1 is name of function to check
555 dnl
556 dnl ASSUMES argument is a math function with TWO parameters
557 dnl
558 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
559 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
560   AC_MSG_CHECKING([for $1 declaration])
561   if test x${glibcpp_cv_func_$1_use+set} != xset; then
562     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
563       AC_LANG_SAVE
564       AC_LANG_CPLUSPLUS
565       AC_TRY_COMPILE([#include <stdlib.h>],
566                      [ $1(0, 0);],
567                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
568       AC_LANG_RESTORE
569     ])
570   fi
571   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
572   if test x$glibcpp_cv_func_$1_use = x"yes"; then
573     AC_CHECK_FUNCS($1)
574   fi
575 ])
576
577
578 dnl
579 dnl Check to see if the (stdlib function) argument passed is
580 dnl 1) declared when using the c++ compiler
581 dnl 2) has "C" linkage
582 dnl
583 dnl argument 1 is name of function to check
584 dnl
585 dnl ASSUMES argument is a function with THREE parameters
586 dnl
587 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3
588 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
589   AC_MSG_CHECKING([for $1 declaration])
590   if test x${glibcpp_cv_func_$1_use+set} != xset; then
591     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
592       AC_LANG_SAVE
593       AC_LANG_CPLUSPLUS
594       AC_TRY_COMPILE([#include <stdlib.h>],
595                      [ $1(0, 0, 0);],
596                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
597       AC_LANG_RESTORE
598     ])
599   fi
600   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
601   if test x$glibcpp_cv_func_$1_use = x"yes"; then
602     AC_CHECK_FUNCS($1)
603   fi
604 ])
605
606 dnl
607 dnl Because the builtins are picky picky picky about the arguments they take,
608 dnl do an explict linkage tests here.
609 dnl Check to see if the (math function) argument passed is
610 dnl 1) declared when using the c++ compiler
611 dnl 2) has "C" linkage
612 dnl
613 dnl Define HAVE_CARGF etc if "cargf" is declared and links
614 dnl
615 dnl argument 1 is name of function to check
616 dnl
617 dnl ASSUMES argument is a math function with ONE parameter
618 dnl
619 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
620 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
621   AC_MSG_CHECKING([for $1 declaration])
622   if test x${glibcpp_cv_func_$1_use+set} != xset; then
623     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
624       AC_LANG_SAVE
625       AC_LANG_CPLUSPLUS
626       AC_TRY_COMPILE([#include <math.h>],
627                      [ $1(0);],
628                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
629       AC_LANG_RESTORE
630     ])
631   fi
632   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
633   if test x$glibcpp_cv_func_$1_use = x"yes"; then
634     AC_MSG_CHECKING([for $1 linkage])
635     if test x${glibcpp_cv_func_$1_link+set} != xset; then
636       AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
637         AC_TRY_LINK([#include <math.h>],
638                     [ $1(0);],
639                     [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
640       ])
641     fi
642     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
643     if test x$glibcpp_cv_func_$1_link = x"yes"; then
644       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
645       AC_DEFINE_UNQUOTED(${ac_tr_func})
646     fi
647   fi
648 ])
649
650
651 dnl
652 dnl Check to see what builtin math functions are supported
653 dnl
654 dnl check for __builtin_abs
655 dnl check for __builtin_fabsf
656 dnl check for __builtin_fabs
657 dnl check for __builtin_fabl
658 dnl check for __builtin_labs
659 dnl check for __builtin_sqrtf
660 dnl check for __builtin_sqrtl
661 dnl check for __builtin_sqrt
662 dnl check for __builtin_sinf
663 dnl check for __builtin_sin
664 dnl check for __builtin_sinl
665 dnl check for __builtin_cosf
666 dnl check for __builtin_cos
667 dnl check for __builtin_cosl
668 dnl
669 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
670 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
671   dnl Test for builtin math functions.
672   dnl These are made in gcc/c-common.c
673   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
674   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
675   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
676   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
677   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
678
679   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
680   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
681   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
682
683   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
684   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
685   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
686
687   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
688   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
689   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
690
691   dnl There is, without a doubt, a more elegant way to have these
692   dnl names exported so that they won't be stripped out of acconfig.h by
693   dnl autoheader. I leave this as an exercise to somebody less frustrated
694   dnl than I.... please email the libstdc++ list if you can figure out a
695   dnl more elegant approach (see autoconf/acgen.m4 and specifically
696   dnl AC_CHECK_FUNC for things to steal.)
697   dummyvar=no
698   if test x$dummyvar = x"yes"; then
699     AC_DEFINE(HAVE___BUILTIN_ABS)
700     AC_DEFINE(HAVE___BUILTIN_LABS)
701     AC_DEFINE(HAVE___BUILTIN_COS)
702     AC_DEFINE(HAVE___BUILTIN_COSF)
703     AC_DEFINE(HAVE___BUILTIN_COSL)
704     AC_DEFINE(HAVE___BUILTIN_FABS)
705     AC_DEFINE(HAVE___BUILTIN_FABSF)
706     AC_DEFINE(HAVE___BUILTIN_FABSL)
707     AC_DEFINE(HAVE___BUILTIN_SIN)
708     AC_DEFINE(HAVE___BUILTIN_SINF)
709     AC_DEFINE(HAVE___BUILTIN_SINL)
710     AC_DEFINE(HAVE___BUILTIN_SQRT)
711     AC_DEFINE(HAVE___BUILTIN_SQRTF)
712     AC_DEFINE(HAVE___BUILTIN_SQRTL)
713   fi
714 ])
715
716 dnl
717 dnl Check to see what the underlying c library is like
718 dnl These checks need to do two things:
719 dnl 1) make sure the name is declared when using the c++ compiler
720 dnl 2) make sure the name has "C" linkage
721 dnl This might seem like overkill but experience has shown that it's not...
722 dnl
723 dnl Define HAVE_STRTOLD if "strtold" is declared and links
724 dnl Define HAVE_STRTOF if "strtof" is declared and links
725 dnl Define HAVE_DRAND48 if "drand48" is declared and links
726 dnl
727 dnl GLIBCPP_CHECK_STDLIB_SUPPORT
728 AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
729   ac_test_CXXFLAGS="${CXXFLAGS+set}"
730   ac_save_CXXFLAGS="$CXXFLAGS"
731   CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
732
733   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
734   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
735   AC_CHECK_FUNCS(drand48)
736
737   CXXFLAGS="$ac_save_CXXFLAGS"
738 ])
739
740 dnl
741 dnl Check to see what the underlying c library or math library is like.
742 dnl These checks need to do two things:
743 dnl 1) make sure the name is declared when using the c++ compiler
744 dnl 2) make sure the name has "C" linkage
745 dnl This might seem like overkill but experience has shown that it's not...
746 dnl
747 dnl Define HAVE_CARGF etc if "cargf" is found.
748 dnl
749 dnl GLIBCPP_CHECK_MATH_SUPPORT
750 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
751   ac_test_CXXFLAGS="${CXXFLAGS+set}"
752   ac_save_CXXFLAGS="$CXXFLAGS"
753   CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
754
755   dnl Check libm
756   AC_CHECK_LIB(m, sin, libm="-lm")
757   ac_save_LIBS="$LIBS"
758   LIBS="$LIBS $libm"
759
760   dnl Check to see if certain C math functions exist.
761   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
762   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
763   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
764   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
765   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
766   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
767   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
768   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
769
770   dnl Check to see if basic C math functions have float versions.
771   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
772                                           float_trig,
773                                           acosf asinf atanf \
774                                           cosf sinf tanf \
775                                           coshf sinhf tanhf)
776   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
777                                           float_round,
778                                           ceilf floorf)
779   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
780   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
781   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
782   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
783   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
784   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
785   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
786   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
787   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
788   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
789   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
790   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
791   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
792   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
793   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
794   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
795
796   dnl Check to see if basic C math functions have long double versions.
797   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
798                                           long_double_trig,
799                                           acosl asinl atanl \
800                                           cosl sinl tanl \
801                                           coshl sinhl tanhl)
802   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
803                                           long_double_round,
804                                           ceill floorl)
805   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
806   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
807   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
808   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
809   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
810   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
811   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
812   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
813   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
814   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
815   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
816   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
817   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
818   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
819   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
820   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
821   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
822
823   dnl Some runtimes have these functions with a preceding underscore. Please
824   dnl keep this sync'd with the one above. And if you add any new symbol,
825   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
826   dnl Check to see if certain C math functions exist.
827
828   dnl Check to see if basic C math functions have float versions.
829   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
830                                           _float_trig,
831                                           _acosf _asinf _atanf \
832                                           _cosf _sinf _tanf \
833                                           _coshf _sinhf _tanhf)
834   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
835                                           _float_round,
836                                           _ceilf _floorf)
837
838   dnl Check to see if basic C math functions have long double versions.
839   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
840                                           _long_double_trig,
841                                           _acosl _asinl _atanl \
842                                           _cosl _sinl _tanl \
843                                           _coshl _sinhl _tanhl)
844   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
845                                           _long_double_round,
846                                           _ceill _floorl)
847
848   LIBS="$ac_save_LIBS"
849   CXXFLAGS="$ac_save_CXXFLAGS"
850 ])
851
852
853 dnl
854 dnl Check to see if there is native support for complex
855 dnl
856 dnl Don't compile bits in math/* if native support exits.
857 dnl
858 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
859 dnl
860 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
861 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
862   dnl Check for complex versions of math functions of platform.  This will
863   dnl always pass if libm is available, and fail if it isn't.  If it is
864   dnl available, we assume we'll need it later, so add it to LIBS.
865   AC_CHECK_LIB(m, main)
866   AC_REPLACE_MATHFUNCS(nan copysignf)
867
868   dnl For __signbit to signbit conversions.
869   AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
870   AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
871
872   dnl Compile the long double complex functions only if the function
873   dnl provides the non-complex long double functions that are needed.
874   dnl Currently this includes copysignl, which should be
875   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
876   if test x$ac_cv_func_copysignl = x"yes"; then
877     AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
878   fi
879
880   if test -n "$LIBMATHOBJS"; then
881     need_libmath=yes
882   fi
883   AC_SUBST(LIBMATHOBJS)
884 ])
885
886
887 dnl Check to see what architecture and operating system we are compiling
888 dnl for.  Also, if architecture- or OS-specific flags are required for
889 dnl compilation, pick them up here.
890 dnl
891 dnl GLIBCPP_CHECK_HOST
892 AC_DEFUN(GLIBCPP_CHECK_HOST, [
893   . [$]{glibcpp_basedir}/configure.host
894   AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
895   AC_MSG_RESULT(OS config directory is $os_include_dir)
896 ])
897
898
899 dnl
900 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
901 dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
902 dnl must have been previously checked.)
903 dnl
904 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found
905 dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
906 dnl
907 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
908 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
909   dnl Wide characters disabled by default.
910
911   dnl Test wchar.h for mbstate_t, which is needed for char_traits and
912   dnl others even if wchar_t support is not on.
913   AC_MSG_CHECKING([for mbstate_t])
914   AC_TRY_COMPILE([#include <wchar.h>],
915   [mbstate_t teststate;],
916   have_mbstate_t=yes, have_mbstate_t=no)
917   AC_MSG_RESULT($have_mbstate_t)
918   if test x"$have_mbstate_t" = xyes; then
919     AC_DEFINE(HAVE_MBSTATE_T)
920   fi
921
922   dnl Sanity check for existence of ISO C99 headers for extended encoding.
923   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
924   AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
925
926   dnl Only continue checking if the ISO C99 headers exist and support is on.
927   if test x"$ac_has_wchar_h" = xyes &&
928      test x"$ac_has_wctype_h" = xyes &&
929      test x"$enable_c_mbchar" != xno; then
930
931     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
932     dnl numeric_limits can instantiate type_traits<wchar_t>
933     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
934     AC_TRY_COMPILE([#include <wchar.h>],
935     [int i = WCHAR_MIN; int j = WCHAR_MAX;],
936     has_wchar_minmax=yes, has_wchar_minmax=no)
937     AC_MSG_RESULT($has_wchar_minmax)
938
939     dnl Test wchar.h for WEOF, which is what we use to determine whether
940     dnl to specialize for char_traits<wchar_t> or not.
941     AC_MSG_CHECKING([for WEOF])
942     AC_TRY_COMPILE([
943       #include <wchar.h>
944       #include <stddef.h>],
945     [wint_t i = WEOF;],
946     has_weof=yes, has_weof=no)
947     AC_MSG_RESULT($has_weof)
948
949     dnl Tests for wide character functions used in char_traits<wchar_t>.
950     ac_wfuncs=yes
951     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
952     ac_wfuncs=no)
953
954     dnl Checks for names injected into std:: by the c_std headers.
955     AC_CHECK_FUNCS(btowc wctob fgetwc fgetws fputwc fputws fwide \
956     fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
957     vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
958     mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
959     wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
960     wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
961     ac_wfuncs=no)
962
963     AC_MSG_CHECKING([for ISO C99 wchar_t support])
964     if test x"$has_weof" = xyes &&
965        test x"$has_wchar_minmax" = xyes &&
966        test x"$ac_wfuncs" = xyes; then
967       ac_isoC99_wchar_t=yes
968     else
969       ac_isoC99_wchar_t=no
970     fi
971     AC_MSG_RESULT($ac_isoC99_wchar_t)
972
973     dnl Use iconv for wchar_t to char conversions. As such, check for
974     dnl X/Open Portability Guide, version 2 features (XPG2).
975     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
976     AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
977
978     dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
979     AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
980     ac_save_LIBS="$LIBS"
981     LIBS="$LIBS $libiconv"
982
983     AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
984     ac_XPG2funcs=yes, ac_XPG2funcs=no)
985
986     LIBS="$ac_save_LIBS"
987
988     AC_MSG_CHECKING([for XPG2 wchar_t support])
989     if test x"$ac_has_iconv_h" = xyes &&
990        test x"$ac_has_langinfo_h" = xyes &&
991        test x"$ac_XPG2funcs" = xyes; then
992       ac_XPG2_wchar_t=yes
993     else
994       ac_XPG2_wchar_t=no
995     fi
996     AC_MSG_RESULT($ac_XPG2_wchar_t)
997
998     dnl At the moment, only enable wchar_t specializations if all the
999     dnl above support is present.
1000     if test x"$ac_isoC99_wchar_t" = xyes && 
1001         test x"$ac_XPG2_wchar_t" = xyes; then
1002       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
1003       enable_wchar_t=yes
1004     fi
1005   fi
1006   AC_MSG_CHECKING([for enabled wchar_t specializations])
1007   AC_MSG_RESULT($enable_wchar_t)        
1008 ])
1009
1010
1011 dnl
1012 dnl Check to see if debugging libraries are to be built.
1013 dnl
1014 dnl GLIBCPP_ENABLE_DEBUG
1015 dnl
1016 dnl --enable-libstdcxx-debug
1017 dnl builds a separate set of debugging libraries in addition to the
1018 dnl normal (shared, static) libstdc++ binaries.
1019 dnl
1020 dnl --disable-libstdcxx-debug
1021 dnl builds only one (non-debug) version of libstdc++.
1022 dnl
1023 dnl --enable-libstdcxx-debug-flags=FLAGS
1024 dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
1025 dnl
1026 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
1027 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1028 dnl       defaults to `no'.
1029 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
1030 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
1031 AC_ARG_ENABLE(libstdcxx_debug,
1032 changequote(<<, >>)dnl
1033 <<  --enable-libstdcxx-debug          build extra debug library [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
1034 changequote([, ])dnl
1035 [case "${enableval}" in
1036  yes) enable_libstdcxx_debug=yes ;;
1037  no)  enable_libstdcxx_debug=no ;;
1038  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1039  esac],
1040 enable_libstdcxx_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1041 AC_MSG_CHECKING([for additional debug build])
1042 AC_MSG_RESULT($enable_libstdcxx_debug)
1043 AM_CONDITIONAL(GLIBCPP_BUILD_DEBUG, test "$enable_libstdcxx_debug" = yes)
1044 ])
1045
1046
1047 dnl Check for explicit debug flags.
1048 dnl
1049 dnl GLIBCPP_ENABLE_DEBUG_FLAGS
1050 dnl
1051 dnl --enable-libstdcxx-debug-flags='-O1'
1052 dnl is a general method for passing flags to be used when
1053 dnl building debug libraries with --enable-debug.
1054 dnl
1055 dnl --disable-libstdcxx-debug-flags does nothing.
1056 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG_FLAGS(default flags)
1057 dnl       If "default flags" is an empty string (or "none"), the effect is
1058 dnl       the same as --disable or --enable=no.
1059 AC_DEFUN(GLIBCPP_ENABLE_DEBUG_FLAGS, [dnl
1060 define([GLIBCPP_ENABLE_DEBUG_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1061 AC_ARG_ENABLE(libstdcxx_debug_flags,
1062 changequote(<<, >>)dnl
1063 <<  --enable-libstdcxx-debug-flags=FLAGS    pass compiler FLAGS when building 
1064                                             debug library;
1065                                 [default=>>GLIBCPP_ENABLE_DEBUG_FLAGS_DEFAULT],
1066 changequote([, ])dnl
1067 [case "${enableval}" in
1068  none)  ;;
1069  -*) enable_libstdcxx_debug_flags="${enableval}" ;;
1070  *)   AC_MSG_ERROR([Unknown argument to extra debugging flags]) ;;
1071  esac],
1072 enable_libstdcxx_debug_flags=GLIBCPP_ENABLE_DEBUG_FLAGS_DEFAULT)dnl
1073
1074 dnl Option parsed, now set things appropriately
1075 case x"$enable_libstdcxx_debug" in
1076     xyes)
1077         case "$enable_libstdcxx_debug_flags" in
1078           none)
1079             DEBUG_FLAGS="-g3 -O0";;
1080           -*) #valid input
1081             DEBUG_FLAGS="${enableval}"
1082         esac
1083         ;;
1084     xno)
1085         DEBUG_FLAGS=""
1086         ;;
1087 esac
1088 AC_SUBST(DEBUG_FLAGS)
1089
1090 AC_MSG_CHECKING([for debug build flags])
1091 AC_MSG_RESULT($DEBUG_FLAGS)
1092 ])
1093
1094
1095 dnl
1096 dnl Check for "unusual" flags to pass to the compiler while building.
1097 dnl
1098 dnl GLIBCPP_ENABLE_CXX_FLAGS
1099 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1100 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1101 dnl     Somehow this same set of flags must be passed when [re]building
1102 dnl     libgcc.
1103 dnl --disable-cxx-flags passes nothing.
1104 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1105 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1106 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
1107 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1108 dnl       If "default flags" is an empty string (or "none"), the effect is
1109 dnl       the same as --disable or --enable=no.
1110 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1111 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1112 AC_MSG_CHECKING([for extra compiler flags for building])
1113 AC_ARG_ENABLE(cxx_flags,
1114 changequote(<<, >>)dnl
1115 <<  --enable-cxx-flags=FLAGS     pass compiler FLAGS when building library;
1116                                   [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1117 changequote([, ])dnl
1118 [case "x$enable_cxx_flags" in
1119   xyes)
1120     AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1121   xno | xnone | x)
1122     enable_cxx_flags='' ;;
1123   *)
1124     enable_cxx_flags="$enableval" ;;
1125 esac],
1126 enable_cxx_flags=GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT)
1127
1128 dnl Run through flags (either default or command-line) and set anything
1129 dnl extra (e.g., #defines) that must accompany particular g++ options.
1130 if test -n "$enable_cxx_flags"; then
1131   for f in $enable_cxx_flags; do
1132     case "$f" in
1133       -fhonor-std)  ;;
1134       -*)  ;;
1135       *)   # and we're trying to pass /what/ exactly?
1136            AC_MSG_ERROR([compiler flags start with a -]) ;;
1137     esac
1138   done
1139 fi
1140 EXTRA_CXX_FLAGS="$enable_cxx_flags"
1141 AC_MSG_RESULT($EXTRA_CXX_FLAGS)
1142 AC_SUBST(EXTRA_CXX_FLAGS)
1143 ])
1144
1145
1146 dnl
1147 dnl Check for which locale library to use:  gnu or generic.
1148 dnl
1149 dnl GLIBCPP_ENABLE_CLOCALE
1150 dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1151 dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
1152 dnl
1153 dnl default is generic
1154 dnl
1155 AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1156   AC_MSG_CHECKING([for clocale to use])
1157   AC_ARG_ENABLE(clocale,
1158   [  --enable-clocale        enable model for target locale package.
1159   --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
1160   ],
1161   if test x$enable_clocale = xno; then
1162      enable_clocale=no
1163   fi,
1164      enable_clocale=no)
1165
1166   enable_clocale_flag=$enable_clocale
1167
1168   dnl Probe for locale support if no specific model is specified.
1169   dnl Default to "generic"
1170   if test x$enable_clocale_flag = xno; then
1171     case x${target_os} in
1172       xlinux* | xgnu*)
1173         AC_EGREP_CPP([_GLIBCPP_ok], [
1174         #include <features.h>
1175         #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
1176           _GLIBCPP_ok
1177         #endif
1178         ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1179
1180         # Test for bugs early in glibc-2.2.x series
1181         if test x$enable_clocale_flag = xgnu; then
1182           AC_TRY_RUN([
1183           #define _GNU_SOURCE 1
1184           #include <locale.h>
1185           #include <string.h>
1186           #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
1187           extern __typeof(newlocale) __newlocale;
1188           extern __typeof(duplocale) __duplocale;
1189           extern __typeof(strcoll_l) __strcoll_l;
1190           #endif
1191           int main()
1192           {
1193             const char __one[] = "Äuglein Augmen";
1194             const char __two[] = "Äuglein";
1195             int i;
1196             int j;
1197             __locale_t  loc;
1198             __locale_t  loc_dup;
1199             loc = __newlocale(1 << LC_ALL, "de_DE", 0);
1200             loc_dup = __duplocale(loc);
1201             i = __strcoll_l(__one, __two, loc);
1202             j = __strcoll_l(__one, __two, loc_dup);
1203             return 0;
1204           }
1205           ],
1206           [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
1207           [enable_clocale_flag=generic])
1208         fi
1209
1210         # ... at some point put __strxfrm_l tests in as well.
1211         ;;
1212       *)
1213         enable_clocale_flag=generic
1214         ;;
1215     esac
1216   fi
1217
1218   dnl Deal with gettext issues.
1219   AC_ARG_ENABLE(nls,
1220   [  --enable-nls            use Native Language Support (default)],
1221   , enable_nls=yes)
1222   USE_NLS=no
1223
1224   dnl Set configure bits for specified locale package
1225   case x${enable_clocale_flag} in
1226     xgeneric)
1227       AC_MSG_RESULT(generic)
1228
1229       CLOCALE_H=config/locale/generic/c_locale.h
1230       CLOCALE_CC=config/locale/generic/c_locale.cc
1231       CCODECVT_H=config/locale/generic/codecvt_specializations.h
1232       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1233       CCOLLATE_CC=config/locale/generic/collate_members.cc
1234       CCTYPE_CC=config/locale/generic/ctype_members.cc
1235       CMESSAGES_H=config/locale/generic/messages_members.h
1236       CMESSAGES_CC=config/locale/generic/messages_members.cc
1237       CMONEY_CC=config/locale/generic/monetary_members.cc
1238       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1239       CTIME_H=config/locale/generic/time_members.h
1240       CTIME_CC=config/locale/generic/time_members.cc
1241       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1242       ;;
1243     xgnu)
1244       AC_MSG_RESULT(gnu)
1245
1246       # Declare intention to use gettext, and add support for specific
1247       # languages.
1248       # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
1249       ALL_LINGUAS="de fr"
1250
1251       # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
1252       AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1253       if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
1254         USE_NLS=yes
1255       fi
1256       # Export the build objects.
1257       for ling in $ALL_LINGUAS; do \
1258         glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
1259         glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
1260       done
1261       AC_SUBST(glibcpp_MOFILES)
1262       AC_SUBST(glibcpp_POFILES)
1263
1264       CLOCALE_H=config/locale/gnu/c_locale.h
1265       CLOCALE_CC=config/locale/gnu/c_locale.cc
1266       CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1267       CCODECVT_CC=config/locale/gnu/codecvt_members.cc
1268       CCOLLATE_CC=config/locale/gnu/collate_members.cc
1269       CCTYPE_CC=config/locale/gnu/ctype_members.cc
1270       CMESSAGES_H=config/locale/gnu/messages_members.h
1271       CMESSAGES_CC=config/locale/gnu/messages_members.cc
1272       CMONEY_CC=config/locale/gnu/monetary_members.cc
1273       CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1274       CTIME_H=config/locale/gnu/time_members.h
1275       CTIME_CC=config/locale/gnu/time_members.cc
1276       CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
1277       ;;
1278     xieee_1003.1-2001)
1279       AC_MSG_RESULT(IEEE 1003.1)
1280
1281       CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1282       CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
1283       CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1284       CCODECVT_CC=config/locale/generic/codecvt_members.cc
1285       CCOLLATE_CC=config/locale/generic/collate_members.cc
1286       CCTYPE_CC=config/locale/generic/ctype_members.cc
1287       CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1288       CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1289       CMONEY_CC=config/locale/generic/monetary_members.cc
1290       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1291       CTIME_H=config/locale/generic/time_members.h
1292       CTIME_CC=config/locale/generic/time_members.cc
1293       CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1294       ;;
1295     *)
1296       echo "$enable_clocale is an unknown locale package" 1>&2
1297       exit 1
1298       ;;
1299   esac
1300
1301   # This is where the testsuite looks for locale catalogs, using the
1302   # -DLOCALEDIR define during testsuite compilation.
1303   glibcpp_localedir=${glibcpp_builddir}/po/share/locale
1304   AC_SUBST(glibcpp_localedir)
1305
1306   # A standalone libintl (e.g., GNU libintl) may be in use.
1307   if test $USE_NLS = yes; then
1308     AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no)
1309     AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no)
1310   fi
1311   if test $USE_NLS = yes; then
1312     AC_DEFINE(_GLIBCPP_USE_NLS)
1313   fi
1314
1315   AC_SUBST(USE_NLS)
1316   AC_SUBST(CLOCALE_H)
1317   AC_SUBST(CCODECVT_H)
1318   AC_SUBST(CMESSAGES_H)
1319   AC_SUBST(CCODECVT_CC)
1320   AC_SUBST(CCOLLATE_CC)
1321   AC_SUBST(CCTYPE_CC)
1322   AC_SUBST(CMESSAGES_CC)
1323   AC_SUBST(CMONEY_CC)
1324   AC_SUBST(CNUMERIC_CC)
1325   AC_SUBST(CTIME_H)
1326   AC_SUBST(CTIME_CC)
1327   AC_SUBST(CLOCALE_CC)
1328   AC_SUBST(CLOCALE_INTERNAL_H)
1329 ])
1330
1331
1332 dnl
1333 dnl Check for which I/O library to use:  stdio, or something specific.
1334 dnl
1335 dnl GLIBCPP_ENABLE_CSTDIO
1336 dnl
1337 dnl default is stdio
1338 dnl
1339 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1340   AC_MSG_CHECKING([for cstdio to use])
1341   AC_ARG_ENABLE(cstdio,
1342   [  --enable-cstdio         enable stdio for target io package.
1343   --enable-cstdio=LIB     use LIB target-specific io package. [default=stdio]
1344   ],
1345   if test x$enable_cstdio = xno; then
1346      enable_cstdio=stdio
1347   fi,
1348      enable_cstdio=stdio)
1349
1350   enable_cstdio_flag=$enable_cstdio
1351
1352   dnl Check if a valid I/O package
1353   case x${enable_cstdio_flag} in
1354     xstdio | x | xno | xnone | xyes)
1355       # default
1356       CSTDIO_H=config/io/c_io_stdio.h
1357       BASIC_FILE_H=config/io/basic_file_stdio.h
1358       BASIC_FILE_CC=config/io/basic_file_stdio.cc
1359       AC_MSG_RESULT(stdio)
1360       ;;
1361     *)
1362       echo "$enable_cstdio is an unknown io package" 1>&2
1363       exit 1
1364       ;;
1365   esac
1366
1367   dnl Set directory for fpos.h
1368   FPOS_H=$fpos_include_dir
1369
1370   AC_SUBST(CSTDIO_H)
1371   AC_SUBST(FPOS_H)
1372   AC_SUBST(BASIC_FILE_H)
1373   AC_SUBST(BASIC_FILE_CC)
1374 ])
1375
1376
1377 dnl
1378 dnl Check to see if building and using a C++ precompiled header can be done.
1379 dnl
1380 dnl GLIBCPP_ENABLE_PCH
1381 dnl
1382 dnl --enable-libstdcxx-pch=yes
1383 dnl default, this shows intent to use stdc++.h.gch If it looks like it
1384 dnl may work, after some light-hearted attempts to puzzle out compiler
1385 dnl support, flip bits on in include/Makefile.am
1386 dnl
1387 dnl --disable-libstdcxx-pch
1388 dnl turns off attempts to use or build stdc++.h.gch.
1389 dnl
1390 AC_DEFUN(GLIBCPP_ENABLE_PCH, [dnl
1391 define([GLIBCPP_ENABLE_PCH_DEFAULT], ifelse($1,,, $1))dnl
1392 AC_ARG_ENABLE(libstdcxx_pch,
1393 changequote(<<, >>)dnl
1394 <<  --enable-libstdcxx-pch     build pre-compiled libstdc++ includes [default=>>GLIBCPP_ENABLE_PCH_DEFAULT],
1395 changequote([, ])dnl
1396 [case "${enableval}" in
1397  yes) enable_libstdcxx_pch=yes ;;
1398  no)  enable_libstdcxx_pch=no ;;
1399  *)   AC_MSG_ERROR([Unknown argument to enable/disable PCH]) ;;
1400  esac],
1401 enable_libstdcxx_pch=GLIBCPP_ENABLE_PCH_DEFAULT)dnl
1402
1403   if test x$enable_libstdcxx_pch = xyes; then
1404     ac_test_CXXFLAGS="${CXXFLAGS+set}"
1405     ac_save_CXXFLAGS="$CXXFLAGS"
1406     CXXFLAGS='-Werror -Winvalid-pch -Wno-deprecated -x c++-header'
1407
1408     AC_MSG_CHECKING([for compiler that seems to compile .gch files])
1409     if test x${pch_comp+set} != xset; then
1410       AC_CACHE_VAL(pch_comp, [
1411         AC_LANG_SAVE
1412         AC_LANG_CPLUSPLUS
1413         AC_TRY_COMPILE([#include <math.h>], ,
1414                        [pch_comp=yes], [pch_comp=no])
1415         AC_LANG_RESTORE
1416       ])
1417     fi
1418     AC_MSG_RESULT([$pch_comp])
1419
1420     CXXFLAGS="$ac_save_CXXFLAGS"
1421   fi
1422
1423   if test x"$enable_libstdcxx_pch" = xyes && test x"$pch_comp" = xno; then
1424     enable_pch=no
1425   fi
1426
1427   AC_MSG_CHECKING([for enabled PCH])
1428   AC_MSG_RESULT([$enable_libstdcxx_pch])
1429
1430   AM_CONDITIONAL(GLIBCPP_BUILD_PCH, test "$enable_libstdcxx_pch" = yes)
1431   if test "$enable_libstdcxx_pch" = yes; then
1432         glibcpp_PCHFLAGS="-include bits/stdc++.h"
1433   else
1434         glibcpp_PCHFLAGS=""
1435   fi
1436   AC_SUBST(glibcpp_PCHFLAGS)
1437 ])
1438
1439 dnl
1440 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1441 dnl We must stage the required headers so that they will be installed
1442 dnl with the library (unlike libgcc, the STL implementation is provided
1443 dnl solely within headers).  Since we must not inject random user-space
1444 dnl macro names into user-provided C++ code, we first stage into <file>-in
1445 dnl and process to <file> with an output command.  The reason for a two-
1446 dnl stage process here is to correctly handle $srcdir!=$objdir without
1447 dnl having to write complex code (the sed commands to clean the macro
1448 dnl namespace are complex and fragile enough as it is).  We must also
1449 dnl add a relative path so that -I- is supported properly.
1450 dnl
1451 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1452   AC_MSG_CHECKING([for thread model used by GCC])
1453   target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1454   AC_MSG_RESULT([$target_thread_file])
1455
1456   if test $target_thread_file != single; then
1457     AC_DEFINE(HAVE_GTHR_DEFAULT)
1458     AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1459   fi
1460
1461   glibcpp_thread_h=gthr-$target_thread_file.h
1462   AC_SUBST(glibcpp_thread_h)
1463 ])
1464
1465
1466 dnl
1467 dnl Check for exception handling support.  If an explicit enable/disable
1468 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1469 dnl target may or may not support call frame exceptions.
1470 dnl
1471 dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1472 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1473 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1474 dnl
1475 dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1476 dnl
1477 AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1478   AC_MSG_CHECKING([for exception model to use])
1479   AC_LANG_SAVE
1480   AC_LANG_CPLUSPLUS
1481   AC_ARG_ENABLE(sjlj-exceptions,
1482   [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1483   [:],
1484   [dnl Botheration.  Now we've got to detect the exception model.
1485    dnl Link tests against libgcc.a are problematic since -- at least
1486    dnl as of this writing -- we've not been given proper -L bits for
1487    dnl single-tree newlib and libgloss.
1488    dnl
1489    dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1490    dnl conftest files before we got a change to grep them first.
1491    cat > conftest.$ac_ext << EOF
1492 [#]line __oline__ "configure"
1493 struct S { ~S(); };
1494 void bar();
1495 void foo()
1496 {
1497   S s;
1498   bar();
1499 }
1500 EOF
1501    old_CXXFLAGS="$CXXFLAGS"
1502    CXXFLAGS=-S
1503    if AC_TRY_EVAL(ac_compile); then
1504      if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1505        enable_sjlj_exceptions=yes
1506      elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1507        enable_sjlj_exceptions=no
1508      fi
1509    fi
1510    CXXFLAGS="$old_CXXFLAGS"
1511    rm -f conftest*])
1512    if test x$enable_sjlj_exceptions = xyes; then
1513      AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1514         [Define if the compiler is configured for setjmp/longjmp exceptions.])
1515      ac_exception_model_name=sjlj
1516    elif test x$enable_sjlj_exceptions = xno; then
1517      ac_exception_model_name="call frame"
1518    else
1519      AC_MSG_ERROR([unable to detect exception model])
1520    fi
1521    AC_LANG_RESTORE
1522    AC_MSG_RESULT($ac_exception_model_name)
1523 ])
1524
1525
1526 dnl
1527 dnl Check for libunwind exception handling support. If enabled then
1528 dnl we assume that the _Unwind_* functions that make up the Unwind ABI
1529 dnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
1530 dnl libunwind instead of libgcc and that libstdc++ has a dependency
1531 dnl on libunwind as well as libgcc.
1532 dnl
1533 dnl GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
1534 dnl --enable-libunwind-exceptions forces the use of libunwind.
1535 dnl --disable-libunwind-exceptions assumes there is no libunwind.
1536 dnl
1537 dnl Define _GLIBCPP_LIBUNWIND_EXCEPTIONS if requested.
1538 dnl
1539 AC_DEFUN(GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS, [
1540   AC_MSG_CHECKING([for use of libunwind])
1541   AC_ARG_ENABLE(libunwind-exceptions,
1542   [  --enable-libunwind-exceptions  force use of libunwind for exceptions],
1543   use_libunwind_exceptions=$enableval,
1544   use_libunwind_exceptions=no)
1545   AC_MSG_RESULT($use_libunwind_exceptions)
1546   dnl Option parsed, now set things appropriately
1547   if test x"$use_libunwind_exceptions" = xyes; then
1548     LIBUNWIND_FLAG="-lunwind"
1549   else
1550     LIBUNWIND_FLAG=""
1551   fi
1552   AC_SUBST(LIBUNWIND_FLAG)
1553 ])
1554
1555 dnl
1556 dnl Check for ISO/IEC 9899:1999 "C99" support.
1557 dnl
1558 dnl GLIBCPP_ENABLE_C99
1559 dnl --enable-c99 defines _GLIBCPP_USE_C99
1560 dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1561 dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1562 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1563 dnl       defaults to `no'.
1564 dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1565 dnl
1566 dnl GLIBCPP_ENABLE_C99
1567 AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1568   define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1569
1570   AC_ARG_ENABLE(c99,
1571   changequote(<<, >>)dnl
1572   <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1573   changequote([, ])dnl
1574   [case "$enableval" in
1575    yes) enable_c99=yes ;;
1576    no)  enable_c99=no ;;
1577    *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1578    esac],
1579   enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1580
1581   AC_LANG_SAVE
1582   AC_LANG_CPLUSPLUS
1583
1584   # Check for the existence of <math.h> functions used if C99 is enabled.
1585   ac_c99_math=yes;
1586   AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1587   AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1588   AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1589   AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1590   AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1591   AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1592   AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1593   AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1594   AC_TRY_COMPILE([#include <math.h>],
1595                  [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1596   AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1597   AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1598   AC_TRY_COMPILE([#include <math.h>],
1599                  [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1600   AC_TRY_COMPILE([#include <math.h>],
1601                  [isunordered(0.0,0.0);],, [ac_c99_math=no])
1602   AC_MSG_RESULT($ac_c99_math)
1603
1604   # Check for the existence in <stdio.h> of vscanf, et. al.
1605   ac_c99_stdio=yes;
1606   AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1607   AC_TRY_COMPILE([#include <stdio.h>],
1608                  [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
1609   AC_TRY_COMPILE([#include <stdio.h>
1610                   #include <stdarg.h>
1611                   void foo(char* fmt, ...)
1612                   {va_list args; va_start(args, fmt);
1613                   vfscanf(stderr, "%i", args);}],
1614                   [],, [ac_c99_stdio=no])
1615   AC_TRY_COMPILE([#include <stdio.h>
1616                   #include <stdarg.h>
1617                   void foo(char* fmt, ...)
1618                   {va_list args; va_start(args, fmt);
1619                   vscanf("%i", args);}],
1620                   [],, [ac_c99_stdio=no])
1621   AC_TRY_COMPILE([#include <stdio.h>
1622                   #include <stdarg.h>
1623                   void foo(char* fmt, ...)
1624                   {va_list args; va_start(args, fmt);
1625                   vsnprintf(fmt, 0, "%i", args);}],
1626                   [],, [ac_c99_stdio=no])
1627   AC_TRY_COMPILE([#include <stdio.h>
1628                   #include <stdarg.h>
1629                   void foo(char* fmt, ...)
1630                   {va_list args; va_start(args, fmt);
1631                   vsscanf(fmt, "%i", args);}],
1632                   [],, [ac_c99_stdio=no])
1633   AC_MSG_RESULT($ac_c99_stdio)
1634
1635   # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1636   ac_c99_stdlib=yes;
1637   AC_MSG_CHECKING([for lldiv_t declaration])
1638   AC_CACHE_VAL(ac_c99_lldiv_t, [
1639   AC_TRY_COMPILE([#include <stdlib.h>],
1640                    [ lldiv_t mydivt;],
1641                    [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1642   ])
1643   AC_MSG_RESULT($ac_c99_lldiv_t)
1644
1645   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1646   AC_TRY_COMPILE([#include <stdlib.h>],
1647                  [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1648   AC_TRY_COMPILE([#include <stdlib.h>],
1649                  [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1650   AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1651   AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1652   AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1653   AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1654   if test x"$ac_c99_lldiv_t" = x"no"; then
1655     ac_c99_stdlib=no;
1656   fi;
1657   AC_MSG_RESULT($ac_c99_stdlib)
1658
1659   # Check for the existence of <wchar.h> functions used if C99 is enabled.
1660   # XXX the wchar.h checks should be rolled into the general C99 bits.
1661   ac_c99_wchar=yes;
1662   AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1663   AC_TRY_COMPILE([#include <wchar.h>],
1664                  [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1665   AC_TRY_COMPILE([#include <wchar.h>],
1666                  [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1667   AC_TRY_COMPILE([#include <wchar.h>],
1668                  [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1669   AC_MSG_RESULT($ac_c99_wchar)
1670
1671   AC_MSG_CHECKING([for enabled ISO C99 support])
1672   if test x"$ac_c99_math" = x"no" ||
1673      test x"$ac_c99_stdio" = x"no" ||
1674      test x"$ac_c99_stdlib" = x"no" ||
1675      test x"$ac_c99_wchar" = x"no"; then
1676     enable_c99=no;
1677   fi;
1678   AC_MSG_RESULT($enable_c99)
1679
1680   # Option parsed, now set things appropriately
1681   if test x"$enable_c99" = x"yes"; then
1682     AC_DEFINE(_GLIBCPP_USE_C99)
1683   fi
1684
1685   AC_LANG_RESTORE
1686 ])
1687
1688
1689 dnl
1690 dnl Check for template specializations for the 'long long' type extension.
1691 dnl The result determines only whether 'long long' I/O is enabled; things
1692 dnl like numeric_limits<> specializations are always available.
1693 dnl
1694 dnl GLIBCPP_ENABLE_LONG_LONG
1695 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1696 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1697 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1698 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1699 dnl       defaults to `no'.
1700 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1701 dnl
1702 dnl GLIBCPP_ENABLE_LONG_LONG
1703 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1704   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1705
1706   AC_ARG_ENABLE(long-long,
1707   changequote(<<, >>)dnl
1708   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1709   changequote([, ])dnl
1710   [case "$enableval" in
1711    yes) enable_long_long=yes ;;
1712    no)  enable_long_long=no ;;
1713    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1714    esac],
1715   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1716
1717   AC_LANG_SAVE
1718   AC_LANG_CPLUSPLUS
1719
1720   AC_MSG_CHECKING([for enabled long long I/O support])
1721   # iostreams require strtoll, strtoull to compile
1722   AC_TRY_COMPILE([#include <stdlib.h>],
1723                  [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
1724   AC_TRY_COMPILE([#include <stdlib.h>],
1725                  [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
1726
1727   # Option parsed, now set things appropriately
1728   if test x"$enable_long_long" = xyes; then
1729     AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1730   fi
1731   AC_MSG_RESULT($enable_long_long)
1732
1733   AC_LANG_RESTORE
1734 ])
1735
1736
1737 dnl
1738 dnl Check for what type of C headers to use.
1739 dnl
1740 dnl GLIBCPP_ENABLE_CHEADERS
1741 dnl --enable-cheaders= [does stuff].
1742 dnl --disable-cheaders [does not do anything, really].
1743 dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1744 dnl       Where DEFAULT is either `c' or `c_std'.
1745 dnl       If ommitted, it defaults to `c_std'.
1746 AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1747 define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1748 AC_MSG_CHECKING([for c header strategy to use])
1749 AC_ARG_ENABLE(cheaders,
1750 changequote(<<, >>)dnl
1751 <<  --enable-cheaders=MODEL       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1752 changequote([, ])
1753   [case "$enableval" in
1754    c)
1755         enable_cheaders=c
1756         ;;
1757    c_std)
1758         enable_cheaders=c_std
1759         ;;
1760    *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers])
1761         ;;
1762   esac],
1763   enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1764   AC_MSG_RESULT($enable_cheaders)
1765
1766   dnl Option parsed, now set things appropriately
1767   case "$enable_cheaders" in
1768     c_std)
1769         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1770         ;;
1771     c)
1772         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1773         ;;
1774   esac
1775
1776   AC_SUBST(C_INCLUDE_DIR)
1777   AM_CONDITIONAL(GLIBCPP_C_HEADERS_C, test "$enable_cheaders" = c)
1778   AM_CONDITIONAL(GLIBCPP_C_HEADERS_C_STD, test "$enable_cheaders" = c_std)
1779   AM_CONDITIONAL(GLIBCPP_C_HEADERS_COMPATIBILITY, test "$c_compatibility" = yes)
1780 ])
1781
1782
1783 dnl
1784 dnl Check for wide character support.  Has the same effect as the option
1785 dnl in gcc's configure, but in a form that autoconf can mess with.
1786 dnl
1787 dnl GLIBCPP_ENABLE_C_MBCHAR
1788 dnl --enable-c-mbchar requests all the wchar_t stuff.
1789 dnl --disable-c-mbchar doesn't.
1790 dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1791 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1792 dnl       defaults to `no'.
1793 AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1794 define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1795 AC_ARG_ENABLE(c-mbchar,
1796 changequote(<<, >>)dnl
1797 <<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1798 changequote([, ])dnl
1799 [case "$enableval" in
1800  yes) enable_c_mbchar=yes ;;
1801  no)  enable_c_mbchar=no ;;
1802  *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1803  esac],
1804 enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1805 dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1806 ])
1807
1808
1809 dnl
1810 dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1811 dnl
1812 dnl TOPLEVEL_INCLUDES
1813 dnl LIBMATH_INCLUDES
1814 dnl LIBSUPCXX_INCLUDES
1815 dnl
1816 dnl GLIBCPP_EXPORT_INCLUDES
1817 AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1818   # Root level of the build directory include sources.
1819   GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1820
1821   # Passed down for canadian crosses.
1822   if test x"$CANADIAN" = xyes; then
1823     TOPLEVEL_INCLUDES='-I$(includedir)'
1824   fi
1825
1826   LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1827
1828   LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1829
1830   # Now, export this to all the little Makefiles....
1831   AC_SUBST(GLIBCPP_INCLUDES)
1832   AC_SUBST(TOPLEVEL_INCLUDES)
1833   AC_SUBST(LIBMATH_INCLUDES)
1834   AC_SUBST(LIBSUPCXX_INCLUDES)
1835 ])
1836
1837
1838 dnl
1839 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1840 dnl
1841 AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1842   # Optimization flags that are probably a good idea for thrill-seekers. Just
1843   # uncomment the lines below and make, everything else is ready to go...
1844   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
1845   OPTIMIZE_CXXFLAGS=
1846   AC_SUBST(OPTIMIZE_CXXFLAGS)
1847
1848   WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings'
1849   AC_SUBST(WARN_FLAGS)
1850 ])
1851
1852 dnl
1853 dnl  GLIBCPP_EXPORT_INSTALL_INFO
1854 dnl  calculates gxx_install_dir
1855 dnl  exports glibcpp_toolexecdir
1856 dnl  exports glibcpp_toolexeclibdir
1857 dnl  exports glibcpp_prefixdir
1858 dnl
1859 dnl Assumes cross_compiling bits already done, and with_cross_host in
1860 dnl particular
1861 dnl
1862 dnl GLIBCPP_EXPORT_INSTALL_INFO
1863 AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1864 # Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
1865 # exported correctly in GLIBCPP_CONFIGURE.
1866 glibcpp_toolexecdir=no
1867 glibcpp_toolexeclibdir=no
1868 glibcpp_prefixdir=${prefix}
1869
1870 # Process the option --with-gxx-include-dir=<path to include-files directory>
1871 AC_MSG_CHECKING([for --with-gxx-include-dir])
1872 AC_ARG_WITH(gxx-include-dir,
1873 [  --with-gxx-include-dir  the installation directory for include files],
1874 [case "${withval}" in
1875   yes)
1876     AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1877     gxx_include_dir=no
1878     ;;
1879   no)
1880     gxx_include_dir=no
1881     ;;
1882   *)
1883     gxx_include_dir=${withval}
1884     ;;
1885 esac], [gxx_include_dir=no])
1886 AC_MSG_RESULT($gxx_include_dir)
1887
1888 # Process the option "--enable-version-specific-runtime-libs"
1889 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1890 AC_ARG_ENABLE(version-specific-runtime-libs,
1891 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1892 [case "$enableval" in
1893  yes) version_specific_libs=yes ;;
1894  no)  version_specific_libs=no ;;
1895  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1896  esac],
1897 version_specific_libs=no)dnl
1898 # Option set, now we can test it.
1899 AC_MSG_RESULT($version_specific_libs)
1900
1901 # Default case for install directory for include files.
1902 if test $version_specific_libs = no && test $gxx_include_dir = no; then
1903   gxx_include_dir='$(prefix)'/include/c++/${gcc_version}
1904 fi
1905
1906 # Version-specific runtime libs processing.
1907 if test $version_specific_libs = yes; then
1908   # Need the gcc compiler version to know where to install libraries
1909   # and header files if --enable-version-specific-runtime-libs option
1910   # is selected.
1911   if test x"$gxx_include_dir" = x"no"; then
1912     gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/c++
1913   fi
1914   glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1915   glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1916 fi
1917
1918 # Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
1919 # Install a library built with a cross compiler in tooldir, not libdir.
1920 if test x"$glibcpp_toolexecdir" = x"no"; then
1921   if test -n "$with_cross_host" &&
1922      test x"$with_cross_host" != x"no"; then
1923     glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1924     glibcpp_toolexeclibdir='$(toolexecdir)/lib'
1925   else
1926     glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1927     glibcpp_toolexeclibdir='$(libdir)'
1928   fi
1929   multi_os_directory=`$CC -print-multi-os-directory`
1930   case $multi_os_directory in
1931   .) ;; # Avoid trailing /.
1932   *) glibcpp_toolexeclibdir=$glibcpp_toolexeclibdir/$multi_os_directory ;;
1933   esac
1934 fi
1935
1936 AC_MSG_CHECKING([for install location])
1937 AC_MSG_RESULT($gxx_include_dir)
1938
1939 AC_SUBST(glibcpp_prefixdir)
1940 AC_SUBST(gxx_include_dir)
1941 AC_SUBST(glibcpp_toolexecdir)
1942 AC_SUBST(glibcpp_toolexeclibdir)
1943 ])
1944
1945
1946 # Check for functions in math library.
1947 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1948 #
1949 # This file can be copied and used freely without restrictions.  It can
1950 # be used in projects which are not available under the GNU Public License
1951 # but which still want to provide support for the GNU gettext functionality.
1952 # Please note that the actual code is *not* freely available.
1953
1954 # serial 1
1955
1956 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1957 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1958 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])])
1959
1960
1961 dnl This macro searches for a GNU version of make.  If a match is found, the
1962 dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1963 dnl set to "#". This is useful for  including a special features in a Makefile,
1964 dnl which cannot be handled by other versions of make.  The variable
1965 dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1966 dnl the empty string otherwise.
1967 dnl
1968 dnl Here is an example of its use:
1969 dnl
1970 dnl Makefile.in might contain:
1971 dnl
1972 dnl     # A failsafe way of putting a dependency rule into a makefile
1973 dnl     $(DEPEND):
1974 dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1975 dnl
1976 dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1977 dnl     @ifGNUmake@ include $(DEPEND)
1978 dnl     @ifGNUmake@ endif
1979 dnl
1980 dnl Then configure.in would normally contain:
1981 dnl
1982 dnl     CHECK_GNU_MAKE()
1983 dnl     AC_OUTPUT(Makefile)
1984 dnl
1985 dnl Then perhaps to cause gnu make to override any other make, we could do
1986 dnl something like this (note that GNU make always looks for GNUmakefile first):
1987 dnl
1988 dnl     if  ! test x$_cv_gnu_make_command = x ; then
1989 dnl             mv Makefile GNUmakefile
1990 dnl             echo .DEFAULT: > Makefile ;
1991 dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1992 dnl     fi
1993 dnl
1994 dnl Then, if any (well almost any) other make is called, and GNU make also
1995 dnl exists, then the other make wraps the GNU make.
1996 dnl
1997 dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1998 dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1999 dnl
2000 dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
2001 dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
2002 dnl #### conditional's subshell (" --version" is not a command), using a
2003 dnl #### different option to grep(1).
2004 dnl #### -pme
2005 dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
2006 dnl #### ${MAKE:-make}).
2007 dnl #### -msokolov
2008 AC_DEFUN(
2009   GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
2010           _cv_gnu_make_command='' ;
2011 dnl Search all the common names for GNU make
2012           for a in "${MAKE-make}" make gmake gnumake ; do
2013                   if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
2014                   then
2015                           _cv_gnu_make_command=$a ;
2016                           break;
2017                   fi
2018           done ;
2019   ) ;
2020 dnl If there was a GNU version, then set @ifGNUmake@ to the empty
2021 dnl string, '#' otherwise
2022   if test  "x$_cv_gnu_make_command" != "x"  ; then
2023           ifGNUmake='' ;
2024   else
2025           ifGNUmake='#' ;
2026   fi
2027   AC_SUBST(ifGNUmake)
2028 ])
2029
2030
2031 dnl Check for headers for, and arguments to, the setrlimit() function.
2032 dnl Used only in testsuite_hooks.h.
2033 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
2034   AC_TRY_COMPILE([#include <unistd.h>
2035                   #include <sys/time.h>
2036                   #include <sys/resource.h>
2037                  ], [ int f = RLIMIT_$1 ; ],
2038                  [glibcpp_mresult=1], [glibcpp_mresult=0])
2039   AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
2040                      [Only used in build directory testsuite_hooks.h.])
2041 ])
2042 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
2043   setrlimit_have_headers=yes
2044   AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
2045                    [],
2046                    setrlimit_have_headers=no)
2047   # If don't have the headers, then we can't run the tests now, and we
2048   # won't be seeing any of these during testsuite compilation.
2049   if test $setrlimit_have_headers = yes; then
2050     # Can't do these in a loop, else the resulting syntax is wrong.
2051     GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
2052     GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
2053     GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
2054     GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
2055
2056     # Check for rlimit, setrlimit.
2057     AC_CACHE_VAL(ac_setrlimit, [
2058       AC_TRY_COMPILE([#include <unistd.h>
2059                   #include <sys/time.h>
2060                   #include <sys/resource.h>
2061                      ],
2062                      [ struct rlimit r; setrlimit(0, &r);],
2063                      [ac_setrlimit=yes], [ac_setrlimit=no])
2064     ])
2065   fi
2066
2067   AC_MSG_CHECKING([for testsuite memory limit support])
2068   if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
2069     ac_mem_limits=yes
2070     AC_DEFINE(_GLIBCPP_MEM_LIMITS)
2071   else
2072     ac_mem_limits=no
2073   fi
2074   AC_MSG_RESULT($ac_mem_limits)
2075 ])
2076
2077
2078 dnl
2079 dnl Does any necessary configuration of the testsuite directory.  Generates
2080 dnl the testsuite_hooks.h header.
2081 dnl
2082 dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
2083 AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
2084
2085   if test  x"$GLIBCPP_IS_CROSS_COMPILING" = xfalse; then
2086     # Do checks for memory limit functions.
2087     GLIBCPP_CHECK_SETRLIMIT
2088
2089     # Look for setenv, so that extended locale tests can be performed.
2090     GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
2091   fi
2092
2093   # Export file names for ABI checking.
2094   baseline_dir="${glibcpp_srcdir}/config/abi/${abi_baseline_pair}\$(MULTISUBDIR)"
2095   AC_SUBST(baseline_dir)
2096
2097   # Determine if checking the ABI is desirable.
2098   if test x$enable_symvers = xno; then
2099     enable_abi_check=no
2100   else
2101     case "$host" in
2102       *-*-cygwin*) 
2103         enable_abi_check=no ;;
2104       *) 
2105         enable_abi_check=yes ;;
2106     esac
2107   fi
2108
2109   AM_CONDITIONAL(GLIBCPP_TEST_WCHAR_T, test "$enable_wchar_t" = yes)    
2110   AM_CONDITIONAL(GLIBCPP_TEST_ABI, test "$enable_abi_check" = yes)
2111 ])
2112
2113
2114 sinclude(../libtool.m4)
2115 dnl The lines below arrange for aclocal not to bring an installed
2116 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
2117 dnl add a definition of LIBTOOL to Makefile.in.
2118 ifelse(,,,[AC_SUBST(LIBTOOL)
2119 AC_DEFUN([AM_PROG_LIBTOOL])
2120 AC_DEFUN([AC_LIBTOOL_DLOPEN])
2121 AC_DEFUN([AC_PROG_LD])
2122 ])
2123
2124 dnl
2125 dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
2126 dnl
2127
2128 AC_DEFUN(GLIBCPP_CHECK_S_ISREG_OR_S_IFREG, [
2129   AC_CACHE_VAL(glibcpp_cv_S_ISREG, [
2130     AC_TRY_LINK([#include <sys/stat.h>],
2131                 [struct stat buffer; fstat(0, &buffer); S_ISREG(buffer.st_mode); ],
2132                 [glibcpp_cv_S_ISREG=yes],
2133                 [glibcpp_cv_S_ISREG=no])
2134   ])
2135   AC_CACHE_VAL(glibcpp_cv_S_IFREG, [
2136     AC_TRY_LINK([#include <sys/stat.h>],
2137                 [struct stat buffer; fstat(0, &buffer); S_IFREG & buffer.st_mode; ],
2138                 [glibcpp_cv_S_IFREG=yes],
2139                 [glibcpp_cv_S_IFREG=no])
2140   ])
2141   if test x$glibcpp_cv_S_ISREG = xyes; then
2142     AC_DEFINE(HAVE_S_ISREG)
2143   elif test x$glibcpp_cv_S_IFREG = xyes; then
2144     AC_DEFINE(HAVE_S_IFREG)
2145   fi
2146 ])
2147
2148 dnl
2149 dnl Check whether poll is available in <poll.h>.
2150 dnl
2151
2152 AC_DEFUN(GLIBCPP_CHECK_POLL, [
2153   AC_CACHE_VAL(glibcpp_cv_POLL, [
2154     AC_TRY_COMPILE([#include <poll.h>],
2155                 [struct pollfd pfd[1]; pfd[0].events = POLLIN; poll(pfd, 1, 0); ],
2156                 [glibcpp_cv_POLL=yes],
2157                 [glibcpp_cv_POLL=no])
2158   ])
2159   if test x$glibcpp_cv_POLL = xyes; then
2160     AC_DEFINE(HAVE_POLL)
2161   fi
2162 ])
2163
2164 # Check whether LC_MESSAGES is available in <locale.h>.
2165 # Ulrich Drepper <drepper@cygnus.com>, 1995.
2166 #
2167 # This file file be copied and used freely without restrictions.  It can
2168 # be used in projects which are not available under the GNU Public License
2169 # but which still want to provide support for the GNU gettext functionality.
2170 # Please note that the actual code is *not* freely available.
2171
2172 # serial 1
2173
2174 AC_DEFUN(AC_LC_MESSAGES, [
2175   AC_CHECK_HEADER(locale.h, [
2176     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
2177       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2178        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
2179     if test $ac_cv_val_LC_MESSAGES = yes; then
2180       AC_DEFINE(HAVE_LC_MESSAGES)
2181     fi
2182   ])
2183 ])
2184
2185
2186 dnl
2187 dnl Check for whether the Boost-derived checks should be turned on.
2188 dnl
2189 dnl GLIBCPP_ENABLE_CONCEPT_CHECKS
2190 dnl --enable-concept-checks turns them on.
2191 dnl --disable-concept-checks leaves them off.
2192 dnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2193 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2194 dnl       defaults to `no'.
2195 AC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
2196 define([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
2197 AC_ARG_ENABLE(concept-checks,
2198 changequote(<<, >>)dnl
2199 <<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
2200 changequote([, ])dnl
2201 [case "$enableval" in
2202  yes) enable_concept_checks=yes ;;
2203  no)  enable_concept_checks=no ;;
2204  *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
2205  esac],
2206 enable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
2207 dnl Option parsed, now set things appropriately
2208 if test x"$enable_concept_checks" = xyes; then
2209   AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
2210 fi
2211 ])
2212
2213
2214 dnl
2215 dnl Add version tags to symbols in shared library (or not), additionally
2216 dnl marking other symbols as private/local (or not).
2217 dnl
2218 dnl GLIBCPP_ENABLE_SYMVERS
2219 dnl --enable-symvers=style adds a version script to the linker call when
2220 dnl       creating the shared library.  The choice of version script is
2221 dnl       controlled by 'style'.
2222 dnl --disable-symvers does not.
2223 dnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
2224 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2225 dnl       defaults to `no'.  Passing `yes' tries to choose a default style
2226 dnl       based on linker characteristics.  Passing 'no' disables versioning.
2227 AC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
2228 define([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
2229 AC_ARG_ENABLE(symvers,
2230 changequote(<<, >>)dnl
2231 <<  --enable-symvers=style  enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
2232 changequote([, ])dnl
2233 [case "$enableval" in
2234  yes) enable_symvers=yes ;;
2235  no)  enable_symvers=no ;;
2236  # other names here, just as sanity checks
2237  #gnu|sun|etcetera) enable_symvers=$enableval ;;
2238  gnu) enable_symvers=$enableval ;;
2239  *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
2240  esac],
2241 enable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
2242
2243 # If we never went through the GLIBCPP_CHECK_LINKER_FEATURES macro, then we
2244 # don't know enough about $LD to do tricks...
2245 if test x$enable_shared = xno ||
2246         test "x$LD" = x ||
2247         test x$glibcpp_gnu_ld_version = x; then
2248   enable_symvers=no
2249 fi
2250
2251 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2252 if test $enable_symvers != no; then
2253   AC_MSG_CHECKING([for shared libgcc])
2254   ac_save_CFLAGS="$CFLAGS"
2255   CFLAGS=' -lgcc_s'
2256   AC_TRY_LINK(, [return 0], glibcpp_shared_libgcc=yes, glibcpp_shared_libgcc=no)
2257   CFLAGS="$ac_save_CFLAGS"
2258   AC_MSG_RESULT($glibcpp_shared_libgcc)
2259 fi
2260
2261 # For GNU ld, we need at least this version.  It's 2.12 in the same format
2262 # as the tested-for version.  See GLIBCPP_CHECK_LINKER_FEATURES for more.
2263 glibcpp_min_gnu_ld_version=21200
2264
2265 # Check to see if unspecified "yes" value can win, given results
2266 # above.
2267 if test $enable_symvers = yes ; then
2268   if test $with_gnu_ld = yes &&
2269     test $glibcpp_shared_libgcc = yes ;
2270   then
2271     if test $glibcpp_gnu_ld_version -ge $glibcpp_min_gnu_ld_version ; then
2272         enable_symvers=gnu
2273     else
2274       ac_test_CFLAGS="${CFLAGS+set}"
2275       ac_save_CFLAGS="$CFLAGS"
2276       CFLAGS='-shared -Wl,--version-script,conftest.map'
2277       enable_symvers=no
2278       changequote(,)
2279       echo 'FOO { global: f[a-z]o; local: *; };' > conftest.map
2280       changequote([,])
2281       AC_TRY_LINK([int foo;],, enable_symvers=gnu)
2282       if test "$ac_test_CFLAGS" = set; then
2283         CFLAGS="$ac_save_CFLAGS"
2284       else
2285         # this is the suspicious part
2286         CFLAGS=''
2287       fi
2288       rm -f conftest.map
2289     fi
2290   else
2291     # just fail for now
2292     enable_symvers=no
2293   fi
2294 fi
2295
2296 dnl Everything parsed; figure out what file to use.
2297 case $enable_symvers in
2298   no)
2299       SYMVER_MAP=config/linker-map.dummy
2300       ;;
2301   gnu)
2302       SYMVER_MAP=config/linker-map.gnu
2303       AC_DEFINE(_GLIBCPP_SYMVER)
2304       ;;
2305 esac
2306
2307 AC_SUBST(SYMVER_MAP)
2308 AM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
2309 AC_MSG_CHECKING([versioning on shared library symbols])
2310 AC_MSG_RESULT($enable_symvers)
2311 ])
2312