aclocal.m4 revision 102782
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
609
610dnl
611dnl Because the builtins are picky picky picky about the arguments they take, 
612dnl do an explict linkage tests here.
613dnl Check to see if the (math function) argument passed is
614dnl 1) declared when using the c++ compiler
615dnl 2) has "C" linkage
616dnl
617dnl Define HAVE_CARGF etc if "cargf" is declared and links
618dnl
619dnl argument 1 is name of function to check
620dnl
621dnl ASSUMES argument is a math function with ONE parameter
622dnl
623dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
624AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
625  AC_MSG_CHECKING([for $1 declaration])
626  if test x${glibcpp_cv_func_$1_use+set} != xset; then
627    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
628      AC_LANG_SAVE
629      AC_LANG_CPLUSPLUS
630      AC_TRY_COMPILE([#include <math.h>], 
631                     [ $1(0);], 
632                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
633      AC_LANG_RESTORE
634    ])
635  fi
636  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
637  if test x$glibcpp_cv_func_$1_use = x"yes"; then
638    AC_MSG_CHECKING([for $1 linkage])
639    if test x${glibcpp_cv_func_$1_link+set} != xset; then
640      AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
641        AC_TRY_LINK([#include <math.h>], 
642                    [ $1(0);], 
643                    [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
644      ])
645    fi
646    AC_MSG_RESULT($glibcpp_cv_func_$1_link)
647    if test x$glibcpp_cv_func_$1_link = x"yes"; then
648      ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
649      AC_DEFINE_UNQUOTED(${ac_tr_func})
650    fi
651  fi
652])
653
654
655dnl
656dnl Check to see what builtin math functions are supported
657dnl
658dnl check for __builtin_abs
659dnl check for __builtin_fabsf
660dnl check for __builtin_fabs
661dnl check for __builtin_fabl
662dnl check for __builtin_labs
663dnl check for __builtin_sqrtf
664dnl check for __builtin_sqrtl
665dnl check for __builtin_sqrt
666dnl check for __builtin_sinf
667dnl check for __builtin_sin
668dnl check for __builtin_sinl
669dnl check for __builtin_cosf
670dnl check for __builtin_cos
671dnl check for __builtin_cosl
672dnl
673dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
674AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
675  dnl Test for builtin math functions.
676  dnl These are made in gcc/c-common.c 
677  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
678  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
679  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
680  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
681  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
682
683  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
684  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
685  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
686
687  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
688  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
689  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
690
691  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
692  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
693  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
694
695  dnl There is, without a doubt, a more elegant way to have these
696  dnl names exported so that they won't be stripped out of acconfig.h by
697  dnl autoheader. I leave this as an exercise to somebody less frustrated
698  dnl than I.... please email the libstdc++ list if you can figure out a
699  dnl more elegant approach (see autoconf/acgen.m4 and specifically
700  dnl AC_CHECK_FUNC for things to steal.)
701  dummyvar=no
702  if test x$dummyvar = x"yes"; then
703    AC_DEFINE(HAVE___BUILTIN_ABS)
704    AC_DEFINE(HAVE___BUILTIN_LABS)
705    AC_DEFINE(HAVE___BUILTIN_COS)
706    AC_DEFINE(HAVE___BUILTIN_COSF)
707    AC_DEFINE(HAVE___BUILTIN_COSL)
708    AC_DEFINE(HAVE___BUILTIN_FABS)
709    AC_DEFINE(HAVE___BUILTIN_FABSF)
710    AC_DEFINE(HAVE___BUILTIN_FABSL)
711    AC_DEFINE(HAVE___BUILTIN_SIN)
712    AC_DEFINE(HAVE___BUILTIN_SINF)
713    AC_DEFINE(HAVE___BUILTIN_SINL)
714    AC_DEFINE(HAVE___BUILTIN_SQRT)
715    AC_DEFINE(HAVE___BUILTIN_SQRTF)
716    AC_DEFINE(HAVE___BUILTIN_SQRTL)
717  fi
718])
719
720
721dnl
722dnl Check to see what the underlying c library 
723dnl These checks need to do two things: 
724dnl 1) make sure the name is declared when using the c++ compiler
725dnl 2) make sure the name has "C" linkage
726dnl This might seem like overkill but experience has shown that it's not...
727dnl
728dnl Define HAVE_STRTOLD if "strtold" is declared and links
729dnl Define HAVE_STRTOF if "strtof" is declared and links
730dnl Define HAVE_DRAND48 if "drand48" is declared and links
731dnl
732dnl GLIBCPP_CHECK_STDLIB_SUPPORT
733AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
734  ac_test_CXXFLAGS="${CXXFLAGS+set}"
735  ac_save_CXXFLAGS="$CXXFLAGS"
736  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
737
738  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
739  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
740  AC_CHECK_FUNCS(drand48)
741
742  CXXFLAGS="$ac_save_CXXFLAGS"
743])
744
745
746dnl
747dnl Check to see what the underlying c library or math library is like.
748dnl These checks need to do two things: 
749dnl 1) make sure the name is declared when using the c++ compiler
750dnl 2) make sure the name has "C" linkage
751dnl This might seem like overkill but experience has shown that it's not...
752dnl
753dnl Define HAVE_CARGF etc if "cargf" is found.
754dnl
755dnl GLIBCPP_CHECK_MATH_SUPPORT
756AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
757  ac_test_CXXFLAGS="${CXXFLAGS+set}"
758  ac_save_CXXFLAGS="$CXXFLAGS"
759  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
760
761  dnl Check libm
762  AC_CHECK_LIB(m, sin, libm="-lm")
763  ac_save_LIBS="$LIBS"
764  LIBS="$LIBS $libm"
765
766  dnl Check to see if certain C math functions exist.
767  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
768  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
769  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
770  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
771  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
772  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
773  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
774  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
775
776  dnl Check to see if basic C math functions have float versions.
777  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
778                                          float_trig,
779                                          acosf asinf atanf \
780                                          cosf sinf tanf \
781                                          coshf sinhf tanhf)
782  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
783                                          float_round,
784                                          ceilf floorf)
785  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
786  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
787  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
788  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
789  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
790  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
791  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
792  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
793  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
794  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
795  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
796  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
797  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
798  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
799  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
800  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
801
802  dnl Check to see if basic C math functions have long double versions.
803  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
804                                          long_double_trig,
805                                          acosl asinl atanl \
806                                          cosl sinl tanl \
807                                          coshl sinhl tanhl)
808  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
809                                          long_double_round,
810                                          ceill floorl)
811  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
812  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
813  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
814  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
815  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
816  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
817  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
818  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
819  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
820  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
821  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
822  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
823  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
824  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
825  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
826  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
827  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
828
829  dnl Some runtimes have these functions with a preceding underscore. Please
830  dnl keep this sync'd with the one above. And if you add any new symbol,
831  dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
832  dnl Check to see if certain C math functions exist.
833
834  dnl Check to see if basic C math functions have float versions.
835  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
836                                          _float_trig,
837                                          _acosf _asinf _atanf \
838                                          _cosf _sinf _tanf \
839                                          _coshf _sinhf _tanhf)
840  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
841                                          _float_round,
842                                          _ceilf _floorf)
843
844  dnl Check to see if basic C math functions have long double versions.
845  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
846                                          _long_double_trig,
847                                          _acosl _asinl _atanl \
848                                          _cosl _sinl _tanl \
849                                          _coshl _sinhl _tanhl)
850  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
851                                          _long_double_round,
852                                          _ceill _floorl)
853
854  LIBS="$ac_save_LIBS"
855  CXXFLAGS="$ac_save_CXXFLAGS"
856])
857
858
859dnl
860dnl Check to see if there is native support for complex 
861dnl
862dnl Don't compile bits in math/* if native support exits.
863dnl
864dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
865dnl
866dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
867AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
868  dnl Check for complex versions of math functions of platform.
869  AC_CHECK_LIB(m, main)
870  AC_REPLACE_MATHFUNCS(nan copysignf)
871
872  dnl For __signbit to signbit conversions.
873  AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
874  AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
875
876  dnl Compile the long double complex functions only if the function 
877  dnl provides the non-complex long double functions that are needed.
878  dnl Currently this includes copysignl, which should be
879  dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
880  if test x$ac_cv_func_copysignl = x"yes"; then
881    AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
882  fi
883
884  AC_SUBST(LIBMATHOBJS)
885])
886
887
888dnl Check to see what architecture and operating system we are compiling
889dnl for.  Also, if architecture- or OS-specific flags are required for
890dnl compilation, pick them up here.
891dnl 
892dnl GLIBCPP_CHECK_TARGET
893AC_DEFUN(GLIBCPP_CHECK_TARGET, [
894    . [$]{glibcpp_basedir}/configure.target
895    AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
896    AC_MSG_RESULT(OS config directory is $os_include_dir)
897])
898
899
900dnl
901dnl Check to see if this target can enable the wchar_t parts of libstdc++.
902dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
903dnl must have been previously checked.)
904dnl
905dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
906dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
907dnl
908dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
909AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
910
911  dnl Test wchar.h for mbstate_t, which is needed for char_traits and
912  dnl others even if wchar_t support is not on.
913  AC_MSG_CHECKING([for mbstate_t])
914  AC_TRY_COMPILE([#include <wchar.h>],
915  [mbstate_t teststate;], 
916  have_mbstate_t=yes, have_mbstate_t=no)
917  AC_MSG_RESULT($have_mbstate_t)
918  if test x"$have_mbstate_t" = xyes; then
919    AC_DEFINE(HAVE_MBSTATE_T)
920  fi
921
922  dnl Sanity check for existence of ISO C99 headers for extended encoding.
923  AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
924  AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
925  
926  dnl Only continue checking if the ISO C99 headers exist and support is on.
927  if test x"$ac_has_wchar_h" = xyes &&
928     test x"$ac_has_wctype_h" = xyes &&
929     test x"$enable_c_mbchar" != xno; then
930      
931    dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
932    dnl numeric_limits can instantiate type_traits<wchar_t>
933    AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
934    AC_TRY_COMPILE([#include <wchar.h>],
935    [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
936    has_wchar_minmax=yes, has_wchar_minmax=no)
937    AC_MSG_RESULT($has_wchar_minmax)
938    
939    dnl Test wchar.h for WEOF, which is what we use to determine whether
940    dnl to specialize for char_traits<wchar_t> or not.
941    AC_MSG_CHECKING([for WEOF])
942    AC_TRY_COMPILE([
943      #include <wchar.h>
944      #include <stddef.h>],
945    [wint_t i = WEOF;],
946    has_weof=yes, has_weof=no)
947    AC_MSG_RESULT($has_weof)
948  
949    dnl Tests for wide character functions used in char_traits<wchar_t>.
950    ac_wfuncs=yes
951    AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
952    ac_wfuncs=no)
953  
954    dnl Checks for names injected into std:: by the c_std headers.
955    AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
956    fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
957    vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
958    mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
959    wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
960    wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
961    ac_wfuncs=no)
962
963    AC_MSG_CHECKING([for ISO C99 wchar_t support])
964    if test x"$has_weof" = xyes &&
965       test x"$has_wchar_minmax" = xyes &&
966       test x"$ac_wfuncs" = xyes; then
967      ac_isoC99_wchar_t=yes
968    else
969      ac_isoC99_wchar_t=no
970    fi
971    AC_MSG_RESULT($ac_isoC99_wchar_t)
972  
973    dnl Use iconv for wchar_t to char conversions. As such, check for 
974    dnl X/Open Portability Guide, version 2 features (XPG2).
975    AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
976    AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
977
978    dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
979    AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
980    ac_save_LIBS="$LIBS"
981    LIBS="$LIBS $libiconv"
982
983    AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
984    ac_XPG2funcs=yes, ac_XPG2funcs=no)
985  
986    LIBS="$ac_save_LIBS"
987
988    AC_MSG_CHECKING([for XPG2 wchar_t support])
989    if test x"$ac_has_iconv_h" = xyes &&
990       test x"$ac_has_langinfo_h" = xyes &&
991       test x"$ac_XPG2funcs" = xyes; then
992      ac_XPG2_wchar_t=yes
993    else
994      ac_XPG2_wchar_t=no
995    fi
996    AC_MSG_RESULT($ac_XPG2_wchar_t)
997  
998    dnl At the moment, only enable wchar_t specializations if all the
999    dnl above support is present.
1000    AC_MSG_CHECKING([for enabled wchar_t specializations])
1001    if test x"$ac_isoC99_wchar_t" = xyes &&
1002       test x"$ac_XPG2_wchar_t" = xyes; then
1003      AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
1004      AC_MSG_RESULT("yes")
1005    else
1006      AC_MSG_RESULT("no")
1007    fi
1008  else
1009    dnl Wide characters disabled by the user. 
1010    AC_MSG_WARN([wchar_t support disabled.])
1011  fi
1012])
1013
1014
1015dnl
1016dnl Check for special debugging mode; not for production use.
1017dnl
1018dnl GLIBCPP_ENABLE_DEBUG
1019dnl --enable-debug sets '-ggdb3 -O0'.
1020dnl --disable-debug sets '-g' and whatever optimization options the
1021dnl     compiler can handle.
1022dnl  +  --enable-maintainer-mode automatically defaults this to on.
1023dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
1024dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
1025dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1026dnl       defaults to `no'.
1027AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
1028define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
1029AC_ARG_ENABLE(debug,
1030changequote(<<, >>)dnl
1031<<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
1032changequote([, ])dnl
1033[case "${enableval}" in
1034 yes) enable_debug=yes ;;
1035 no)  enable_debug=no ;;
1036 *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1037 esac],
1038enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1039
1040dnl Option parsed, now set things appropriately
1041case "${enable_debug}" in
1042    yes) 
1043        DEBUG_FLAGS='-O0 -ggdb3'                        
1044        ;; 
1045    no)   
1046        DEBUG_FLAGS='-g'
1047        ;;
1048esac
1049AC_SUBST(DEBUG_FLAGS)
1050])
1051
1052
1053dnl
1054dnl Check for "unusual" flags to pass to the compiler while building.
1055dnl
1056dnl GLIBCPP_ENABLE_CXX_FLAGS
1057dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1058dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1059dnl     Somehow this same set of flags must be passed when [re]building
1060dnl     libgcc.
1061dnl --disable-cxx-flags passes nothing.
1062dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1063dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1064dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
1065dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1066dnl       If "default flags" is an empty string (or "none"), the effect is
1067dnl       the same as --disable or --enable=no.
1068AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1069define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1070AC_ARG_ENABLE(cxx-flags,
1071changequote(<<, >>)dnl
1072<<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
1073                                [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1074changequote([, ])dnl
1075[case "x$enableval" in
1076 xyes)   
1077        AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1078 xno|x)  
1079        enable_cxx_flags='' ;;
1080 *)      
1081        enable_cxx_flags="$enableval" ;;
1082 esac],
1083enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1084
1085dnl Thinko on my part during design.  This kludge is the workaround.
1086if test "$enable_cxx_flags" = "none"; then 
1087  enable_cxx_flags=''; 
1088fi
1089
1090dnl Run through flags (either default or command-line) and set anything
1091dnl extra (e.g., #defines) that must accompany particular g++ options.
1092if test -n "$enable_cxx_flags"; then
1093    for f in $enable_cxx_flags; do
1094        case "$f" in
1095            -fhonor-std)  ;;
1096            -*)  ;;
1097            *)   # and we're trying to pass /what/ exactly?
1098                 AC_MSG_ERROR([compiler flags start with a -]) ;;
1099        esac
1100    done
1101fi
1102EXTRA_CXX_FLAGS="$enable_cxx_flags"
1103AC_SUBST(EXTRA_CXX_FLAGS)
1104])
1105
1106
1107dnl
1108dnl Check for which locale library to use:  gnu or generic.
1109dnl
1110dnl GLIBCPP_ENABLE_CLOCALE
1111dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1112dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
1113dnl 
1114dnl default is generic
1115dnl
1116AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1117  AC_MSG_CHECKING([for clocale to use])
1118  AC_ARG_ENABLE(clocale,
1119  [  --enable-clocale        enable model for target locale package. 
1120  --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
1121  ], 
1122  if test x$enable_clocale = xno; then
1123     enable_clocale=no
1124  fi,
1125     enable_clocale=no)
1126
1127  enable_clocale_flag=$enable_clocale
1128
1129  dnl Probe for locale support if no specific model is specified.
1130  dnl Default to "generic"
1131  if test x$enable_clocale_flag = xno; then
1132    case x${target_os} in
1133      xlinux* | xgnu*)
1134	AC_EGREP_CPP([_GLIBCPP_ok], [
1135        #include <features.h>
1136        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1137          _GLIBCPP_ok
1138        #endif
1139        ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1140
1141	# Test for bugs early in glibc-2.2.x series
1142  	if test x$enable_clocale_flag = xgnu; then
1143    	  AC_TRY_RUN([
1144	  #define _GNU_SOURCE 1
1145	  #include <locale.h>
1146	  int main()
1147	  {
1148  	    const char __one[] = "�uglein Augmen";
1149  	    const char __two[] = "�uglein";
1150  	    int i;
1151  	    int j;
1152  	    __locale_t	loc;
1153   	    __locale_t	loc_dup;
1154  	    loc = __newlocale(1 << LC_ALL, "de_DE", 0);
1155  	    loc_dup = __duplocale(loc);
1156  	    i = __strcoll_l(__one, __two, loc);
1157  	    j = __strcoll_l(__one, __two, loc_dup);
1158  	    return 0;
1159	  }
1160	  ], 
1161	  [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
1162	  [enable_clocale_flag=generic])
1163  	fi
1164
1165	# ... at some point put __strxfrm_l tests in as well.
1166        ;;
1167      *)
1168	enable_clocale_flag=generic
1169	;;
1170    esac
1171  fi
1172
1173  dnl Deal with gettext issues.
1174  AC_ARG_ENABLE(nls,
1175  [  --enable-nls            use Native Language Support (default)],
1176  , enable_nls=yes)
1177  USE_NLS=no
1178
1179  dnl Set configure bits for specified locale package
1180  case x${enable_clocale_flag} in
1181    xgeneric)
1182      AC_MSG_RESULT(generic)
1183
1184      CLOCALE_H=config/locale/generic/c_locale.h
1185      CLOCALE_CC=config/locale/generic/c_locale.cc
1186      CCODECVT_H=config/locale/generic/codecvt_specializations.h
1187      CCOLLATE_CC=config/locale/generic/collate_members.cc
1188      CCTYPE_CC=config/locale/generic/ctype_members.cc
1189      CMESSAGES_H=config/locale/generic/messages_members.h
1190      CMESSAGES_CC=config/locale/generic/messages_members.cc
1191      CMONEY_CC=config/locale/generic/monetary_members.cc
1192      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1193      CTIME_CC=config/locale/generic/time_members.cc
1194      ;;
1195    xgnu)
1196      AC_MSG_RESULT(gnu)
1197
1198      # Declare intention to use gettext, and add support for specific
1199      # languages.
1200      # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
1201      ALL_LINGUAS="de fr"
1202
1203      # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
1204      AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1205      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
1206	USE_NLS=yes
1207      fi
1208      # Export the build objects.
1209      for ling in $ALL_LINGUAS; do \
1210        glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
1211        glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
1212      done
1213      AC_SUBST(glibcpp_MOFILES)
1214      AC_SUBST(glibcpp_POFILES)
1215
1216      CLOCALE_H=config/locale/gnu/c_locale.h
1217      CLOCALE_CC=config/locale/gnu/c_locale.cc
1218      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1219      CCOLLATE_CC=config/locale/gnu/collate_members.cc
1220      CCTYPE_CC=config/locale/gnu/ctype_members.cc
1221      CMESSAGES_H=config/locale/gnu/messages_members.h
1222      CMESSAGES_CC=config/locale/gnu/messages_members.cc
1223      CMONEY_CC=config/locale/gnu/monetary_members.cc
1224      CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1225      CTIME_CC=config/locale/gnu/time_members.cc
1226      ;;
1227    xieee_1003.1-2001)
1228      AC_MSG_RESULT(generic)
1229
1230      CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1231      CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
1232      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1233      CCOLLATE_CC=config/locale/generic/collate_members.cc
1234      CCTYPE_CC=config/locale/generic/ctype_members.cc
1235      CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1236      CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1237      CMONEY_CC=config/locale/generic/monetary_members.cc
1238      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1239      CTIME_CC=config/locale/generic/time_members.cc
1240      ;;
1241    *)
1242      echo "$enable_clocale is an unknown locale package" 1>&2
1243      exit 1
1244      ;;
1245  esac
1246
1247  # This is where the testsuite looks for locale catalogs, using the
1248  # -DLOCALEDIR define during testsuite compilation.
1249  glibcpp_localedir=${glibcpp_builddir}/po/share/locale
1250  AC_SUBST(glibcpp_localedir)
1251
1252  AC_SUBST(USE_NLS)
1253  AC_SUBST(CLOCALE_H)
1254  AC_SUBST(CCODECVT_H)
1255  AC_SUBST(CMESSAGES_H)
1256  AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1257  AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
1258  AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
1259  AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
1260  AC_LINK_FILES($CMONEY_CC, src/monetary.cc)
1261  AC_LINK_FILES($CNUMERIC_CC, src/numeric.cc)
1262  AC_LINK_FILES($CTIME_CC, src/time.cc)
1263])
1264
1265
1266dnl
1267dnl Check for which I/O library to use:  libio, or something specific.
1268dnl
1269dnl GLIBCPP_ENABLE_CSTDIO
1270dnl --enable-cstdio=libio sets config/io/c_io_libio.h and friends
1271dnl 
1272dnl default is stdio
1273dnl
1274AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1275  AC_MSG_CHECKING([for cstdio to use])
1276  AC_ARG_ENABLE(cstdio,
1277  [  --enable-cstdio         enable stdio for target io package. 
1278  --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
1279  ], 
1280  if test x$enable_cstdio = xno; then
1281     enable_cstdio=stdio
1282  fi,
1283     enable_cstdio=stdio)
1284
1285  enable_cstdio_flag=$enable_cstdio
1286
1287  dnl Check if a valid I/O package
1288  case x${enable_cstdio_flag} in
1289    xlibio)
1290      CSTDIO_H=config/io/c_io_libio.h
1291      BASIC_FILE_H=config/io/basic_file_libio.h
1292      BASIC_FILE_CC=config/io/basic_file_libio.cc
1293      AC_MSG_RESULT(libio)
1294
1295      # see if we are on a system with libio native (ie, linux)
1296      AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1297
1298      # Need to check and see what version of glibc is being used. If
1299      # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1300      # compile most of libio for linux systems.
1301      if test x$has_libio = x"yes"; then
1302        case "$target" in
1303          *-*-linux*)
1304              AC_MSG_CHECKING([for glibc version >= 2.2])
1305              AC_EGREP_CPP([ok], [
1306            #include <features.h>
1307              #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1308                    ok
1309              #endif
1310              ], glibc_satisfactory=yes, glibc_satisfactory=no)
1311              AC_MSG_RESULT($glibc_satisfactory)
1312            ;;
1313        esac
1314
1315        # XXX at the moment, admit defeat and force the recompilation
1316        # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1317        glibc_satisfactory=no        
1318
1319        if test x$glibc_satisfactory = x"yes"; then
1320           need_libio=no
1321           need_wlibio=no        
1322        else
1323           need_libio=yes
1324           # bkoz XXX need to add checks to enable this
1325           # pme XXX here's a first pass at such a check
1326           if test x$enable_c_mbchar != xno; then
1327              need_wlibio=yes
1328           else
1329              need_wlibio=no
1330           fi
1331        fi
1332
1333      else
1334         # Using libio, but <libio.h> doesn't exist on the target system. . .
1335         need_libio=yes
1336         # bkoz XXX need to add checks to enable this
1337         # pme XXX here's a first pass at such a check
1338         if test x$enable_c_mbchar != xno; then
1339             need_wlibio=yes
1340         else
1341             need_wlibio=no
1342         fi
1343      fi
1344      ;;
1345    xstdio | x | xno | xnone | xyes)
1346      # default
1347      CSTDIO_H=config/io/c_io_stdio.h
1348      BASIC_FILE_H=config/io/basic_file_stdio.h
1349      BASIC_FILE_CC=config/io/basic_file_stdio.cc
1350      AC_MSG_RESULT(stdio)
1351
1352      # We're not using stdio.
1353      need_libio=no
1354      need_wlibio=no
1355      ;;
1356    *)
1357      echo "$enable_cstdio is an unknown io package" 1>&2
1358      exit 1
1359      ;;
1360  esac
1361  AC_SUBST(CSTDIO_H)
1362  AC_SUBST(BASIC_FILE_H)
1363  AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
1364
1365  # 2000-08-04 bkoz hack
1366  CCODECVT_C=config/io/c_io_libio_codecvt.c
1367  AC_SUBST(CCODECVT_C)
1368  # 2000-08-04 bkoz hack
1369
1370  AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1371                 test "$need_libio" = yes || test "$need_wlibio" = yes)
1372  AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1373  AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1374  if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1375    libio_la=../libio/libio.la
1376  else
1377    libio_la=
1378  fi
1379  AC_SUBST(libio_la)
1380])
1381
1382
1383dnl
1384dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1385dnl We must stage the required headers so that they will be installed
1386dnl with the library (unlike libgcc, the STL implementation is provided
1387dnl solely within headers).  Since we must not inject random user-space
1388dnl macro names into user-provided C++ code, we first stage into <file>-in
1389dnl and process to <file> with an output command.  The reason for a two-
1390dnl stage process here is to correctly handle $srcdir!=$objdir without
1391dnl having to write complex code (the sed commands to clean the macro
1392dnl namespace are complex and fragile enough as it is).  We must also
1393dnl add a relative path so that -I- is supported properly.
1394dnl
1395AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1396  AC_MSG_CHECKING([for thread model used by GCC])
1397  target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1398  AC_MSG_RESULT([$target_thread_file])
1399
1400  if test $target_thread_file != single; then
1401    AC_DEFINE(HAVE_GTHR_DEFAULT)
1402    AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1403  fi
1404
1405  glibcpp_thread_h=gthr-$target_thread_file.h
1406  AC_SUBST(glibcpp_thread_h)
1407])
1408
1409
1410dnl
1411dnl Check for exception handling support.  If an explicit enable/disable
1412dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1413dnl target may or may not support call frame exceptions.
1414dnl
1415dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1416dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1417dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1418dnl
1419dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1420dnl
1421AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1422  AC_MSG_CHECKING([for exception model to use])
1423  AC_LANG_SAVE
1424  AC_LANG_CPLUSPLUS
1425  AC_ARG_ENABLE(sjlj-exceptions,
1426  [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1427  [:],
1428  [dnl Botheration.  Now we've got to detect the exception model.
1429   dnl Link tests against libgcc.a are problematic since -- at least
1430   dnl as of this writing -- we've not been given proper -L bits for
1431   dnl single-tree newlib and libgloss.
1432   dnl
1433   dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1434   dnl conftest files before we got a change to grep them first.
1435   cat > conftest.$ac_ext << EOF
1436[#]line __oline__ "configure"
1437struct S { ~S(); };
1438void bar();
1439void foo()
1440{
1441  S s;
1442  bar();
1443}
1444EOF
1445   old_CXXFLAGS="$CXXFLAGS"  
1446   CXXFLAGS="-S -fexceptions"
1447   if AC_TRY_EVAL(ac_compile); then
1448     if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1449       enable_sjlj_exceptions=yes
1450     elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1451       enable_sjlj_exceptions=no
1452     fi
1453   fi
1454   CXXFLAGS="$old_CXXFLAGS"
1455   rm -f conftest*])
1456   if test x$enable_sjlj_exceptions = xyes; then
1457     AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1458        [Define if the compiler is configured for setjmp/longjmp exceptions.])
1459     ac_exception_model_name=sjlj
1460   elif test x$enable_sjlj_exceptions = xno; then
1461     ac_exception_model_name="call frame"
1462   else
1463     AC_MSG_ERROR([unable to detect exception model])
1464   fi
1465   AC_LANG_RESTORE
1466   AC_MSG_RESULT($ac_exception_model_name)
1467])
1468
1469
1470dnl
1471dnl Check for libunwind exception handling support. If enabled then
1472dnl we assume that the _Unwind_* functions that make up the Unwind ABI
1473dnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
1474dnl libunwind instead of libgcc and that libstdc++ has a dependency
1475dnl on libunwind as well as libgcc.
1476dnl
1477dnl GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
1478dnl --enable-libunwind-exceptions forces the use of libunwind.
1479dnl --disable-libunwind-exceptions assumes there is no libunwind.
1480dnl
1481dnl Define _GLIBCPP_LIBUNWIND_EXCEPTIONS if requested.
1482dnl
1483AC_DEFUN(GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS, [
1484  AC_MSG_CHECKING([for use of libunwind])
1485  AC_ARG_ENABLE(libunwind-exceptions,
1486  [  --enable-libunwind-exceptions  force use of libunwind for exceptions],
1487  use_libunwind_exceptions=$enableval,
1488  use_libunwind_exceptions=no)
1489  AC_MSG_RESULT($use_libunwind_exceptions)
1490  dnl Option parsed, now set things appropriately
1491  if test x"$use_libunwind_exceptions" = xyes; then
1492    LIBUNWIND_FLAG="-lunwind"
1493  else
1494    LIBUNWIND_FLAG=""
1495  fi
1496  AC_SUBST(LIBUNWIND_FLAG)
1497])
1498
1499dnl
1500dnl Check for ISO/IEC 9899:1999 "C99" support.
1501dnl
1502dnl GLIBCPP_ENABLE_C99
1503dnl --enable-c99 defines _GLIBCPP_USE_C99
1504dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1505dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1506dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1507dnl       defaults to `no'.
1508dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1509dnl
1510dnl GLIBCPP_ENABLE_C99
1511AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1512  define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1513
1514  AC_ARG_ENABLE(c99,
1515  changequote(<<, >>)dnl
1516  <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1517  changequote([, ])dnl
1518  [case "$enableval" in
1519   yes) enable_c99=yes ;;
1520   no)  enable_c99=no ;;
1521   *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1522   esac],
1523  enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1524 
1525  AC_LANG_SAVE
1526  AC_LANG_CPLUSPLUS
1527
1528  # Check for the existence of <math.h> functions used if C99 is enabled.
1529  ac_c99_math=yes;
1530  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1531  AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1532  AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1533  AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1534  AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1535  AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1536  AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1537  AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1538  AC_TRY_COMPILE([#include <math.h>],
1539                 [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1540  AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1541  AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1542  AC_TRY_COMPILE([#include <math.h>],
1543	         [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1544  AC_TRY_COMPILE([#include <math.h>],
1545	         [isunordered(0.0,0.0);],, [ac_c99_math=no])
1546  AC_MSG_RESULT($ac_c99_math)
1547
1548  # Check for the existence in <stdio.h> of vscanf, et. al.
1549  ac_c99_stdio=yes;
1550  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1551  AC_TRY_COMPILE([#include <stdio.h>],
1552		 [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
1553  AC_TRY_COMPILE([#include <stdio.h>
1554		  #include <stdarg.h>
1555		  void foo(char* fmt, ...)
1556		  {va_list args; va_start(args, fmt);
1557	          vfscanf(stderr, "%i", args);}],
1558	          [],, [ac_c99_stdio=no])
1559  AC_TRY_COMPILE([#include <stdio.h>
1560		  #include <stdarg.h>
1561		  void foo(char* fmt, ...)
1562		  {va_list args; va_start(args, fmt);
1563	          vscanf("%i", args);}],
1564	          [],, [ac_c99_stdio=no])
1565  AC_TRY_COMPILE([#include <stdio.h>
1566		  #include <stdarg.h>
1567		  void foo(char* fmt, ...)
1568		  {va_list args; va_start(args, fmt);
1569	          vsnprintf(fmt, 0, "%i", args);}],
1570	          [],, [ac_c99_stdio=no])
1571  AC_TRY_COMPILE([#include <stdio.h>
1572		  #include <stdarg.h>
1573		  void foo(char* fmt, ...)
1574		  {va_list args; va_start(args, fmt);
1575	          vsscanf(fmt, "%i", args);}],
1576	          [],, [ac_c99_stdio=no])
1577  AC_MSG_RESULT($ac_c99_stdio)
1578
1579  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1580  ac_c99_stdlib=yes;
1581  AC_MSG_CHECKING([for lldiv_t declaration])
1582  AC_CACHE_VAL(ac_c99_lldiv_t, [
1583  AC_TRY_COMPILE([#include <stdlib.h>], 
1584                   [ lldiv_t mydivt;], 
1585                   [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1586  ])
1587  AC_MSG_RESULT($ac_c99_lldiv_t)
1588
1589  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1590  AC_TRY_COMPILE([#include <stdlib.h>],
1591	         [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1592  AC_TRY_COMPILE([#include <stdlib.h>],
1593	         [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1594  AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1595  AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1596  AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1597  AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1598  if test x"$ac_c99_lldiv_t" = x"no"; then
1599    ac_c99_stdlib=no; 
1600  fi; 
1601  AC_MSG_RESULT($ac_c99_stdlib)
1602
1603  # Check for the existence of <wchar.h> functions used if C99 is enabled.
1604  # XXX the wchar.h checks should be rolled into the general C99 bits.
1605  ac_c99_wchar=yes;
1606  AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1607  AC_TRY_COMPILE([#include <wchar.h>], 
1608	         [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1609  AC_TRY_COMPILE([#include <wchar.h>], 
1610	         [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1611  AC_TRY_COMPILE([#include <wchar.h>], 
1612	         [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1613  AC_MSG_RESULT($ac_c99_wchar)
1614
1615  AC_MSG_CHECKING([for enabled ISO C99 support])
1616  if test x"$ac_c99_math" = x"no" ||
1617     test x"$ac_c99_stdio" = x"no" ||
1618     test x"$ac_c99_stdlib" = x"no" ||
1619     test x"$ac_c99_wchar" = x"no"; then
1620    enable_c99=no; 
1621  fi; 
1622  AC_MSG_RESULT($enable_c99)
1623
1624  # Option parsed, now set things appropriately
1625  if test x"$enable_c99" = x"yes"; then
1626    AC_DEFINE(_GLIBCPP_USE_C99)
1627  fi
1628
1629  AC_LANG_RESTORE
1630])
1631
1632
1633dnl
1634dnl Check for template specializations for the 'long long' type extension.
1635dnl The result determines only whether 'long long' I/O is enabled; things
1636dnl like numeric_limits<> specializations are always available.
1637dnl
1638dnl GLIBCPP_ENABLE_LONG_LONG
1639dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1640dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1641dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1642dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1643dnl       defaults to `no'.
1644dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1645dnl
1646dnl GLIBCPP_ENABLE_LONG_LONG
1647AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1648  define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1649
1650  AC_ARG_ENABLE(long-long,
1651  changequote(<<, >>)dnl
1652  <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1653  changequote([, ])dnl
1654  [case "$enableval" in
1655   yes) enable_long_long=yes ;;
1656   no)  enable_long_long=no ;;
1657   *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1658   esac],
1659  enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1660
1661  AC_LANG_SAVE
1662  AC_LANG_CPLUSPLUS
1663
1664  AC_MSG_CHECKING([for enabled long long I/O support])
1665  # iostreams require strtoll, strtoull to compile
1666  AC_TRY_COMPILE([#include <stdlib.h>],
1667                 [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
1668  AC_TRY_COMPILE([#include <stdlib.h>],
1669                 [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
1670
1671  # Option parsed, now set things appropriately
1672  if test x"$enable_long_long" = xyes; then
1673    AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1674  fi
1675  AC_MSG_RESULT($enable_long_long)
1676
1677  AC_LANG_RESTORE
1678])
1679
1680
1681dnl
1682dnl Check for what kind of C headers to use.
1683dnl
1684dnl GLIBCPP_ENABLE_CHEADERS
1685dnl --enable-cheaders= [does stuff].
1686dnl --disable-cheaders [does not do anything, really].
1687dnl  +  This will eventually need to be 'c_shadow' by default.
1688dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1689dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1690dnl       If ommitted, it defaults to `c_std'.
1691AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1692define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1693AC_MSG_CHECKING([for c header strategy to use])
1694AC_ARG_ENABLE(cheaders,
1695changequote(<<, >>)dnl
1696<<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1697changequote([, ])
1698  [case "$enableval" in
1699   c) 
1700        enable_cheaders=c 
1701        ;;
1702   c_std)  
1703        enable_cheaders=c_std 
1704        ;;
1705   c_shadow)  
1706        enable_cheaders=c_shadow 
1707        ;;
1708   *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1709        ;;
1710  esac],
1711  enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1712  AC_MSG_RESULT($enable_cheaders)
1713
1714  dnl Option parsed, now set things appropriately
1715  case "$enable_cheaders" in
1716    c_shadow) 
1717        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
1718        ;;
1719    c_std)   
1720        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1721        ;;
1722    c)   
1723        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1724        ;;
1725  esac
1726
1727  AC_SUBST(C_INCLUDE_DIR)
1728  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C, test "$enable_cheaders" = c)
1729  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C_STD, test "$enable_cheaders" = c_std)
1730  AM_CONDITIONAL(GLIBCPP_C_HEADERS_COMPATIBILITY, test "$c_compatibility" = yes)
1731])
1732
1733
1734dnl
1735dnl Check for wide character support.  Has the same effect as the option
1736dnl in gcc's configure, but in a form that autoconf can mess with.
1737dnl
1738dnl GLIBCPP_ENABLE_C_MBCHAR
1739dnl --enable-c-mbchar requests all the wchar_t stuff.
1740dnl --disable-c-mbchar doesn't.
1741dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1742dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1743dnl       defaults to `no'.
1744AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1745define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1746AC_ARG_ENABLE(c-mbchar,
1747changequote(<<, >>)dnl
1748<<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1749changequote([, ])dnl
1750[case "$enableval" in
1751 yes) enable_c_mbchar=yes ;;
1752 no)  enable_c_mbchar=no ;;
1753 *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1754 esac],
1755enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1756dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1757])
1758
1759
1760dnl
1761dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1762dnl
1763dnl TOPLEVEL_INCLUDES
1764dnl LIBMATH_INCLUDES
1765dnl LIBSUPCXX_INCLUDES
1766dnl LIBIO_INCLUDES
1767dnl CSHADOW_INCLUDES
1768dnl
1769dnl GLIBCPP_EXPORT_INCLUDES
1770AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1771  # Root level of the build directory include sources.
1772  GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1773
1774  # Passed down for canadian crosses.
1775  if test x"$CANADIAN" = xyes; then
1776    TOPLEVEL_INCLUDES='-I$(includedir)'
1777  fi
1778
1779  LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1780
1781  LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1782
1783  if test x"$need_libio" = xyes; then
1784    LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1785    AC_SUBST(LIBIO_INCLUDES)
1786  fi
1787
1788  # Now, export this to all the little Makefiles....
1789  AC_SUBST(GLIBCPP_INCLUDES)
1790  AC_SUBST(TOPLEVEL_INCLUDES)
1791  AC_SUBST(LIBMATH_INCLUDES)
1792  AC_SUBST(LIBSUPCXX_INCLUDES)
1793])
1794
1795
1796dnl
1797dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1798dnl
1799AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1800  # Optimization flags that are probably a good idea for thrill-seekers. Just
1801  # uncomment the lines below and make, everything else is ready to go... 
1802  # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1803  OPTIMIZE_CXXFLAGS=
1804  AC_SUBST(OPTIMIZE_CXXFLAGS)
1805
1806  WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1807  AC_SUBST(WARN_FLAGS)
1808])
1809
1810dnl
1811dnl  GLIBCPP_EXPORT_INSTALL_INFO
1812dnl  calculates gxx_install_dir
1813dnl  exports glibcpp_toolexecdir
1814dnl  exports glibcpp_toolexeclibdir
1815dnl  exports glibcpp_prefixdir
1816dnl
1817dnl Assumes cross_compiling bits already done, and with_cross_host in
1818dnl particular
1819dnl
1820dnl GLIBCPP_EXPORT_INSTALL_INFO
1821AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1822# Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
1823# exported correctly in GLIBCPP_CONFIGURE.
1824glibcpp_toolexecdir=no
1825glibcpp_toolexeclibdir=no
1826glibcpp_prefixdir=${prefix}
1827
1828# Process the option --with-gxx-include-dir=<path to include-files directory>
1829AC_MSG_CHECKING([for --with-gxx-include-dir])
1830AC_ARG_WITH(gxx-include-dir,
1831[  --with-gxx-include-dir  the installation directory for include files],
1832[case "${withval}" in
1833  yes)
1834    AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1835    gxx_include_dir=no
1836    ;;
1837  no)
1838    gxx_include_dir=no
1839    ;;
1840  *)
1841    gxx_include_dir=${withval}
1842    ;;
1843esac], [gxx_include_dir=no])
1844AC_MSG_RESULT($gxx_include_dir)
1845
1846# Process the option "--enable-version-specific-runtime-libs"
1847AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1848AC_ARG_ENABLE(version-specific-runtime-libs,
1849[  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1850[case "$enableval" in
1851 yes) version_specific_libs=yes ;;
1852 no)  version_specific_libs=no ;;
1853 *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1854 esac],
1855version_specific_libs=no)dnl
1856# Option set, now we can test it.
1857AC_MSG_RESULT($version_specific_libs)
1858
1859# Default case for install directory for include files.
1860if test $version_specific_libs = no && test $gxx_include_dir = no; then
1861  gxx_include_dir='$(prefix)'/include/c++/${gcc_version}
1862fi
1863
1864# Version-specific runtime libs processing.
1865if test $version_specific_libs = yes; then
1866  # Need the gcc compiler version to know where to install libraries
1867  # and header files if --enable-version-specific-runtime-libs option
1868  # is selected.
1869  if test x"$gxx_include_dir" = x"no"; then
1870    gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/c++
1871  fi
1872  glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1873  glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1874fi
1875
1876# Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
1877# Install a library built with a cross compiler in tooldir, not libdir.
1878if test x"$glibcpp_toolexecdir" = x"no"; then 
1879  if test -n "$with_cross_host" &&
1880     test x"$with_cross_host" != x"no"; then
1881    glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1882    glibcpp_toolexeclibdir='$(toolexecdir)/lib$(MULTISUBDIR)'
1883  else
1884    glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1885    glibcpp_toolexeclibdir='$(libdir)$(MULTISUBDIR)'
1886  fi
1887fi
1888
1889AC_MSG_CHECKING([for install location])
1890AC_MSG_RESULT($gxx_include_dir)
1891
1892AC_SUBST(glibcpp_prefixdir)
1893AC_SUBST(gxx_include_dir)
1894AC_SUBST(glibcpp_toolexecdir)
1895AC_SUBST(glibcpp_toolexeclibdir)
1896])
1897
1898
1899# Check for functions in math library.
1900# Ulrich Drepper <drepper@cygnus.com>, 1998.
1901#
1902# This file can be copied and used freely without restrictions.  It can
1903# be used in projects which are not available under the GNU Public License
1904# but which still want to provide support for the GNU gettext functionality.
1905# Please note that the actual code is *not* freely available.
1906
1907# serial 1
1908
1909dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1910AC_DEFUN(AC_REPLACE_MATHFUNCS,
1911[AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])])
1912
1913
1914dnl This macro searches for a GNU version of make.  If a match is found, the
1915dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1916dnl set to "#". This is useful for  including a special features in a Makefile,
1917dnl which cannot be handled by other versions of make.  The variable
1918dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1919dnl the empty string otherwise.
1920dnl
1921dnl Here is an example of its use:
1922dnl
1923dnl Makefile.in might contain:
1924dnl
1925dnl     # A failsafe way of putting a dependency rule into a makefile
1926dnl     $(DEPEND):
1927dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1928dnl
1929dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1930dnl     @ifGNUmake@ include $(DEPEND)
1931dnl     @ifGNUmake@ endif
1932dnl
1933dnl Then configure.in would normally contain:
1934dnl
1935dnl     CHECK_GNU_MAKE()
1936dnl     AC_OUTPUT(Makefile)
1937dnl
1938dnl Then perhaps to cause gnu make to override any other make, we could do
1939dnl something like this (note that GNU make always looks for GNUmakefile first):
1940dnl
1941dnl     if  ! test x$_cv_gnu_make_command = x ; then
1942dnl             mv Makefile GNUmakefile
1943dnl             echo .DEFAULT: > Makefile ;
1944dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1945dnl     fi
1946dnl
1947dnl Then, if any (well almost any) other make is called, and GNU make also
1948dnl exists, then the other make wraps the GNU make.
1949dnl
1950dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1951dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1952dnl
1953dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1954dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1955dnl #### conditional's subshell (" --version" is not a command), using a
1956dnl #### different option to grep(1).
1957dnl #### -pme
1958dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
1959dnl #### ${MAKE:-make}).
1960dnl #### -msokolov
1961AC_DEFUN(
1962  GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1963          _cv_gnu_make_command='' ;
1964dnl Search all the common names for GNU make
1965          for a in "${MAKE-make}" make gmake gnumake ; do
1966                  if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
1967                  then
1968                          _cv_gnu_make_command=$a ;
1969                          break;
1970                  fi
1971          done ;
1972  ) ;
1973dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1974dnl string, '#' otherwise
1975  if test  "x$_cv_gnu_make_command" != "x"  ; then
1976          ifGNUmake='' ;
1977  else
1978          ifGNUmake='#' ;
1979  fi
1980  AC_SUBST(ifGNUmake)
1981])
1982
1983
1984dnl Check for headers for, and arguments to, the setrlimit() function.
1985dnl Used only in testsuite_hooks.h.
1986AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
1987  AC_TRY_COMPILE([#include <sys/resource.h>
1988                  #include <unistd.h>
1989                 ], [ int f = RLIMIT_$1 ; ],
1990                 [glibcpp_mresult=1], [glibcpp_mresult=0])
1991  AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
1992                     [Only used in build directory testsuite_hooks.h.])
1993])
1994AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
1995  setrlimit_have_headers=yes
1996  AC_CHECK_HEADERS(sys/resource.h unistd.h,
1997                   [],
1998                   setrlimit_have_headers=no)
1999  # If don't have the headers, then we can't run the tests now, and we
2000  # won't be seeing any of these during testsuite compilation.
2001  if test $setrlimit_have_headers = yes; then
2002    # Can't do these in a loop, else the resulting syntax is wrong.
2003    GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
2004    GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
2005    GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
2006    GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
2007
2008    # Check for rlimit, setrlimit.
2009    AC_CACHE_VAL(ac_setrlimit, [
2010      AC_TRY_COMPILE([#include <sys/resource.h>
2011		      #include <unistd.h>
2012		     ], 
2013                     [ struct rlimit r; setrlimit(0, &r);], 
2014                     [ac_setrlimit=yes], [ac_setrlimit=no])
2015    ])
2016  fi
2017
2018  AC_MSG_CHECKING([for testsuite memory limit support])
2019  if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
2020    ac_mem_limits=yes
2021    AC_DEFINE(_GLIBCPP_MEM_LIMITS)
2022  else
2023    ac_mem_limits=no
2024  fi
2025  AC_MSG_RESULT($ac_mem_limits)
2026])
2027
2028
2029dnl
2030dnl Does any necessary configuration of the testsuite directory.  Generates
2031dnl the testsuite_hooks.h header.
2032dnl
2033dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
2034AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
2035  GLIBCPP_CHECK_SETRLIMIT
2036
2037  # Look for setenv, so that extended locale tests can be performed.
2038  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
2039
2040  # Export file names for ABI checking.
2041  baseline_file="${glibcpp_srcdir}/config/abi/${abi_baseline_triplet}/baseline_symbols.txt"
2042  AC_SUBST(baseline_file)
2043
2044  # Don't do ABI checking unless native.
2045  AM_CONDITIONAL(GLIBCPP_BUILD_ABI_CHECK,
2046                 test x"$build" = x"$host" && test -z "$with_cross_host")
2047])
2048
2049
2050sinclude(../libtool.m4)
2051dnl The lines below arrange for aclocal not to bring an installed
2052dnl libtool.m4 into aclocal.m4, while still arranging for automake to
2053dnl add a definition of LIBTOOL to Makefile.in.
2054ifelse(,,,[AC_SUBST(LIBTOOL)
2055AC_DEFUN([AM_PROG_LIBTOOL])
2056AC_DEFUN([AC_LIBTOOL_DLOPEN])
2057AC_DEFUN([AC_PROG_LD])
2058])
2059
2060
2061# Check whether LC_MESSAGES is available in <locale.h>.
2062# Ulrich Drepper <drepper@cygnus.com>, 1995.
2063#
2064# This file file be copied and used freely without restrictions.  It can
2065# be used in projects which are not available under the GNU Public License
2066# but which still want to provide support for the GNU gettext functionality.
2067# Please note that the actual code is *not* freely available.
2068
2069# serial 1
2070
2071AC_DEFUN(AC_LC_MESSAGES, [
2072  AC_CHECK_HEADER(locale.h, [
2073    AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
2074      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2075       ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
2076    if test $ac_cv_val_LC_MESSAGES = yes; then
2077      AC_DEFINE(HAVE_LC_MESSAGES)
2078    fi
2079  ])
2080])
2081
2082
2083dnl
2084dnl Check for whether the Boost-derived checks should be turned on.
2085dnl
2086dnl GLIBCPP_ENABLE_CONCEPT_CHECKS
2087dnl --enable-concept-checks turns them on.
2088dnl --disable-concept-checks leaves them off.
2089dnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2090dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2091dnl       defaults to `no'.
2092AC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
2093define([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
2094AC_ARG_ENABLE(concept-checks,
2095changequote(<<, >>)dnl
2096<<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
2097changequote([, ])dnl
2098[case "$enableval" in
2099 yes) enable_concept_checks=yes ;;
2100 no)  enable_concept_checks=no ;;
2101 *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
2102 esac],
2103enable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
2104dnl Option parsed, now set things appropriately
2105if test x"$enable_concept_checks" = xyes; then
2106  AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
2107fi
2108])
2109
2110
2111dnl
2112dnl Add version tags to symbols in shared library (or not), additionally
2113dnl marking other symbols as private/local (or not).
2114dnl
2115dnl GLIBCPP_ENABLE_SYMVERS
2116dnl --enable-symvers=style adds a version script to the linker call when
2117dnl       creating the shared library.  The choice of version script is
2118dnl       controlled by 'style'.
2119dnl --disable-symvers does not.
2120dnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
2121dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2122dnl       defaults to `no'.  Passing `yes' tries to choose a default style
2123dnl       based on linker characteristics.  Passing 'no' disables versioning.
2124AC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
2125define([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
2126AC_ARG_ENABLE(symvers,
2127changequote(<<, >>)dnl
2128<<  --enable-symvers=style  enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
2129changequote([, ])dnl
2130[case "$enableval" in
2131 yes) enable_symvers=yes ;;
2132 no)  enable_symvers=no ;;
2133 # other names here, just as sanity checks
2134 #gnu|sun|etcetera) enable_symvers=$enableval ;;
2135 gnu) enable_symvers=$enableval ;;
2136 *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
2137 esac],
2138enable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
2139
2140# If we never went through the GLIBCPP_CHECK_LINKER_FEATURES macro, then we
2141# don't know enough about $LD to do tricks... 
2142if test x$enable_shared = xno || 
2143	test "x$LD" = x || 
2144	test x$glibcpp_gnu_ld_version = x; then
2145  enable_symvers=no
2146fi
2147
2148# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2149AC_MSG_CHECKING([for shared libgcc])
2150ac_save_CFLAGS="$CFLAGS"
2151CFLAGS=' -lgcc_s'
2152AC_TRY_LINK( , [return 0], glibcpp_shared_libgcc=yes, glibcpp_shared_libgcc=no)
2153CFLAGS="$ac_save_CFLAGS"
2154AC_MSG_RESULT($glibcpp_shared_libgcc)
2155
2156# For GNU ld, we need at least this version.  It's 2.12 in the same format
2157# as the tested-for version.  See GLIBCPP_CHECK_LINKER_FEATURES for more.
2158glibcpp_min_gnu_ld_version=21200
2159
2160# Check to see if unspecified "yes" value can win, given results
2161# above.  
2162if test $enable_symvers = yes ; then
2163  if test $with_gnu_ld = yes &&
2164    test $glibcpp_shared_libgcc = yes ;
2165  then
2166    if test $glibcpp_gnu_ld_version -ge $glibcpp_min_gnu_ld_version ; then
2167        enable_symvers=gnu
2168    else
2169      ac_test_CFLAGS="${CFLAGS+set}"
2170      ac_save_CFLAGS="$CFLAGS"
2171      CFLAGS='-shared -Wl,--version-script,conftest.map'
2172      enable_symvers=no
2173      changequote(,)
2174      echo 'FOO { global: f[a-z]o; local: *; };' > conftest.map
2175      changequote([,])
2176      AC_TRY_LINK([int foo;],, enable_symvers=gnu)
2177      if test "$ac_test_CFLAGS" = set; then
2178	CFLAGS="$ac_save_CFLAGS"
2179      else
2180	# this is the suspicious part
2181	CFLAGS=''
2182      fi
2183      rm -f conftest.map
2184    fi
2185  else
2186    # just fail for now
2187    enable_symvers=no
2188  fi
2189fi
2190
2191dnl Everything parsed; figure out what file to use.
2192case $enable_symvers in
2193  no)
2194      LINKER_MAP=config/linker-map.dummy
2195      ;;
2196  gnu)
2197      LINKER_MAP=config/linker-map.gnu
2198      ;;
2199esac
2200
2201AC_LINK_FILES($LINKER_MAP, src/linker.map)
2202AM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
2203AC_MSG_CHECKING([versioning on shared library symbols])
2204AC_MSG_RESULT($enable_symvers)
2205])
2206
2207
2208# isc-posix.m4 serial 2 (gettext-0.11.2)
2209dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
2210dnl This file is free software, distributed under the terms of the GNU
2211dnl General Public License.  As a special exception to the GNU General
2212dnl Public License, this file may be distributed as part of a program
2213dnl that contains a configuration script generated by Autoconf, under
2214dnl the same distribution terms as the rest of that program.
2215
2216# This file is not needed with autoconf-2.53 and newer.  Remove it in 2005.
2217
2218# This test replaces the one in autoconf.
2219# Currently this macro should have the same name as the autoconf macro
2220# because gettext's gettext.m4 (distributed in the automake package)
2221# still uses it.  Otherwise, the use in gettext.m4 makes autoheader
2222# give these diagnostics:
2223#   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
2224#   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
2225
2226undefine([AC_ISC_POSIX])
2227
2228AC_DEFUN([AC_ISC_POSIX],
2229  [
2230    dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
2231    AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
2232  ]
2233)
2234
2235# Add --enable-maintainer-mode option to configure.
2236# From Jim Meyering
2237
2238# serial 1
2239
2240AC_DEFUN([AM_MAINTAINER_MODE],
2241[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
2242  dnl maintainer-mode is disabled by default
2243  AC_ARG_ENABLE(maintainer-mode,
2244[  --enable-maintainer-mode enable make rules and dependencies not useful
2245                          (and sometimes confusing) to the casual installer],
2246      USE_MAINTAINER_MODE=$enableval,
2247      USE_MAINTAINER_MODE=no)
2248  AC_MSG_RESULT($USE_MAINTAINER_MODE)
2249  AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
2250  MAINT=$MAINTAINER_MODE_TRUE
2251  AC_SUBST(MAINT)dnl
2252]
2253)
2254
2255# Define a conditional.
2256
2257AC_DEFUN([AM_CONDITIONAL],
2258[AC_SUBST($1_TRUE)
2259AC_SUBST($1_FALSE)
2260if $2; then
2261  $1_TRUE=
2262  $1_FALSE='#'
2263else
2264  $1_TRUE='#'
2265  $1_FALSE=
2266fi])
2267
2268# Do all the work for Automake.  This macro actually does too much --
2269# some checks are only needed if your package does certain things.
2270# But this isn't really a big deal.
2271
2272# serial 1
2273
2274dnl Usage:
2275dnl AM_INIT_AUTOMAKE(package,version, [no-define])
2276
2277AC_DEFUN([AM_INIT_AUTOMAKE],
2278[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
2279AC_REQUIRE([AC_PROG_INSTALL])
2280PACKAGE=[$1]
2281AC_SUBST(PACKAGE)
2282VERSION=[$2]
2283AC_SUBST(VERSION)
2284dnl test to see if srcdir already configured
2285if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
2286  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
2287fi
2288ifelse([$3],,
2289AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
2290AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
2291AC_REQUIRE([AM_SANITY_CHECK])
2292AC_REQUIRE([AC_ARG_PROGRAM])
2293dnl FIXME This is truly gross.
2294missing_dir=`cd $ac_aux_dir && pwd`
2295AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir)
2296AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
2297AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir)
2298AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
2299AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
2300AC_REQUIRE([AC_PROG_MAKE_SET])])
2301
2302# Copyright 2002  Free Software Foundation, Inc.
2303
2304# This program is free software; you can redistribute it and/or modify
2305# it under the terms of the GNU General Public License as published by
2306# the Free Software Foundation; either version 2, or (at your option)
2307# any later version.
2308
2309# This program is distributed in the hope that it will be useful,
2310# but WITHOUT ANY WARRANTY; without even the implied warranty of
2311# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2312# GNU General Public License for more details.
2313
2314# You should have received a copy of the GNU General Public License
2315# along with this program; if not, write to the Free Software
2316# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2317
2318# AM_AUTOMAKE_VERSION(VERSION)
2319# ----------------------------
2320# Automake X.Y traces this macro to ensure aclocal.m4 has been
2321# generated from the m4 files accompanying Automake X.Y.
2322AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"])
2323
2324# AM_SET_CURRENT_AUTOMAKE_VERSION
2325# -------------------------------
2326# Call AM_AUTOMAKE_VERSION so it can be traced.
2327# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
2328AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
2329	 [AM_AUTOMAKE_VERSION([1.4-p6])])
2330
2331#
2332# Check to make sure that the build environment is sane.
2333#
2334
2335AC_DEFUN([AM_SANITY_CHECK],
2336[AC_MSG_CHECKING([whether build environment is sane])
2337# Just in case
2338sleep 1
2339echo timestamp > conftestfile
2340# Do `set' in a subshell so we don't clobber the current shell's
2341# arguments.  Must try -L first in case configure is actually a
2342# symlink; some systems play weird games with the mod time of symlinks
2343# (eg FreeBSD returns the mod time of the symlink's containing
2344# directory).
2345if (
2346   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
2347   if test "[$]*" = "X"; then
2348      # -L didn't work.
2349      set X `ls -t $srcdir/configure conftestfile`
2350   fi
2351   if test "[$]*" != "X $srcdir/configure conftestfile" \
2352      && test "[$]*" != "X conftestfile $srcdir/configure"; then
2353
2354      # If neither matched, then we have a broken ls.  This can happen
2355      # if, for instance, CONFIG_SHELL is bash and it inherits a
2356      # broken ls alias from the environment.  This has actually
2357      # happened.  Such a system could not be considered "sane".
2358      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
2359alias in your environment])
2360   fi
2361
2362   test "[$]2" = conftestfile
2363   )
2364then
2365   # Ok.
2366   :
2367else
2368   AC_MSG_ERROR([newly created file is older than distributed files!
2369Check your system clock])
2370fi
2371rm -f conftest*
2372AC_MSG_RESULT(yes)])
2373
2374dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
2375dnl The program must properly implement --version.
2376AC_DEFUN([AM_MISSING_PROG],
2377[AC_MSG_CHECKING(for working $2)
2378# Run test in a subshell; some versions of sh will print an error if
2379# an executable is not found, even if stderr is redirected.
2380# Redirect stdin to placate older versions of autoconf.  Sigh.
2381if ($2 --version) < /dev/null > /dev/null 2>&1; then
2382   $1=$2
2383   AC_MSG_RESULT(found)
2384else
2385   $1="$3/missing $2"
2386   AC_MSG_RESULT(missing)
2387fi
2388AC_SUBST($1)])
2389
2390# Like AC_CONFIG_HEADER, but automatically create stamp file.
2391
2392AC_DEFUN([AM_CONFIG_HEADER],
2393[AC_PREREQ([2.12])
2394AC_CONFIG_HEADER([$1])
2395dnl When config.status generates a header, we must update the stamp-h file.
2396dnl This file resides in the same directory as the config header
2397dnl that is generated.  We must strip everything past the first ":",
2398dnl and everything past the last "/".
2399AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
2400ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
2401<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
2402<<am_indx=1
2403for am_file in <<$1>>; do
2404  case " <<$>>CONFIG_HEADERS " in
2405  *" <<$>>am_file "*<<)>>
2406    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
2407    ;;
2408  esac
2409  am_indx=`expr "<<$>>am_indx" + 1`
2410done<<>>dnl>>)
2411changequote([,]))])
2412
2413