OSDN Git Service

2000-10-05 Benjamin Kosnik <bkoz@cygnus.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4
2
3 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl
14 dnl Initialize configure bits.
15 dnl
16 dnl Define OPTLEVEL='-O2' if new inlining code present.
17 dnl
18 dnl GLIBCPP_CONFIGURE
19 AC_DEFUN(GLIBCPP_CONFIGURE, [
20   dnl Default to --enable-multilib
21   AC_ARG_ENABLE(multilib,
22   [  --enable-multilib       build hella library versions (default)],
23   [case "${enableval}" in
24     yes) multilib=yes ;;
25     no)  multilib=no ;;
26     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
27    esac], [multilib=yes])dnl
28
29   dnl We may get other options which we dont document:
30   dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
31   if test "[$]{srcdir}" = "."; then
32     if test "[$]{with_target_subdir}" != "."; then
33       glibcpp_basedir="[$]{srcdir}/[$]{with_multisrctop}../$1"
34     else
35       glibcpp_basedir="[$]{srcdir}/[$]{with_multisrctop}$1"
36     fi
37   else
38     glibcpp_basedir="[$]{srcdir}/$1"
39   fi
40   AC_SUBST(glibcpp_basedir)
41
42   AM_INIT_AUTOMAKE(libstdc++, 2.90.8)
43
44   # Never versions of autoconf add an underscore to these functions.
45   # Prevent future problems ...
46   ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
47   ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
48   ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
49   ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
50
51 #  AC_PROG_CC
52
53 # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
54 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
55 # are probably using a cross compiler, which will not be able to fully
56 # link an executable.  This should really be fixed in autoconf
57 # itself.
58
59 AC_DEFUN(LIB_AC_PROG_CC,
60 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
61 dnl Fool anybody using AC_PROG_CC.
62 AC_PROVIDE([AC_PROG_CC])
63 AC_CHECK_PROG(CC, gcc, gcc)
64 if test -z "$CC"; then
65   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
66   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
67 fi
68
69 AC_PROG_CC_GNU
70
71 if test $ac_cv_prog_gcc = yes; then
72   GCC=yes
73 dnl Check whether -g works, even if CFLAGS is set, in case the package
74 dnl plays around with CFLAGS (such as to build both debugging and
75 dnl normal versions of a library), tasteless as that idea is.
76   ac_test_CFLAGS="${CFLAGS+set}"
77   ac_save_CFLAGS="$CFLAGS"
78   CFLAGS=
79   AC_PROG_CC_G
80   if test "$ac_test_CFLAGS" = set; then
81     CFLAGS="$ac_save_CFLAGS"
82   elif test $ac_cv_prog_cc_g = yes; then
83     CFLAGS="-g -O2"
84   else
85     CFLAGS="-O2"
86   fi
87 else
88   GCC=
89   test "${CFLAGS+set}" = set || CFLAGS="-g"
90 fi
91 ])
92
93 LIB_AC_PROG_CC
94
95 # Can't just call these here as g++ requires libstc++ to be built....
96 #  AC_PROG_CXX
97
98 # Likewise for AC_PROG_CXX.
99 AC_DEFUN(LIB_AC_PROG_CXX,
100 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
101 dnl Fool anybody using AC_PROG_CXX.
102 AC_PROVIDE([AC_PROG_CXX])
103 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
104 test -z "$CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
105
106 AC_PROG_CXX_GNU
107
108 if test $ac_cv_prog_gxx = yes; then
109   GXX=yes
110 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
111 dnl plays around with CXXFLAGS (such as to build both debugging and
112 dnl normal versions of a library), tasteless as that idea is.
113   ac_test_CXXFLAGS="${CXXFLAGS+set}"
114   ac_save_CXXFLAGS="$CXXFLAGS"
115   CXXFLAGS=
116   AC_PROG_CXX_G
117   if test "$ac_test_CXXFLAGS" = set; then
118     CXXFLAGS="$ac_save_CXXFLAGS"
119   elif test $ac_cv_prog_cxx_g = yes; then
120     CXXFLAGS="-g -O2"
121   else
122     CXXFLAGS="-O2"
123   fi
124 else
125   GXX=
126   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
127 fi
128 ])
129
130 LIB_AC_PROG_CXX
131
132   AC_CHECK_TOOL(AS, as)
133   AC_CHECK_TOOL(AR, ar)
134   AC_CHECK_TOOL(RANLIB, ranlib, :)
135
136   AC_PROG_INSTALL
137
138   AM_MAINTAINER_MODE
139
140   # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
141   # at least currently, we never actually build a program, so we never
142   # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
143   # fails, because we are probably configuring with a cross compiler
144   # which cant create executables.  So we include AC_EXEEXT to keep
145   # automake happy, but we dont execute it, since we dont care about
146   # the result.
147   if false; then
148     AC_EXEEXT
149   fi
150
151   # configure.host sets the following important variables
152   #     glibcpp_cflags    - host specific C compiler flags
153   #     glibcpp_cxxflags  - host specific C++ compiler flags
154   glibcpp_cflags=
155   glibcpp_cxxflags=
156
157   . [$]{glibcpp_basedir}/configure.host
158
159   case [$]{glibcpp_basedir} in
160     /* | [A-Za-z]:[/\\]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
161     *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
162   esac
163
164   GLIBCPP_CFLAGS="[$]{glibcpp_cflags}"
165   GLIBCPP_CXXFLAGS="[$]{glibcpp_cxxflags}"
166   AC_SUBST(GLIBCPP_CFLAGS)
167   AC_SUBST(GLIBCPP_CXXFLAGS)
168 ])
169
170
171 dnl
172 dnl Check to see if g++ can compile this library, and if so, if any version-
173 dnl specific precautions need to be taken. 
174 dnl 
175 dnl GLIBCPP_CHECK_COMPILER_VERSION
176 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
177   # Sanity check that g++ is capable of dealing with v-3.
178   AC_MSG_CHECKING([for g++ that will successfully compile this code])
179   AC_EGREP_CPP([ok], [
180   #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 
181     ok
182   #endif
183   ], gpp_satisfactory=yes, AC_MSG_ERROR("please upgrade to gcc-2.95 or above"))
184   AC_MSG_RESULT($gpp_satisfactory)
185 ])
186
187
188 dnl
189 dnl Test for newer compiler features, or features that are present in newer
190 dnl compiler version but not older compiler versions should be placed
191 dnl here.
192 dnl
193 dnl Define WFMT_FLAGS='-fdiagnostics-show-location=once' if possible
194 dnl 
195 dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
196 dnl new inlining code or the new system_header pragma will die on -Werror.
197 dnl Leave it out by default and use maint-mode to use it.
198 dnl
199 dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
200 dnl compiler supports it.  
201 dnl GLIBCPP_CHECK_COMPILER_FEATURES
202 AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
203   # All these tests are for C++; save the language and the compiler flags.
204   # The CXXFLAGS thing is suspicious, but based on similar bits 
205   # found in GLIBCPP_CONFIGURE.
206   AC_LANG_SAVE
207   AC_LANG_CPLUSPLUS
208   ac_test_CXXFLAGS="${CXXFLAGS+set}"
209   ac_save_CXXFLAGS="$CXXFLAGS"
210
211   # Check for maintainer-mode bits.
212   if test x"$USE_MAINTAINER_MODE" = xno; then
213     WERROR=''
214   else
215     WERROR='-Werror'
216   fi
217
218   # Check for more sophisticated diagnostic control.
219   AC_MSG_CHECKING([for g++ that supports -fdiagnostics-show-location=once])
220   CXXFLAGS='-Werror -fdiagnostics-show-location=once'
221   AC_TRY_COMPILE(, [int foo;
222   ], [ac_gabydiags=yes], [ac_gabydiags=no])
223   if test "$ac_test_CXXFLAGS" = set; then
224     CXXFLAGS="$ac_save_CXXFLAGS"
225   else
226     # this is the suspicious part
227     CXXFLAGS=''
228   fi
229   if test "$ac_gabydiags" = "yes"; then
230     WFMT_FLAGS='-fdiagnostics-show-location=once'
231   fi
232   AC_MSG_RESULT($ac_gabydiags)
233
234   # Check for -ffunction-sections -fdata-sections
235   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
236   CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
237   AC_TRY_COMPILE(, [int foo;
238   ], [ac_fdsections=yes], [ac_fdsections=no])
239   if test "$ac_test_CXXFLAGS" = set; then
240     CXXFLAGS="$ac_save_CXXFLAGS"
241   else
242     # this is the suspicious part
243     CXXFLAGS=''
244   fi
245   if test "$ac_fdsections" = "yes"; then
246     SECTION_FLAGS='-ffunction-sections -fdata-sections'
247   fi
248   AC_MSG_RESULT($ac_fdsections)
249
250   AC_LANG_RESTORE
251   AC_SUBST(WERROR)
252   AC_SUBST(WFMT_FLAGS)
253   AC_SUBST(SECTION_FLAGS)
254 ])
255
256
257 dnl
258 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
259 dnl the native linker is in use, all variables will be defined to something
260 dnl safe (like an empty string).
261 dnl
262 dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
263 dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
264 dnl
265 dnl GLIBCPP_CHECK_LINKER_FEATURES
266 AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
267   # If we're not using GNU ld, then there's no point in even trying these
268   # tests.  Check for that first.  We should have already tested for gld
269   # by now (in libtool), but require it now just to be safe...
270   AC_REQUIRE([AC_PROG_LD])
271   if test "$ac_cv_prog_gnu_ld" = "no"; then
272     SECTION_LDFLAGS=''
273     OPT_LDFLAGS=''
274
275   else   # GNU ld it is!  Joy and bunny rabbits!
276
277     # All these tests are for C++; save the language and the compiler flags.
278     # Need to do this so that g++ won't try to link in libstdc++
279     ac_test_CFLAGS="${CFLAGS+set}"
280     ac_save_CFLAGS="$CFLAGS"
281     CFLAGS='-x c++  -Wl,--gc-sections'
282
283     # Check for -Wl,--gc-sections
284     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
285     AC_TRY_RUN([
286      int main(void) 
287      {
288        try { throw 1; }
289        catch (...) { };
290        return 0;
291      }
292     ], [ac_sectionLDflags=yes], [ac_sectionLFflags=no], [ac_sectionLDflags=yes])
293     if test "$ac_test_CFLAGS" = set; then
294       CFLAGS="$ac_save_CFLAGS"
295     else
296       # this is the suspicious part
297       CFLAGS=''
298     fi
299     if test "$ac_sectionLDflags" = "yes"; then
300       SECTION_LDFLAGS='-Wl,--gc-sections'
301     fi
302     AC_MSG_RESULT($ac_sectionLDflags)
303     OPT_LDFLAGS='-Wl,-O1'
304
305   fi
306   AC_SUBST(SECTION_LDFLAGS)
307   AC_SUBST(OPT_LDFLAGS)
308 ])
309
310
311 dnl
312 dnl Check to see if the (math function) argument passed is
313 dnl 1) declared when using the c++ compiler
314 dnl 2) has "C" linkage
315 dnl
316 dnl Define HAVE_CARGF etc if "cargf" is declared and links
317 dnl
318 dnl argument 1 is name of function to check
319 dnl
320 dnl ASSUMES argument is a math function with ONE parameter
321 dnl
322 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
323 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
324   AC_MSG_CHECKING([for $1 declaration])
325   AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
326     AC_LANG_SAVE
327     AC_LANG_CPLUSPLUS
328     AC_TRY_COMPILE([#include <math.h>], 
329                    [ $1(0);], 
330                    [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
331     AC_LANG_RESTORE
332   ])
333   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
334   if test x$glibcpp_cv_func_$1_use = x"yes"; then
335     AC_CHECK_FUNCS($1)    
336   fi
337 ])
338
339
340 dnl
341 dnl Check to see if the (math function) argument passed is
342 dnl 1) declared when using the c++ compiler
343 dnl 2) has "C" linkage
344 dnl
345 dnl Define HAVE_CARGF etc if "cargf" is declared and links
346 dnl
347 dnl argument 1 is name of function to check
348 dnl
349 dnl ASSUMES argument is a math function with TWO parameters
350 dnl
351 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
352 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
353   AC_MSG_CHECKING([for $1 declaration])
354   AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
355     AC_LANG_SAVE
356     AC_LANG_CPLUSPLUS
357     AC_TRY_COMPILE([#include <math.h>], 
358                    [ $1(0, 0);], 
359                    [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
360     AC_LANG_RESTORE
361   ])
362   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
363   if test x$glibcpp_cv_func_$1_use = x"yes"; then
364     AC_CHECK_FUNCS($1)    
365   fi
366 ])
367
368
369 dnl
370 dnl Check to see if the (math function) argument passed is
371 dnl 1) declared when using the c++ compiler
372 dnl 2) has "C" linkage
373 dnl
374 dnl Define HAVE_CARGF etc if "cargf" is declared and links
375 dnl
376 dnl argument 1 is name of function to check
377 dnl
378 dnl ASSUMES argument is a math function with THREE parameters
379 dnl
380 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
381 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
382   AC_MSG_CHECKING([for $1 declaration])
383   AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
384     AC_LANG_SAVE
385     AC_LANG_CPLUSPLUS
386     AC_TRY_COMPILE([#include <math.h>], 
387                    [ $1(0, 0, 0);], 
388                    [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
389     AC_LANG_RESTORE
390   ])
391   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
392   if test x$glibcpp_cv_func_$1_use = x"yes"; then
393     AC_CHECK_FUNCS($1)    
394   fi
395 ])
396
397
398 dnl
399 dnl Because the builtins are picky picky picky about the arguments they take, 
400 dnl do an explict linkage tests here.
401 dnl Check to see if the (math function) argument passed is
402 dnl 1) declared when using the c++ compiler
403 dnl 2) has "C" linkage
404 dnl
405 dnl Define HAVE_CARGF etc if "cargf" is declared and links
406 dnl
407 dnl argument 1 is name of function to check
408 dnl
409 dnl ASSUMES argument is a math function with ONE parameter
410 dnl
411 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
412 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
413   AC_MSG_CHECKING([for $1 declaration])
414   AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
415     AC_LANG_SAVE
416     AC_LANG_CPLUSPLUS
417     AC_TRY_COMPILE([#include <math.h>], 
418                    [ $1(0);], 
419                    [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
420     AC_LANG_RESTORE
421   ])
422   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
423   if test x$glibcpp_cv_func_$1_use = x"yes"; then
424     AC_MSG_CHECKING([for $1 linkage])
425     AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
426       AC_TRY_LINK([#include <math.h>], 
427                   [ $1(0);], 
428                   [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
429     ])
430     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
431     if test x$glibcpp_cv_func_$1_link = x"yes"; then
432       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
433       AC_DEFINE_UNQUOTED(${ac_tr_func})
434     fi
435   fi
436 ])
437
438
439 dnl
440 dnl Check to see what builtin math functions are supported
441 dnl
442 dnl check for __builtin_abs
443 dnl check for __builtin_fabsf
444 dnl check for __builtin_fabs
445 dnl check for __builtin_fabl
446 dnl check for __builtin_labs
447 dnl check for __builtin_sqrtf
448 dnl check for __builtin_sqrtl
449 dnl check for __builtin_fsqrt
450 dnl check for __builtin_sinf
451 dnl check for __builtin_sin
452 dnl check for __builtin_sinl
453 dnl check for __builtin_cosf
454 dnl check for __builtin_cos
455 dnl check for __builtin_cosl
456 dnl
457 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
458 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
459   dnl Test for builtin math functions.
460   dnl These are made in gcc/c-common.c 
461   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
462   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
463   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
464   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
465   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
466
467   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
468   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fsqrt)
469   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
470
471   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
472   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
473   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
474
475   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
476   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
477   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
478
479   dnl There is, without a doubt, a more elegant way to have these
480   dnl names exported so that they won't be stripped out of acconfig.h by
481   dnl autoheader. I leave this as an exercise to somebody less frustrated
482   dnl than I.... please email the libstdc++ list if you can figure out a
483   dnl more elegant approach (see autoconf/acgen.m4 and specifically
484   dnl AC_CHECK_FUNC for things to steal.)
485   dummyvar=no
486   if test x$dummyvar = x"yes"; then
487     AC_DEFINE(HAVE___BUILTIN_ABS)
488     AC_DEFINE(HAVE___BUILTIN_LABS)
489     AC_DEFINE(HAVE___BUILTIN_COS)
490     AC_DEFINE(HAVE___BUILTIN_COSF)
491     AC_DEFINE(HAVE___BUILTIN_COSL)
492     AC_DEFINE(HAVE___BUILTIN_FABS)
493     AC_DEFINE(HAVE___BUILTIN_FABSF)
494     AC_DEFINE(HAVE___BUILTIN_FABSL)
495     AC_DEFINE(HAVE___BUILTIN_SIN)
496     AC_DEFINE(HAVE___BUILTIN_SINF)
497     AC_DEFINE(HAVE___BUILTIN_SINL)
498     AC_DEFINE(HAVE___BUILTIN_FSQRT)
499     AC_DEFINE(HAVE___BUILTIN_SQRTF)
500     AC_DEFINE(HAVE___BUILTIN_SQRTL)
501   fi
502 ])
503
504
505 dnl
506 dnl Check to see what the underlying c library or math library is like.
507 dnl These checks need to do two things: 
508 dnl 1) make sure the name is declared when using the c++ compiler
509 dnl 2) make sure the name has "C" linkage
510 dnl This might seem like overkill but experience has shown that it's not...
511 dnl
512 dnl Define HAVE_CARGF etc if "cargf" is found.
513 dnl
514 dnl GLIBCPP_CHECK_MATH_SUPPORT
515 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
516   ac_test_CXXFLAGS="${CXXFLAGS+set}"
517   ac_save_CXXFLAGS="$CXXFLAGS"
518   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
519
520   dnl Check libm
521   AC_CHECK_LIB(m, sin, libm="-lm")
522   ac_save_LIBS="$LIBS"
523   LIBS="$LIBS $libm"
524
525   dnl Although not math functions, needed and for some reason checked here.
526   AC_CHECK_FUNCS(strtof strtold)
527
528   dnl Check to see if certain C math functions exist.
529   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
530   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
531   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
532   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
533   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
534   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
535   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
536
537   dnl Check to see if basic C math functions have float versions.
538   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
539   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
540   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(acosf)
541   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(asinf)
542   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(atanf)
543   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
544   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(ceilf)
545   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(cosf)
546   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(coshf)
547   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
548   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
549   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(floorf)
550   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
551   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
552   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
553   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
554   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
555   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
556   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
557   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinf)
558   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinhf)
559   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
560   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanf)
561   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanhf)
562   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
563   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
564
565   dnl Check to see if basic C math functions have long double versions.
566   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
567   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
568   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
569   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(acosl)
570   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(asinl)
571   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(atanl)
572   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
573   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(ceill)
574   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(cosl)
575   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(coshl)
576   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
577   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
578   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(floorl)
579   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
580   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
581   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
582   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
583   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
584   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
585   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
586   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinl)
587   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinhl)
588   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
589   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanl)
590   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanhl)
591   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
592   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
593
594   dnl Some runtimes have these functions with a preceding underscore. Please
595   dnl keep this sync'd with the one above. And if you add any new symbol,
596   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
597   dnl Check to see if certain C math functions exist.
598   dnl Check to see if certain C math functions exist.
599   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isinf)
600   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isnan)
601   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_finite)
602   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_copysign)
603   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(_sincos)
604   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_fpclass)
605   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_qfpclass)
606
607   dnl Check to see if basic C math functions have float versions.
608   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isnanf)
609   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isinff)
610   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_acosf)
611   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_asinf)
612   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_atanf)
613   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_atan2f)
614   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_ceilf)
615   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_cosf)
616   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_coshf)
617   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_expf)
618   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_fabsf)
619   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_floorf)
620   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_fmodf)
621   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_frexpf)
622   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_ldexpf)
623   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_logf)
624   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_log10f)
625   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_modff)
626   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_powf)
627   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinf)
628   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinhf)
629   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sqrtf)
630   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanf)
631   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanhf)
632   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(_sincosf)
633   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_finitef)
634
635   dnl Check to see if basic C math functions have long double versions.
636   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isnanl)
637   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isinfl)
638   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_copysignl)
639   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_acosl)
640   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_asinl)
641   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_atanl)
642   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_atan2l)
643   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_ceill)
644   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_cosl)
645   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_coshl)
646   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_expl)
647   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_fabsl)
648   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_floorl)
649   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_fmodl)
650   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_frexpl)
651   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_ldexpl)
652   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_logl)
653   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_log10l)
654   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_modfl)
655   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_powl)
656   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinl)
657   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinhl)
658   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sqrtl)
659   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanl)
660   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanhl)
661   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(_sincosl)
662   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_finitel)
663
664   LIBS="$ac_save_LIBS"
665   CXXFLAGS="$ac_save_CXXFLAGS"
666 ])
667
668
669 dnl
670 dnl Check to see if there is native support for complex 
671 dnl
672 dnl Don't compile bits in math/* if native support exits.
673 dnl
674 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "cargf" is found.
675 dnl
676 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
677 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
678   dnl Check for complex versions of math functions of platform.
679   AC_CHECK_HEADERS([complex.h])
680   AC_REPLACE_MATHFUNCS(ccos ccosf ccosh ccoshf cexp cexpf c_log c_logf \
681   clog10 clog10f cpow cpowf csin csinf csinh csinhf csqrt csqrtf \
682   ctan ctanf ctanh ctanhf carg cargf nan hypot hypotf atan2f expf copysignf)
683
684   dnl Compile the long double complex functions only if the function 
685   dnl provides the non-complex long double functions that are needed.
686   dnl Currently this includes copysignl and atan2l, which should be
687   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
688   USE_COMPLEX_LONG_DOUBLE=no
689   if test x$ac_cv_func_atan2l = x"yes" \
690      && test x$ac_cv_func_copysignl = x"yes"; then
691     USE_COMPLEX_LONG_DOUBLE=yes
692     AC_REPLACE_MATHFUNCS(ccoshl ccosl cexpl cpowl csinhl csinl \
693     csqrtl ctanhl ctanl cargl hypotl signbitl c_logl clog10l)
694   fi
695
696   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
697 ])
698
699
700 dnl Check to see what architecture we are compiling for. If it's
701 dnl supported, use special hand-crafted routines to provide thread
702 dnl primitives. Also, if architecture-specific flags are required for 
703 dnl compilation, add them here.
704 dnl 
705 dnl Depending on what is found, select configure/cpu/*/bits/atomicity.h 
706 dnl If not found, select configure/cpu/generic/bits/atomicity.h
707 dnl
708 dnl GLIBCPP_CHECK_CPU
709 AC_DEFUN(GLIBCPP_CHECK_CPU, [
710     AC_MSG_CHECKING([for cpu primitives directory])
711     CPU_FLAGS=                  
712     case "${target_cpu}" in
713       alpha*)
714         cpu_include_dir="config/cpu/alpha"
715         ;;
716       arm*)
717         cpu_include_dir="config/cpu/arm"
718         ;;
719       ia64)
720         cpu_include_dir="config/cpu/ia64"
721         ;;
722       i386)
723         cpu_include_dir="config/cpu/i386"
724         ;;
725       i486 | i586 | i686 | i786)
726         cpu_include_dir="config/cpu/i486"
727         ;;
728       powerpc | rs6000)
729         cpu_include_dir="config/cpu/powerpc"
730         CPU_FLAGS='-mcpu=powerpc'
731         ;;
732       sparc64 | ultrasparc)
733         cpu_include_dir="config/cpu/sparc/sparc64"
734         ;;
735       sparc*)
736         cpu_include_dir="config/cpu/sparc/sparc32"
737         ;;
738       *)
739         cpu_include_dir="config/cpu/generic"
740         ;;
741     esac
742     AC_MSG_RESULT($cpu_include_dir)
743     AC_SUBST(cpu_include_dir)
744     AC_SUBST(CPU_FLAGS)
745 ])
746
747  
748 dnl
749 dnl Check to see what the underlying c library's interface to ctype looks
750 dnl like. Bits of locale rely on things like isspace, toupper, etc. This
751 dnl stuff makes sure the right bits from the clibrary get called.
752 dnl 
753 dnl Depending on what is found, select various configure/*/bits/ctype_base.h 
754 dnl Depending on what is found, select various configure/*/ctype.cc
755 dnl
756 dnl GLIBCPP_CHECK_CTYPE
757 AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
758   AC_CHECK_HEADER(ctype.h, [
759     
760     dnl If doesn't match any specified, go with defaults.
761     ctype_default=yes
762
763     dnl Test for <ctype> functionality -- gnu-linux
764     AC_MSG_CHECKING([<ctype> for gnu-linux ])
765     AC_TRY_COMPILE([#include <ctype.h>],
766     [int
767     foo (int a)
768     { return _ISspace + _ISprint + _IScntrl + _ISupper + _ISlower + _ISalpha \
769         + _ISdigit + _ISpunct + _ISxdigit + _ISalnum + _ISgraph \
770         + __ctype_tolower[a] + __ctype_toupper[a] + __ctype_b[a];}], \
771     ctype_linux=yes, ctype_linux=no)
772     AC_MSG_RESULT($ctype_linux)
773     if test $ctype_linux = "yes"; then
774       ctype_include_dir="config/gnu-linux"
775       ctype_default=no
776     fi
777
778     dnl Test for <ctype> functionality -- FreeBSD 4.0
779     if test $ctype_default = "yes"; then
780     AC_MSG_CHECKING([<ctype> for freebsd 4.0 ])
781     AC_TRY_COMPILE([#include <ctype.h>],
782     [int
783     foo (int a)
784     { return _CTYPE_S + _CTYPE_R + _CTYPE_C + _CTYPE_U + _CTYPE_L + _CTYPE_A \
785         + _CTYPE_D + _CTYPE_P + _CTYPE_X + _CTYPE_G ;}], \
786     ctype_bsd=yes, ctype_bsd=no)
787     AC_MSG_RESULT($ctype_bsd)
788     if test $ctype_bsd = "yes"; then
789       ctype_include_dir="config/bsd"
790       ctype_default=no
791     fi
792     fi
793
794     dnl Test for <ctype> functionality -- FreeBSD 3.4
795     if test $ctype_default = "yes"; then
796     AC_MSG_CHECKING([<ctype> for freebsd 3.4 ])
797     AC_TRY_COMPILE([#include <ctype.h>],
798     [int
799     foo (int a)
800     { return _S + _R + _C + _U + _L + _A \
801       + _D + _P + _X + _G + __istype (a, 0);}], \
802     ctype_freebsd34=yes, ctype_freebsd34=no)
803     AC_MSG_RESULT($ctype_freebsd34)
804     if test $ctype_freebsd34 = "yes"; then
805       ctype_include_dir="config/bsd"
806       ctype_default=no
807     fi
808     fi
809
810     dnl Test for <ctype> functionality -- solaris 2.6 and 2.7
811     if test $ctype_default = "yes"; then
812     AC_MSG_CHECKING([<ctype> for solaris 2.[6,7,8] ])
813     AC_TRY_COMPILE([#include <ctype.h>],
814     [int
815     foo (int a)
816     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
817         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
818         + __trans_lower[a] + __trans_upper[a] + __ctype_mask[a];}], \
819     ctype_solaris=yes, ctype_solaris=no)
820     AC_MSG_RESULT($ctype_solaris)
821
822     if test $ctype_solaris = "yes"; then
823       AC_MSG_CHECKING([  for version])
824       AC_LANG_CPLUSPLUS 
825       AC_TRY_COMPILE([#include <ctype.h>],
826       [typedef long* __to_type; __to_type const& _M_toupper = __trans_upper;],\
827       ctype_solaris26=yes, ctype_solaris26=no)
828       AC_LANG_C
829       if test $ctype_solaris26 = "yes"; then
830         ctype_include_dir="config/solaris/solaris2.6"
831         AC_MSG_RESULT("solaris2.6")
832         ctype_default=no
833       else
834         ctype_include_dir="config/solaris/solaris2.7"
835         AC_MSG_RESULT("solaris2.[7,8]")
836         ctype_default=no
837       fi
838     fi
839     fi  
840
841     dnl Test for <ctype> functionality -- solaris 2.5.1
842     if test $ctype_default = "yes"; then
843     AC_MSG_CHECKING([<ctype> for solaris 2.5.1 ])
844     AC_TRY_COMPILE([#include <ctype.h>],
845     [int
846     foo (int a)
847     { return _U + _L + _N + _S + _P + _C + _X + _B \
848         + __ctype[a];}], \
849     ctype_solaris25=yes, ctype_solaris25=no)
850     AC_MSG_RESULT($ctype_solaris25)
851     if test $ctype_solaris25 = "yes"; then
852       ctype_include_dir="config/solaris/solaris2.5"
853       ctype_default=no
854     fi
855     fi
856
857     dnl Test for <ctype> functionality -- aix
858     if test $ctype_default = "yes"; then
859     AC_MSG_CHECKING([<ctype> for aix ])
860     AC_TRY_COMPILE([#include <ctype.h>],
861     [int
862     foo (int a)
863     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
864         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
865         + _VALC('a') + _IS('c', 0);}], \
866     ctype_aix=yes, ctype_aix=no)
867     AC_MSG_RESULT($ctype_aix)
868     if test $ctype_aix = "yes"; then
869       ctype_include_dir="config/aix"
870       ctype_default=no
871     fi
872     fi
873
874     dnl Test for <ctype> functionality -- newlib
875     if test $ctype_default = "yes"; then
876     AC_MSG_CHECKING([<ctype> for newlib ])
877     AC_TRY_COMPILE([#include <ctype.h>],
878     [int
879     foo (int a)
880     { return _U + _L + _N + _S + _P + _C + _X + _B \
881         + _ctype_[a];}], \
882     ctype_newlib=yes, ctype_newlib=no)
883     AC_MSG_RESULT($ctype_newlib)
884     if test $ctype_newlib = "yes"; then
885       ctype_include_dir="config/newlib"
886       ctype_default=no
887     fi
888     fi
889
890     if test $ctype_default = "yes"; then
891       ctype_include_dir="config/generic"
892       AC_MSG_WARN("Using default ctype headers.")
893     fi
894     AC_SUBST(ctype_include_dir)
895   ])
896 ])
897
898
899 dnl
900 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
901 dnl
902 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
903 dnl Define _GLIBCPP_NEED_MBSTATE_T if mbstate_t is not in wchar.h
904 dnl
905 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
906 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
907
908   dnl Sanity check for existence of ISO C9X headers for extended encoding.
909   AC_CHECK_HEADER(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
910   AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
911         
912   dnl Only continue checking if the ISO C9X headers exist.
913   if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes; then
914
915     dnl Test wchar.h for mbstate_t, which is needed for char_traits and others.
916     AC_MSG_CHECKING([for mbstate_t])
917     AC_TRY_COMPILE([#include <wchar.h>],
918     [mbstate_t teststate;], 
919     use_native_mbstatet=yes, use_native_mbstatet=no)
920     AC_MSG_RESULT($use_native_mbstatet)
921     if test x"$use_native_mbstatet" = xno; then
922       AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
923     fi
924   
925     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
926     dnl numeric_limits can instantiate type_traits<wchar_t>
927     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
928     AC_TRY_COMPILE([#include <wchar.h>],
929     [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
930     has_wchar_minmax=yes, has_wchar_minmax=no)
931     AC_MSG_RESULT($has_wchar_minmax)
932   
933     dnl Test wchar.h for WEOF, which is what we use to determine whether
934     dnl to specialize for char_traits<wchar_t> or not.
935     AC_MSG_CHECKING([for WEOF])
936     AC_TRY_COMPILE([
937       #include <wchar.h>
938       #include <stddef.h>],
939     [wint_t i = WEOF;],
940     has_weof=yes, has_weof=no)
941     AC_MSG_RESULT($has_weof)
942
943     dnl Tests for wide character functions used in char_traits<wchar_t>.
944     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \
945     wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no)
946
947     AC_MSG_CHECKING([for ISO C9X wchar_t support])
948     if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
949        && test x"$ac_wfuncs" = xyes; then
950       ac_isoC9X_wchar_t=yes
951     else
952       ac_isoC9X_wchar_t=no
953     fi
954     AC_MSG_RESULT($ac_isoC9X_wchar_t)
955
956     dnl Use iconv for wchar_t to char conversions. As such, check for 
957     dnl X/Open Portability Guide, version 2 features (XPG2).
958     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
959     AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
960     AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
961     ac_XPG2funcs=yes, ac_XPG2funcs=no)
962
963     AC_MSG_CHECKING([for XPG2 wchar_t support])
964     if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
965        && test x"$ac_XPG2funcs" = xyes; then
966       ac_XPG2_wchar_t=yes
967     else
968       ac_XPG2_wchar_t=no
969     fi
970     AC_MSG_RESULT($ac_XPG2_wchar_t)
971
972     dnl At the moment, only enable wchar_t specializations if all the
973     dnl above support is present.
974     AC_MSG_CHECKING([for enabled wchar_t specializations])
975     if test x"$ac_isoC9X_wchar_t" = xyes \
976        && test x"$ac_XPG2_wchar_t" = xyes; then
977       libinst_wstring_la="libinst-wstring.la"
978       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
979       AC_MSG_RESULT("yes")
980     else
981       libinst_wstring_la=""
982       AC_MSG_RESULT("no")
983     fi
984     AC_SUBST(libinst_wstring_la)
985
986   else
987     AC_MSG_WARN([<wchar.h> not found])
988     AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
989   fi
990 ])
991
992
993 dnl
994 dnl Check to see if this version of GNU C++ is afflicted by bugs in
995 dnl __complex__ float support.
996 dnl
997 dnl Define _GLIBCPP_BUGGY_FLOAT_COMPLEX if buggy.
998 dnl
999 dnl Check to see if this version of GNU C++ is afflicted by bugs in 
1000 dnl __complex__ support.Check for buggy __complex__ that will cause ICE in
1001 dnl gcc-2.95.x when using the library, unless we define the default copy
1002 dnl ctor in the specializations of complex<>. 
1003 dnl 
1004 dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
1005 dnl GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT
1006 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT, [
1007   AC_REQUIRE([AC_PROG_CXX])
1008
1009   AC_MSG_CHECKING([for GNU C++ __complex__ support])
1010   AC_CACHE_VAL(glibcpp_cv_complex, [
1011     AC_LANG_SAVE
1012     AC_LANG_CPLUSPLUS
1013     AC_TRY_COMPILE([struct dcomplex { __complex__ double x; }; \
1014                     dcomplex f(const dcomplex& x) { return dcomplex(x); }], \
1015                     [ dcomplex x; f(x); ],
1016       glibcpp_cv_complex=ok,
1017       glibcpp_cv_complex=buggy
1018     )
1019     AC_LANG_RESTORE
1020   ])
1021   AC_MSG_RESULT($glibcpp_cv_complex)
1022   if test $glibcpp_cv_complex = buggy; then
1023     AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
1024   fi
1025
1026   AC_MSG_CHECKING([for GNU C++ __complex__ float support])
1027   AC_CACHE_VAL(glibcpp_cv_float_complex, [
1028     AC_LANG_SAVE
1029     AC_LANG_CPLUSPLUS
1030     rm -f conftest.h
1031     cat > conftest.h <<EOB
1032       //
1033       // Check for buggy __complex__ that causes ICE in most versions of egcs
1034       // and gcc-2.95.x on certain platforms (eg., x86-win32).
1035       //
1036       // See http://egcs.cygnus.com/ml/gcc-bugs/1999-07/msg00845.html for
1037       // more info on the bug itself.
1038       //
1039       struct
1040       float_complex
1041       {
1042        __complex__ float m_value;
1043        float_complex (float = 0.0f, float = 0.0f);
1044        float_complex (__complex__ float val) : m_value (val) {}
1045        float_complex foo (const float_complex &val)
1046          { return float_complex (~val.m_value); }
1047       };
1048 EOB
1049     AC_TRY_COMPILE([#include "conftest.h"], ,
1050       glibcpp_cv_float_complex=ok,
1051       glibcpp_cv_float_complex=buggy
1052     )
1053     AC_LANG_RESTORE
1054   ])
1055   AC_MSG_RESULT($glibcpp_cv_float_complex)
1056   if test $glibcpp_cv_float_complex = buggy; then
1057     AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
1058   fi
1059 ])
1060
1061
1062 dnl
1063 dnl Check for special debugging mode; not for production use.
1064 dnl
1065 dnl GLIBCPP_ENABLE_DEBUG
1066 dnl --enable-debug sets '-ggdb -O0'.
1067 dnl --disable-debug sets '-g' and whatever optimization options the
1068 dnl     compiler can handle.
1069 dnl  +  --enable-maintainer-mode automatically defaults this to on.
1070 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
1071 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
1072 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1073 dnl       defaults to `no'.
1074 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
1075 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
1076 AC_ARG_ENABLE(debug,
1077 changequote(<<, >>)dnl
1078 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
1079 changequote([, ])dnl
1080 [case "${enableval}" in
1081  yes) enable_debug=yes ;;
1082  no)  enable_debug=no ;;
1083  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1084  esac],
1085 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1086
1087 dnl Option parsed, now set things appropriately
1088 case "${enable_debug}" in
1089     yes) 
1090         DEBUG_FLAGS='-O0 -ggdb'                 
1091         ;;
1092     no)   
1093         DEBUG_FLAGS='-g'
1094         ;;
1095 esac
1096 AC_SUBST(DEBUG_FLAGS)
1097 ])
1098
1099
1100 dnl
1101 dnl Check for "unusual" flags to pass to the compiler while building.
1102 dnl
1103 dnl GLIBCPP_ENABLE_CXX_FLAGS
1104 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1105 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1106 dnl     Somehow this same set of flags must be passed when [re]building
1107 dnl     libgcc.
1108 dnl --disable-cxx-flags passes nothing.
1109 dnl  +  See http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00131.html
1110 dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00284.html
1111 dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q1/msg00035.html
1112 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1113 dnl       If "default flags" is an empty string (or "none"), the effect is
1114 dnl       the same as --disable or --enable=no.
1115 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1116 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1117 AC_ARG_ENABLE(cxx-flags,
1118 changequote(<<, >>)dnl
1119 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
1120                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1121 changequote([, ])dnl
1122 [case "x$enableval" in
1123  xyes)   
1124         AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1125  xno|x)  
1126         enable_cxx_flags='' ;;
1127  *)      
1128         enable_cxx_flags="$enableval" ;;
1129  esac],
1130 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1131
1132 dnl Thinko on my part during design.  This kludge is the workaround.
1133 if test "$enable_cxx_flags" = "none"; then 
1134   enable_cxx_flags=''; 
1135 fi
1136
1137 dnl Run through flags (either default or command-line) and set anything
1138 dnl extra (e.g., #defines) that must accompany particular g++ options.
1139 if test -n "$enable_cxx_flags"; then
1140     for f in $enable_cxx_flags; do
1141         case "$f" in
1142             -fhonor-std)  ;;
1143             -*)  ;;
1144             *)   # and we're trying to pass /what/ exactly?
1145                  AC_MSG_ERROR([compiler flags start with a -]) ;;
1146         esac
1147     done
1148 fi
1149 EXTRA_CXX_FLAGS="$enable_cxx_flags"
1150 AC_SUBST(EXTRA_CXX_FLAGS)
1151 ])
1152
1153
1154 dnl
1155 dnl Check for instructions to automatically rebuild libgcc.a.  Requires,
1156 dnl of course, the location of the gcc objdir.  Note that if --disable-
1157 dnl namespaces is in effect, rebuilding libgcc.a is an expensive no-op.
1158 dnl
1159 dnl GLIBCPP_ENABLE_RELIBGCC
1160 dnl --enable-libgcc-rebuild=/absolute/path/to/gcc/objdir sets GCC_OBJDIR
1161 dnl     (presumably in the top-level Makefile) to /absol.../objdir
1162 dnl --disable-libgcc-rebuild will not touch libgcc.a at all (maybe print
1163 dnl     a warning if this is given along with --enable-namespaces), by
1164 dnl     setting GCC_OBJDIR to `no'.
1165 dnl  +  Doing this by default is going to be interesting.  What default
1166 dnl     "on" value can there be?
1167 dnl  +  Usage:  GLIBCPP_ENABLE_RELIBGCC[(DEFAULT)]
1168 dnl       The default path should be ../.. if bundled with GCC source.
1169 dnl       If ommitted, it defaults to `no'.
1170 dnl
1171 AC_DEFUN(GLIBCPP_ENABLE_RELIBGCC, [dnl
1172 define([GLIBCPP_ENABLE_RELIBGCC_DEFAULT], ifelse($1,, no, $1))dnl
1173 AC_ARG_ENABLE(libgcc-rebuild,
1174 changequote(<<, >>)dnl
1175 <<  --enable-libgcc-rebuild=DIR     also rebuild libgcc.a; DIR is
1176                                   the GCC objdir; see install.html>>,
1177 changequote([, ])dnl
1178 [case "$enableval" in
1179  yes) AC_MSG_ERROR([--enable-libgcc-rebuild needs a pathname]) ;;
1180  no)  enable_libgcc_rebuild=no ;;
1181  *)   if test -d "$enableval" && test -d "${enableval}/gcc" && \
1182          test -d "${enableval}/libiberty"
1183       then
1184          enable_libgcc_rebuild="$enableval"
1185       else
1186          AC_MSG_ERROR(["$enableval" does not appear to be the GCC objdir])
1187       fi
1188       ;;
1189  esac],
1190 enable_libgcc_rebuild=GLIBCPP_ENABLE_RELIBGCC_DEFAULT)dnl
1191 GCC_OBJDIR="$enable_libgcc_rebuild"
1192 AC_SUBST(GCC_OBJDIR)
1193 ])
1194
1195
1196 dnl
1197 dnl Check for which I/O library to use:  libio, or something specific.
1198 dnl
1199 dnl GLIBCPP_ENABLE_CSTDIO
1200 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
1201 dnl 
1202 dnl default is libio
1203 dnl
1204 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1205   AC_MSG_CHECKING([for cstdio to use])
1206   AC_ARG_ENABLE(cstdio,
1207   [  --enable-cstdio         enable GNU libio for target io package. (default)
1208   --enable-cstdio=LIB     use LIB target-speific io package.], 
1209   if test x$enable_cstdio = xno; then
1210     enable_cstdio=libio
1211   fi,
1212      enable_cstdio=libio)
1213
1214   enable_cstdio_flag=$enable_cstdio
1215
1216   dnl Check if a valid thread package
1217   case x${enable_cstdio_flag} in
1218     xlibio | x | xno | xnone | xyes)
1219       # default
1220       CSTDIO_H=config/c_io_libio.h
1221       CSTDIO_CC=config/c_io_libio.cc
1222       AC_MSG_RESULT(libio)
1223
1224       # see if we are on a system with libio native (ie, linux)
1225       AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1226
1227       # Need to check and see what version of glibc is being used. If
1228       # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1229       # compile most of libio for linux systems.
1230       if test x$has_libio = x"yes"; then
1231         case "$target" in
1232           *-*-linux*)
1233             AC_MSG_CHECKING([for glibc version >= 2.2])
1234             AC_EGREP_CPP([ok], [
1235             #include <features.h>
1236             #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1237                 ok
1238             #endif
1239             ], glibc_satisfactory=yes, glibc_satisfactory=no)
1240             AC_MSG_RESULT($glibc_satisfactory)
1241             ;;
1242         esac
1243
1244         # XXX at the moment, admit defeat and force the recompilation
1245         # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1246         glibc_satisfactory=no   
1247
1248         if test x$glibc_satisfactory = x"yes"; then
1249           need_libio=no
1250           need_xtra_libio=no
1251           need_wlibio=no        
1252         else
1253           need_libio=yes
1254           need_xtra_libio=yes
1255           # bkoz XXX need to add checks to enable this
1256           need_wlibio=yes
1257         fi
1258
1259       # Using libio, but <libio.h> doesn't exist on the target system. . .
1260       else
1261         need_libio=yes
1262         need_xtra_libio=no
1263         # bkoz XXX need to add checks to enable this
1264         need_wlibio=no
1265       fi
1266       ;;
1267
1268     xwince)
1269       CSTDIO_H=config/c_io_wince.h
1270       CSTDIO_CC=config/c_io_wince.cc
1271       AC_MSG_RESULT(wince)
1272
1273       need_libio=no
1274       ;;
1275     *)
1276       echo "$enable_cstdio is an unknown io package" 1>&2
1277       exit 1
1278       ;;
1279   esac
1280   AC_LINK_FILES($CSTDIO_H, bits/c++io.h)
1281   AC_LINK_FILES($CSTDIO_CC, src/c++io.cc)
1282
1283   # 2000-08-04 bkoz hack
1284   CCODECVT_C=config/c_io_libio_codecvt.c
1285   AC_LINK_FILES($CCODECVT_C, libio/c_codecvt.c)
1286   # 2000-08-04 bkoz hack
1287         
1288   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1289   AM_CONDITIONAL(GLIBCPP_NEED_XTRA_LIBIO, test "$need_xtra_libio" = yes)
1290   AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1291 ])
1292
1293
1294 dnl
1295 dnl Check for which threading library to use.
1296 dnl
1297 dnl GLIBCPP_ENABLE_THREADS
1298 dnl --enable-threads=posix sets config/threads-posix.h et. al.
1299 dnl 
1300 dnl default is no threads
1301 dnl
1302 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1303   dnl Note this comes from the gcc/config.in and libjava/config.in
1304   dnl Efforts should be made to keep this in sync.
1305   AC_MSG_CHECKING([for threads package to use])
1306   AC_ARG_ENABLE(threads,
1307   [  --enable-threads        enable thread usage for target GCC.
1308   --enable-threads=LIB    use LIB thread package for target GCC.],
1309   if test x$enable_threads = xno; then
1310     enable_threads=''
1311   fi,
1312     enable_threads='')
1313
1314   enable_threads_flag=$enable_threads
1315
1316   dnl Check if a valid thread package
1317   case x${enable_threads_flag} in
1318         x | xno | xnone)
1319                 # No threads
1320                 target_thread_file='single'
1321                 ;;
1322         xyes)
1323                 # default
1324                 target_thread_file=''
1325                 ;;
1326         xdecosf1 | xirix | xmach | xos2 | xposix | xpthreads | xsingle | \
1327         xsolaris | xwin32 | xdce | xvxworks)
1328                 target_thread_file=$enable_threads_flag
1329                 ;;
1330         *)
1331                 echo "$enable_threads is an unknown thread package" 1>&2
1332                 exit 1
1333                 ;;
1334   esac
1335
1336   dnl Check for thread package actually supported in libstdc++ 
1337   case "$target_thread_file" in
1338     no | none | single)
1339       THREADS=none
1340       ;;
1341     posix | pthreads)
1342       THREADS=posix
1343       case "$target" in
1344         *-*-linux*)
1345         ;;
1346       esac
1347       ;;
1348     decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
1349       AC_MSG_ERROR(thread package $THREADS not yet supported)
1350       ;;
1351     *)
1352       AC_MSG_ERROR($THREADS is an unknown thread package)
1353       ;;
1354   esac
1355   AC_MSG_RESULT($THREADS)
1356
1357   THREADLIBS=
1358   THREADINCS=
1359   THREADDEPS=
1360   THREADOBJS=
1361   THREADH=
1362   THREADSPEC=
1363   case "$THREADS" in
1364     posix)
1365       AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
1366       THREADLIBS=-lpthread
1367       THREADSPEC=-lpthread
1368       dnl Not presently used
1369       dnl THREADOBJS=threads-posix.lo
1370       THREADH=threads-posix.h
1371       ;;
1372     none)
1373       dnl Not presently used
1374       dnl THREADOBJS=threads-no.lo
1375       THREADH=threads-no.h
1376       ;;
1377   esac
1378   AC_SUBST(THREADLIBS)
1379   AC_SUBST(THREADINCS)
1380   AC_SUBST(THREADDEPS)
1381   AC_SUBST(THREADOBJS)
1382   AC_SUBST(THREADSPEC)
1383   AC_LINK_FILES(config/$THREADH, bits/c++threads.h)
1384 ])
1385
1386
1387 dnl
1388 dnl Check for template specializations for the 'long long' type extension.
1389 dnl
1390 dnl GLIBCPP_ENABLE_LONG_LONG
1391 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1392 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1393 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1394 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1395 dnl       defaults to `no'.
1396 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1397 dnl
1398 dnl GLIBCPP_ENABLE_LONG_LONG
1399 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1400   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1401
1402   AC_ARG_ENABLE(long-long,
1403   changequote(<<, >>)dnl
1404   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1405   changequote([, ])dnl
1406   [case "$enableval" in
1407    yes) enable_long_long=yes ;;
1408    no)  enable_long_long=no ;;
1409    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1410    esac],
1411   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1412
1413   # Check for the existance of functions used if long long is enabled.
1414   AC_CHECK_FUNC(strtoll,,ac_strtoll=no)
1415   AC_CHECK_FUNC(strtoull,,ac_strtoull=no)
1416
1417   AC_MSG_CHECKING([for enabled long long])
1418   if test x"$ac_strtoll" = xno || test x"$ac_strtoull" = xno; then 
1419     enable_long_long=no; 
1420   fi; 
1421   AC_MSG_RESULT($enable_long_long)
1422
1423   dnl Option parsed, now set things appropriately
1424   case "$enable_long_long" in
1425     yes)  AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1426           ;;
1427   esac
1428 ])
1429
1430
1431 dnl
1432 dnl Check for whether or not to do shadowed C headers.
1433 dnl
1434 dnl GLIBCPP_ENABLE_SHADOW
1435 dnl --enable-cshadow-headers [does stuff].
1436 dnl --disable-cshadow-headers [does not do stuff].
1437 dnl  +  This will eventually need to be on by default.
1438 dnl  +  Usage:  GLIBCPP_ENABLE_SHADOW[(DEFAULT)]
1439 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1440 dnl       defaults to `no'.
1441 AC_DEFUN(GLIBCPP_ENABLE_SHADOW, [dnl
1442 define([GLIBCPP_ENABLE_SHADOW_DEFAULT], ifelse($1, yes, yes, no))dnl
1443 AC_MSG_CHECKING([for enabled cshadow headers])
1444 AC_ARG_ENABLE(cshadow-headers,
1445 changequote(<<, >>)dnl
1446 <<  --enable-cshadow-headers construct "shadowed" C header files for
1447                            g++ [default=>>GLIBCPP_ENABLE_SHADOW_DEFAULT],
1448 changequote([, ])
1449   [case "$enableval" in
1450    yes) enable_cshadow_headers=yes 
1451         ;;
1452    no)  enable_cshadow_headers=no 
1453         ;;
1454    *)   AC_MSG_ERROR([Unknown argument to enable/disable shadowed C headers]) 
1455         ;;
1456   esac],
1457   enable_cshadow_headers=GLIBCPP_ENABLE_SHADOW_DEFAULT)
1458   AC_MSG_RESULT($enable_cshadow_headers)
1459
1460   dnl Option parsed, now set things appropriately
1461   dnl NB: these things may be duplicated in c++config.h as well.
1462   case "$enable_cshadow_headers" in
1463     yes) 
1464         CSHADOWFLAGS="-fno-builtin"
1465         AC_DEFINE(_GLIBCPP_USE_SHADOW_HEADERS)
1466         ;;
1467     no)   
1468         CSHADOWFLAGS=""
1469         ;;
1470   esac
1471
1472   AC_SUBST(CSHADOWFLAGS)
1473   AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cshadow_headers" = yes)
1474 ])
1475
1476
1477 # Check whether LC_MESSAGES is available in <locale.h>.
1478 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1479 #
1480 # This file file be copied and used freely without restrictions.  It can
1481 # be used in projects which are not available under the GNU Public License
1482 # but which still want to provide support for the GNU gettext functionality.
1483 # Please note that the actual code is *not* freely available.
1484
1485 # serial 1
1486
1487 AC_DEFUN(AC_LC_MESSAGES,
1488   [if test $ac_cv_header_locale_h = yes; then
1489     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
1490       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1491        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
1492     if test $ac_cv_val_LC_MESSAGES = yes; then
1493       AC_DEFINE(HAVE_LC_MESSAGES)
1494     fi
1495   fi])
1496
1497
1498 # Check for functions in math library.
1499 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1500 #
1501 # This file can be copied and used freely without restrictions.  It can
1502 # be used in projects which are not available under the GNU Public License
1503 # but which still want to provide support for the GNU gettext functionality.
1504 # Please note that the actual code is *not* freely available.
1505
1506 # serial 1
1507
1508 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1509 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1510 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1511 AC_SUBST(LIBMATHOBJS)dnl
1512 ])
1513
1514
1515 # Check for string functions.
1516 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1517 #
1518 # This file can be copied and used freely without restrictions.  It can
1519 # be used in projects which are not available under the GNU Public License
1520 # but which still want to provide support for the GNU gettext functionality.
1521 # Please note that the actual code is *not* freely available.
1522
1523 # serial 1
1524
1525 dnl AC_REPLACE_STRINGFUNCS(FUNCTION...)
1526 AC_DEFUN(AC_REPLACE_STRINGFUNCS,
1527 [AC_CHECK_FUNCS([$1], , [LIBSTRINGOBJS="$LIBSTRINGOBJS ${ac_func}.lo"])
1528 AC_SUBST(LIBSTRINGOBJS)dnl
1529 ])
1530
1531
1532 dnl This macro searches for a GNU version of make.  If a match is found, the
1533 dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1534 dnl set to "#". This is useful for  including a special features in a Makefile,
1535 dnl which cannot be handled by other versions of make.  The variable
1536 dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1537 dnl the empty string otherwise.
1538 dnl
1539 dnl Here is an example of its use:
1540 dnl
1541 dnl Makefile.in might contain:
1542 dnl
1543 dnl     # A failsafe way of putting a dependency rule into a makefile
1544 dnl     $(DEPEND):
1545 dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1546 dnl
1547 dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1548 dnl     @ifGNUmake@ include $(DEPEND)
1549 dnl     @ifGNUmake@ endif
1550 dnl
1551 dnl Then configure.in would normally contain:
1552 dnl
1553 dnl     CHECK_GNU_MAKE()
1554 dnl     AC_OUTPUT(Makefile)
1555 dnl
1556 dnl Then perhaps to cause gnu make to override any other make, we could do
1557 dnl something like this (note that GNU make always looks for GNUmakefile first):
1558 dnl
1559 dnl     if  ! test x$_cv_gnu_make_command = x ; then
1560 dnl             mv Makefile GNUmakefile
1561 dnl             echo .DEFAULT: > Makefile ;
1562 dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1563 dnl     fi
1564 dnl
1565 dnl Then, if any (well almost any) other make is called, and GNU make also
1566 dnl exists, then the other make wraps the GNU make.
1567 dnl
1568 dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1569 dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1570 dnl
1571 dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1572 dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1573 dnl #### conditional's subshell (" --version" is not a command), using a
1574 dnl #### different option to grep(1).
1575 dnl #### -pme
1576 AC_DEFUN(
1577   GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1578           _cv_gnu_make_command='' ;
1579 dnl Search all the common names for GNU make
1580           for a in "${MAKE:-make}" make gmake gnumake ; do
1581                   if ( $a --version 2> /dev/null | grep -c GNU )
1582                   then
1583                           _cv_gnu_make_command=$a ;
1584                           break;
1585                   fi
1586           done ;
1587   ) ;
1588 dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1589 dnl string, '#' otherwise
1590   if test  "x$_cv_gnu_make_command" != "x"  ; then
1591           ifGNUmake='' ;
1592   else
1593           ifGNUmake='#' ;
1594   fi
1595   AC_SUBST(ifGNUmake)
1596 ])
1597
1598 sinclude(../libtool.m4)
1599 dnl The lines below arrange for aclocal not to bring an installed
1600 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
1601 dnl add a definition of LIBTOOL to Makefile.in.
1602 ifelse(,,,[AC_SUBST(LIBTOOL)
1603 AC_DEFUN([AM_PROG_LIBTOOL])
1604 AC_DEFUN([AC_LIBTOOL_DLOPEN])
1605 AC_DEFUN([AC_PROG_LD])
1606 ])
1607
1608 # Do all the work for Automake.  This macro actually does too much --
1609 # some checks are only needed if your package does certain things.
1610 # But this isn't really a big deal.
1611
1612 # serial 1
1613
1614 dnl Usage:
1615 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
1616
1617 AC_DEFUN(AM_INIT_AUTOMAKE,
1618 [AC_REQUIRE([AC_PROG_INSTALL])
1619 PACKAGE=[$1]
1620 AC_SUBST(PACKAGE)
1621 VERSION=[$2]
1622 AC_SUBST(VERSION)
1623 dnl test to see if srcdir already configured
1624 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
1625   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
1626 fi
1627 ifelse([$3],,
1628 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
1629 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
1630 AC_REQUIRE([AM_SANITY_CHECK])
1631 AC_REQUIRE([AC_ARG_PROGRAM])
1632 dnl FIXME This is truly gross.
1633 missing_dir=`cd $ac_aux_dir && pwd`
1634 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
1635 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
1636 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
1637 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
1638 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
1639 AC_REQUIRE([AC_PROG_MAKE_SET])])
1640
1641 #
1642 # Check to make sure that the build environment is sane.
1643 #
1644
1645 AC_DEFUN(AM_SANITY_CHECK,
1646 [AC_MSG_CHECKING([whether build environment is sane])
1647 # Just in case
1648 sleep 1
1649 echo timestamp > conftestfile
1650 # Do `set' in a subshell so we don't clobber the current shell's
1651 # arguments.  Must try -L first in case configure is actually a
1652 # symlink; some systems play weird games with the mod time of symlinks
1653 # (eg FreeBSD returns the mod time of the symlink's containing
1654 # directory).
1655 if (
1656    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
1657    if test "[$]*" = "X"; then
1658       # -L didn't work.
1659       set X `ls -t $srcdir/configure conftestfile`
1660    fi
1661    if test "[$]*" != "X $srcdir/configure conftestfile" \
1662       && test "[$]*" != "X conftestfile $srcdir/configure"; then
1663
1664       # If neither matched, then we have a broken ls.  This can happen
1665       # if, for instance, CONFIG_SHELL is bash and it inherits a
1666       # broken ls alias from the environment.  This has actually
1667       # happened.  Such a system could not be considered "sane".
1668       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
1669 alias in your environment])
1670    fi
1671
1672    test "[$]2" = conftestfile
1673    )
1674 then
1675    # Ok.
1676    :
1677 else
1678    AC_MSG_ERROR([newly created file is older than distributed files!
1679 Check your system clock])
1680 fi
1681 rm -f conftest*
1682 AC_MSG_RESULT(yes)])
1683
1684 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
1685 dnl The program must properly implement --version.
1686 AC_DEFUN(AM_MISSING_PROG,
1687 [AC_MSG_CHECKING(for working $2)
1688 # Run test in a subshell; some versions of sh will print an error if
1689 # an executable is not found, even if stderr is redirected.
1690 # Redirect stdin to placate older versions of autoconf.  Sigh.
1691 if ($2 --version) < /dev/null > /dev/null 2>&1; then
1692    $1=$2
1693    AC_MSG_RESULT(found)
1694 else
1695    $1="$3/missing $2"
1696    AC_MSG_RESULT(missing)
1697 fi
1698 AC_SUBST($1)])
1699
1700 # Add --enable-maintainer-mode option to configure.
1701 # From Jim Meyering
1702
1703 # serial 1
1704
1705 AC_DEFUN(AM_MAINTAINER_MODE,
1706 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
1707   dnl maintainer-mode is disabled by default
1708   AC_ARG_ENABLE(maintainer-mode,
1709 [  --enable-maintainer-mode enable make rules and dependencies not useful
1710                           (and sometimes confusing) to the casual installer],
1711       USE_MAINTAINER_MODE=$enableval,
1712       USE_MAINTAINER_MODE=no)
1713   AC_MSG_RESULT($USE_MAINTAINER_MODE)
1714   AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
1715   MAINT=$MAINTAINER_MODE_TRUE
1716   AC_SUBST(MAINT)dnl
1717 ]
1718 )
1719
1720 # Define a conditional.
1721
1722 AC_DEFUN(AM_CONDITIONAL,
1723 [AC_SUBST($1_TRUE)
1724 AC_SUBST($1_FALSE)
1725 if $2; then
1726   $1_TRUE=
1727   $1_FALSE='#'
1728 else
1729   $1_TRUE='#'
1730   $1_FALSE=
1731 fi])
1732
1733 # Like AC_CONFIG_HEADER, but automatically create stamp file.
1734
1735 AC_DEFUN(AM_CONFIG_HEADER,
1736 [AC_PREREQ([2.12])
1737 AC_CONFIG_HEADER([$1])
1738 dnl When config.status generates a header, we must update the stamp-h file.
1739 dnl This file resides in the same directory as the config header
1740 dnl that is generated.  We must strip everything past the first ":",
1741 dnl and everything past the last "/".
1742 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
1743 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
1744 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
1745 <<am_indx=1
1746 for am_file in <<$1>>; do
1747   case " <<$>>CONFIG_HEADERS " in
1748   *" <<$>>am_file "*<<)>>
1749     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
1750     ;;
1751   esac
1752   am_indx=`expr "<<$>>am_indx" + 1`
1753 done<<>>dnl>>)
1754 changequote([,]))])
1755