Update version
[official-gcc.git] / libstdc++-v3 / aclocal.m4
blobfa7bcf7fd5303b23c6c202c77c951b90d06798e2
1 dnl aclocal.m4 generated automatically by aclocal 1.4
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.
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.
13 dnl
14 dnl Initialize configure bits.
15 dnl
16 dnl GLIBCPP_CONFIGURE
17 AC_DEFUN(GLIBCPP_CONFIGURE, [
18   dnl Default to --enable-multilib
19   AC_ARG_ENABLE(multilib,
20   [  --enable-multilib       build hella library versions (default)],
21   [case "${enableval}" in
22     yes) multilib=yes ;;
23     no)  multilib=no ;;
24     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
25    esac], [multilib=yes])dnl
27   glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
28   AC_SUBST(glibcpp_basedir)
30   AM_INIT_AUTOMAKE(libstdc++, 3.0.0)
32   # Never versions of autoconf add an underscore to these functions.
33   # Prevent future problems ...
34   ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
35   ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
36   ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
37   ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
39 #  AC_PROG_CC
41 # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
42 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
43 # are probably using a cross compiler, which will not be able to fully
44 # link an executable.  This should really be fixed in autoconf
45 # itself.
47 AC_DEFUN(LIB_AC_PROG_CC,
48 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
49 dnl Fool anybody using AC_PROG_CC.
50 AC_PROVIDE([AC_PROG_CC])
51 AC_CHECK_PROG(CC, gcc, gcc)
52 if test -z "$CC"; then
53   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
54   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
57 AC_PROG_CC_GNU
59 if test $ac_cv_prog_gcc = yes; then
60   GCC=yes
61 dnl Check whether -g works, even if CFLAGS is set, in case the package
62 dnl plays around with CFLAGS (such as to build both debugging and
63 dnl normal versions of a library), tasteless as that idea is.
64   ac_test_CFLAGS="${CFLAGS+set}"
65   ac_save_CFLAGS="$CFLAGS"
66   CFLAGS=
67   AC_PROG_CC_G
68   if test "$ac_test_CFLAGS" = set; then
69     CFLAGS="$ac_save_CFLAGS"
70   elif test $ac_cv_prog_cc_g = yes; then
71     CFLAGS="-g -O2"
72   else
73     CFLAGS="-O2"
74   fi
75 else
76   GCC=
77   test "${CFLAGS+set}" = set || CFLAGS="-g"
81 LIB_AC_PROG_CC
83 # Can't just call these here as g++ requires libstc++ to be built....
84 #  AC_PROG_CXX
86 # Likewise for AC_PROG_CXX.
87 AC_DEFUN(LIB_AC_PROG_CXX,
88 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
89 dnl Fool anybody using AC_PROG_CXX.
90 AC_PROVIDE([AC_PROG_CXX])
91 # Use glibcpp_CXX so that we do not cause CXX to be cached with the
92 # flags that come in CXX while configuring libstdc++.  They're different
93 # from those used for all other target libraries.  If CXX is set in
94 # the environment, respect that here.
95 glibcpp_CXX=$CXX
96 AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
97 AC_SUBST(glibcpp_CXX)
98 CXX=$glibcpp_CXX
99 test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
101 AC_PROG_CXX_GNU
103 if test $ac_cv_prog_gxx = yes; then
104   GXX=yes
105 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
106 dnl plays around with CXXFLAGS (such as to build both debugging and
107 dnl normal versions of a library), tasteless as that idea is.
108   ac_test_CXXFLAGS="${CXXFLAGS+set}"
109   ac_save_CXXFLAGS="$CXXFLAGS"
110   CXXFLAGS=
111   AC_PROG_CXX_G
112   if test "$ac_test_CXXFLAGS" = set; then
113     CXXFLAGS="$ac_save_CXXFLAGS"
114   elif test $ac_cv_prog_cxx_g = yes; then
115     CXXFLAGS="-g -O2"
116   else
117     CXXFLAGS="-O2"
118   fi
119 else
120   GXX=
121   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
125 LIB_AC_PROG_CXX
127   AC_CHECK_TOOL(AS, as)
128   AC_CHECK_TOOL(AR, ar)
129   AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
130   AC_PROG_INSTALL
132   AM_MAINTAINER_MODE
134   # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
135   # at least currently, we never actually build a program, so we never
136   # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
137   # fails, because we are probably configuring with a cross compiler
138   # which cant create executables.  So we include AC_EXEEXT to keep
139   # automake happy, but we dont execute it, since we dont care about
140   # the result.
141   if false; then
142     # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
143     # to nothing, so nothing would remain between `then' and `fi' if it
144     # were not for the `:' below.
145     :
146     AC_EXEEXT
147   fi
149   . [$]{glibcpp_basedir}/configure.host
151   case [$]{glibcpp_basedir} in
152     /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
153     *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
154   esac
156   # This does for the target what configure.host does for the host.  In
157   # addition to possibly modifying the same flags, it also sets up symlinks.
158   GLIBCPP_CHECK_TARGET
163 dnl Check to see if g++ can compile this library, and if so, if any version-
164 dnl specific precautions need to be taken. 
165 dnl 
166 dnl GLIBCPP_CHECK_COMPILER_VERSION
167 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
168 if test ! -f stamp-sanity-compiler; then
169   AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
170   AC_LANG_SAVE
171   AC_LANG_CPLUSPLUS
172   AC_TRY_COMPILE(, [
173   #if __GNUC__ < 3
174     not_ok
175   #endif
176   ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
177   AC_LANG_RESTORE
178   AC_MSG_RESULT($gpp_satisfactory)
179   touch stamp-sanity-compiler
185 dnl Tests for newer compiler features, or features that are present in newer
186 dnl compiler versions but not older compiler versions still in use, should
187 dnl be placed here.
189 dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
190 dnl new inlining code or the new system_header pragma will die on -Werror.
191 dnl Leave it out by default and use maint-mode to use it.
193 dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
194 dnl compiler supports it and the user has not requested debug mode.
196 dnl GLIBCPP_CHECK_COMPILER_FEATURES
197 AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
198   # All these tests are for C++; save the language and the compiler flags.
199   # The CXXFLAGS thing is suspicious, but based on similar bits previously
200   # found in GLIBCPP_CONFIGURE.
201   AC_LANG_SAVE
202   AC_LANG_CPLUSPLUS
203   ac_test_CXXFLAGS="${CXXFLAGS+set}"
204   ac_save_CXXFLAGS="$CXXFLAGS"
206   # Check for maintainer-mode bits.
207   if test x"$USE_MAINTAINER_MODE" = xno; then
208     WERROR=''
209   else
210     WERROR='-Werror'
211   fi
213   # Check for -ffunction-sections -fdata-sections
214   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
215   CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
216   AC_TRY_COMPILE(, [int foo;
217   ], [ac_fdsections=yes], [ac_fdsections=no])
218   if test "$ac_test_CXXFLAGS" = set; then
219     CXXFLAGS="$ac_save_CXXFLAGS"
220   else
221     # this is the suspicious part
222     CXXFLAGS=''
223   fi
224   if test x"$ac_fdsections" = x"yes" && test x"$enable_debug" = x"no"; then
225     SECTION_FLAGS='-ffunction-sections -fdata-sections'
226   fi
227   AC_MSG_RESULT($ac_fdsections)
229   AC_LANG_RESTORE
230   AC_SUBST(WERROR)
231   AC_SUBST(SECTION_FLAGS)
236 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
237 dnl the native linker is in use, all variables will be defined to something
238 dnl safe (like an empty string).
240 dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
241 dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
243 dnl GLIBCPP_CHECK_LINKER_FEATURES
244 AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
245   # If we're not using GNU ld, then there's no point in even trying these
246   # tests.  Check for that first.  We should have already tested for gld
247   # by now (in libtool), but require it now just to be safe...
248   SECTION_LDFLAGS=''
249   OPT_LDFLAGS=''
250   AC_REQUIRE([AC_PROG_LD])
252   # Set --gc-sections.
253   if test "$ac_cv_prog_gnu_ld" = "notbroken"; then
254     # GNU ld it is!  Joy and bunny rabbits!
256     # All these tests are for C++; save the language and the compiler flags.
257     # Need to do this so that g++ won't try to link in libstdc++
258     ac_test_CFLAGS="${CFLAGS+set}"
259     ac_save_CFLAGS="$CFLAGS"
260     CFLAGS='-x c++  -Wl,--gc-sections'
262     # Check for -Wl,--gc-sections
263     # XXX This test is broken at the moment, as symbols required for
264     # linking are now in libsupc++ (not built yet.....). In addition, 
265     # this test has cored on solaris in the past. In addition,
266     # --gc-sections doesn't really work at the moment (keeps on discarding
267     # used sections, first .eh_frame and now some of the glibc sections for
268     # iconv). Bzzzzt. Thanks for playing, maybe next time.
269     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
270     AC_TRY_RUN([
271      int main(void) 
272      {
273        try { throw 1; }
274        catch (...) { };
275        return 0;
276      }
277     ], [ac_sectionLDflags=yes],[ac_sectionLFflags=no], [ac_sectionLDflags=yes])
278     if test "$ac_test_CFLAGS" = set; then
279       CFLAGS="$ac_save_CFLAGS"
280     else
281       # this is the suspicious part
282       CFLAGS=''
283     fi
284     if test "$ac_sectionLDflags" = "yes"; then
285       SECTION_LDFLAGS='-Wl,--gc-sections'
286     fi
287     AC_MSG_RESULT($ac_sectionLDflags)
288   fi
290   # Set linker optimization flags.
291   if test x"$ac_cv_prog_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
292     OPT_LDFLAGS='-Wl,-O1'
293   fi
295   AC_SUBST(SECTION_LDFLAGS)
296   AC_SUBST(OPT_LDFLAGS)
301 dnl Check to see if the (math function) argument passed is
302 dnl declared when using the c++ compiler
303 dnl ASSUMES argument is a math function with ONE parameter
305 dnl GLIBCPP_CHECK_MATH_DECL_1
306 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
307   AC_MSG_CHECKING([for $1 declaration])
308   if test x${glibcpp_cv_func_$1_use+set} != xset; then
309     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
310       AC_LANG_SAVE
311       AC_LANG_CPLUSPLUS
312       AC_TRY_COMPILE([#include <math.h>
313                       #ifdef HAVE_IEEEFP_H
314                       #include <ieeefp.h>
315                       #endif
316                      ], 
317                      [ $1(0);], 
318                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
319       AC_LANG_RESTORE
320     ])
321   fi
322   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
326 dnl Check to see if the (math function) argument passed is
327 dnl 1) declared when using the c++ compiler
328 dnl 2) has "C" linkage
329 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
331 dnl Define HAVE_CARGF etc if "cargf" is declared and links
333 dnl argument 1 is name of function to check
335 dnl ASSUMES argument is a math function with ONE parameter
337 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
338 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
339   GLIBCPP_CHECK_MATH_DECL_1($1)
340   if test x$glibcpp_cv_func_$1_use = x"yes"; then
341     AC_CHECK_FUNCS($1)    
342   else
343     GLIBCPP_CHECK_MATH_DECL_1(_$1)
344     if test x$glibcpp_cv_func__$1_use = x"yes"; then
345       AC_CHECK_FUNCS(_$1)    
346     fi  
347   fi
352 dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
353 dnl of functions at once.  It's an all-or-nothing check -- either 
354 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
355 dnl Doing it this way saves significant configure time.
356 AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
357   AC_MSG_CHECKING([for $1 functions])
358   AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
359     AC_LANG_SAVE
360     AC_LANG_CPLUSPLUS
361     AC_TRY_COMPILE([#include <math.h>],
362                    [ `for x in $3; do echo "$x (0);"; done` ],
363                    [glibcpp_cv_func_$2_use=yes],
364                    [glibcpp_cv_func_$2_use=no])
365     AC_LANG_RESTORE])
366   AC_MSG_RESULT($glibcpp_cv_func_$2_use)
367   if test x$glibcpp_cv_func_$2_use = x"yes"; then
368     AC_CHECK_FUNCS($3)
369   fi
373 dnl Check to see if the (math function) argument passed is
374 dnl declared when using the c++ compiler
375 dnl ASSUMES argument is a math function with TWO parameters
377 dnl GLIBCPP_CHECK_MATH_DECL_2
378 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
379   AC_MSG_CHECKING([for $1 declaration])
380   if test x${glibcpp_cv_func_$1_use+set} != xset; then
381     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
382       AC_LANG_SAVE
383       AC_LANG_CPLUSPLUS
384       AC_TRY_COMPILE([#include <math.h>], 
385                      [ $1(0, 0);], 
386                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
387       AC_LANG_RESTORE
388     ])
389   fi
390   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
394 dnl Check to see if the (math function) argument passed is
395 dnl 1) declared when using the c++ compiler
396 dnl 2) has "C" linkage
398 dnl Define HAVE_CARGF etc if "cargf" is declared and links
400 dnl argument 1 is name of function to check
402 dnl ASSUMES argument is a math function with TWO parameters
404 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
405 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
406   GLIBCPP_CHECK_MATH_DECL_2($1)
407   if test x$glibcpp_cv_func_$1_use = x"yes"; then
408     AC_CHECK_FUNCS($1)    
409   else
410     GLIBCPP_CHECK_MATH_DECL_2(_$1)
411     if test x$glibcpp_cv_func__$1_use = x"yes"; then
412       AC_CHECK_FUNCS(_$1)    
413     fi  
414   fi
419 dnl Check to see if the (math function) argument passed is
420 dnl declared when using the c++ compiler
421 dnl ASSUMES argument is a math function with THREE parameters
423 dnl GLIBCPP_CHECK_MATH_DECL_3
424 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
425   AC_MSG_CHECKING([for $1 declaration])
426   if test x${glibcpp_cv_func_$1_use+set} != xset; then
427     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
428       AC_LANG_SAVE
429       AC_LANG_CPLUSPLUS
430       AC_TRY_COMPILE([#include <math.h>], 
431                      [ $1(0, 0, 0);], 
432                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
433       AC_LANG_RESTORE
434     ])
435   fi
436   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
440 dnl Check to see if the (math function) argument passed is
441 dnl 1) declared when using the c++ compiler
442 dnl 2) has "C" linkage
444 dnl Define HAVE_CARGF etc if "cargf" is declared and links
446 dnl argument 1 is name of function to check
448 dnl ASSUMES argument is a math function with THREE parameters
450 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
451 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
452   GLIBCPP_CHECK_MATH_DECL_3($1)
453   if test x$glibcpp_cv_func_$1_use = x"yes"; then
454     AC_CHECK_FUNCS($1)    
455   else
456     GLIBCPP_CHECK_MATH_DECL_3(_$1)
457     if test x$glibcpp_cv_func__$1_use = x"yes"; then
458       AC_CHECK_FUNCS(_$1)    
459     fi  
460   fi
465 dnl Check to see if the (stdlib function) argument passed is
466 dnl 1) declared when using the c++ compiler
467 dnl 2) has "C" linkage
469 dnl argument 1 is name of function to check
471 dnl ASSUMES argument is a math function with TWO parameters
473 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
474 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
475   AC_MSG_CHECKING([for $1 declaration])
476   if test x${glibcpp_cv_func_$1_use+set} != xset; then
477     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
478       AC_LANG_SAVE
479       AC_LANG_CPLUSPLUS
480       AC_TRY_COMPILE([#include <stdlib.h>], 
481                      [ $1(0, 0);], 
482                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
483       AC_LANG_RESTORE
484     ])
485   fi
486   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
487   if test x$glibcpp_cv_func_$1_use = x"yes"; then
488     AC_CHECK_FUNCS($1)    
489   fi
494 dnl Because the builtins are picky picky picky about the arguments they take, 
495 dnl do an explict linkage tests here.
496 dnl Check to see if the (math function) argument passed is
497 dnl 1) declared when using the c++ compiler
498 dnl 2) has "C" linkage
500 dnl Define HAVE_CARGF etc if "cargf" is declared and links
502 dnl argument 1 is name of function to check
504 dnl ASSUMES argument is a math function with ONE parameter
506 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
507 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
508   AC_MSG_CHECKING([for $1 declaration])
509   if test x${glibcpp_cv_func_$1_use+set} != xset; then
510     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
511       AC_LANG_SAVE
512       AC_LANG_CPLUSPLUS
513       AC_TRY_COMPILE([#include <math.h>], 
514                      [ $1(0);], 
515                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
516       AC_LANG_RESTORE
517     ])
518   fi
519   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
520   if test x$glibcpp_cv_func_$1_use = x"yes"; then
521     AC_MSG_CHECKING([for $1 linkage])
522     if test x${glibcpp_cv_func_$1_link+set} != xset; then
523       AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
524         AC_TRY_LINK([#include <math.h>], 
525                     [ $1(0);], 
526                     [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
527       ])
528     fi
529     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
530     if test x$glibcpp_cv_func_$1_link = x"yes"; then
531       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
532       AC_DEFINE_UNQUOTED(${ac_tr_func})
533     fi
534   fi
539 dnl Check to see what builtin math functions are supported
541 dnl check for __builtin_abs
542 dnl check for __builtin_fabsf
543 dnl check for __builtin_fabs
544 dnl check for __builtin_fabl
545 dnl check for __builtin_labs
546 dnl check for __builtin_sqrtf
547 dnl check for __builtin_sqrtl
548 dnl check for __builtin_fsqrt
549 dnl check for __builtin_sinf
550 dnl check for __builtin_sin
551 dnl check for __builtin_sinl
552 dnl check for __builtin_cosf
553 dnl check for __builtin_cos
554 dnl check for __builtin_cosl
556 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
557 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
558   dnl Test for builtin math functions.
559   dnl These are made in gcc/c-common.c 
560   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
561   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
562   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
563   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
564   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
566   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
567   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fsqrt)
568   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
570   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
571   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
572   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
574   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
575   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
576   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
578   dnl There is, without a doubt, a more elegant way to have these
579   dnl names exported so that they won't be stripped out of acconfig.h by
580   dnl autoheader. I leave this as an exercise to somebody less frustrated
581   dnl than I.... please email the libstdc++ list if you can figure out a
582   dnl more elegant approach (see autoconf/acgen.m4 and specifically
583   dnl AC_CHECK_FUNC for things to steal.)
584   dummyvar=no
585   if test x$dummyvar = x"yes"; then
586     AC_DEFINE(HAVE___BUILTIN_ABS)
587     AC_DEFINE(HAVE___BUILTIN_LABS)
588     AC_DEFINE(HAVE___BUILTIN_COS)
589     AC_DEFINE(HAVE___BUILTIN_COSF)
590     AC_DEFINE(HAVE___BUILTIN_COSL)
591     AC_DEFINE(HAVE___BUILTIN_FABS)
592     AC_DEFINE(HAVE___BUILTIN_FABSF)
593     AC_DEFINE(HAVE___BUILTIN_FABSL)
594     AC_DEFINE(HAVE___BUILTIN_SIN)
595     AC_DEFINE(HAVE___BUILTIN_SINF)
596     AC_DEFINE(HAVE___BUILTIN_SINL)
597     AC_DEFINE(HAVE___BUILTIN_FSQRT)
598     AC_DEFINE(HAVE___BUILTIN_SQRTF)
599     AC_DEFINE(HAVE___BUILTIN_SQRTL)
600   fi
605 dnl Check to see what the underlying c library 
606 dnl These checks need to do two things: 
607 dnl 1) make sure the name is declared when using the c++ compiler
608 dnl 2) make sure the name has "C" linkage
609 dnl This might seem like overkill but experience has shown that it's not...
611 dnl Define HAVE_STRTOLD if "strtold" is declared and links
612 dnl Define HAVE_STRTOF if "strtof" is declared and links
613 dnl Define HAVE_DRAND48 if "drand48" is declared and links
615 dnl GLIBCPP_CHECK_STDLIB_SUPPORT
616 AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
617   ac_test_CXXFLAGS="${CXXFLAGS+set}"
618   ac_save_CXXFLAGS="$CXXFLAGS"
619   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
621   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
622   AC_CHECK_FUNCS(drand48)
624   CXXFLAGS="$ac_save_CXXFLAGS"
629 dnl Check to see what the underlying c library or math library is like.
630 dnl These checks need to do two things: 
631 dnl 1) make sure the name is declared when using the c++ compiler
632 dnl 2) make sure the name has "C" linkage
633 dnl This might seem like overkill but experience has shown that it's not...
635 dnl Define HAVE_CARGF etc if "cargf" is found.
637 dnl GLIBCPP_CHECK_MATH_SUPPORT
638 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
639   ac_test_CXXFLAGS="${CXXFLAGS+set}"
640   ac_save_CXXFLAGS="$CXXFLAGS"
641   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
643   dnl Check libm
644   AC_CHECK_LIB(m, sin, libm="-lm")
645   ac_save_LIBS="$LIBS"
646   LIBS="$LIBS $libm"
648   dnl Check to see if certain C math functions exist.
649   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
650   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
651   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
652   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
653   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
654   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
655   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
656   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
658   dnl Check to see if basic C math functions have float versions.
659   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
660                                           float_trig,
661                                           acosf asinf atanf \
662                                           cosf sinf tanf \
663                                           coshf sinhf tanhf)
664   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
665                                           float_round,
666                                           ceilf floorf)
667   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
668   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
669   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
670   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
671   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
672   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
673   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
674   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
675   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
676   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
677   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
678   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
679   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
680   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
681   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
683   dnl Check to see if basic C math functions have long double versions.
684   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
685                                           long_double_trig,
686                                           acosl asinl atanl \
687                                           cosl sinl tanl \
688                                           coshl sinhl tanhl)
689   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
690                                           long_double_round,
691                                           ceill floorl)
692   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
693   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
694   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
695   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
696   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
697   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
698   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
699   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
700   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
701   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
702   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
703   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
704   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
705   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
706   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
707   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
708   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
710   dnl Some runtimes have these functions with a preceding underscore. Please
711   dnl keep this sync'd with the one above. And if you add any new symbol,
712   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
713   dnl Check to see if certain C math functions exist.
715   dnl Check to see if basic C math functions have float versions.
716   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
717                                           _float_trig,
718                                           _acosf _asinf _atanf \
719                                           _cosf _sinf _tanf \
720                                           _coshf _sinhf _tanhf)
721   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
722                                           _float_round,
723                                           _ceilf _floorf)
725   dnl Check to see if basic C math functions have long double versions.
726   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
727                                           _long_double_trig,
728                                           _acosl _asinl _atanl \
729                                           _cosl _sinl _tanl \
730                                           _coshl _sinhl _tanhl)
731   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
732                                           _long_double_round,
733                                           _ceill _floorl)
735   LIBS="$ac_save_LIBS"
736   CXXFLAGS="$ac_save_CXXFLAGS"
741 dnl Check to see if there is native support for complex 
743 dnl Don't compile bits in math/* if native support exits.
745 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
747 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
748 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
749   dnl Check for complex versions of math functions of platform.
750   AC_CHECK_LIB(m, main)
751   AC_REPLACE_MATHFUNCS(nan copysignf)
753   dnl Compile the long double complex functions only if the function 
754   dnl provides the non-complex long double functions that are needed.
755   dnl Currently this includes copysignl, which should be
756   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
757   USE_COMPLEX_LONG_DOUBLE=no
758   if test x$ac_cv_func_copysignl = x"yes"; then
759     USE_COMPLEX_LONG_DOUBLE=yes
760     AC_REPLACE_MATHFUNCS(signbitl)
761   fi
763   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
767 dnl Check to see what architecture and operating system we are compiling
768 dnl for.  Also, if architecture- or OS-specific flags are required for
769 dnl compilation, pick them up here.
770 dnl 
771 dnl GLIBCPP_CHECK_TARGET
772 AC_DEFUN(GLIBCPP_CHECK_TARGET, [
773     . [$]{glibcpp_basedir}/configure.target
774     AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
775     AC_MSG_RESULT(OS config directory is $os_include_dir)
780 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
781 dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
782 dnl must have been previously checked.)
784 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
785 dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
787 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
788 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
790   dnl Test wchar.h for mbstate_t, which is needed for char_traits and
791   dnl others even if wchar_t support is not on.
792   AC_MSG_CHECKING([for mbstate_t])
793   AC_TRY_COMPILE([#include <wchar.h>],
794   [mbstate_t teststate;], 
795   have_mbstate_t=yes, have_mbstate_t=no)
796   AC_MSG_RESULT($have_mbstate_t)
797   if test x"$have_mbstate_t" = xyes; then
798     AC_DEFINE(HAVE_MBSTATE_T)
799   fi
801   dnl Sanity check for existence of ISO C99 headers for extended encoding.
802   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
803   AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
804   
805   dnl Only continue checking if the ISO C99 headers exist and support is on.
806   if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes \
807      && test x"$enable_c_mbchar" != xno; then
808       
809     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
810     dnl numeric_limits can instantiate type_traits<wchar_t>
811     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
812     AC_TRY_COMPILE([#include <wchar.h>],
813     [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
814     has_wchar_minmax=yes, has_wchar_minmax=no)
815     AC_MSG_RESULT($has_wchar_minmax)
816     
817     dnl Test wchar.h for WEOF, which is what we use to determine whether
818     dnl to specialize for char_traits<wchar_t> or not.
819     AC_MSG_CHECKING([for WEOF])
820     AC_TRY_COMPILE([
821       #include <wchar.h>
822       #include <stddef.h>],
823     [wint_t i = WEOF;],
824     has_weof=yes, has_weof=no)
825     AC_MSG_RESULT($has_weof)
826   
827     dnl Tests for wide character functions used in char_traits<wchar_t>.
828     ac_wfuncs=yes
829     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
830     ac_wfuncs=no)
831   
832     dnl Checks for names injected into std:: by the c_std headers.
833     AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
834     fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
835     vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
836     mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
837     wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
838     wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
839     ac_wfuncs=no)
841     AC_MSG_CHECKING([for ISO C99 wchar_t support])
842     if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
843        && test x"$ac_wfuncs" = xyes; then
844       ac_isoC99_wchar_t=yes
845     else
846       ac_isoC99_wchar_t=no
847     fi
848     AC_MSG_RESULT($ac_isoC99_wchar_t)
849   
850     dnl Use iconv for wchar_t to char conversions. As such, check for 
851     dnl X/Open Portability Guide, version 2 features (XPG2).
852     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
853     AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
855     dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
856     AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
857     ac_save_LIBS="$LIBS"
858     LIBS="$LIBS $libiconv"
860     AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
861     ac_XPG2funcs=yes, ac_XPG2funcs=no)
862   
863     LIBS="$ac_save_LIBS"
865     AC_MSG_CHECKING([for XPG2 wchar_t support])
866     if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
867        && test x"$ac_XPG2funcs" = xyes; then
868       ac_XPG2_wchar_t=yes
869     else
870       ac_XPG2_wchar_t=no
871     fi
872     AC_MSG_RESULT($ac_XPG2_wchar_t)
873   
874     dnl At the moment, only enable wchar_t specializations if all the
875     dnl above support is present.
876     AC_MSG_CHECKING([for enabled wchar_t specializations])
877     if test x"$ac_isoC99_wchar_t" = xyes \
878     && test x"$ac_XPG2_wchar_t" = xyes; then
879       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
880       AC_MSG_RESULT("yes")
881     else
882       AC_MSG_RESULT("no")
883     fi
884   else
885     dnl Wide characters disabled by the user. 
886     AC_MSG_WARN([wchar_t support disabled.])
887   fi
892 dnl Check for special debugging mode; not for production use.
894 dnl GLIBCPP_ENABLE_DEBUG
895 dnl --enable-debug sets '-ggdb3 -O0'.
896 dnl --disable-debug sets '-g' and whatever optimization options the
897 dnl     compiler can handle.
898 dnl  +  --enable-maintainer-mode automatically defaults this to on.
899 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
900 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
901 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
902 dnl       defaults to `no'.
903 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
904 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
905 AC_ARG_ENABLE(debug,
906 changequote(<<, >>)dnl
907 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
908 changequote([, ])dnl
909 [case "${enableval}" in
910  yes) enable_debug=yes ;;
911  no)  enable_debug=no ;;
912  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
913  esac],
914 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
916 dnl Option parsed, now set things appropriately
917 case "${enable_debug}" in
918     yes) 
919         DEBUG_FLAGS='-O0 -ggdb3'                        
920         ;; 
921     no)   
922         DEBUG_FLAGS='-g'
923         ;;
924 esac
925 AC_SUBST(DEBUG_FLAGS)
930 dnl Check for "unusual" flags to pass to the compiler while building.
932 dnl GLIBCPP_ENABLE_CXX_FLAGS
933 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
934 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
935 dnl     Somehow this same set of flags must be passed when [re]building
936 dnl     libgcc.
937 dnl --disable-cxx-flags passes nothing.
938 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
939 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
940 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
941 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
942 dnl       If "default flags" is an empty string (or "none"), the effect is
943 dnl       the same as --disable or --enable=no.
944 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
945 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
946 AC_ARG_ENABLE(cxx-flags,
947 changequote(<<, >>)dnl
948 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
949                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
950 changequote([, ])dnl
951 [case "x$enableval" in
952  xyes)   
953         AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
954  xno|x)  
955         enable_cxx_flags='' ;;
956  *)      
957         enable_cxx_flags="$enableval" ;;
958  esac],
959 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
961 dnl Thinko on my part during design.  This kludge is the workaround.
962 if test "$enable_cxx_flags" = "none"; then 
963   enable_cxx_flags=''; 
966 dnl Run through flags (either default or command-line) and set anything
967 dnl extra (e.g., #defines) that must accompany particular g++ options.
968 if test -n "$enable_cxx_flags"; then
969     for f in $enable_cxx_flags; do
970         case "$f" in
971             -fhonor-std)  ;;
972             -*)  ;;
973             *)   # and we're trying to pass /what/ exactly?
974                  AC_MSG_ERROR([compiler flags start with a -]) ;;
975         esac
976     done
978 EXTRA_CXX_FLAGS="$enable_cxx_flags"
979 AC_SUBST(EXTRA_CXX_FLAGS)
984 dnl Check for which locale library to use:  gnu or generic.
986 dnl GLIBCPP_ENABLE_CLOCALE
987 dnl --enable-clocale=gnu sets config/c_locale_gnu.cc and friends
988 dnl --enable-clocale=generic sets config/c_locale_generic.cc and friends
989 dnl 
990 dnl default is generic
992 AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
993   AC_MSG_CHECKING([for clocale to use])
994   AC_ARG_ENABLE(clocale,
995   [  --enable-clocale        enable model for target locale package. 
996   --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
997   ], 
998   if test x$enable_clocale = xno; then
999      enable_clocale=generic
1000   fi,
1001      enable_clocale=generic)
1003   enable_clocale_flag=$enable_clocale
1005   dnl Check if a valid locale package
1006   case x${enable_clocale_flag} in
1007     xgnu)
1008       CLOCALE_H=config/c_locale_gnu.h
1009       CLOCALE_CC=config/c_locale_gnu.cc
1010       AC_MSG_RESULT(gnu)
1011       ;;
1012     xgeneric)
1013       CLOCALE_H=config/c_locale_generic.h
1014       CLOCALE_CC=config/c_locale_generic.cc
1015       AC_MSG_RESULT(generic)
1016       ;;
1017     *)
1018       echo "$enable_clocale is an unknown locale package" 1>&2
1019       exit 1
1020       ;;
1021   esac
1023   AC_SUBST(CLOCALE_H)
1024   AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1029 dnl Check for which I/O library to use:  libio, or something specific.
1031 dnl GLIBCPP_ENABLE_CSTDIO
1032 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
1033 dnl 
1034 dnl default is stdio
1036 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1037   AC_MSG_CHECKING([for cstdio to use])
1038   AC_ARG_ENABLE(cstdio,
1039   [  --enable-cstdio         enable stdio for target io package. 
1040   --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
1041   ], 
1042   if test x$enable_cstdio = xno; then
1043      enable_cstdio=stdio
1044   fi,
1045      enable_cstdio=stdio)
1047   enable_cstdio_flag=$enable_cstdio
1049   dnl Check if a valid I/O package
1050   case x${enable_cstdio_flag} in
1051     xlibio)
1052       CSTDIO_H=config/c_io_libio.h
1053       BASIC_FILE_H=config/basic_file_libio.h
1054       BASIC_FILE_CC=config/basic_file_libio.cc
1055       AC_MSG_RESULT(libio)
1057       # see if we are on a system with libio native (ie, linux)
1058       AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1060       # Need to check and see what version of glibc is being used. If
1061       # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1062       # compile most of libio for linux systems.
1063       if test x$has_libio = x"yes"; then
1064         case "$target" in
1065           *-*-linux*)
1066               AC_MSG_CHECKING([for glibc version >= 2.2])
1067               AC_EGREP_CPP([ok], [
1068             #include <features.h>
1069               #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1070                     ok
1071               #endif
1072               ], glibc_satisfactory=yes, glibc_satisfactory=no)
1073               AC_MSG_RESULT($glibc_satisfactory)
1074             ;;
1075         esac
1077         # XXX at the moment, admit defeat and force the recompilation
1078         # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1079         glibc_satisfactory=no        
1081         if test x$glibc_satisfactory = x"yes"; then
1082            need_libio=no
1083            need_wlibio=no        
1084         else
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
1095       else
1096          # Using libio, but <libio.h> doesn't exist on the target system. . .
1097          need_libio=yes
1098          # bkoz XXX need to add checks to enable this
1099          # pme XXX here's a first pass at such a check
1100          if test x$enable_c_mbchar != xno; then
1101              need_wlibio=yes
1102          else
1103              need_wlibio=no
1104          fi
1105       fi
1106       ;;
1107     xstdio | x | xno | xnone | xyes)
1108       # default
1109       CSTDIO_H=config/c_io_stdio.h
1110       BASIC_FILE_H=config/basic_file_stdio.h
1111       BASIC_FILE_CC=config/basic_file_stdio.cc
1112       AC_MSG_RESULT(stdio)
1114       # We're not using stdio.
1115       need_libio=no
1116       need_wlibio=no
1117       ;;
1118     *)
1119       echo "$enable_cstdio is an unknown io package" 1>&2
1120       exit 1
1121       ;;
1122   esac
1123   AC_SUBST(CSTDIO_H)
1124   AC_SUBST(BASIC_FILE_H)
1125   AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
1127   # 2000-08-04 bkoz hack
1128   CCODECVT_C=config/c_io_libio_codecvt.c
1129   AC_SUBST(CCODECVT_C)
1130   # 2000-08-04 bkoz hack
1132   AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1133                  test "$need_libio" = yes || test "$need_wlibio" = yes)
1134   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1135   AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1136   if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1137     libio_la=../libio/libio.la
1138   else
1139     libio_la=
1140   fi
1141   AC_SUBST(libio_la)
1146 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1147 dnl We must stage the required headers so that they will be installed
1148 dnl with the library (unlike libgcc, the STL implementation is provided
1149 dnl solely within headers).  Since we must not inject random user-space
1150 dnl macro names into user-provided C++ code, we first stage into <file>-in
1151 dnl and process to <file> with an output command.  The reason for a two-
1152 dnl stage process here is to correctly handle $srcdir!=$objdir without
1153 dnl having to write complex code (the sed commands to clean the macro
1154 dnl namespace are complex and fragile enough as it is).  We must also
1155 dnl add a relative path so that -I- is supported properly.
1157 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1158   AC_MSG_CHECKING([for thread model used by GCC])
1159   target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1160   AC_MSG_RESULT([$target_thread_file])
1162   if test $target_thread_file != single; then
1163     AC_DEFINE(HAVE_GTHR_DEFAULT)
1164     AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1165   fi
1167   glibcpp_thread_h=gthr-$target_thread_file.h
1168   AC_SUBST(glibcpp_thread_h)
1173 dnl Check for exception handling support.  If an explicit enable/disable
1174 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1175 dnl target may or may not support call frame exceptions.
1177 dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1178 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1179 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1181 dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1183 AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1184   AC_MSG_CHECKING([for exception model to use])
1185   AC_LANG_SAVE
1186   AC_LANG_CPLUSPLUS
1187   AC_ARG_ENABLE(sjlj-exceptions,
1188   [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1189   [:],
1190   [dnl Botheration.  Now we've got to detect the exception model.
1191    dnl Link tests against libgcc.a are problematic since -- at least
1192    dnl as of this writing -- we've not been given proper -L bits for
1193    dnl single-tree newlib and libgloss.
1194    dnl
1195    dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1196    dnl conftest files before we got a change to grep them first.
1197    cat > conftest.$ac_ext << EOF
1198 [#]line __oline__ "configure"
1199 struct S { ~S(); };
1200 void bar();
1201 void foo()
1203   S s;
1204   bar();
1207    old_CXXFLAGS="$CXXFLAGS"  
1208    CXXFLAGS=-S
1209    if AC_TRY_EVAL(ac_compile); then
1210      if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1211        enable_sjlj_exceptions=yes
1212      elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1213        enable_sjlj_exceptions=no
1214      fi
1215    fi
1216    CXXFLAGS="$old_CXXFLAGS"
1217    rm -f conftest*])
1218    if test x$enable_sjlj_exceptions = xyes; then
1219      AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1220         [Define if the compiler is configured for setjmp/longjmp exceptions.])
1221      ac_exception_model_name=sjlj
1222    elif test x$enable_sjlj_exceptions = xno; then
1223      ac_exception_model_name="call frame"
1224    else
1225      AC_MSG_ERROR([unable to detect exception model])
1226    fi
1227    AC_LANG_RESTORE
1228    AC_MSG_RESULT($ac_exception_model_name)
1233 dnl Check for ISO/IEC 9899:1999 "C99" support.
1235 dnl GLIBCPP_ENABLE_C99
1236 dnl --enable-c99 defines _GLIBCPP_USE_C99
1237 dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1238 dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1239 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1240 dnl       defaults to `no'.
1241 dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1243 dnl GLIBCPP_ENABLE_C99
1244 AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1245   define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1247   AC_ARG_ENABLE(c99,
1248   changequote(<<, >>)dnl
1249   <<--enable-c99      turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1250   changequote([, ])dnl
1251   [case "$enableval" in
1252    yes) enable_c99=yes ;;
1253    no)  enable_c99=no ;;
1254    *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1255    esac],
1256   enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1258   AC_LANG_SAVE
1259   AC_LANG_CPLUSPLUS
1261   # Check for the existence of <math.h> functions used if C99 is enabled.
1262   ac_c99_math=yes;
1263   AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1264   AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1265   AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1266   AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1267   AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1268   AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1269   AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1270   AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1271   AC_TRY_COMPILE([#include <math.h>],
1272                  [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1273   AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1274   AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1275   AC_TRY_COMPILE([#include <math.h>],
1276                  [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1277   AC_TRY_COMPILE([#include <math.h>],
1278                  [isunordered(0.0,0.0);],, [ac_c99_math=no])
1279   AC_MSG_RESULT($ac_c99_math)
1281   # Check for the existence in <stdio.h> of vscanf, et. al.
1282   ac_c99_stdio=yes;
1283   AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1284   AC_TRY_COMPILE([#include <stdio.h>],
1285                  [snprintf("12", 0, "%i");],, [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                   vfscanf(stderr, "%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                   vscanf("%i", args);}],
1297                   [],, [ac_c99_stdio=no])
1298   AC_TRY_COMPILE([#include <stdio.h>
1299                   #include <stdarg.h>
1300                   void foo(char* fmt, ...)
1301                   {va_list args; va_start(args, fmt);
1302                   vsnprintf(fmt, 0, "%i", args);}],
1303                   [],, [ac_c99_stdio=no])
1304   AC_TRY_COMPILE([#include <stdio.h>
1305                   #include <stdarg.h>
1306                   void foo(char* fmt, ...)
1307                   {va_list args; va_start(args, fmt);
1308                   vsscanf(fmt, "%i", args);}],
1309                   [],, [ac_c99_stdio=no])
1310   AC_MSG_RESULT($ac_c99_stdio)
1312   # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1313   ac_c99_stdlib=yes;
1314   AC_MSG_CHECKING([for lldiv_t declaration])
1315   AC_CACHE_VAL(ac_c99_lldiv_t, [
1316   AC_TRY_COMPILE([#include <stdlib.h>], 
1317                    [ lldiv_t mydivt;], 
1318                    [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1319   ])
1320   AC_MSG_RESULT($ac_c99_lldiv_t)
1322   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1323   AC_TRY_COMPILE([#include <stdlib.h>],
1324                  [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1325   AC_TRY_COMPILE([#include <stdlib.h>],
1326                  [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1327   AC_TRY_COMPILE([#include <stdlib.h>],
1328                  [char* tmp; strtoll("gnu", &tmp, 10);],, [ac_c99_stdlib=no])
1329   AC_TRY_COMPILE([#include <stdlib.h>],
1330                  [char* tmp; strtoull("gnu", &tmp, 10);],, [ac_c99_stdlib=no])
1331   AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1332   AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1333   AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1334   AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1335   if test x"$ac_c99_lldiv_t" = x"no"; then
1336     ac_c99_stdlib=no; 
1337   fi; 
1338   AC_MSG_RESULT($ac_c99_stdlib)
1340   # Check for the existence of <wchar.h> functions used if C99 is enabled.
1341   # XXX the wchar.h checks should be rolled into the general C99 bits.
1342   ac_c99_wchar=yes;
1343   AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1344   AC_TRY_COMPILE([#include <wchar.h>], 
1345                  [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1346   AC_TRY_COMPILE([#include <wchar.h>], 
1347                  [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1348   AC_TRY_COMPILE([#include <wchar.h>], 
1349                  [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1350   AC_MSG_RESULT($ac_c99_wchar)
1352   AC_MSG_CHECKING([for enabled ISO C99 support])
1353   if test x"$ac_c99_math" = x"no" || test x"$ac_c99_stdio" = x"no" \
1354       || test x"$ac_c99_stdlib" = x"no" \
1355       || test x"$ac_c99_wchar" = x"no"; then
1356     enable_c99=no; 
1357   fi; 
1358   AC_MSG_RESULT($enable_c99)
1360   # Option parsed, now set things appropriately
1361   if test x"$enable_c99" = x"yes"; then
1362     AC_DEFINE(_GLIBCPP_USE_C99)
1363   fi
1365   AC_LANG_RESTORE
1370 dnl Check for template specializations for the 'long long' type extension.
1371 dnl NB: Must check for C99 support before calling _GLIBCPP_ENABLE_LONG_LONG
1373 dnl GLIBCPP_ENABLE_LONG_LONG
1374 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1375 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1376 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1377 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1378 dnl       defaults to `no'.
1379 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1381 dnl GLIBCPP_ENABLE_LONG_LONG
1382 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1383   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1385   AC_ARG_ENABLE(long-long,
1386   changequote(<<, >>)dnl
1387   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1388   changequote([, ])dnl
1389   [case "$enableval" in
1390    yes) enable_long_long=yes ;;
1391    no)  enable_long_long=no ;;
1392    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1393    esac],
1394   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1396   # iostreams require strtoll, strtoull to compile. If the
1397   # GLIBCPP_ENABLE_C99 tests found these, and if C99 support is enabled,
1398   # go ahead and allow long long to be used.
1399   if test x"$enable_c99" = x"no"; then
1400     enable_long_long=no; 
1401   fi
1403   # Option parsed, now set things appropriately
1404   AC_MSG_CHECKING([for enabled long long support])
1405   if test x"$enable_long_long" = xyes; then
1406     AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1407   fi
1408   AC_MSG_RESULT($enable_long_long)
1413 dnl Check for what kind of C headers to use.
1415 dnl GLIBCPP_ENABLE_CHEADERS
1416 dnl --enable-cheaders= [does stuff].
1417 dnl --disable-cheaders [does not do anything, really].
1418 dnl  +  This will eventually need to be 'c_shadow' by default.
1419 dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1420 dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1421 dnl       If ommitted, it defaults to `c_std'.
1422 AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1423 define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1424 AC_MSG_CHECKING([for c header strategy to use])
1425 AC_ARG_ENABLE(cheaders,
1426 changequote(<<, >>)dnl
1427 <<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1428 changequote([, ])
1429   [case "$enableval" in
1430    c) 
1431         enable_cheaders=c 
1432         ;;
1433    c_std)  
1434         enable_cheaders=c_std 
1435         ;;
1436    c_shadow)  
1437         enable_cheaders=c_shadow 
1438         ;;
1439    *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1440         ;;
1441   esac],
1442   enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1443   AC_MSG_RESULT($enable_cheaders)
1445   dnl Option parsed, now set things appropriately
1446   case "$enable_cheaders" in
1447     c_shadow) 
1448         CSHADOW_FLAGS="-fno-builtin"
1449         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
1450         AC_DEFINE(_GLIBCPP_USE_SHADOW_HEADERS)
1451         ;;
1452     c_std)   
1453         CSHADOW_FLAGS=""
1454         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1455         ;;
1456     c)   
1457         CSHADOW_FLAGS=""
1458         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1459         ;;
1460   esac
1462   AC_SUBST(CSHADOW_FLAGS)
1463   AC_SUBST(C_INCLUDE_DIR)
1464   AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cheaders" = c_shadow)
1469 dnl Check for wide character support.  Has the same effect as the option
1470 dnl in gcc's configure, but in a form that autoconf can mess with.
1472 dnl GLIBCPP_ENABLE_C_MBCHAR
1473 dnl --enable-c-mbchar requests all the wchar_t stuff.
1474 dnl --disable-c-mbchar doesn't.
1475 dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1476 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1477 dnl       defaults to `no'.
1478 AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1479 define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1480 AC_ARG_ENABLE(c-mbchar,
1481 changequote(<<, >>)dnl
1482 <<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1483 changequote([, ])dnl
1484 [case "$enableval" in
1485  yes) enable_c_mbchar=yes ;;
1486  no)  enable_c_mbchar=no ;;
1487  *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1488  esac],
1489 enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1490 dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1495 dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1497 dnl TOPLEVEL_INCLUDES
1498 dnl LIBMATH_INCLUDES
1499 dnl LIBSUPCXX_INCLUDES
1500 dnl LIBIO_INCLUDES
1501 dnl CSHADOW_INCLUDES
1503 dnl GLIBCPP_EXPORT_INCLUDES
1504 AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1505   # Root level of the build directory include sources.
1506   GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1508   # Passed down for canadian crosses.
1509   if test x"$CANADIAN" = xyes; then
1510     TOPLEVEL_INCLUDES='-I$(includedir)'
1511   fi
1513   LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1515   LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1517   if test x"$need_libio" = xyes; then
1518     LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1519     AC_SUBST(LIBIO_INCLUDES)
1520   fi
1522   # Now, export this to all the little Makefiles....
1523   AC_SUBST(GLIBCPP_INCLUDES)
1524   AC_SUBST(TOPLEVEL_INCLUDES)
1525   AC_SUBST(LIBMATH_INCLUDES)
1526   AC_SUBST(LIBSUPCXX_INCLUDES)
1531 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1533 AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1534   # Optimization flags that are probably a good idea for thrill-seekers. Just
1535   # uncomment the lines below and make, everything else is ready to go... 
1536   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1537   OPTIMIZE_CXXFLAGS=
1538   AC_SUBST(OPTIMIZE_CXXFLAGS)
1540   WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1541   AC_SUBST(WARN_FLAGS)
1545 dnl  GLIBCPP_EXPORT_INSTALL_INFO
1546 dnl  calculates gxx_install_dir
1547 dnl  exports glibcpp_toolexecdir
1548 dnl  exports glibcpp_toolexeclibdir
1549 dnl  exports glibcpp_builddir
1550 dnl  exports glibcpp_srcdir
1551 dnl  exports glibcpp_prefixdir
1553 dnl Assumes cross_compiling bits already done, and with_cross_host in
1554 dnl particular
1556 dnl GLIBCPP_EXPORT_INSTALL_INFO
1557 AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1559 glibcpp_toolexecdir=no
1560 glibcpp_toolexeclibdir=no
1562 # Export build and source directories.
1563 # These need to be absolute paths, yet at the same time need to
1564 # canonicalize only relative paths, because then amd will not unmount
1565 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
1566 glibcpp_builddir=`pwd`
1567 case $srcdir in
1568 [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
1569 *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
1570 esac
1571 glibcpp_prefixdir=${prefix}
1573 AC_MSG_CHECKING([for interface version number])
1574 libstdcxx_interface=$INTERFACE
1575 AC_MSG_RESULT($libstdcxx_interface)
1577 # Process the option --with-gxx-include-dir=<path to include-files directory>
1578 AC_MSG_CHECKING([for --with-gxx-include-dir])
1579 AC_ARG_WITH(gxx-include-dir,
1580 [  --with-gxx-include-dir  the installation directory for include files],
1581 [case "${withval}" in
1582   yes)
1583     AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1584     gxx_include_dir=no
1585     ;;
1586   no)
1587     gxx_include_dir=no
1588     ;;
1589   *)
1590     gxx_include_dir=${withval}
1591     ;;
1592 esac], [gxx_include_dir=no])
1593 AC_MSG_RESULT($gxx_include_dir)
1595 # Process the option "--enable-version-specific-runtime-libs"
1596 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1597 AC_ARG_ENABLE(version-specific-runtime-libs,
1598 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1599 [case "$enableval" in
1600  yes) version_specific_libs=yes ;;
1601  no)  version_specific_libs=no ;;
1602  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1603  esac],
1604 version_specific_libs=no)dnl
1605 # Option set, now we can test it.
1606 AC_MSG_RESULT($version_specific_libs)
1608 if test $version_specific_libs = yes; then
1609   # Need the gcc compiler version to know where to install libraries
1610   # and header files if --enable-version-specific-runtime-libs option
1611   # is selected.
1612   changequote(,)dnl
1613   gcc_version_trigger=${srcdir}/../gcc/version.c
1614   gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
1615   gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
1616   gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/g++
1617   glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1618   glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1619   changequote([,])dnl
1622 # Default case for install directory for include files.
1623 if test $version_specific_libs = no &&
1624    test $gxx_include_dir = no; then
1625   gxx_include_dir='$(prefix)'/include/g++-${libstdcxx_interface}
1628 # Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
1629 # Install a library built with a cross compiler in tooldir, not libdir.
1630 if test x"$glibcpp_toolexecdir" = x"no"; then 
1631   if test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
1632     glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1633     glibcpp_toolexeclibdir='$(toolexecdir)/lib$(MULTISUBDIR)'
1634   else
1635     glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1636     glibcpp_toolexeclibdir='$(libdir)$(MULTISUBDIR)'
1637   fi
1640 AC_MSG_CHECKING([for install location])
1641 AC_MSG_RESULT($gxx_include_dir)
1643 AC_SUBST(glibcpp_builddir)
1644 AC_SUBST(glibcpp_srcdir)
1645 AC_SUBST(glibcpp_prefixdir)
1646 AC_SUBST(gxx_include_dir)
1647 AC_SUBST(glibcpp_toolexecdir)
1648 AC_SUBST(glibcpp_toolexeclibdir)
1652 # Check whether LC_MESSAGES is available in <locale.h>.
1653 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1655 # This file file be copied and used freely without restrictions.  It can
1656 # be used in projects which are not available under the GNU Public License
1657 # but which still want to provide support for the GNU gettext functionality.
1658 # Please note that the actual code is *not* freely available.
1660 # serial 1
1662 AC_DEFUN(AC_LC_MESSAGES, [
1663   AC_CHECK_HEADER(locale.h, [
1664     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
1665       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1666        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
1667     if test $ac_cv_val_LC_MESSAGES = yes; then
1668       AC_DEFINE(HAVE_LC_MESSAGES)
1669     fi
1670   ])
1674 # Check for functions in math library.
1675 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1677 # This file can be copied and used freely without restrictions.  It can
1678 # be used in projects which are not available under the GNU Public License
1679 # but which still want to provide support for the GNU gettext functionality.
1680 # Please note that the actual code is *not* freely available.
1682 # serial 1
1684 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1685 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1686 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1687 AC_SUBST(LIBMATHOBJS)dnl
1691 # Check for string functions.
1692 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1694 # This file can be copied and used freely without restrictions.  It can
1695 # be used in projects which are not available under the GNU Public License
1696 # but which still want to provide support for the GNU gettext functionality.
1697 # Please note that the actual code is *not* freely available.
1699 # serial 1
1701 dnl AC_REPLACE_STRINGFUNCS(FUNCTION...)
1702 AC_DEFUN(AC_REPLACE_STRINGFUNCS,
1703 [AC_CHECK_FUNCS([$1], , [LIBSTRINGOBJS="$LIBSTRINGOBJS ${ac_func}.lo"])
1704 AC_SUBST(LIBSTRINGOBJS)dnl
1708 dnl This macro searches for a GNU version of make.  If a match is found, the
1709 dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1710 dnl set to "#". This is useful for  including a special features in a Makefile,
1711 dnl which cannot be handled by other versions of make.  The variable
1712 dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1713 dnl the empty string otherwise.
1715 dnl Here is an example of its use:
1717 dnl Makefile.in might contain:
1719 dnl     # A failsafe way of putting a dependency rule into a makefile
1720 dnl     $(DEPEND):
1721 dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1723 dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1724 dnl     @ifGNUmake@ include $(DEPEND)
1725 dnl     @ifGNUmake@ endif
1727 dnl Then configure.in would normally contain:
1729 dnl     CHECK_GNU_MAKE()
1730 dnl     AC_OUTPUT(Makefile)
1732 dnl Then perhaps to cause gnu make to override any other make, we could do
1733 dnl something like this (note that GNU make always looks for GNUmakefile first):
1735 dnl     if  ! test x$_cv_gnu_make_command = x ; then
1736 dnl             mv Makefile GNUmakefile
1737 dnl             echo .DEFAULT: > Makefile ;
1738 dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1739 dnl     fi
1741 dnl Then, if any (well almost any) other make is called, and GNU make also
1742 dnl exists, then the other make wraps the GNU make.
1744 dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1745 dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1747 dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1748 dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1749 dnl #### conditional's subshell (" --version" is not a command), using a
1750 dnl #### different option to grep(1).
1751 dnl #### -pme
1752 dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
1753 dnl #### ${MAKE:-make}).
1754 dnl #### -msokolov
1755 AC_DEFUN(
1756   GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1757           _cv_gnu_make_command='' ;
1758 dnl Search all the common names for GNU make
1759           for a in "${MAKE-make}" make gmake gnumake ; do
1760                   if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
1761                   then
1762                           _cv_gnu_make_command=$a ;
1763                           break;
1764                   fi
1765           done ;
1766   ) ;
1767 dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1768 dnl string, '#' otherwise
1769   if test  "x$_cv_gnu_make_command" != "x"  ; then
1770           ifGNUmake='' ;
1771   else
1772           ifGNUmake='#' ;
1773   fi
1774   AC_SUBST(ifGNUmake)
1778 dnl Check for headers for, and arguments to, the setrlimit() function.
1779 dnl Used only in testsuite_hooks.h.
1780 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
1781   AC_TRY_COMPILE([#include <sys/resource.h>
1782                   #include <unistd.h>
1783                  ], [ int f = RLIMIT_$1 ; ],
1784                  [glibcpp_mresult=1], [glibcpp_mresult=0])
1785   AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
1786                      [Only used in build directory testsuite_hooks.h.])
1788 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
1789   setrlimit_have_headers=yes
1790   AC_CHECK_HEADERS(sys/resource.h unistd.h,
1791                    [],
1792                    setrlimit_have_headers=no)
1793   # If don't have the headers, then we can't run the tests now, and we
1794   # won't be seeing any of these during testsuite compilation.
1795   if test $setrlimit_have_headers = yes; then
1796     # Can't do these in a loop, else the resulting syntax is wrong.
1797     GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
1798     GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
1799     GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
1800     GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
1802     # Check for rlimit, setrlimit.
1803     AC_CACHE_VAL(ac_setrlimit, [
1804       AC_TRY_COMPILE([#include <sys/resource.h>
1805                       #include <unistd.h>
1806                      ],
1807                      [ struct rlimit r; setrlimit(0, &r);],
1808                      [ac_setrlimit=yes], [ac_setrlimit=no])
1809     ])
1810   fi
1812   AC_MSG_CHECKING([for testsuite memory limit support])
1813   if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
1814     ac_mem_limits=yes
1815     AC_DEFINE(_GLIBCPP_MEM_LIMITS)
1816   else
1817     ac_mem_limits=no
1818   fi
1819   AC_MSG_RESULT($ac_mem_limits)
1824 dnl Does any necessary configuration of the testsuite directory.  Generates
1825 dnl the testsuite_hooks.h header.
1827 dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
1828 AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
1829   GLIBCPP_CHECK_SETRLIMIT
1833 sinclude(../libtool.m4)
1834 dnl The lines below arrange for aclocal not to bring an installed
1835 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
1836 dnl add a definition of LIBTOOL to Makefile.in.
1837 ifelse(,,,[AC_SUBST(LIBTOOL)
1838 AC_DEFUN([AM_PROG_LIBTOOL])
1839 AC_DEFUN([AC_LIBTOOL_DLOPEN])
1840 AC_DEFUN([AC_PROG_LD])
1845 # Do all the work for Automake.  This macro actually does too much --
1846 # some checks are only needed if your package does certain things.
1847 # But this isn't really a big deal.
1849 # serial 1
1851 dnl Usage:
1852 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
1854 AC_DEFUN(AM_INIT_AUTOMAKE,
1855 [AC_REQUIRE([AC_PROG_INSTALL])
1856 PACKAGE=[$1]
1857 AC_SUBST(PACKAGE)
1858 VERSION=[$2]
1859 AC_SUBST(VERSION)
1860 dnl test to see if srcdir already configured
1861 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
1862   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
1864 ifelse([$3],,
1865 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
1866 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
1867 AC_REQUIRE([AM_SANITY_CHECK])
1868 AC_REQUIRE([AC_ARG_PROGRAM])
1869 dnl FIXME This is truly gross.
1870 missing_dir=`cd $ac_aux_dir && pwd`
1871 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
1872 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
1873 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
1874 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
1875 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
1876 AC_REQUIRE([AC_PROG_MAKE_SET])])
1879 # Check to make sure that the build environment is sane.
1882 AC_DEFUN(AM_SANITY_CHECK,
1883 [AC_MSG_CHECKING([whether build environment is sane])
1884 # Just in case
1885 sleep 1
1886 echo timestamp > conftestfile
1887 # Do `set' in a subshell so we don't clobber the current shell's
1888 # arguments.  Must try -L first in case configure is actually a
1889 # symlink; some systems play weird games with the mod time of symlinks
1890 # (eg FreeBSD returns the mod time of the symlink's containing
1891 # directory).
1892 if (
1893    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
1894    if test "[$]*" = "X"; then
1895       # -L didn't work.
1896       set X `ls -t $srcdir/configure conftestfile`
1897    fi
1898    if test "[$]*" != "X $srcdir/configure conftestfile" \
1899       && test "[$]*" != "X conftestfile $srcdir/configure"; then
1901       # If neither matched, then we have a broken ls.  This can happen
1902       # if, for instance, CONFIG_SHELL is bash and it inherits a
1903       # broken ls alias from the environment.  This has actually
1904       # happened.  Such a system could not be considered "sane".
1905       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
1906 alias in your environment])
1907    fi
1909    test "[$]2" = conftestfile
1910    )
1911 then
1912    # Ok.
1913    :
1914 else
1915    AC_MSG_ERROR([newly created file is older than distributed files!
1916 Check your system clock])
1918 rm -f conftest*
1919 AC_MSG_RESULT(yes)])
1921 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
1922 dnl The program must properly implement --version.
1923 AC_DEFUN(AM_MISSING_PROG,
1924 [AC_MSG_CHECKING(for working $2)
1925 # Run test in a subshell; some versions of sh will print an error if
1926 # an executable is not found, even if stderr is redirected.
1927 # Redirect stdin to placate older versions of autoconf.  Sigh.
1928 if ($2 --version) < /dev/null > /dev/null 2>&1; then
1929    $1=$2
1930    AC_MSG_RESULT(found)
1931 else
1932    $1="$3/missing $2"
1933    AC_MSG_RESULT(missing)
1935 AC_SUBST($1)])
1937 # Add --enable-maintainer-mode option to configure.
1938 # From Jim Meyering
1940 # serial 1
1942 AC_DEFUN(AM_MAINTAINER_MODE,
1943 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
1944   dnl maintainer-mode is disabled by default
1945   AC_ARG_ENABLE(maintainer-mode,
1946 [  --enable-maintainer-mode enable make rules and dependencies not useful
1947                           (and sometimes confusing) to the casual installer],
1948       USE_MAINTAINER_MODE=$enableval,
1949       USE_MAINTAINER_MODE=no)
1950   AC_MSG_RESULT($USE_MAINTAINER_MODE)
1951   AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
1952   MAINT=$MAINTAINER_MODE_TRUE
1953   AC_SUBST(MAINT)dnl
1957 # Define a conditional.
1959 AC_DEFUN(AM_CONDITIONAL,
1960 [AC_SUBST($1_TRUE)
1961 AC_SUBST($1_FALSE)
1962 if $2; then
1963   $1_TRUE=
1964   $1_FALSE='#'
1965 else
1966   $1_TRUE='#'
1967   $1_FALSE=
1968 fi])
1970 # Like AC_CONFIG_HEADER, but automatically create stamp file.
1972 AC_DEFUN(AM_CONFIG_HEADER,
1973 [AC_PREREQ([2.12])
1974 AC_CONFIG_HEADER([$1])
1975 dnl When config.status generates a header, we must update the stamp-h file.
1976 dnl This file resides in the same directory as the config header
1977 dnl that is generated.  We must strip everything past the first ":",
1978 dnl and everything past the last "/".
1979 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
1980 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
1981 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
1982 <<am_indx=1
1983 for am_file in <<$1>>; do
1984   case " <<$>>CONFIG_HEADERS " in
1985   *" <<$>>am_file "*<<)>>
1986     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
1987     ;;
1988   esac
1989   am_indx=`expr "<<$>>am_indx" + 1`
1990 done<<>>dnl>>)
1991 changequote([,]))])