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