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