* sibcall.c (optimize_sibling_and_tail_recursive_calls): Call
[official-gcc.git] / libstdc++-v3 / acinclude.m4
blob13614a17cf95c7095e5d0ada174c22ff64bcb379
1 dnl
2 dnl Initialize configure bits.
3 dnl
4 dnl GLIBCPP_CONFIGURE
5 AC_DEFUN(GLIBCPP_CONFIGURE, [
6   dnl Default to --enable-multilib
7   AC_ARG_ENABLE(multilib,
8   [  --enable-multilib       build hella library versions (default)],
9   [case "${enableval}" in
10     yes) multilib=yes ;;
11     no)  multilib=no ;;
12     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
13    esac], [multilib=yes])dnl
15   glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
16   AC_SUBST(glibcpp_basedir)
18   AM_INIT_AUTOMAKE(libstdc++, 3.0.0)
20   # Never versions of autoconf add an underscore to these functions.
21   # Prevent future problems ...
22   ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
23   ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
24   ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
25   ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
27 #  AC_PROG_CC
29 # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
30 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
31 # are probably using a cross compiler, which will not be able to fully
32 # link an executable.  This should really be fixed in autoconf
33 # itself.
35 AC_DEFUN(LIB_AC_PROG_CC,
36 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
37 dnl Fool anybody using AC_PROG_CC.
38 AC_PROVIDE([AC_PROG_CC])
39 AC_CHECK_PROG(CC, gcc, gcc)
40 if test -z "$CC"; then
41   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
42   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
45 AC_PROG_CC_GNU
47 if test $ac_cv_prog_gcc = yes; then
48   GCC=yes
49 dnl Check whether -g works, even if CFLAGS is set, in case the package
50 dnl plays around with CFLAGS (such as to build both debugging and
51 dnl normal versions of a library), tasteless as that idea is.
52   ac_test_CFLAGS="${CFLAGS+set}"
53   ac_save_CFLAGS="$CFLAGS"
54   CFLAGS=
55   AC_PROG_CC_G
56   if test "$ac_test_CFLAGS" = set; then
57     CFLAGS="$ac_save_CFLAGS"
58   elif test $ac_cv_prog_cc_g = yes; then
59     CFLAGS="-g -O2"
60   else
61     CFLAGS="-O2"
62   fi
63 else
64   GCC=
65   test "${CFLAGS+set}" = set || CFLAGS="-g"
69 LIB_AC_PROG_CC
71 # Can't just call these here as g++ requires libstc++ to be built....
72 #  AC_PROG_CXX
74 # Likewise for AC_PROG_CXX.
75 AC_DEFUN(LIB_AC_PROG_CXX,
76 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
77 dnl Fool anybody using AC_PROG_CXX.
78 AC_PROVIDE([AC_PROG_CXX])
79 # Use glibcpp_CXX so that we do not cause CXX to be cached with the
80 # flags that come in CXX while configuring libstdc++.  They're different
81 # from those used for all other target libraries.  If CXX is set in
82 # the environment, respect that here.
83 glibcpp_CXX=$CXX
84 AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
85 AC_SUBST(glibcpp_CXX)
86 CXX=$glibcpp_CXX
87 test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
89 AC_PROG_CXX_GNU
91 if test $ac_cv_prog_gxx = yes; then
92   GXX=yes
93 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
94 dnl plays around with CXXFLAGS (such as to build both debugging and
95 dnl normal versions of a library), tasteless as that idea is.
96   ac_test_CXXFLAGS="${CXXFLAGS+set}"
97   ac_save_CXXFLAGS="$CXXFLAGS"
98   CXXFLAGS=
99   AC_PROG_CXX_G
100   if test "$ac_test_CXXFLAGS" = set; then
101     CXXFLAGS="$ac_save_CXXFLAGS"
102   elif test $ac_cv_prog_cxx_g = yes; then
103     CXXFLAGS="-g -O2"
104   else
105     CXXFLAGS="-O2"
106   fi
107 else
108   GXX=
109   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
113 LIB_AC_PROG_CXX
115   AC_CHECK_TOOL(AS, as)
116   AC_CHECK_TOOL(AR, ar)
117   AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
118   AC_PROG_INSTALL
120   AM_MAINTAINER_MODE
122   # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
123   # at least currently, we never actually build a program, so we never
124   # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
125   # fails, because we are probably configuring with a cross compiler
126   # which cant create executables.  So we include AC_EXEEXT to keep
127   # automake happy, but we dont execute it, since we dont care about
128   # the result.
129   if false; then
130     # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
131     # to nothing, so nothing would remain between `then' and `fi' if it
132     # were not for the `:' below.
133     :
134     AC_EXEEXT
135   fi
137   . [$]{glibcpp_basedir}/configure.host
139   case [$]{glibcpp_basedir} in
140     /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
141     *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
142   esac
144   # This does for the target what configure.host does for the host.  In
145   # addition to possibly modifying the same flags, it also sets up symlinks.
146   GLIBCPP_CHECK_TARGET
151 dnl Check to see if g++ can compile this library, and if so, if any version-
152 dnl specific precautions need to be taken. 
153 dnl 
154 dnl GLIBCPP_CHECK_COMPILER_VERSION
155 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
156 if test ! -f stamp-sanity-compiler; then
157   AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
158   AC_LANG_SAVE
159   AC_LANG_CPLUSPLUS
160   AC_TRY_COMPILE(, [
161   #if __GNUC__ < 3
162     not_ok
163   #endif
164   ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
165   AC_LANG_RESTORE
166   AC_MSG_RESULT($gpp_satisfactory)
167   touch stamp-sanity-compiler
173 dnl Tests for newer compiler features, or features that are present in newer
174 dnl compiler versions but not older compiler versions still in use, should
175 dnl be placed here.
177 dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
178 dnl new inlining code or the new system_header pragma will die on -Werror.
179 dnl Leave it out by default and use maint-mode to use it.
181 dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
182 dnl compiler supports it and the user has not requested debug mode.
184 dnl GLIBCPP_CHECK_COMPILER_FEATURES
185 AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
186   # All these tests are for C++; save the language and the compiler flags.
187   # The CXXFLAGS thing is suspicious, but based on similar bits previously
188   # found in GLIBCPP_CONFIGURE.
189   AC_LANG_SAVE
190   AC_LANG_CPLUSPLUS
191   ac_test_CXXFLAGS="${CXXFLAGS+set}"
192   ac_save_CXXFLAGS="$CXXFLAGS"
194   # Check for maintainer-mode bits.
195   if test x"$USE_MAINTAINER_MODE" = xno; then
196     WERROR=''
197   else
198     WERROR='-Werror'
199   fi
201   # Check for -ffunction-sections -fdata-sections
202   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
203   CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
204   AC_TRY_COMPILE(, [int foo;
205   ], [ac_fdsections=yes], [ac_fdsections=no])
206   if test "$ac_test_CXXFLAGS" = set; then
207     CXXFLAGS="$ac_save_CXXFLAGS"
208   else
209     # this is the suspicious part
210     CXXFLAGS=''
211   fi
212   if test x"$ac_fdsections" = x"yes" && test x"$enable_debug" = x"no"; then
213     SECTION_FLAGS='-ffunction-sections -fdata-sections'
214   fi
215   AC_MSG_RESULT($ac_fdsections)
217   AC_LANG_RESTORE
218   AC_SUBST(WERROR)
219   AC_SUBST(SECTION_FLAGS)
224 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
225 dnl the native linker is in use, all variables will be defined to something
226 dnl safe (like an empty string).
228 dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
229 dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
231 dnl GLIBCPP_CHECK_LINKER_FEATURES
232 AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
233   # If we're not using GNU ld, then there's no point in even trying these
234   # tests.  Check for that first.  We should have already tested for gld
235   # by now (in libtool), but require it now just to be safe...
236   SECTION_LDFLAGS=''
237   OPT_LDFLAGS=''
238   AC_REQUIRE([AC_PROG_LD])
240   # Set --gc-sections.
241   if test "$ac_cv_prog_gnu_ld" = "notbroken"; then
242     # GNU ld it is!  Joy and bunny rabbits!
244     # All these tests are for C++; save the language and the compiler flags.
245     # Need to do this so that g++ won't try to link in libstdc++
246     ac_test_CFLAGS="${CFLAGS+set}"
247     ac_save_CFLAGS="$CFLAGS"
248     CFLAGS='-x c++  -Wl,--gc-sections'
250     # Check for -Wl,--gc-sections
251     # XXX This test is broken at the moment, as symbols required for
252     # linking are now in libsupc++ (not built yet.....). In addition, 
253     # this test has cored on solaris in the past. In addition,
254     # --gc-sections doesn't really work at the moment (keeps on discarding
255     # used sections, first .eh_frame and now some of the glibc sections for
256     # iconv). Bzzzzt. Thanks for playing, maybe next time.
257     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
258     AC_TRY_RUN([
259      int main(void) 
260      {
261        try { throw 1; }
262        catch (...) { };
263        return 0;
264      }
265     ], [ac_sectionLDflags=yes],[ac_sectionLFflags=no], [ac_sectionLDflags=yes])
266     if test "$ac_test_CFLAGS" = set; then
267       CFLAGS="$ac_save_CFLAGS"
268     else
269       # this is the suspicious part
270       CFLAGS=''
271     fi
272     if test "$ac_sectionLDflags" = "yes"; then
273       SECTION_LDFLAGS='-Wl,--gc-sections'
274     fi
275     AC_MSG_RESULT($ac_sectionLDflags)
276   fi
278   # Set linker optimization flags.
279   if test x"$ac_cv_prog_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
280     OPT_LDFLAGS='-Wl,-O1'
281   fi
283   AC_SUBST(SECTION_LDFLAGS)
284   AC_SUBST(OPT_LDFLAGS)
289 dnl Check to see if the (math function) argument passed is
290 dnl declared when using the c++ compiler
291 dnl ASSUMES argument is a math function with ONE parameter
293 dnl GLIBCPP_CHECK_MATH_DECL_1
294 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
295   AC_MSG_CHECKING([for $1 declaration])
296   if test x${glibcpp_cv_func_$1_use+set} != xset; then
297     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
298       AC_LANG_SAVE
299       AC_LANG_CPLUSPLUS
300       AC_TRY_COMPILE([#include <math.h>
301                       #ifdef HAVE_IEEEFP_H
302                       #include <ieeefp.h>
303                       #endif
304                      ], 
305                      [ $1(0);], 
306                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
307       AC_LANG_RESTORE
308     ])
309   fi
310   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
314 dnl Check to see if the (math function) argument passed is
315 dnl 1) declared when using the c++ compiler
316 dnl 2) has "C" linkage
317 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
319 dnl Define HAVE_CARGF etc if "cargf" is declared and links
321 dnl argument 1 is name of function to check
323 dnl ASSUMES argument is a math function with ONE parameter
325 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
326 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
327   GLIBCPP_CHECK_MATH_DECL_1($1)
328   if test x$glibcpp_cv_func_$1_use = x"yes"; then
329     AC_CHECK_FUNCS($1)    
330   else
331     GLIBCPP_CHECK_MATH_DECL_1(_$1)
332     if test x$glibcpp_cv_func__$1_use = x"yes"; then
333       AC_CHECK_FUNCS(_$1)    
334     fi  
335   fi
340 dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
341 dnl of functions at once.  It's an all-or-nothing check -- either 
342 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
343 dnl Doing it this way saves significant configure time.
344 AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
345   AC_MSG_CHECKING([for $1 functions])
346   AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
347     AC_LANG_SAVE
348     AC_LANG_CPLUSPLUS
349     AC_TRY_COMPILE([#include <math.h>],
350                    [ `for x in $3; do echo "$x (0);"; done` ],
351                    [glibcpp_cv_func_$2_use=yes],
352                    [glibcpp_cv_func_$2_use=no])
353     AC_LANG_RESTORE])
354   AC_MSG_RESULT($glibcpp_cv_func_$2_use)
355   if test x$glibcpp_cv_func_$2_use = x"yes"; then
356     AC_CHECK_FUNCS($3)
357   fi
361 dnl Check to see if the (math function) argument passed is
362 dnl declared when using the c++ compiler
363 dnl ASSUMES argument is a math function with TWO parameters
365 dnl GLIBCPP_CHECK_MATH_DECL_2
366 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
367   AC_MSG_CHECKING([for $1 declaration])
368   if test x${glibcpp_cv_func_$1_use+set} != xset; then
369     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
370       AC_LANG_SAVE
371       AC_LANG_CPLUSPLUS
372       AC_TRY_COMPILE([#include <math.h>], 
373                      [ $1(0, 0);], 
374                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
375       AC_LANG_RESTORE
376     ])
377   fi
378   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
382 dnl Check to see if the (math function) argument passed is
383 dnl 1) declared when using the c++ compiler
384 dnl 2) has "C" linkage
386 dnl Define HAVE_CARGF etc if "cargf" is declared and links
388 dnl argument 1 is name of function to check
390 dnl ASSUMES argument is a math function with TWO parameters
392 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
393 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
394   GLIBCPP_CHECK_MATH_DECL_2($1)
395   if test x$glibcpp_cv_func_$1_use = x"yes"; then
396     AC_CHECK_FUNCS($1)    
397   else
398     GLIBCPP_CHECK_MATH_DECL_2(_$1)
399     if test x$glibcpp_cv_func__$1_use = x"yes"; then
400       AC_CHECK_FUNCS(_$1)    
401     fi  
402   fi
407 dnl Check to see if the (math function) argument passed is
408 dnl declared when using the c++ compiler
409 dnl ASSUMES argument is a math function with THREE parameters
411 dnl GLIBCPP_CHECK_MATH_DECL_3
412 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
413   AC_MSG_CHECKING([for $1 declaration])
414   if test x${glibcpp_cv_func_$1_use+set} != xset; then
415     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
416       AC_LANG_SAVE
417       AC_LANG_CPLUSPLUS
418       AC_TRY_COMPILE([#include <math.h>], 
419                      [ $1(0, 0, 0);], 
420                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
421       AC_LANG_RESTORE
422     ])
423   fi
424   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
428 dnl Check to see if the (math function) argument passed is
429 dnl 1) declared when using the c++ compiler
430 dnl 2) has "C" linkage
432 dnl Define HAVE_CARGF etc if "cargf" is declared and links
434 dnl argument 1 is name of function to check
436 dnl ASSUMES argument is a math function with THREE parameters
438 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
439 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
440   GLIBCPP_CHECK_MATH_DECL_3($1)
441   if test x$glibcpp_cv_func_$1_use = x"yes"; then
442     AC_CHECK_FUNCS($1)    
443   else
444     GLIBCPP_CHECK_MATH_DECL_3(_$1)
445     if test x$glibcpp_cv_func__$1_use = x"yes"; then
446       AC_CHECK_FUNCS(_$1)    
447     fi  
448   fi
453 dnl Check to see if the (stdlib function) argument passed is
454 dnl 1) declared when using the c++ compiler
455 dnl 2) has "C" linkage
457 dnl argument 1 is name of function to check
459 dnl ASSUMES argument is a math function with TWO parameters
461 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
462 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
463   AC_MSG_CHECKING([for $1 declaration])
464   if test x${glibcpp_cv_func_$1_use+set} != xset; then
465     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
466       AC_LANG_SAVE
467       AC_LANG_CPLUSPLUS
468       AC_TRY_COMPILE([#include <stdlib.h>], 
469                      [ $1(0, 0);], 
470                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
471       AC_LANG_RESTORE
472     ])
473   fi
474   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
475   if test x$glibcpp_cv_func_$1_use = x"yes"; then
476     AC_CHECK_FUNCS($1)    
477   fi
482 dnl Because the builtins are picky picky picky about the arguments they take, 
483 dnl do an explict linkage tests here.
484 dnl Check to see if the (math function) argument passed is
485 dnl 1) declared when using the c++ compiler
486 dnl 2) has "C" linkage
488 dnl Define HAVE_CARGF etc if "cargf" is declared and links
490 dnl argument 1 is name of function to check
492 dnl ASSUMES argument is a math function with ONE parameter
494 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
495 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
496   AC_MSG_CHECKING([for $1 declaration])
497   if test x${glibcpp_cv_func_$1_use+set} != xset; then
498     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
499       AC_LANG_SAVE
500       AC_LANG_CPLUSPLUS
501       AC_TRY_COMPILE([#include <math.h>], 
502                      [ $1(0);], 
503                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
504       AC_LANG_RESTORE
505     ])
506   fi
507   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
508   if test x$glibcpp_cv_func_$1_use = x"yes"; then
509     AC_MSG_CHECKING([for $1 linkage])
510     if test x${glibcpp_cv_func_$1_link+set} != xset; then
511       AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
512         AC_TRY_LINK([#include <math.h>], 
513                     [ $1(0);], 
514                     [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
515       ])
516     fi
517     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
518     if test x$glibcpp_cv_func_$1_link = x"yes"; then
519       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
520       AC_DEFINE_UNQUOTED(${ac_tr_func})
521     fi
522   fi
527 dnl Check to see what builtin math functions are supported
529 dnl check for __builtin_abs
530 dnl check for __builtin_fabsf
531 dnl check for __builtin_fabs
532 dnl check for __builtin_fabl
533 dnl check for __builtin_labs
534 dnl check for __builtin_sqrtf
535 dnl check for __builtin_sqrtl
536 dnl check for __builtin_fsqrt
537 dnl check for __builtin_sinf
538 dnl check for __builtin_sin
539 dnl check for __builtin_sinl
540 dnl check for __builtin_cosf
541 dnl check for __builtin_cos
542 dnl check for __builtin_cosl
544 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
545 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
546   dnl Test for builtin math functions.
547   dnl These are made in gcc/c-common.c 
548   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
549   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
550   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
551   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
552   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
554   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
555   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fsqrt)
556   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
558   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
559   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
560   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
562   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
563   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
564   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
566   dnl There is, without a doubt, a more elegant way to have these
567   dnl names exported so that they won't be stripped out of acconfig.h by
568   dnl autoheader. I leave this as an exercise to somebody less frustrated
569   dnl than I.... please email the libstdc++ list if you can figure out a
570   dnl more elegant approach (see autoconf/acgen.m4 and specifically
571   dnl AC_CHECK_FUNC for things to steal.)
572   dummyvar=no
573   if test x$dummyvar = x"yes"; then
574     AC_DEFINE(HAVE___BUILTIN_ABS)
575     AC_DEFINE(HAVE___BUILTIN_LABS)
576     AC_DEFINE(HAVE___BUILTIN_COS)
577     AC_DEFINE(HAVE___BUILTIN_COSF)
578     AC_DEFINE(HAVE___BUILTIN_COSL)
579     AC_DEFINE(HAVE___BUILTIN_FABS)
580     AC_DEFINE(HAVE___BUILTIN_FABSF)
581     AC_DEFINE(HAVE___BUILTIN_FABSL)
582     AC_DEFINE(HAVE___BUILTIN_SIN)
583     AC_DEFINE(HAVE___BUILTIN_SINF)
584     AC_DEFINE(HAVE___BUILTIN_SINL)
585     AC_DEFINE(HAVE___BUILTIN_FSQRT)
586     AC_DEFINE(HAVE___BUILTIN_SQRTF)
587     AC_DEFINE(HAVE___BUILTIN_SQRTL)
588   fi
593 dnl Check to see what the underlying c library 
594 dnl These checks need to do two things: 
595 dnl 1) make sure the name is declared when using the c++ compiler
596 dnl 2) make sure the name has "C" linkage
597 dnl This might seem like overkill but experience has shown that it's not...
599 dnl Define HAVE_STRTOLD if "strtold" is declared and links
600 dnl Define HAVE_STRTOF if "strtof" is declared and links
601 dnl Define HAVE_DRAND48 if "drand48" is declared and links
603 dnl GLIBCPP_CHECK_STDLIB_SUPPORT
604 AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
605   ac_test_CXXFLAGS="${CXXFLAGS+set}"
606   ac_save_CXXFLAGS="$CXXFLAGS"
607   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
609   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
610   AC_CHECK_FUNCS(drand48)
612   CXXFLAGS="$ac_save_CXXFLAGS"
617 dnl Check to see what the underlying c library or math library is like.
618 dnl These checks need to do two things: 
619 dnl 1) make sure the name is declared when using the c++ compiler
620 dnl 2) make sure the name has "C" linkage
621 dnl This might seem like overkill but experience has shown that it's not...
623 dnl Define HAVE_CARGF etc if "cargf" is found.
625 dnl GLIBCPP_CHECK_MATH_SUPPORT
626 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
627   ac_test_CXXFLAGS="${CXXFLAGS+set}"
628   ac_save_CXXFLAGS="$CXXFLAGS"
629   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
631   dnl Check libm
632   AC_CHECK_LIB(m, sin, libm="-lm")
633   ac_save_LIBS="$LIBS"
634   LIBS="$LIBS $libm"
636   dnl Check to see if certain C math functions exist.
637   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
638   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
639   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
640   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
641   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
642   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
643   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
644   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
646   dnl Check to see if basic C math functions have float versions.
647   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
648                                           float_trig,
649                                           acosf asinf atanf \
650                                           cosf sinf tanf \
651                                           coshf sinhf tanhf)
652   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
653                                           float_round,
654                                           ceilf floorf)
655   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
656   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
657   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
658   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
659   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
660   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
661   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
662   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
663   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
664   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
665   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
666   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
667   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
668   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
669   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
671   dnl Check to see if basic C math functions have long double versions.
672   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
673                                           long_double_trig,
674                                           acosl asinl atanl \
675                                           cosl sinl tanl \
676                                           coshl sinhl tanhl)
677   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
678                                           long_double_round,
679                                           ceill floorl)
680   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
681   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
682   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
683   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
684   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
685   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
686   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
687   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
688   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
689   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
690   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
691   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
692   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
693   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
694   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
695   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
696   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
698   dnl Some runtimes have these functions with a preceding underscore. Please
699   dnl keep this sync'd with the one above. And if you add any new symbol,
700   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
701   dnl Check to see if certain C math functions exist.
703   dnl Check to see if basic C math functions have float versions.
704   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
705                                           _float_trig,
706                                           _acosf _asinf _atanf \
707                                           _cosf _sinf _tanf \
708                                           _coshf _sinhf _tanhf)
709   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
710                                           _float_round,
711                                           _ceilf _floorf)
713   dnl Check to see if basic C math functions have long double versions.
714   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
715                                           _long_double_trig,
716                                           _acosl _asinl _atanl \
717                                           _cosl _sinl _tanl \
718                                           _coshl _sinhl _tanhl)
719   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
720                                           _long_double_round,
721                                           _ceill _floorl)
723   LIBS="$ac_save_LIBS"
724   CXXFLAGS="$ac_save_CXXFLAGS"
729 dnl Check to see if there is native support for complex 
731 dnl Don't compile bits in math/* if native support exits.
733 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
735 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
736 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
737   dnl Check for complex versions of math functions of platform.
738   AC_CHECK_LIB(m, main)
739   AC_REPLACE_MATHFUNCS(nan copysignf)
741   dnl Compile the long double complex functions only if the function 
742   dnl provides the non-complex long double functions that are needed.
743   dnl Currently this includes copysignl, which should be
744   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
745   USE_COMPLEX_LONG_DOUBLE=no
746   if test x$ac_cv_func_copysignl = x"yes"; then
747     USE_COMPLEX_LONG_DOUBLE=yes
748     AC_REPLACE_MATHFUNCS(signbitl)
749   fi
751   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
755 dnl Check to see what architecture and operating system we are compiling
756 dnl for.  Also, if architecture- or OS-specific flags are required for
757 dnl compilation, pick them up here.
758 dnl 
759 dnl GLIBCPP_CHECK_TARGET
760 AC_DEFUN(GLIBCPP_CHECK_TARGET, [
761     . [$]{glibcpp_basedir}/configure.target
762     AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
763     AC_MSG_RESULT(OS config directory is $os_include_dir)
768 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
769 dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
770 dnl must have been previously checked.)
772 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
773 dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
775 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
776 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
778   dnl Test wchar.h for mbstate_t, which is needed for char_traits and
779   dnl others even if wchar_t support is not on.
780   AC_MSG_CHECKING([for mbstate_t])
781   AC_TRY_COMPILE([#include <wchar.h>],
782   [mbstate_t teststate;], 
783   have_mbstate_t=yes, have_mbstate_t=no)
784   AC_MSG_RESULT($have_mbstate_t)
785   if test x"$have_mbstate_t" = xyes; then
786     AC_DEFINE(HAVE_MBSTATE_T)
787   fi
789   dnl Sanity check for existence of ISO C99 headers for extended encoding.
790   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
791   AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
792   
793   dnl Only continue checking if the ISO C99 headers exist and support is on.
794   if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes \
795      && test x"$enable_c_mbchar" != xno; then
796       
797     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
798     dnl numeric_limits can instantiate type_traits<wchar_t>
799     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
800     AC_TRY_COMPILE([#include <wchar.h>],
801     [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
802     has_wchar_minmax=yes, has_wchar_minmax=no)
803     AC_MSG_RESULT($has_wchar_minmax)
804     
805     dnl Test wchar.h for WEOF, which is what we use to determine whether
806     dnl to specialize for char_traits<wchar_t> or not.
807     AC_MSG_CHECKING([for WEOF])
808     AC_TRY_COMPILE([
809       #include <wchar.h>
810       #include <stddef.h>],
811     [wint_t i = WEOF;],
812     has_weof=yes, has_weof=no)
813     AC_MSG_RESULT($has_weof)
814   
815     dnl Tests for wide character functions used in char_traits<wchar_t>.
816     ac_wfuncs=yes
817     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
818     ac_wfuncs=no)
819   
820     dnl Checks for names injected into std:: by the c_std headers.
821     AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
822     fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
823     vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
824     mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
825     wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
826     wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
827     ac_wfuncs=no)
829     AC_MSG_CHECKING([for ISO C99 wchar_t support])
830     if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
831        && test x"$ac_wfuncs" = xyes; then
832       ac_isoC99_wchar_t=yes
833     else
834       ac_isoC99_wchar_t=no
835     fi
836     AC_MSG_RESULT($ac_isoC99_wchar_t)
837   
838     dnl Use iconv for wchar_t to char conversions. As such, check for 
839     dnl X/Open Portability Guide, version 2 features (XPG2).
840     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
841     AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
843     dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
844     AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
845     ac_save_LIBS="$LIBS"
846     LIBS="$LIBS $libiconv"
848     AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
849     ac_XPG2funcs=yes, ac_XPG2funcs=no)
850   
851     LIBS="$ac_save_LIBS"
853     AC_MSG_CHECKING([for XPG2 wchar_t support])
854     if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
855        && test x"$ac_XPG2funcs" = xyes; then
856       ac_XPG2_wchar_t=yes
857     else
858       ac_XPG2_wchar_t=no
859     fi
860     AC_MSG_RESULT($ac_XPG2_wchar_t)
861   
862     dnl At the moment, only enable wchar_t specializations if all the
863     dnl above support is present.
864     AC_MSG_CHECKING([for enabled wchar_t specializations])
865     if test x"$ac_isoC99_wchar_t" = xyes \
866     && test x"$ac_XPG2_wchar_t" = xyes; then
867       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
868       AC_MSG_RESULT("yes")
869     else
870       AC_MSG_RESULT("no")
871     fi
872   else
873     dnl Wide characters disabled by the user. 
874     AC_MSG_WARN([wchar_t support disabled.])
875   fi
880 dnl Check for special debugging mode; not for production use.
882 dnl GLIBCPP_ENABLE_DEBUG
883 dnl --enable-debug sets '-ggdb3 -O0'.
884 dnl --disable-debug sets '-g' and whatever optimization options the
885 dnl     compiler can handle.
886 dnl  +  --enable-maintainer-mode automatically defaults this to on.
887 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
888 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
889 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
890 dnl       defaults to `no'.
891 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
892 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
893 AC_ARG_ENABLE(debug,
894 changequote(<<, >>)dnl
895 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
896 changequote([, ])dnl
897 [case "${enableval}" in
898  yes) enable_debug=yes ;;
899  no)  enable_debug=no ;;
900  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
901  esac],
902 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
904 dnl Option parsed, now set things appropriately
905 case "${enable_debug}" in
906     yes) 
907         DEBUG_FLAGS='-O0 -ggdb3'                        
908         ;; 
909     no)   
910         DEBUG_FLAGS='-g'
911         ;;
912 esac
913 AC_SUBST(DEBUG_FLAGS)
918 dnl Check for "unusual" flags to pass to the compiler while building.
920 dnl GLIBCPP_ENABLE_CXX_FLAGS
921 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
922 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
923 dnl     Somehow this same set of flags must be passed when [re]building
924 dnl     libgcc.
925 dnl --disable-cxx-flags passes nothing.
926 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
927 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
928 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
929 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
930 dnl       If "default flags" is an empty string (or "none"), the effect is
931 dnl       the same as --disable or --enable=no.
932 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
933 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
934 AC_ARG_ENABLE(cxx-flags,
935 changequote(<<, >>)dnl
936 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
937                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
938 changequote([, ])dnl
939 [case "x$enableval" in
940  xyes)   
941         AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
942  xno|x)  
943         enable_cxx_flags='' ;;
944  *)      
945         enable_cxx_flags="$enableval" ;;
946  esac],
947 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
949 dnl Thinko on my part during design.  This kludge is the workaround.
950 if test "$enable_cxx_flags" = "none"; then 
951   enable_cxx_flags=''; 
954 dnl Run through flags (either default or command-line) and set anything
955 dnl extra (e.g., #defines) that must accompany particular g++ options.
956 if test -n "$enable_cxx_flags"; then
957     for f in $enable_cxx_flags; do
958         case "$f" in
959             -fhonor-std)  ;;
960             -*)  ;;
961             *)   # and we're trying to pass /what/ exactly?
962                  AC_MSG_ERROR([compiler flags start with a -]) ;;
963         esac
964     done
966 EXTRA_CXX_FLAGS="$enable_cxx_flags"
967 AC_SUBST(EXTRA_CXX_FLAGS)
972 dnl Check for which locale library to use:  gnu or generic.
974 dnl GLIBCPP_ENABLE_CLOCALE
975 dnl --enable-clocale=gnu sets config/c_locale_gnu.cc and friends
976 dnl --enable-clocale=generic sets config/c_locale_generic.cc and friends
977 dnl 
978 dnl default is generic
980 AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
981   AC_MSG_CHECKING([for clocale to use])
982   AC_ARG_ENABLE(clocale,
983   [  --enable-clocale        enable model for target locale package. 
984   --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
985   ], 
986   if test x$enable_clocale = xno; then
987      enable_clocale=generic
988   fi,
989      enable_clocale=generic)
991   enable_clocale_flag=$enable_clocale
993   dnl Check if a valid locale package
994   case x${enable_clocale_flag} in
995     xgnu)
996       CLOCALE_H=config/c_locale_gnu.h
997       CLOCALE_CC=config/c_locale_gnu.cc
998       AC_MSG_RESULT(gnu)
999       ;;
1000     xgeneric)
1001       CLOCALE_H=config/c_locale_generic.h
1002       CLOCALE_CC=config/c_locale_generic.cc
1003       AC_MSG_RESULT(generic)
1004       ;;
1005     *)
1006       echo "$enable_clocale is an unknown locale package" 1>&2
1007       exit 1
1008       ;;
1009   esac
1011   AC_SUBST(CLOCALE_H)
1012   AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1017 dnl Check for which I/O library to use:  libio, or something specific.
1019 dnl GLIBCPP_ENABLE_CSTDIO
1020 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
1021 dnl 
1022 dnl default is stdio
1024 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1025   AC_MSG_CHECKING([for cstdio to use])
1026   AC_ARG_ENABLE(cstdio,
1027   [  --enable-cstdio         enable stdio for target io package. 
1028   --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
1029   ], 
1030   if test x$enable_cstdio = xno; then
1031      enable_cstdio=stdio
1032   fi,
1033      enable_cstdio=stdio)
1035   enable_cstdio_flag=$enable_cstdio
1037   dnl Check if a valid I/O package
1038   case x${enable_cstdio_flag} in
1039     xlibio)
1040       CSTDIO_H=config/c_io_libio.h
1041       BASIC_FILE_H=config/basic_file_libio.h
1042       BASIC_FILE_CC=config/basic_file_libio.cc
1043       AC_MSG_RESULT(libio)
1045       # see if we are on a system with libio native (ie, linux)
1046       AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1048       # Need to check and see what version of glibc is being used. If
1049       # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1050       # compile most of libio for linux systems.
1051       if test x$has_libio = x"yes"; then
1052         case "$target" in
1053           *-*-linux*)
1054               AC_MSG_CHECKING([for glibc version >= 2.2])
1055               AC_EGREP_CPP([ok], [
1056             #include <features.h>
1057               #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1058                     ok
1059               #endif
1060               ], glibc_satisfactory=yes, glibc_satisfactory=no)
1061               AC_MSG_RESULT($glibc_satisfactory)
1062             ;;
1063         esac
1065         # XXX at the moment, admit defeat and force the recompilation
1066         # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1067         glibc_satisfactory=no        
1069         if test x$glibc_satisfactory = x"yes"; then
1070            need_libio=no
1071            need_wlibio=no        
1072         else
1073            need_libio=yes
1074            # bkoz XXX need to add checks to enable this
1075            # pme XXX here's a first pass at such a check
1076            if test x$enable_c_mbchar != xno; then
1077               need_wlibio=yes
1078            else
1079               need_wlibio=no
1080            fi
1081         fi
1083       else
1084          # Using libio, but <libio.h> doesn't exist on the target system. . .
1085          need_libio=yes
1086          # bkoz XXX need to add checks to enable this
1087          # pme XXX here's a first pass at such a check
1088          if test x$enable_c_mbchar != xno; then
1089              need_wlibio=yes
1090          else
1091              need_wlibio=no
1092          fi
1093       fi
1094       ;;
1095     xstdio | x | xno | xnone | xyes)
1096       # default
1097       CSTDIO_H=config/c_io_stdio.h
1098       BASIC_FILE_H=config/basic_file_stdio.h
1099       BASIC_FILE_CC=config/basic_file_stdio.cc
1100       AC_MSG_RESULT(stdio)
1102       # We're not using stdio.
1103       need_libio=no
1104       need_wlibio=no
1105       ;;
1106     *)
1107       echo "$enable_cstdio is an unknown io package" 1>&2
1108       exit 1
1109       ;;
1110   esac
1111   AC_SUBST(CSTDIO_H)
1112   AC_SUBST(BASIC_FILE_H)
1113   AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
1115   # 2000-08-04 bkoz hack
1116   CCODECVT_C=config/c_io_libio_codecvt.c
1117   AC_SUBST(CCODECVT_C)
1118   # 2000-08-04 bkoz hack
1120   AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1121                  test "$need_libio" = yes || test "$need_wlibio" = yes)
1122   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1123   AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1124   if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1125     libio_la=../libio/libio.la
1126   else
1127     libio_la=
1128   fi
1129   AC_SUBST(libio_la)
1134 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1135 dnl We must stage the required headers so that they will be installed
1136 dnl with the library (unlike libgcc, the STL implementation is provided
1137 dnl solely within headers).  Since we must not inject random user-space
1138 dnl macro names into user-provided C++ code, we first stage into <file>-in
1139 dnl and process to <file> with an output command.  The reason for a two-
1140 dnl stage process here is to correctly handle $srcdir!=$objdir without
1141 dnl having to write complex code (the sed commands to clean the macro
1142 dnl namespace are complex and fragile enough as it is).  We must also
1143 dnl add a relative path so that -I- is supported properly.
1145 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1146   AC_MSG_CHECKING([for thread model used by GCC])
1147   target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1148   AC_MSG_RESULT([$target_thread_file])
1150   if test $target_thread_file != single; then
1151     AC_DEFINE(HAVE_GTHR_DEFAULT)
1152     AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1153   fi
1155   glibcpp_thread_h=gthr-$target_thread_file.h
1156   AC_SUBST(glibcpp_thread_h)
1161 dnl Check for exception handling support.  If an explicit enable/disable
1162 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1163 dnl target may or may not support call frame exceptions.
1165 dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1166 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1167 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1169 dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1171 AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1172   AC_MSG_CHECKING([for exception model to use])
1173   AC_LANG_SAVE
1174   AC_LANG_CPLUSPLUS
1175   AC_ARG_ENABLE(sjlj-exceptions,
1176   [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1177   [:],
1178   [dnl Botheration.  Now we've got to detect the exception model.
1179    dnl Link tests against libgcc.a are problematic since -- at least
1180    dnl as of this writing -- we've not been given proper -L bits for
1181    dnl single-tree newlib and libgloss.
1182    dnl
1183    dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1184    dnl conftest files before we got a change to grep them first.
1185    cat > conftest.$ac_ext << EOF
1186 [#]line __oline__ "configure"
1187 struct S { ~S(); };
1188 void bar();
1189 void foo()
1191   S s;
1192   bar();
1195    old_CXXFLAGS="$CXXFLAGS"  
1196    CXXFLAGS=-S
1197    if AC_TRY_EVAL(ac_compile); then
1198      if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1199        enable_sjlj_exceptions=yes
1200      elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1201        enable_sjlj_exceptions=no
1202      fi
1203    fi
1204    CXXFLAGS="$old_CXXFLAGS"
1205    rm -f conftest*])
1206    if test x$enable_sjlj_exceptions = xyes; then
1207      AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1208         [Define if the compiler is configured for setjmp/longjmp exceptions.])
1209      ac_exception_model_name=sjlj
1210    elif test x$enable_sjlj_exceptions = xno; then
1211      ac_exception_model_name="call frame"
1212    else
1213      AC_MSG_ERROR([unable to detect exception model])
1214    fi
1215    AC_LANG_RESTORE
1216    AC_MSG_RESULT($ac_exception_model_name)
1221 dnl Check for ISO/IEC 9899:1999 "C99" support.
1223 dnl GLIBCPP_ENABLE_C99
1224 dnl --enable-c99 defines _GLIBCPP_USE_C99
1225 dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1226 dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1227 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1228 dnl       defaults to `no'.
1229 dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1231 dnl GLIBCPP_ENABLE_C99
1232 AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1233   define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1235   AC_ARG_ENABLE(c99,
1236   changequote(<<, >>)dnl
1237   <<--enable-c99      turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1238   changequote([, ])dnl
1239   [case "$enableval" in
1240    yes) enable_c99=yes ;;
1241    no)  enable_c99=no ;;
1242    *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1243    esac],
1244   enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1246   AC_LANG_SAVE
1247   AC_LANG_CPLUSPLUS
1249   # Check for the existence of <math.h> functions used if C99 is enabled.
1250   ac_c99_math=yes;
1251   AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1252   AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1253   AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1254   AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1255   AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1256   AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1257   AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1258   AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1259   AC_TRY_COMPILE([#include <math.h>],
1260                  [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1261   AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1262   AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1263   AC_TRY_COMPILE([#include <math.h>],
1264                  [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1265   AC_TRY_COMPILE([#include <math.h>],
1266                  [isunordered(0.0,0.0);],, [ac_c99_math=no])
1267   AC_MSG_RESULT($ac_c99_math)
1269   # Check for the existence in <stdio.h> of vscanf, et. al.
1270   ac_c99_stdio=yes;
1271   AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1272   AC_TRY_COMPILE([#include <stdio.h>],
1273                  [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
1274   AC_TRY_COMPILE([#include <stdio.h>
1275                   #include <stdarg.h>
1276                   void foo(char* fmt, ...)
1277                   {va_list args; va_start(args, fmt);
1278                   vfscanf(stderr, "%i", args);}],
1279                   [],, [ac_c99_stdio=no])       
1280   AC_TRY_COMPILE([#include <stdio.h>
1281                   #include <stdarg.h>
1282                   void foo(char* fmt, ...)
1283                   {va_list args; va_start(args, fmt);
1284                   vscanf("%i", args);}],
1285                   [],, [ac_c99_stdio=no])
1286   AC_TRY_COMPILE([#include <stdio.h>
1287                   #include <stdarg.h>
1288                   void foo(char* fmt, ...)
1289                   {va_list args; va_start(args, fmt);
1290                   vsnprintf(fmt, 0, "%i", args);}],
1291                   [],, [ac_c99_stdio=no])
1292   AC_TRY_COMPILE([#include <stdio.h>
1293                   #include <stdarg.h>
1294                   void foo(char* fmt, ...)
1295                   {va_list args; va_start(args, fmt);
1296                   vsscanf(fmt, "%i", args);}],
1297                   [],, [ac_c99_stdio=no])
1298   AC_MSG_RESULT($ac_c99_stdio)
1300   # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1301   ac_c99_stdlib=yes;
1302   AC_MSG_CHECKING([for lldiv_t declaration])
1303   AC_CACHE_VAL(ac_c99_lldiv_t, [
1304   AC_TRY_COMPILE([#include <stdlib.h>], 
1305                    [ lldiv_t mydivt;], 
1306                    [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1307   ])
1308   AC_MSG_RESULT($ac_c99_lldiv_t)
1310   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1311   AC_TRY_COMPILE([#include <stdlib.h>],
1312                  [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1313   AC_TRY_COMPILE([#include <stdlib.h>],
1314                  [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1315   AC_TRY_COMPILE([#include <stdlib.h>],
1316                  [char* tmp; strtoll("gnu", &tmp, 10);],, [ac_c99_stdlib=no])
1317   AC_TRY_COMPILE([#include <stdlib.h>],
1318                  [char* tmp; strtoull("gnu", &tmp, 10);],, [ac_c99_stdlib=no])
1319   AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1320   AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1321   AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1322   AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1323   if test x"$ac_c99_lldiv_t" = x"no"; then
1324     ac_c99_stdlib=no; 
1325   fi; 
1326   AC_MSG_RESULT($ac_c99_stdlib)
1328   # Check for the existence of <wchar.h> functions used if C99 is enabled.
1329   # XXX the wchar.h checks should be rolled into the general C99 bits.
1330   ac_c99_wchar=yes;
1331   AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1332   AC_TRY_COMPILE([#include <wchar.h>], 
1333                  [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1334   AC_TRY_COMPILE([#include <wchar.h>], 
1335                  [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1336   AC_TRY_COMPILE([#include <wchar.h>], 
1337                  [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1338   AC_MSG_RESULT($ac_c99_wchar)
1340   AC_MSG_CHECKING([for enabled ISO C99 support])
1341   if test x"$ac_c99_math" = x"no" || test x"$ac_c99_stdio" = x"no" \
1342       || test x"$ac_c99_stdlib" = x"no" \
1343       || test x"$ac_c99_wchar" = x"no"; then
1344     enable_c99=no; 
1345   fi; 
1346   AC_MSG_RESULT($enable_c99)
1348   # Option parsed, now set things appropriately
1349   if test x"$enable_c99" = x"yes"; then
1350     AC_DEFINE(_GLIBCPP_USE_C99)
1351   fi
1353   AC_LANG_RESTORE
1358 dnl Check for template specializations for the 'long long' type extension.
1359 dnl NB: Must check for C99 support before calling _GLIBCPP_ENABLE_LONG_LONG
1361 dnl GLIBCPP_ENABLE_LONG_LONG
1362 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1363 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1364 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1365 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1366 dnl       defaults to `no'.
1367 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1369 dnl GLIBCPP_ENABLE_LONG_LONG
1370 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1371   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1373   AC_ARG_ENABLE(long-long,
1374   changequote(<<, >>)dnl
1375   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1376   changequote([, ])dnl
1377   [case "$enableval" in
1378    yes) enable_long_long=yes ;;
1379    no)  enable_long_long=no ;;
1380    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1381    esac],
1382   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1384   # iostreams require strtoll, strtoull to compile. If the
1385   # GLIBCPP_ENABLE_C99 tests found these, and if C99 support is enabled,
1386   # go ahead and allow long long to be used.
1387   if test x"$enable_c99" = x"no"; then
1388     enable_long_long=no; 
1389   fi
1391   # Option parsed, now set things appropriately
1392   AC_MSG_CHECKING([for enabled long long support])
1393   if test x"$enable_long_long" = xyes; then
1394     AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1395   fi
1396   AC_MSG_RESULT($enable_long_long)
1401 dnl Check for what kind of C headers to use.
1403 dnl GLIBCPP_ENABLE_CHEADERS
1404 dnl --enable-cheaders= [does stuff].
1405 dnl --disable-cheaders [does not do anything, really].
1406 dnl  +  This will eventually need to be 'c_shadow' by default.
1407 dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1408 dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1409 dnl       If ommitted, it defaults to `c_std'.
1410 AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1411 define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1412 AC_MSG_CHECKING([for c header strategy to use])
1413 AC_ARG_ENABLE(cheaders,
1414 changequote(<<, >>)dnl
1415 <<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1416 changequote([, ])
1417   [case "$enableval" in
1418    c) 
1419         enable_cheaders=c 
1420         ;;
1421    c_std)  
1422         enable_cheaders=c_std 
1423         ;;
1424    c_shadow)  
1425         enable_cheaders=c_shadow 
1426         ;;
1427    *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1428         ;;
1429   esac],
1430   enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1431   AC_MSG_RESULT($enable_cheaders)
1433   dnl Option parsed, now set things appropriately
1434   case "$enable_cheaders" in
1435     c_shadow) 
1436         CSHADOW_FLAGS="-fno-builtin"
1437         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
1438         AC_DEFINE(_GLIBCPP_USE_SHADOW_HEADERS)
1439         ;;
1440     c_std)   
1441         CSHADOW_FLAGS=""
1442         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1443         ;;
1444     c)   
1445         CSHADOW_FLAGS=""
1446         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1447         ;;
1448   esac
1450   AC_SUBST(CSHADOW_FLAGS)
1451   AC_SUBST(C_INCLUDE_DIR)
1452   AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cheaders" = c_shadow)
1457 dnl Check for wide character support.  Has the same effect as the option
1458 dnl in gcc's configure, but in a form that autoconf can mess with.
1460 dnl GLIBCPP_ENABLE_C_MBCHAR
1461 dnl --enable-c-mbchar requests all the wchar_t stuff.
1462 dnl --disable-c-mbchar doesn't.
1463 dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1464 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1465 dnl       defaults to `no'.
1466 AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1467 define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1468 AC_ARG_ENABLE(c-mbchar,
1469 changequote(<<, >>)dnl
1470 <<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1471 changequote([, ])dnl
1472 [case "$enableval" in
1473  yes) enable_c_mbchar=yes ;;
1474  no)  enable_c_mbchar=no ;;
1475  *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1476  esac],
1477 enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1478 dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1483 dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1485 dnl TOPLEVEL_INCLUDES
1486 dnl LIBMATH_INCLUDES
1487 dnl LIBSUPCXX_INCLUDES
1488 dnl LIBIO_INCLUDES
1489 dnl CSHADOW_INCLUDES
1491 dnl GLIBCPP_EXPORT_INCLUDES
1492 AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1493   # Root level of the build directory include sources.
1494   GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1496   # Passed down for canadian crosses.
1497   if test x"$CANADIAN" = xyes; then
1498     TOPLEVEL_INCLUDES='-I$(includedir)'
1499   fi
1501   LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1503   LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1505   if test x"$need_libio" = xyes; then
1506     LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1507     AC_SUBST(LIBIO_INCLUDES)
1508   fi
1510   # Now, export this to all the little Makefiles....
1511   AC_SUBST(GLIBCPP_INCLUDES)
1512   AC_SUBST(TOPLEVEL_INCLUDES)
1513   AC_SUBST(LIBMATH_INCLUDES)
1514   AC_SUBST(LIBSUPCXX_INCLUDES)
1519 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1521 AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1522   # Optimization flags that are probably a good idea for thrill-seekers. Just
1523   # uncomment the lines below and make, everything else is ready to go... 
1524   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1525   OPTIMIZE_CXXFLAGS=
1526   AC_SUBST(OPTIMIZE_CXXFLAGS)
1528   WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1529   AC_SUBST(WARN_FLAGS)
1533 dnl  GLIBCPP_EXPORT_INSTALL_INFO
1534 dnl  calculates gxx_install_dir
1535 dnl  exports glibcpp_toolexecdir
1536 dnl  exports glibcpp_toolexeclibdir
1537 dnl  exports glibcpp_builddir
1538 dnl  exports glibcpp_srcdir
1539 dnl  exports glibcpp_prefixdir
1541 dnl Assumes cross_compiling bits already done, and with_cross_host in
1542 dnl particular
1544 dnl GLIBCPP_EXPORT_INSTALL_INFO
1545 AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1547 glibcpp_toolexecdir=no
1548 glibcpp_toolexeclibdir=no
1550 # Export build and source directories.
1551 # These need to be absolute paths, yet at the same time need to
1552 # canonicalize only relative paths, because then amd will not unmount
1553 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
1554 glibcpp_builddir=`pwd`
1555 case $srcdir in
1556 [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
1557 *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
1558 esac
1559 glibcpp_prefixdir=${prefix}
1561 AC_MSG_CHECKING([for interface version number])
1562 libstdcxx_interface=$INTERFACE
1563 AC_MSG_RESULT($libstdcxx_interface)
1565 # Process the option --with-gxx-include-dir=<path to include-files directory>
1566 AC_MSG_CHECKING([for --with-gxx-include-dir])
1567 AC_ARG_WITH(gxx-include-dir,
1568 [  --with-gxx-include-dir  the installation directory for include files],
1569 [case "${withval}" in
1570   yes)
1571     AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1572     gxx_include_dir=no
1573     ;;
1574   no)
1575     gxx_include_dir=no
1576     ;;
1577   *)
1578     gxx_include_dir=${withval}
1579     ;;
1580 esac], [gxx_include_dir=no])
1581 AC_MSG_RESULT($gxx_include_dir)
1583 # Process the option "--enable-version-specific-runtime-libs"
1584 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1585 AC_ARG_ENABLE(version-specific-runtime-libs,
1586 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1587 [case "$enableval" in
1588  yes) version_specific_libs=yes ;;
1589  no)  version_specific_libs=no ;;
1590  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1591  esac],
1592 version_specific_libs=no)dnl
1593 # Option set, now we can test it.
1594 AC_MSG_RESULT($version_specific_libs)
1596 if test $version_specific_libs = yes; then
1597   # Need the gcc compiler version to know where to install libraries
1598   # and header files if --enable-version-specific-runtime-libs option
1599   # is selected.
1600   changequote(,)dnl
1601   gcc_version_trigger=${srcdir}/../gcc/version.c
1602   gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
1603   gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
1604   gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/g++
1605   glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1606   glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1607   changequote([,])dnl
1610 # Default case for install directory for include files.
1611 if test $version_specific_libs = no &&
1612    test $gxx_include_dir = no; then
1613   gxx_include_dir='$(prefix)'/include/g++-${libstdcxx_interface}
1616 # Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
1617 # Install a library built with a cross compiler in tooldir, not libdir.
1618 if test x"$glibcpp_toolexecdir" = x"no"; then 
1619   if test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
1620     glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1621     glibcpp_toolexeclibdir='$(toolexecdir)/lib$(MULTISUBDIR)'
1622   else
1623     glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1624     glibcpp_toolexeclibdir='$(libdir)$(MULTISUBDIR)'
1625   fi
1628 AC_MSG_CHECKING([for install location])
1629 AC_MSG_RESULT($gxx_include_dir)
1631 AC_SUBST(glibcpp_builddir)
1632 AC_SUBST(glibcpp_srcdir)
1633 AC_SUBST(glibcpp_prefixdir)
1634 AC_SUBST(gxx_include_dir)
1635 AC_SUBST(glibcpp_toolexecdir)
1636 AC_SUBST(glibcpp_toolexeclibdir)
1640 # Check whether LC_MESSAGES is available in <locale.h>.
1641 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1643 # This file file be copied and used freely without restrictions.  It can
1644 # be used in projects which are not available under the GNU Public License
1645 # but which still want to provide support for the GNU gettext functionality.
1646 # Please note that the actual code is *not* freely available.
1648 # serial 1
1650 AC_DEFUN(AC_LC_MESSAGES, [
1651   AC_CHECK_HEADER(locale.h, [
1652     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
1653       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1654        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
1655     if test $ac_cv_val_LC_MESSAGES = yes; then
1656       AC_DEFINE(HAVE_LC_MESSAGES)
1657     fi
1658   ])
1662 # Check for functions in math library.
1663 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1665 # This file can be copied and used freely without restrictions.  It can
1666 # be used in projects which are not available under the GNU Public License
1667 # but which still want to provide support for the GNU gettext functionality.
1668 # Please note that the actual code is *not* freely available.
1670 # serial 1
1672 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1673 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1674 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1675 AC_SUBST(LIBMATHOBJS)dnl
1679 # Check for string functions.
1680 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1682 # This file can be copied and used freely without restrictions.  It can
1683 # be used in projects which are not available under the GNU Public License
1684 # but which still want to provide support for the GNU gettext functionality.
1685 # Please note that the actual code is *not* freely available.
1687 # serial 1
1689 dnl AC_REPLACE_STRINGFUNCS(FUNCTION...)
1690 AC_DEFUN(AC_REPLACE_STRINGFUNCS,
1691 [AC_CHECK_FUNCS([$1], , [LIBSTRINGOBJS="$LIBSTRINGOBJS ${ac_func}.lo"])
1692 AC_SUBST(LIBSTRINGOBJS)dnl
1696 dnl This macro searches for a GNU version of make.  If a match is found, the
1697 dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1698 dnl set to "#". This is useful for  including a special features in a Makefile,
1699 dnl which cannot be handled by other versions of make.  The variable
1700 dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1701 dnl the empty string otherwise.
1703 dnl Here is an example of its use:
1705 dnl Makefile.in might contain:
1707 dnl     # A failsafe way of putting a dependency rule into a makefile
1708 dnl     $(DEPEND):
1709 dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1711 dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1712 dnl     @ifGNUmake@ include $(DEPEND)
1713 dnl     @ifGNUmake@ endif
1715 dnl Then configure.in would normally contain:
1717 dnl     CHECK_GNU_MAKE()
1718 dnl     AC_OUTPUT(Makefile)
1720 dnl Then perhaps to cause gnu make to override any other make, we could do
1721 dnl something like this (note that GNU make always looks for GNUmakefile first):
1723 dnl     if  ! test x$_cv_gnu_make_command = x ; then
1724 dnl             mv Makefile GNUmakefile
1725 dnl             echo .DEFAULT: > Makefile ;
1726 dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1727 dnl     fi
1729 dnl Then, if any (well almost any) other make is called, and GNU make also
1730 dnl exists, then the other make wraps the GNU make.
1732 dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1733 dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1735 dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1736 dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1737 dnl #### conditional's subshell (" --version" is not a command), using a
1738 dnl #### different option to grep(1).
1739 dnl #### -pme
1740 dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
1741 dnl #### ${MAKE:-make}).
1742 dnl #### -msokolov
1743 AC_DEFUN(
1744   GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1745           _cv_gnu_make_command='' ;
1746 dnl Search all the common names for GNU make
1747           for a in "${MAKE-make}" make gmake gnumake ; do
1748                   if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
1749                   then
1750                           _cv_gnu_make_command=$a ;
1751                           break;
1752                   fi
1753           done ;
1754   ) ;
1755 dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1756 dnl string, '#' otherwise
1757   if test  "x$_cv_gnu_make_command" != "x"  ; then
1758           ifGNUmake='' ;
1759   else
1760           ifGNUmake='#' ;
1761   fi
1762   AC_SUBST(ifGNUmake)
1766 dnl Check for headers for, and arguments to, the setrlimit() function.
1767 dnl Used only in testsuite_hooks.h.
1768 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
1769   AC_TRY_COMPILE([#include <sys/resource.h>
1770                   #include <unistd.h>
1771                  ], [ int f = RLIMIT_$1 ; ],
1772                  [glibcpp_mresult=1], [glibcpp_mresult=0])
1773   AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
1774                      [Only used in build directory testsuite_hooks.h.])
1776 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
1777   setrlimit_have_headers=yes
1778   AC_CHECK_HEADERS(sys/resource.h unistd.h,
1779                    [],
1780                    setrlimit_have_headers=no)
1781   # If don't have the headers, then we can't run the tests now, and we
1782   # won't be seeing any of these during testsuite compilation.
1783   if test $setrlimit_have_headers = yes; then
1784     # Can't do these in a loop, else the resulting syntax is wrong.
1785     GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
1786     GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
1787     GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
1788     GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
1790     # Check for rlimit, setrlimit.
1791     AC_CACHE_VAL(ac_setrlimit, [
1792       AC_TRY_COMPILE([#include <sys/resource.h>
1793                       #include <unistd.h>
1794                      ],
1795                      [ struct rlimit r; setrlimit(0, &r);],
1796                      [ac_setrlimit=yes], [ac_setrlimit=no])
1797     ])
1798   fi
1800   AC_MSG_CHECKING([for testsuite memory limit support])
1801   if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
1802     ac_mem_limits=yes
1803     AC_DEFINE(_GLIBCPP_MEM_LIMITS)
1804   else
1805     ac_mem_limits=no
1806   fi
1807   AC_MSG_RESULT($ac_mem_limits)
1812 dnl Does any necessary configuration of the testsuite directory.  Generates
1813 dnl the testsuite_hooks.h header.
1815 dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
1816 AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
1817   GLIBCPP_CHECK_SETRLIMIT
1821 sinclude(../libtool.m4)
1822 dnl The lines below arrange for aclocal not to bring an installed
1823 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
1824 dnl add a definition of LIBTOOL to Makefile.in.
1825 ifelse(,,,[AC_SUBST(LIBTOOL)
1826 AC_DEFUN([AM_PROG_LIBTOOL])
1827 AC_DEFUN([AC_LIBTOOL_DLOPEN])
1828 AC_DEFUN([AC_PROG_LD])