aclocal.m4 revision 97403
1dnl aclocal.m4 generated automatically by aclocal 1.4-p5
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_CONFIGURE
17AC_DEFUN(GLIBCPP_CONFIGURE, [
18  dnl Default to --enable-multilib
19  AC_ARG_ENABLE(multilib,
20  [  --enable-multilib       build hella library versions (default)],
21  [case "${enableval}" in
22    yes) multilib=yes ;;
23    no)  multilib=no ;;
24    *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
25   esac], [multilib=yes])dnl
26
27  # When building with srcdir == objdir, links to the source files will
28  # be created in directories within the target_subdir.  We have to
29  # adjust toplevel_srcdir accordingly, so that configure finds
30  # install-sh and other auxiliary files that live in the top-level
31  # source directory.
32  if test "${srcdir}" = "."; then
33    if test -z "${with_target_subdir}"; then
34      toprel=".."
35    else
36      if test "${with_target_subdir}" != "."; then
37        toprel="${with_multisrctop}../.."
38      else
39        toprel="${with_multisrctop}.."
40      fi
41    fi
42  else
43    toprel=".."
44  fi
45  AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
46  toplevel_srcdir=\${top_srcdir}/$toprel
47  AC_SUBST(toplevel_srcdir)
48
49  # Export build and source directories.
50  # These need to be absolute paths, yet at the same time need to
51  # canonicalize only relative paths, because then amd will not unmount
52  # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
53  glibcpp_builddir=`pwd`
54  case $srcdir in
55  [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
56  *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
57  esac
58  AC_SUBST(glibcpp_builddir)
59  AC_SUBST(glibcpp_srcdir)
60
61  dnl This is here just to satisfy automake.
62  ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)])
63
64  AC_PROG_AWK
65  # Will set LN_S to either 'ln -s' or 'ln'.  With autoconf 2.5x, can also
66  # be 'cp -p' if linking isn't available.
67  #ac_cv_prog_LN_S='cp -p'
68  AC_PROG_LN_S
69
70  # We use these options to decide which functions to include.
71  AC_ARG_WITH(target-subdir,
72  [  --with-target-subdir=SUBDIR
73                          configuring in a subdirectory])
74  AC_ARG_WITH(cross-host,
75  [  --with-cross-host=HOST  configuring with a cross compiler])
76
77  glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
78  AC_SUBST(glibcpp_basedir)
79
80  # Never versions of autoconf add an underscore to these functions.
81  # Prevent future problems ...
82  ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
83  ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
84  ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
85  ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
86
87  # AC_PROG_CC
88  # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
89  # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
90  # are probably using a cross compiler, which will not be able to fully
91  # link an executable.  This is addressed in later versions of autoconf.
92
93  AC_DEFUN(LIB_AC_PROG_CC,
94  [AC_BEFORE([$0], [AC_PROG_CPP])dnl
95  dnl Fool anybody using AC_PROG_CC.
96  AC_PROVIDE([AC_PROG_CC])
97  AC_CHECK_PROG(CC, gcc, gcc)
98  if test -z "$CC"; then
99    AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
100    test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
101  fi
102
103  AC_PROG_CC_GNU
104
105  if test $ac_cv_prog_gcc = yes; then
106    GCC=yes
107  dnl Check whether -g works, even if CFLAGS is set, in case the package
108  dnl plays around with CFLAGS (such as to build both debugging and
109  dnl normal versions of a library), tasteless as that idea is.
110    ac_test_CFLAGS="${CFLAGS+set}"
111    ac_save_CFLAGS="$CFLAGS"
112    CFLAGS=
113    AC_PROG_CC_G
114    if test "$ac_test_CFLAGS" = set; then
115      CFLAGS="$ac_save_CFLAGS"
116    elif test $ac_cv_prog_cc_g = yes; then
117      CFLAGS="-g -O2"
118    else
119      CFLAGS="-O2"
120    fi
121  else
122    GCC=
123    test "${CFLAGS+set}" = set || CFLAGS="-g"
124  fi
125  ])
126
127  LIB_AC_PROG_CC
128
129  # Likewise for AC_PROG_CXX.  We can't just call it directly because g++
130  # will try to link in libstdc++.
131  AC_DEFUN(LIB_AC_PROG_CXX,
132  [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
133  dnl Fool anybody using AC_PROG_CXX.
134  AC_PROVIDE([AC_PROG_CXX])
135  # Use glibcpp_CXX so that we do not cause CXX to be cached with the
136  # flags that come in CXX while configuring libstdc++.  They're different
137  # from those used for all other target libraries.  If CXX is set in
138  # the environment, respect that here.
139  glibcpp_CXX=$CXX
140  AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
141  AC_SUBST(glibcpp_CXX)
142  CXX=$glibcpp_CXX
143  test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
144
145  AC_PROG_CXX_GNU
146
147  if test $ac_cv_prog_gxx = yes; then
148    GXX=yes
149    dnl Check whether -g works, even if CXXFLAGS is set, in case the package
150    dnl plays around with CXXFLAGS (such as to build both debugging and
151    dnl normal versions of a library), tasteless as that idea is.
152    ac_test_CXXFLAGS="${CXXFLAGS+set}"
153    ac_save_CXXFLAGS="$CXXFLAGS"
154    CXXFLAGS=
155    AC_PROG_CXX_G
156    if test "$ac_test_CXXFLAGS" = set; then
157      CXXFLAGS="$ac_save_CXXFLAGS"
158    elif test $ac_cv_prog_cxx_g = yes; then
159      CXXFLAGS="-g -O2"
160    else
161      CXXFLAGS="-O2"
162    fi
163  else
164    GXX=
165    test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
166  fi
167  ])
168
169  LIB_AC_PROG_CXX
170
171  # For some reason, gettext needs this.
172  AC_ISC_POSIX
173
174  AC_CHECK_TOOL(AS, as)
175  AC_CHECK_TOOL(AR, ar)
176  AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
177  AC_PROG_INSTALL
178
179  AM_MAINTAINER_MODE
180
181  # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
182  # at least currently, we never actually build a program, so we never
183  # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
184  # fails, because we are probably configuring with a cross compiler
185  # which can't create executables.  So we include AC_EXEEXT to keep
186  # automake happy, but we don't execute it, since we don't care about
187  # the result.
188  if false; then
189    # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
190    # to nothing, so nothing would remain between `then' and `fi' if it
191    # were not for the `:' below.
192    :
193    AC_EXEEXT
194  fi
195
196  . [$]{glibcpp_basedir}/configure.host
197
198  case [$]{glibcpp_basedir} in
199    /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
200    *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
201  esac
202
203  # This does for the target what configure.host does for the host.  In
204  # addition to possibly modifying the same flags, it also sets up symlinks.
205  GLIBCPP_CHECK_TARGET
206
207])
208
209
210dnl
211dnl Check to see if g++ can compile this library, and if so, if any version-
212dnl specific precautions need to be taken. 
213dnl 
214dnl GLIBCPP_CHECK_COMPILER_VERSION
215AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
216if test ! -f stamp-sanity-compiler; then
217  AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
218  AC_LANG_SAVE
219  AC_LANG_CPLUSPLUS
220  AC_TRY_COMPILE(, [
221  #if __GNUC__ < 3
222    not_ok
223  #endif
224  ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
225  AC_LANG_RESTORE
226  AC_MSG_RESULT($gpp_satisfactory)
227  touch stamp-sanity-compiler
228fi
229])
230
231
232dnl
233dnl Tests for newer compiler features, or features that are present in newer
234dnl compiler versions but not older compiler versions still in use, should
235dnl be placed here.
236dnl
237dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
238dnl new inlining code or the new system_header pragma will die on -Werror.
239dnl Leave it out by default and use maint-mode to use it.
240dnl
241dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
242dnl compiler supports it and the user has not requested debug mode.
243dnl
244dnl GLIBCPP_CHECK_COMPILER_FEATURES
245AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
246  # All these tests are for C++; save the language and the compiler flags.
247  # The CXXFLAGS thing is suspicious, but based on similar bits previously
248  # found in GLIBCPP_CONFIGURE.
249  AC_LANG_SAVE
250  AC_LANG_CPLUSPLUS
251  ac_test_CXXFLAGS="${CXXFLAGS+set}"
252  ac_save_CXXFLAGS="$CXXFLAGS"
253
254  # Check for maintainer-mode bits.
255  if test x"$USE_MAINTAINER_MODE" = xno; then
256    WERROR=''
257  else
258    WERROR='-Werror'
259  fi
260
261  # Check for -ffunction-sections -fdata-sections
262  AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
263  CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
264  AC_TRY_COMPILE(, [int foo;
265  ], [ac_fdsections=yes], [ac_fdsections=no])
266  if test "$ac_test_CXXFLAGS" = set; then
267    CXXFLAGS="$ac_save_CXXFLAGS"
268  else
269    # this is the suspicious part
270    CXXFLAGS=''
271  fi
272  if test x"$ac_fdsections" = x"yes" &&
273     test x"$enable_debug" = x"no"; then
274    SECTION_FLAGS='-ffunction-sections -fdata-sections'
275  fi
276  AC_MSG_RESULT($ac_fdsections)
277
278  AC_LANG_RESTORE
279  AC_SUBST(WERROR)
280  AC_SUBST(SECTION_FLAGS)
281])
282
283
284dnl
285dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
286dnl the native linker is in use, all variables will be defined to something
287dnl safe (like an empty string).
288dnl
289dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
290dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
291dnl Define LD, with_gnu_ld, and (possibly) glibcpp_gnu_ld_version as
292dnl side-effects of testing.
293dnl
294dnl GLIBCPP_CHECK_LINKER_FEATURES
295AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
296  # If we're not using GNU ld, then there's no point in even trying these
297  # tests.  Check for that first.  We should have already tested for gld
298  # by now (in libtool), but require it now just to be safe...
299  test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
300  test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
301  AC_REQUIRE([AC_PROG_LD])
302
303  # The name set by libtool depends on the version of libtool.  Shame on us
304  # for depending on an impl detail, but c'est la vie.  Older versions used
305  # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
306  # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
307  # makes sense).  We'll test with_gnu_ld everywhere else, so if that isn't
308  # set (hence we're using an older libtool), then set it.
309  if test x${with_gnu_ld+set} != xset; then
310    if test x${ac_cv_prog_gnu_ld+set} != xset; then
311      # We got through "ac_require(ac_prog_ld)" and still not set?  Huh?
312      with_gnu_ld=no
313    else
314      with_gnu_ld=$ac_cv_prog_gnu_ld
315    fi
316  fi
317
318  # Start by getting the version number.  I think the libtool test already
319  # does some of this, but throws away the result.
320  changequote(,)
321  ldver=`$LD --version 2>/dev/null | head -1 | \
322         sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
323  changequote([,])
324  glibcpp_gnu_ld_version=`echo $ldver | \
325         $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
326
327  # Set --gc-sections.
328  if test "$with_gnu_ld" = "notbroken"; then
329    # GNU ld it is!  Joy and bunny rabbits!
330
331    # All these tests are for C++; save the language and the compiler flags.
332    # Need to do this so that g++ won't try to link in libstdc++
333    ac_test_CFLAGS="${CFLAGS+set}"
334    ac_save_CFLAGS="$CFLAGS"
335    CFLAGS='-x c++  -Wl,--gc-sections'
336
337    # Check for -Wl,--gc-sections
338    # XXX This test is broken at the moment, as symbols required for
339    # linking are now in libsupc++ (not built yet.....). In addition, 
340    # this test has cored on solaris in the past. In addition,
341    # --gc-sections doesn't really work at the moment (keeps on discarding
342    # used sections, first .eh_frame and now some of the glibc sections for
343    # iconv). Bzzzzt. Thanks for playing, maybe next time.
344    AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
345    AC_TRY_RUN([
346     int main(void) 
347     {
348       try { throw 1; }
349       catch (...) { };
350       return 0;
351     }
352    ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
353    if test "$ac_test_CFLAGS" = set; then
354      CFLAGS="$ac_save_CFLAGS"
355    else
356      # this is the suspicious part
357      CFLAGS=''
358    fi
359    if test "$ac_sectionLDflags" = "yes"; then
360      SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
361    fi
362    AC_MSG_RESULT($ac_sectionLDflags)
363  fi
364
365  # Set linker optimization flags.
366  if test x"$with_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
367    OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
368  fi
369
370  AC_SUBST(SECTION_LDFLAGS)
371  AC_SUBST(OPT_LDFLAGS)
372])
373
374
375dnl
376dnl Check to see if the (math function) argument passed is
377dnl declared when using the c++ compiler
378dnl ASSUMES argument is a math function with ONE parameter
379dnl
380dnl GLIBCPP_CHECK_MATH_DECL_1
381AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
382  AC_MSG_CHECKING([for $1 declaration])
383  if test x${glibcpp_cv_func_$1_use+set} != xset; then
384    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
385      AC_LANG_SAVE
386      AC_LANG_CPLUSPLUS
387      AC_TRY_COMPILE([#include <math.h>
388		      #ifdef HAVE_IEEEFP_H
389		      #include <ieeefp.h>
390		      #endif
391		     ], 
392                     [ $1(0);], 
393                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
394      AC_LANG_RESTORE
395    ])
396  fi
397  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
398])
399
400dnl
401dnl Check to see if the (math function) argument passed is
402dnl 1) declared when using the c++ compiler
403dnl 2) has "C" linkage
404dnl 3) if not, see if 1) and 2) for argument prepended with '_'
405dnl
406dnl Define HAVE_CARGF etc if "cargf" is declared and links
407dnl
408dnl argument 1 is name of function to check
409dnl
410dnl ASSUMES argument is a math function with ONE parameter
411dnl
412dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
413AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
414  GLIBCPP_CHECK_MATH_DECL_1($1)
415  if test x$glibcpp_cv_func_$1_use = x"yes"; then
416    AC_CHECK_FUNCS($1)    
417  else
418    GLIBCPP_CHECK_MATH_DECL_1(_$1)
419    if test x$glibcpp_cv_func__$1_use = x"yes"; then
420      AC_CHECK_FUNCS(_$1)    
421    fi
422  fi
423])
424
425
426dnl
427dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
428dnl of functions at once.  It's an all-or-nothing check -- either 
429dnl HAVE_XYZ is defined for each of the functions, or for none of them.
430dnl Doing it this way saves significant configure time.
431AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
432  AC_MSG_CHECKING([for $1 functions])
433  AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
434    AC_LANG_SAVE
435    AC_LANG_CPLUSPLUS
436    AC_TRY_COMPILE([#include <math.h>],
437                   [ `for x in $3; do echo "$x (0);"; done` ],
438                   [glibcpp_cv_func_$2_use=yes],
439                   [glibcpp_cv_func_$2_use=no])
440    AC_LANG_RESTORE])
441  AC_MSG_RESULT($glibcpp_cv_func_$2_use)
442  if test x$glibcpp_cv_func_$2_use = x"yes"; then
443    AC_CHECK_FUNCS($3)
444  fi
445])
446
447dnl
448dnl Check to see if the (math function) argument passed is
449dnl declared when using the c++ compiler
450dnl ASSUMES argument is a math function with TWO parameters
451dnl
452dnl GLIBCPP_CHECK_MATH_DECL_2
453AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
454  AC_MSG_CHECKING([for $1 declaration])
455  if test x${glibcpp_cv_func_$1_use+set} != xset; then
456    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
457      AC_LANG_SAVE
458      AC_LANG_CPLUSPLUS
459      AC_TRY_COMPILE([#include <math.h>], 
460                     [ $1(0, 0);], 
461                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
462      AC_LANG_RESTORE
463    ])
464  fi
465  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
466])
467
468dnl
469dnl Check to see if the (math function) argument passed is
470dnl 1) declared when using the c++ compiler
471dnl 2) has "C" linkage
472dnl
473dnl Define HAVE_CARGF etc if "cargf" is declared and links
474dnl
475dnl argument 1 is name of function to check
476dnl
477dnl ASSUMES argument is a math function with TWO parameters
478dnl
479dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
480AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
481  GLIBCPP_CHECK_MATH_DECL_2($1)
482  if test x$glibcpp_cv_func_$1_use = x"yes"; then
483    AC_CHECK_FUNCS($1)    
484  else
485    GLIBCPP_CHECK_MATH_DECL_2(_$1)
486    if test x$glibcpp_cv_func__$1_use = x"yes"; then
487      AC_CHECK_FUNCS(_$1)    
488    fi
489  fi
490])
491
492
493dnl
494dnl Check to see if the (math function) argument passed is
495dnl declared when using the c++ compiler
496dnl ASSUMES argument is a math function with THREE parameters
497dnl
498dnl GLIBCPP_CHECK_MATH_DECL_3
499AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
500  AC_MSG_CHECKING([for $1 declaration])
501  if test x${glibcpp_cv_func_$1_use+set} != xset; then
502    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
503      AC_LANG_SAVE
504      AC_LANG_CPLUSPLUS
505      AC_TRY_COMPILE([#include <math.h>], 
506                     [ $1(0, 0, 0);], 
507                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
508      AC_LANG_RESTORE
509    ])
510  fi
511  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
512])
513
514dnl
515dnl Check to see if the (math function) argument passed is
516dnl 1) declared when using the c++ compiler
517dnl 2) has "C" linkage
518dnl
519dnl Define HAVE_CARGF etc if "cargf" is declared and links
520dnl
521dnl argument 1 is name of function to check
522dnl
523dnl ASSUMES argument is a math function with THREE parameters
524dnl
525dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
526AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
527  GLIBCPP_CHECK_MATH_DECL_3($1)
528  if test x$glibcpp_cv_func_$1_use = x"yes"; then
529    AC_CHECK_FUNCS($1)    
530  else
531    GLIBCPP_CHECK_MATH_DECL_3(_$1)
532    if test x$glibcpp_cv_func__$1_use = x"yes"; then
533      AC_CHECK_FUNCS(_$1)    
534    fi
535  fi
536])
537
538
539dnl
540dnl Check to see if the (stdlib function) argument passed is
541dnl 1) declared when using the c++ compiler
542dnl 2) has "C" linkage
543dnl
544dnl argument 1 is name of function to check
545dnl
546dnl ASSUMES argument is a math function with TWO parameters
547dnl
548dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
549AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
550  AC_MSG_CHECKING([for $1 declaration])
551  if test x${glibcpp_cv_func_$1_use+set} != xset; then
552    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
553      AC_LANG_SAVE
554      AC_LANG_CPLUSPLUS
555      AC_TRY_COMPILE([#include <stdlib.h>], 
556                     [ $1(0, 0);], 
557                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
558      AC_LANG_RESTORE
559    ])
560  fi
561  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
562  if test x$glibcpp_cv_func_$1_use = x"yes"; then
563    AC_CHECK_FUNCS($1)    
564  fi
565])
566
567
568dnl
569dnl Check to see if the (stdlib function) argument passed is
570dnl 1) declared when using the c++ compiler
571dnl 2) has "C" linkage
572dnl
573dnl argument 1 is name of function to check
574dnl
575dnl ASSUMES argument is a function with THREE parameters
576dnl
577dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3
578AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
579  AC_MSG_CHECKING([for $1 declaration])
580  if test x${glibcpp_cv_func_$1_use+set} != xset; then
581    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
582      AC_LANG_SAVE
583      AC_LANG_CPLUSPLUS
584      AC_TRY_COMPILE([#include <stdlib.h>], 
585                     [ $1(0, 0, 0);], 
586                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
587      AC_LANG_RESTORE
588    ])
589  fi
590  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
591  if test x$glibcpp_cv_func_$1_use = x"yes"; then
592    AC_CHECK_FUNCS($1)    
593  fi
594])
595
596
597dnl
598dnl Because the builtins are picky picky picky about the arguments they take, 
599dnl do an explict linkage tests here.
600dnl Check to see if the (math function) argument passed is
601dnl 1) declared when using the c++ compiler
602dnl 2) has "C" linkage
603dnl
604dnl Define HAVE_CARGF etc if "cargf" is declared and links
605dnl
606dnl argument 1 is name of function to check
607dnl
608dnl ASSUMES argument is a math function with ONE parameter
609dnl
610dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
611AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
612  AC_MSG_CHECKING([for $1 declaration])
613  if test x${glibcpp_cv_func_$1_use+set} != xset; then
614    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
615      AC_LANG_SAVE
616      AC_LANG_CPLUSPLUS
617      AC_TRY_COMPILE([#include <math.h>], 
618                     [ $1(0);], 
619                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
620      AC_LANG_RESTORE
621    ])
622  fi
623  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
624  if test x$glibcpp_cv_func_$1_use = x"yes"; then
625    AC_MSG_CHECKING([for $1 linkage])
626    if test x${glibcpp_cv_func_$1_link+set} != xset; then
627      AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
628        AC_TRY_LINK([#include <math.h>], 
629                    [ $1(0);], 
630                    [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
631      ])
632    fi
633    AC_MSG_RESULT($glibcpp_cv_func_$1_link)
634    if test x$glibcpp_cv_func_$1_link = x"yes"; then
635      ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
636      AC_DEFINE_UNQUOTED(${ac_tr_func})
637    fi
638  fi
639])
640
641
642dnl
643dnl Check to see what builtin math functions are supported
644dnl
645dnl check for __builtin_abs
646dnl check for __builtin_fabsf
647dnl check for __builtin_fabs
648dnl check for __builtin_fabl
649dnl check for __builtin_labs
650dnl check for __builtin_sqrtf
651dnl check for __builtin_sqrtl
652dnl check for __builtin_sqrt
653dnl check for __builtin_sinf
654dnl check for __builtin_sin
655dnl check for __builtin_sinl
656dnl check for __builtin_cosf
657dnl check for __builtin_cos
658dnl check for __builtin_cosl
659dnl
660dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
661AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
662  dnl Test for builtin math functions.
663  dnl These are made in gcc/c-common.c 
664  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
665  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
666  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
667  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
668  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
669
670  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
671  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
672  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
673
674  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
675  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
676  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
677
678  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
679  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
680  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
681
682  dnl There is, without a doubt, a more elegant way to have these
683  dnl names exported so that they won't be stripped out of acconfig.h by
684  dnl autoheader. I leave this as an exercise to somebody less frustrated
685  dnl than I.... please email the libstdc++ list if you can figure out a
686  dnl more elegant approach (see autoconf/acgen.m4 and specifically
687  dnl AC_CHECK_FUNC for things to steal.)
688  dummyvar=no
689  if test x$dummyvar = x"yes"; then
690    AC_DEFINE(HAVE___BUILTIN_ABS)
691    AC_DEFINE(HAVE___BUILTIN_LABS)
692    AC_DEFINE(HAVE___BUILTIN_COS)
693    AC_DEFINE(HAVE___BUILTIN_COSF)
694    AC_DEFINE(HAVE___BUILTIN_COSL)
695    AC_DEFINE(HAVE___BUILTIN_FABS)
696    AC_DEFINE(HAVE___BUILTIN_FABSF)
697    AC_DEFINE(HAVE___BUILTIN_FABSL)
698    AC_DEFINE(HAVE___BUILTIN_SIN)
699    AC_DEFINE(HAVE___BUILTIN_SINF)
700    AC_DEFINE(HAVE___BUILTIN_SINL)
701    AC_DEFINE(HAVE___BUILTIN_SQRT)
702    AC_DEFINE(HAVE___BUILTIN_SQRTF)
703    AC_DEFINE(HAVE___BUILTIN_SQRTL)
704  fi
705])
706
707
708dnl
709dnl Check to see what the underlying c library 
710dnl These checks need to do two things: 
711dnl 1) make sure the name is declared when using the c++ compiler
712dnl 2) make sure the name has "C" linkage
713dnl This might seem like overkill but experience has shown that it's not...
714dnl
715dnl Define HAVE_STRTOLD if "strtold" is declared and links
716dnl Define HAVE_STRTOF if "strtof" is declared and links
717dnl Define HAVE_DRAND48 if "drand48" is declared and links
718dnl
719dnl GLIBCPP_CHECK_STDLIB_SUPPORT
720AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
721  ac_test_CXXFLAGS="${CXXFLAGS+set}"
722  ac_save_CXXFLAGS="$CXXFLAGS"
723  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
724
725  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
726  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
727  AC_CHECK_FUNCS(drand48)
728
729  CXXFLAGS="$ac_save_CXXFLAGS"
730])
731
732
733dnl
734dnl Check to see what the underlying c library or math library is like.
735dnl These checks need to do two things: 
736dnl 1) make sure the name is declared when using the c++ compiler
737dnl 2) make sure the name has "C" linkage
738dnl This might seem like overkill but experience has shown that it's not...
739dnl
740dnl Define HAVE_CARGF etc if "cargf" is found.
741dnl
742dnl GLIBCPP_CHECK_MATH_SUPPORT
743AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
744  ac_test_CXXFLAGS="${CXXFLAGS+set}"
745  ac_save_CXXFLAGS="$CXXFLAGS"
746  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
747
748  dnl Check libm
749  AC_CHECK_LIB(m, sin, libm="-lm")
750  ac_save_LIBS="$LIBS"
751  LIBS="$LIBS $libm"
752
753  dnl Check to see if certain C math functions exist.
754  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
755  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
756  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
757  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
758  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
759  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
760  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
761  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
762
763  dnl Check to see if basic C math functions have float versions.
764  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
765                                          float_trig,
766                                          acosf asinf atanf \
767                                          cosf sinf tanf \
768                                          coshf sinhf tanhf)
769  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
770                                          float_round,
771                                          ceilf floorf)
772  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
773  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
774  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
775  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
776  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
777  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
778  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
779  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
780  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
781  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
782  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
783  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
784  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
785  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
786  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
787  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
788
789  dnl Check to see if basic C math functions have long double versions.
790  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
791                                          long_double_trig,
792                                          acosl asinl atanl \
793                                          cosl sinl tanl \
794                                          coshl sinhl tanhl)
795  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
796                                          long_double_round,
797                                          ceill floorl)
798  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
799  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
800  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
801  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
802  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
803  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
804  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
805  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
806  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
807  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
808  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
809  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
810  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
811  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
812  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
813  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
814  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
815
816  dnl Some runtimes have these functions with a preceding underscore. Please
817  dnl keep this sync'd with the one above. And if you add any new symbol,
818  dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
819  dnl Check to see if certain C math functions exist.
820
821  dnl Check to see if basic C math functions have float versions.
822  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
823                                          _float_trig,
824                                          _acosf _asinf _atanf \
825                                          _cosf _sinf _tanf \
826                                          _coshf _sinhf _tanhf)
827  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
828                                          _float_round,
829                                          _ceilf _floorf)
830
831  dnl Check to see if basic C math functions have long double versions.
832  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
833                                          _long_double_trig,
834                                          _acosl _asinl _atanl \
835                                          _cosl _sinl _tanl \
836                                          _coshl _sinhl _tanhl)
837  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
838                                          _long_double_round,
839                                          _ceill _floorl)
840
841  LIBS="$ac_save_LIBS"
842  CXXFLAGS="$ac_save_CXXFLAGS"
843])
844
845
846dnl
847dnl Check to see if there is native support for complex 
848dnl
849dnl Don't compile bits in math/* if native support exits.
850dnl
851dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
852dnl
853dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
854AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
855  dnl Check for complex versions of math functions of platform.
856  AC_CHECK_LIB(m, main)
857  AC_REPLACE_MATHFUNCS(nan copysignf)
858
859  dnl For __signbit to signbit conversions.
860  AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
861  AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
862
863  dnl Compile the long double complex functions only if the function 
864  dnl provides the non-complex long double functions that are needed.
865  dnl Currently this includes copysignl, which should be
866  dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
867  if test x$ac_cv_func_copysignl = x"yes"; then
868    AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
869  fi
870
871  AC_SUBST(LIBMATHOBJS)
872])
873
874
875dnl Check to see what architecture and operating system we are compiling
876dnl for.  Also, if architecture- or OS-specific flags are required for
877dnl compilation, pick them up here.
878dnl 
879dnl GLIBCPP_CHECK_TARGET
880AC_DEFUN(GLIBCPP_CHECK_TARGET, [
881    . [$]{glibcpp_basedir}/configure.target
882    AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
883    AC_MSG_RESULT(OS config directory is $os_include_dir)
884])
885
886
887dnl
888dnl Check to see if this target can enable the wchar_t parts of libstdc++.
889dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
890dnl must have been previously checked.)
891dnl
892dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
893dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
894dnl
895dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
896AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
897
898  dnl Test wchar.h for mbstate_t, which is needed for char_traits and
899  dnl others even if wchar_t support is not on.
900  AC_MSG_CHECKING([for mbstate_t])
901  AC_TRY_COMPILE([#include <wchar.h>],
902  [mbstate_t teststate;], 
903  have_mbstate_t=yes, have_mbstate_t=no)
904  AC_MSG_RESULT($have_mbstate_t)
905  if test x"$have_mbstate_t" = xyes; then
906    AC_DEFINE(HAVE_MBSTATE_T)
907  fi
908
909  dnl Sanity check for existence of ISO C99 headers for extended encoding.
910  AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
911  AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
912  
913  dnl Only continue checking if the ISO C99 headers exist and support is on.
914  if test x"$ac_has_wchar_h" = xyes &&
915     test x"$ac_has_wctype_h" = xyes &&
916     test x"$enable_c_mbchar" != xno; then
917      
918    dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
919    dnl numeric_limits can instantiate type_traits<wchar_t>
920    AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
921    AC_TRY_COMPILE([#include <wchar.h>],
922    [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
923    has_wchar_minmax=yes, has_wchar_minmax=no)
924    AC_MSG_RESULT($has_wchar_minmax)
925    
926    dnl Test wchar.h for WEOF, which is what we use to determine whether
927    dnl to specialize for char_traits<wchar_t> or not.
928    AC_MSG_CHECKING([for WEOF])
929    AC_TRY_COMPILE([
930      #include <wchar.h>
931      #include <stddef.h>],
932    [wint_t i = WEOF;],
933    has_weof=yes, has_weof=no)
934    AC_MSG_RESULT($has_weof)
935  
936    dnl Tests for wide character functions used in char_traits<wchar_t>.
937    ac_wfuncs=yes
938    AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
939    ac_wfuncs=no)
940  
941    dnl Checks for names injected into std:: by the c_std headers.
942    AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
943    fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
944    vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
945    mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
946    wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
947    wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
948    ac_wfuncs=no)
949
950    AC_MSG_CHECKING([for ISO C99 wchar_t support])
951    if test x"$has_weof" = xyes &&
952       test x"$has_wchar_minmax" = xyes &&
953       test x"$ac_wfuncs" = xyes; then
954      ac_isoC99_wchar_t=yes
955    else
956      ac_isoC99_wchar_t=no
957    fi
958    AC_MSG_RESULT($ac_isoC99_wchar_t)
959  
960    dnl Use iconv for wchar_t to char conversions. As such, check for 
961    dnl X/Open Portability Guide, version 2 features (XPG2).
962    AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
963    AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
964
965    dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
966    AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
967    ac_save_LIBS="$LIBS"
968    LIBS="$LIBS $libiconv"
969
970    AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
971    ac_XPG2funcs=yes, ac_XPG2funcs=no)
972  
973    LIBS="$ac_save_LIBS"
974
975    AC_MSG_CHECKING([for XPG2 wchar_t support])
976    if test x"$ac_has_iconv_h" = xyes &&
977       test x"$ac_has_langinfo_h" = xyes &&
978       test x"$ac_XPG2funcs" = xyes; then
979      ac_XPG2_wchar_t=yes
980    else
981      ac_XPG2_wchar_t=no
982    fi
983    AC_MSG_RESULT($ac_XPG2_wchar_t)
984  
985    dnl At the moment, only enable wchar_t specializations if all the
986    dnl above support is present.
987    AC_MSG_CHECKING([for enabled wchar_t specializations])
988    if test x"$ac_isoC99_wchar_t" = xyes &&
989       test x"$ac_XPG2_wchar_t" = xyes; then
990      AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
991      AC_MSG_RESULT("yes")
992    else
993      AC_MSG_RESULT("no")
994    fi
995  else
996    dnl Wide characters disabled by the user. 
997    AC_MSG_WARN([wchar_t support disabled.])
998  fi
999])
1000
1001
1002dnl
1003dnl Check for special debugging mode; not for production use.
1004dnl
1005dnl GLIBCPP_ENABLE_DEBUG
1006dnl --enable-debug sets '-ggdb3 -O0'.
1007dnl --disable-debug sets '-g' and whatever optimization options the
1008dnl     compiler can handle.
1009dnl  +  --enable-maintainer-mode automatically defaults this to on.
1010dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
1011dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
1012dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1013dnl       defaults to `no'.
1014AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
1015define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
1016AC_ARG_ENABLE(debug,
1017changequote(<<, >>)dnl
1018<<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
1019changequote([, ])dnl
1020[case "${enableval}" in
1021 yes) enable_debug=yes ;;
1022 no)  enable_debug=no ;;
1023 *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1024 esac],
1025enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1026
1027dnl Option parsed, now set things appropriately
1028case "${enable_debug}" in
1029    yes) 
1030        DEBUG_FLAGS='-O0 -ggdb3'                        
1031        ;; 
1032    no)   
1033        DEBUG_FLAGS='-g'
1034        ;;
1035esac
1036AC_SUBST(DEBUG_FLAGS)
1037])
1038
1039
1040dnl
1041dnl Check for "unusual" flags to pass to the compiler while building.
1042dnl
1043dnl GLIBCPP_ENABLE_CXX_FLAGS
1044dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1045dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1046dnl     Somehow this same set of flags must be passed when [re]building
1047dnl     libgcc.
1048dnl --disable-cxx-flags passes nothing.
1049dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1050dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1051dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
1052dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1053dnl       If "default flags" is an empty string (or "none"), the effect is
1054dnl       the same as --disable or --enable=no.
1055AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1056define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1057AC_ARG_ENABLE(cxx-flags,
1058changequote(<<, >>)dnl
1059<<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
1060                                [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1061changequote([, ])dnl
1062[case "x$enableval" in
1063 xyes)   
1064        AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1065 xno|x)  
1066        enable_cxx_flags='' ;;
1067 *)      
1068        enable_cxx_flags="$enableval" ;;
1069 esac],
1070enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1071
1072dnl Thinko on my part during design.  This kludge is the workaround.
1073if test "$enable_cxx_flags" = "none"; then 
1074  enable_cxx_flags=''; 
1075fi
1076
1077dnl Run through flags (either default or command-line) and set anything
1078dnl extra (e.g., #defines) that must accompany particular g++ options.
1079if test -n "$enable_cxx_flags"; then
1080    for f in $enable_cxx_flags; do
1081        case "$f" in
1082            -fhonor-std)  ;;
1083            -*)  ;;
1084            *)   # and we're trying to pass /what/ exactly?
1085                 AC_MSG_ERROR([compiler flags start with a -]) ;;
1086        esac
1087    done
1088fi
1089EXTRA_CXX_FLAGS="$enable_cxx_flags"
1090AC_SUBST(EXTRA_CXX_FLAGS)
1091])
1092
1093
1094dnl
1095dnl Check for which locale library to use:  gnu or generic.
1096dnl
1097dnl GLIBCPP_ENABLE_CLOCALE
1098dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1099dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
1100dnl 
1101dnl default is generic
1102dnl
1103AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1104  AC_MSG_CHECKING([for clocale to use])
1105  AC_ARG_ENABLE(clocale,
1106  [  --enable-clocale        enable model for target locale package. 
1107  --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
1108  ], 
1109  if test x$enable_clocale = xno; then
1110     enable_clocale=no
1111  fi,
1112     enable_clocale=no)
1113
1114  enable_clocale_flag=$enable_clocale
1115
1116  dnl Probe for locale support if no specific model is specified.
1117  dnl Default to "generic"
1118  if test x$enable_clocale_flag = xno; then
1119    case x${target_os} in
1120      xlinux* | xgnu*)
1121	AC_EGREP_CPP([_GLIBCPP_ok], [
1122        #include <features.h>
1123        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1124          _GLIBCPP_ok
1125        #endif
1126        ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1127
1128	# Test for bugs early in glibc-2.2.x series
1129  	if test x$enable_clocale_flag = xgnu; then
1130    	  AC_TRY_RUN([
1131	  #define _GNU_SOURCE 1
1132	  #include <locale.h>
1133	  int main()
1134	  {
1135  	    const char __one[] = "�uglein Augmen";
1136  	    const char __two[] = "�uglein";
1137  	    int i;
1138  	    int j;
1139  	    __locale_t	loc;
1140   	    __locale_t	loc_dup;
1141  	    loc = __newlocale(1 << LC_ALL, "de_DE", 0);
1142  	    loc_dup = __duplocale(loc);
1143  	    i = __strcoll_l(__one, __two, loc);
1144  	    j = __strcoll_l(__one, __two, loc_dup);
1145  	    return 0;
1146	  }
1147	  ], 
1148	  [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
1149	  [enable_clocale_flag=generic])
1150  	fi
1151
1152	# ... at some point put __strxfrm_l tests in as well.
1153        ;;
1154      *)
1155	enable_clocale_flag=generic
1156	;;
1157    esac
1158  fi
1159
1160  dnl Deal with gettext issues.
1161  AC_ARG_ENABLE(nls,
1162  [  --enable-nls            use Native Language Support (default)],
1163  , enable_nls=yes)
1164  USE_NLS=no
1165
1166  dnl Set configure bits for specified locale package
1167  case x${enable_clocale_flag} in
1168    xgeneric)
1169      AC_MSG_RESULT(generic)
1170
1171      CLOCALE_H=config/locale/generic/c_locale.h
1172      CLOCALE_CC=config/locale/generic/c_locale.cc
1173      CCODECVT_H=config/locale/generic/codecvt_specializations.h
1174      CCOLLATE_CC=config/locale/generic/collate_members.cc
1175      CCTYPE_CC=config/locale/generic/ctype_members.cc
1176      CMESSAGES_H=config/locale/generic/messages_members.h
1177      CMESSAGES_CC=config/locale/generic/messages_members.cc
1178      CMONEY_CC=config/locale/generic/monetary_members.cc
1179      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1180      CTIME_CC=config/locale/generic/time_members.cc
1181      ;;
1182    xgnu)
1183      AC_MSG_RESULT(gnu)
1184
1185      # Declare intention to use gettext, and add support for specific
1186      # languages.
1187      # For some reason, ALL_LINGUAS has to be before AM_GNU_GETTEXT
1188      ALL_LINGUAS="de fr"
1189
1190      # Don't call AM_GNU_GETTEXT here. Instead, assume glibc.
1191      AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1192      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
1193	USE_NLS=yes
1194      fi
1195
1196      # Export the build objects.
1197      for ling in $ALL_LINGUAS; do \
1198        glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
1199        glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
1200      done
1201      AC_SUBST(glibcpp_MOFILES)
1202      AC_SUBST(glibcpp_POFILES)
1203
1204      CLOCALE_H=config/locale/gnu/c_locale.h
1205      CLOCALE_CC=config/locale/gnu/c_locale.cc
1206      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1207      CCOLLATE_CC=config/locale/gnu/collate_members.cc
1208      CCTYPE_CC=config/locale/gnu/ctype_members.cc
1209      CMESSAGES_H=config/locale/gnu/messages_members.h
1210      CMESSAGES_CC=config/locale/gnu/messages_members.cc
1211      CMONEY_CC=config/locale/gnu/monetary_members.cc
1212      CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1213      CTIME_CC=config/locale/gnu/time_members.cc
1214      ;;
1215    xieee_1003.1-2001)
1216      AC_MSG_RESULT(generic)
1217
1218      CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1219      CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
1220      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1221      CCOLLATE_CC=config/locale/generic/collate_members.cc
1222      CCTYPE_CC=config/locale/generic/ctype_members.cc
1223      CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1224      CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1225      CMONEY_CC=config/locale/generic/monetary_members.cc
1226      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1227      CTIME_CC=config/locale/generic/time_members.cc
1228      ;;
1229    *)
1230      echo "$enable_clocale is an unknown locale package" 1>&2
1231      exit 1
1232      ;;
1233  esac
1234
1235  # This is where the testsuite looks for locale catalogs, using the
1236  # -DLOCALEDIR define during testsuite compilation.
1237  glibcpp_localedir=${glibcpp_builddir}/po/share/locale
1238  AC_SUBST(glibcpp_localedir)
1239
1240  AC_SUBST(USE_NLS)
1241  AC_SUBST(CLOCALE_H)
1242  AC_SUBST(CCODECVT_H)
1243  AC_SUBST(CMESSAGES_H)
1244  AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1245  AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
1246  AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
1247  AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
1248  AC_LINK_FILES($CMONEY_CC, src/monetary.cc)
1249  AC_LINK_FILES($CNUMERIC_CC, src/numeric.cc)
1250  AC_LINK_FILES($CTIME_CC, src/time.cc)
1251])
1252
1253
1254dnl
1255dnl Check for which I/O library to use:  libio, or something specific.
1256dnl
1257dnl GLIBCPP_ENABLE_CSTDIO
1258dnl --enable-cstdio=libio sets config/io/c_io_libio.h and friends
1259dnl 
1260dnl default is stdio
1261dnl
1262AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1263  AC_MSG_CHECKING([for cstdio to use])
1264  AC_ARG_ENABLE(cstdio,
1265  [  --enable-cstdio         enable stdio for target io package. 
1266  --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
1267  ], 
1268  if test x$enable_cstdio = xno; then
1269     enable_cstdio=stdio
1270  fi,
1271     enable_cstdio=stdio)
1272
1273  enable_cstdio_flag=$enable_cstdio
1274
1275  dnl Check if a valid I/O package
1276  case x${enable_cstdio_flag} in
1277    xlibio)
1278      CSTDIO_H=config/io/c_io_libio.h
1279      BASIC_FILE_H=config/io/basic_file_libio.h
1280      BASIC_FILE_CC=config/io/basic_file_libio.cc
1281      AC_MSG_RESULT(libio)
1282
1283      # see if we are on a system with libio native (ie, linux)
1284      AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1285
1286      # Need to check and see what version of glibc is being used. If
1287      # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1288      # compile most of libio for linux systems.
1289      if test x$has_libio = x"yes"; then
1290        case "$target" in
1291          *-*-linux*)
1292              AC_MSG_CHECKING([for glibc version >= 2.2])
1293              AC_EGREP_CPP([ok], [
1294            #include <features.h>
1295              #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1296                    ok
1297              #endif
1298              ], glibc_satisfactory=yes, glibc_satisfactory=no)
1299              AC_MSG_RESULT($glibc_satisfactory)
1300            ;;
1301        esac
1302
1303        # XXX at the moment, admit defeat and force the recompilation
1304        # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1305        glibc_satisfactory=no        
1306
1307        if test x$glibc_satisfactory = x"yes"; then
1308           need_libio=no
1309           need_wlibio=no        
1310        else
1311           need_libio=yes
1312           # bkoz XXX need to add checks to enable this
1313           # pme XXX here's a first pass at such a check
1314           if test x$enable_c_mbchar != xno; then
1315              need_wlibio=yes
1316           else
1317              need_wlibio=no
1318           fi
1319        fi
1320
1321      else
1322         # Using libio, but <libio.h> doesn't exist on the target system. . .
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    xstdio | x | xno | xnone | xyes)
1334      # default
1335      CSTDIO_H=config/io/c_io_stdio.h
1336      BASIC_FILE_H=config/io/basic_file_stdio.h
1337      BASIC_FILE_CC=config/io/basic_file_stdio.cc
1338      AC_MSG_RESULT(stdio)
1339
1340      # We're not using stdio.
1341      need_libio=no
1342      need_wlibio=no
1343      ;;
1344    *)
1345      echo "$enable_cstdio is an unknown io package" 1>&2
1346      exit 1
1347      ;;
1348  esac
1349  AC_SUBST(CSTDIO_H)
1350  AC_SUBST(BASIC_FILE_H)
1351  AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
1352
1353  # 2000-08-04 bkoz hack
1354  CCODECVT_C=config/io/c_io_libio_codecvt.c
1355  AC_SUBST(CCODECVT_C)
1356  # 2000-08-04 bkoz hack
1357
1358  AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1359                 test "$need_libio" = yes || test "$need_wlibio" = yes)
1360  AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1361  AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1362  if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1363    libio_la=../libio/libio.la
1364  else
1365    libio_la=
1366  fi
1367  AC_SUBST(libio_la)
1368])
1369
1370
1371dnl
1372dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1373dnl We must stage the required headers so that they will be installed
1374dnl with the library (unlike libgcc, the STL implementation is provided
1375dnl solely within headers).  Since we must not inject random user-space
1376dnl macro names into user-provided C++ code, we first stage into <file>-in
1377dnl and process to <file> with an output command.  The reason for a two-
1378dnl stage process here is to correctly handle $srcdir!=$objdir without
1379dnl having to write complex code (the sed commands to clean the macro
1380dnl namespace are complex and fragile enough as it is).  We must also
1381dnl add a relative path so that -I- is supported properly.
1382dnl
1383AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1384  AC_MSG_CHECKING([for thread model used by GCC])
1385  target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1386  AC_MSG_RESULT([$target_thread_file])
1387
1388  if test $target_thread_file != single; then
1389    AC_DEFINE(HAVE_GTHR_DEFAULT)
1390    AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1391  fi
1392
1393  glibcpp_thread_h=gthr-$target_thread_file.h
1394  AC_SUBST(glibcpp_thread_h)
1395])
1396
1397
1398dnl
1399dnl Check for exception handling support.  If an explicit enable/disable
1400dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1401dnl target may or may not support call frame exceptions.
1402dnl
1403dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1404dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1405dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1406dnl
1407dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1408dnl
1409AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1410  AC_MSG_CHECKING([for exception model to use])
1411  AC_LANG_SAVE
1412  AC_LANG_CPLUSPLUS
1413  AC_ARG_ENABLE(sjlj-exceptions,
1414  [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1415  [:],
1416  [dnl Botheration.  Now we've got to detect the exception model.
1417   dnl Link tests against libgcc.a are problematic since -- at least
1418   dnl as of this writing -- we've not been given proper -L bits for
1419   dnl single-tree newlib and libgloss.
1420   dnl
1421   dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1422   dnl conftest files before we got a change to grep them first.
1423   cat > conftest.$ac_ext << EOF
1424[#]line __oline__ "configure"
1425struct S { ~S(); };
1426void bar();
1427void foo()
1428{
1429  S s;
1430  bar();
1431}
1432EOF
1433   old_CXXFLAGS="$CXXFLAGS"  
1434   CXXFLAGS="-S -fexceptions"
1435   if AC_TRY_EVAL(ac_compile); then
1436     if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1437       enable_sjlj_exceptions=yes
1438     elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1439       enable_sjlj_exceptions=no
1440     fi
1441   fi
1442   CXXFLAGS="$old_CXXFLAGS"
1443   rm -f conftest*])
1444   if test x$enable_sjlj_exceptions = xyes; then
1445     AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1446        [Define if the compiler is configured for setjmp/longjmp exceptions.])
1447     ac_exception_model_name=sjlj
1448   elif test x$enable_sjlj_exceptions = xno; then
1449     ac_exception_model_name="call frame"
1450   else
1451     AC_MSG_ERROR([unable to detect exception model])
1452   fi
1453   AC_LANG_RESTORE
1454   AC_MSG_RESULT($ac_exception_model_name)
1455])
1456
1457
1458dnl
1459dnl Check for libunwind exception handling support. If enabled then
1460dnl we assume that the _Unwind_* functions that make up the Unwind ABI
1461dnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
1462dnl libunwind instead of libgcc and that libstdc++ has a dependency
1463dnl on libunwind as well as libgcc.
1464dnl
1465dnl GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
1466dnl --enable-libunwind-exceptions forces the use of libunwind.
1467dnl --disable-libunwind-exceptions assumes there is no libunwind.
1468dnl
1469dnl Define _GLIBCPP_LIBUNWIND_EXCEPTIONS if requested.
1470dnl
1471AC_DEFUN(GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS, [
1472  AC_MSG_CHECKING([for use of libunwind])
1473  AC_ARG_ENABLE(libunwind-exceptions,
1474  [  --enable-libunwind-exceptions  force use of libunwind for exceptions],
1475  use_libunwind_exceptions=$enableval,
1476  use_libunwind_exceptions=no)
1477  AC_MSG_RESULT($use_libunwind_exceptions)
1478  dnl Option parsed, now set things appropriately
1479  if test x"$use_libunwind_exceptions" = xyes; then
1480    LIBUNWIND_FLAG="-lunwind"
1481  else
1482    LIBUNWIND_FLAG=""
1483  fi
1484  AC_SUBST(LIBUNWIND_FLAG)
1485])
1486
1487dnl
1488dnl Check for ISO/IEC 9899:1999 "C99" support.
1489dnl
1490dnl GLIBCPP_ENABLE_C99
1491dnl --enable-c99 defines _GLIBCPP_USE_C99
1492dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1493dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1494dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1495dnl       defaults to `no'.
1496dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1497dnl
1498dnl GLIBCPP_ENABLE_C99
1499AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1500  define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1501
1502  AC_ARG_ENABLE(c99,
1503  changequote(<<, >>)dnl
1504  <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1505  changequote([, ])dnl
1506  [case "$enableval" in
1507   yes) enable_c99=yes ;;
1508   no)  enable_c99=no ;;
1509   *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1510   esac],
1511  enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1512 
1513  AC_LANG_SAVE
1514  AC_LANG_CPLUSPLUS
1515
1516  # Check for the existence of <math.h> functions used if C99 is enabled.
1517  ac_c99_math=yes;
1518  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1519  AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1520  AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1521  AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1522  AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1523  AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1524  AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1525  AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1526  AC_TRY_COMPILE([#include <math.h>],
1527                 [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1528  AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1529  AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1530  AC_TRY_COMPILE([#include <math.h>],
1531	         [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1532  AC_TRY_COMPILE([#include <math.h>],
1533	         [isunordered(0.0,0.0);],, [ac_c99_math=no])
1534  AC_MSG_RESULT($ac_c99_math)
1535
1536  # Check for the existence in <stdio.h> of vscanf, et. al.
1537  ac_c99_stdio=yes;
1538  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1539  AC_TRY_COMPILE([#include <stdio.h>],
1540		 [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
1541  AC_TRY_COMPILE([#include <stdio.h>
1542		  #include <stdarg.h>
1543		  void foo(char* fmt, ...)
1544		  {va_list args; va_start(args, fmt);
1545	          vfscanf(stderr, "%i", args);}],
1546	          [],, [ac_c99_stdio=no])
1547  AC_TRY_COMPILE([#include <stdio.h>
1548		  #include <stdarg.h>
1549		  void foo(char* fmt, ...)
1550		  {va_list args; va_start(args, fmt);
1551	          vscanf("%i", args);}],
1552	          [],, [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	          vsnprintf(fmt, 0, "%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	          vsscanf(fmt, "%i", args);}],
1564	          [],, [ac_c99_stdio=no])
1565  AC_MSG_RESULT($ac_c99_stdio)
1566
1567  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1568  ac_c99_stdlib=yes;
1569  AC_MSG_CHECKING([for lldiv_t declaration])
1570  AC_CACHE_VAL(ac_c99_lldiv_t, [
1571  AC_TRY_COMPILE([#include <stdlib.h>], 
1572                   [ lldiv_t mydivt;], 
1573                   [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1574  ])
1575  AC_MSG_RESULT($ac_c99_lldiv_t)
1576
1577  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1578  AC_TRY_COMPILE([#include <stdlib.h>],
1579	         [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1580  AC_TRY_COMPILE([#include <stdlib.h>],
1581	         [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1582  AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1583  AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1584  AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1585  AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1586  if test x"$ac_c99_lldiv_t" = x"no"; then
1587    ac_c99_stdlib=no; 
1588  fi; 
1589  AC_MSG_RESULT($ac_c99_stdlib)
1590
1591  # Check for the existence of <wchar.h> functions used if C99 is enabled.
1592  # XXX the wchar.h checks should be rolled into the general C99 bits.
1593  ac_c99_wchar=yes;
1594  AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1595  AC_TRY_COMPILE([#include <wchar.h>], 
1596	         [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1597  AC_TRY_COMPILE([#include <wchar.h>], 
1598	         [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1599  AC_TRY_COMPILE([#include <wchar.h>], 
1600	         [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1601  AC_MSG_RESULT($ac_c99_wchar)
1602
1603  AC_MSG_CHECKING([for enabled ISO C99 support])
1604  if test x"$ac_c99_math" = x"no" ||
1605     test x"$ac_c99_stdio" = x"no" ||
1606     test x"$ac_c99_stdlib" = x"no" ||
1607     test x"$ac_c99_wchar" = x"no"; then
1608    enable_c99=no; 
1609  fi; 
1610  AC_MSG_RESULT($enable_c99)
1611
1612  # Option parsed, now set things appropriately
1613  if test x"$enable_c99" = x"yes"; then
1614    AC_DEFINE(_GLIBCPP_USE_C99)
1615  fi
1616
1617  AC_LANG_RESTORE
1618])
1619
1620
1621dnl
1622dnl Check for template specializations for the 'long long' type extension.
1623dnl The result determines only whether 'long long' I/O is enabled; things
1624dnl like numeric_limits<> specializations are always available.
1625dnl
1626dnl GLIBCPP_ENABLE_LONG_LONG
1627dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1628dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1629dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1630dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1631dnl       defaults to `no'.
1632dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1633dnl
1634dnl GLIBCPP_ENABLE_LONG_LONG
1635AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1636  define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1637
1638  AC_ARG_ENABLE(long-long,
1639  changequote(<<, >>)dnl
1640  <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1641  changequote([, ])dnl
1642  [case "$enableval" in
1643   yes) enable_long_long=yes ;;
1644   no)  enable_long_long=no ;;
1645   *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1646   esac],
1647  enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1648
1649  AC_LANG_SAVE
1650  AC_LANG_CPLUSPLUS
1651
1652  AC_MSG_CHECKING([for enabled long long I/O support])
1653  # iostreams require strtoll, strtoull to compile
1654  AC_TRY_COMPILE([#include <stdlib.h>],
1655                 [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
1656  AC_TRY_COMPILE([#include <stdlib.h>],
1657                 [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
1658
1659  # Option parsed, now set things appropriately
1660  if test x"$enable_long_long" = xyes; then
1661    AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1662  fi
1663  AC_MSG_RESULT($enable_long_long)
1664
1665  AC_LANG_RESTORE
1666])
1667
1668
1669dnl
1670dnl Check for what kind of C headers to use.
1671dnl
1672dnl GLIBCPP_ENABLE_CHEADERS
1673dnl --enable-cheaders= [does stuff].
1674dnl --disable-cheaders [does not do anything, really].
1675dnl  +  This will eventually need to be 'c_shadow' by default.
1676dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1677dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1678dnl       If ommitted, it defaults to `c_std'.
1679AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1680define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1681AC_MSG_CHECKING([for c header strategy to use])
1682AC_ARG_ENABLE(cheaders,
1683changequote(<<, >>)dnl
1684<<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1685changequote([, ])
1686  [case "$enableval" in
1687   c) 
1688        enable_cheaders=c 
1689        ;;
1690   c_std)  
1691        enable_cheaders=c_std 
1692        ;;
1693   c_shadow)  
1694        enable_cheaders=c_shadow 
1695        ;;
1696   *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1697        ;;
1698  esac],
1699  enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1700  AC_MSG_RESULT($enable_cheaders)
1701
1702  dnl Option parsed, now set things appropriately
1703  case "$enable_cheaders" in
1704    c_shadow) 
1705        CSHADOW_FLAGS="-fno-builtin"
1706        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
1707        ;;
1708    c_std)   
1709        CSHADOW_FLAGS=""
1710        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1711        ;;
1712    c)   
1713        CSHADOW_FLAGS=""
1714        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1715        ;;
1716  esac
1717
1718  AC_SUBST(CSHADOW_FLAGS)
1719  AC_SUBST(C_INCLUDE_DIR)
1720  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C, test "$enable_cheaders" = c)
1721  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C_STD, test "$enable_cheaders" = c_std)
1722])
1723
1724
1725dnl
1726dnl Check for wide character support.  Has the same effect as the option
1727dnl in gcc's configure, but in a form that autoconf can mess with.
1728dnl
1729dnl GLIBCPP_ENABLE_C_MBCHAR
1730dnl --enable-c-mbchar requests all the wchar_t stuff.
1731dnl --disable-c-mbchar doesn't.
1732dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1733dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1734dnl       defaults to `no'.
1735AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1736define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1737AC_ARG_ENABLE(c-mbchar,
1738changequote(<<, >>)dnl
1739<<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1740changequote([, ])dnl
1741[case "$enableval" in
1742 yes) enable_c_mbchar=yes ;;
1743 no)  enable_c_mbchar=no ;;
1744 *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1745 esac],
1746enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1747dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1748])
1749
1750
1751dnl
1752dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1753dnl
1754dnl TOPLEVEL_INCLUDES
1755dnl LIBMATH_INCLUDES
1756dnl LIBSUPCXX_INCLUDES
1757dnl LIBIO_INCLUDES
1758dnl CSHADOW_INCLUDES
1759dnl
1760dnl GLIBCPP_EXPORT_INCLUDES
1761AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1762  # Root level of the build directory include sources.
1763  GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1764
1765  # Passed down for canadian crosses.
1766  if test x"$CANADIAN" = xyes; then
1767    TOPLEVEL_INCLUDES='-I$(includedir)'
1768  fi
1769
1770  LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1771
1772  LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1773
1774  if test x"$need_libio" = xyes; then
1775    LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1776    AC_SUBST(LIBIO_INCLUDES)
1777  fi
1778
1779  # Now, export this to all the little Makefiles....
1780  AC_SUBST(GLIBCPP_INCLUDES)
1781  AC_SUBST(TOPLEVEL_INCLUDES)
1782  AC_SUBST(LIBMATH_INCLUDES)
1783  AC_SUBST(LIBSUPCXX_INCLUDES)
1784])
1785
1786
1787dnl
1788dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1789dnl
1790AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1791  # Optimization flags that are probably a good idea for thrill-seekers. Just
1792  # uncomment the lines below and make, everything else is ready to go... 
1793  # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1794  OPTIMIZE_CXXFLAGS=
1795  AC_SUBST(OPTIMIZE_CXXFLAGS)
1796
1797  WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1798  AC_SUBST(WARN_FLAGS)
1799])
1800
1801dnl
1802dnl  GLIBCPP_EXPORT_INSTALL_INFO
1803dnl  calculates gxx_install_dir
1804dnl  exports glibcpp_toolexecdir
1805dnl  exports glibcpp_toolexeclibdir
1806dnl  exports glibcpp_prefixdir
1807dnl
1808dnl Assumes cross_compiling bits already done, and with_cross_host in
1809dnl particular
1810dnl
1811dnl GLIBCPP_EXPORT_INSTALL_INFO
1812AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1813# Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
1814# exported correctly in GLIBCPP_CONFIGURE.
1815glibcpp_toolexecdir=no
1816glibcpp_toolexeclibdir=no
1817glibcpp_prefixdir=${prefix}
1818
1819AC_MSG_CHECKING([for interface version number])
1820libstdcxx_interface=$INTERFACE
1821AC_MSG_RESULT($libstdcxx_interface)
1822
1823# Process the option --with-gxx-include-dir=<path to include-files directory>
1824AC_MSG_CHECKING([for --with-gxx-include-dir])
1825AC_ARG_WITH(gxx-include-dir,
1826[  --with-gxx-include-dir  the installation directory for include files],
1827[case "${withval}" in
1828  yes)
1829    AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1830    gxx_include_dir=no
1831    ;;
1832  no)
1833    gxx_include_dir=no
1834    ;;
1835  *)
1836    gxx_include_dir=${withval}
1837    ;;
1838esac], [gxx_include_dir=no])
1839AC_MSG_RESULT($gxx_include_dir)
1840
1841# Process the option "--enable-version-specific-runtime-libs"
1842AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1843AC_ARG_ENABLE(version-specific-runtime-libs,
1844[  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1845[case "$enableval" in
1846 yes) version_specific_libs=yes ;;
1847 no)  version_specific_libs=no ;;
1848 *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1849 esac],
1850version_specific_libs=no)dnl
1851# Option set, now we can test it.
1852AC_MSG_RESULT($version_specific_libs)
1853
1854if test $version_specific_libs = yes; then
1855  # Need the gcc compiler version to know where to install libraries
1856  # and header files if --enable-version-specific-runtime-libs option
1857  # is selected.
1858  changequote(,)dnl
1859  gcc_version_trigger=${srcdir}/../gcc/version.c
1860  gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
1861  gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
1862  if test x"$gxx_include_dir" = x"no"; then
1863    gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/g++
1864  fi
1865  glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1866  glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1867  changequote([,])dnl
1868fi
1869
1870# Default case for install directory for include files.
1871if test $version_specific_libs = no &&
1872   test $gxx_include_dir = no; then
1873  gxx_include_dir='$(prefix)'/include/g++-${libstdcxx_interface}
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
2041
2042sinclude(../libtool.m4)
2043dnl The lines below arrange for aclocal not to bring an installed
2044dnl libtool.m4 into aclocal.m4, while still arranging for automake to
2045dnl add a definition of LIBTOOL to Makefile.in.
2046ifelse(,,,[AC_SUBST(LIBTOOL)
2047AC_DEFUN([AM_PROG_LIBTOOL])
2048AC_DEFUN([AC_LIBTOOL_DLOPEN])
2049AC_DEFUN([AC_PROG_LD])
2050])
2051
2052
2053# Check whether LC_MESSAGES is available in <locale.h>.
2054# Ulrich Drepper <drepper@cygnus.com>, 1995.
2055#
2056# This file file be copied and used freely without restrictions.  It can
2057# be used in projects which are not available under the GNU Public License
2058# but which still want to provide support for the GNU gettext functionality.
2059# Please note that the actual code is *not* freely available.
2060
2061# serial 1
2062
2063AC_DEFUN(AC_LC_MESSAGES, [
2064  AC_CHECK_HEADER(locale.h, [
2065    AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
2066      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2067       ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
2068    if test $ac_cv_val_LC_MESSAGES = yes; then
2069      AC_DEFINE(HAVE_LC_MESSAGES)
2070    fi
2071  ])
2072])
2073
2074
2075dnl
2076dnl Check for whether the Boost-derived checks should be turned on.
2077dnl
2078dnl GLIBCPP_ENABLE_CONCEPT_CHECKS
2079dnl --enable-concept-checks turns them on.
2080dnl --disable-concept-checks leaves them off.
2081dnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2082dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2083dnl       defaults to `no'.
2084AC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
2085define([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
2086AC_ARG_ENABLE(concept-checks,
2087changequote(<<, >>)dnl
2088<<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
2089changequote([, ])dnl
2090[case "$enableval" in
2091 yes) enable_concept_checks=yes ;;
2092 no)  enable_concept_checks=no ;;
2093 *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
2094 esac],
2095enable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
2096dnl Option parsed, now set things appropriately
2097if test x"$enable_concept_checks" = xyes; then
2098  AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
2099fi
2100])
2101
2102
2103dnl
2104dnl Add version tags to symbols in shared library (or not), additionally
2105dnl marking other symbols as private/local (or not).
2106dnl
2107dnl GLIBCPP_ENABLE_SYMVERS
2108dnl --enable-symvers=style adds a version script to the linker call when
2109dnl       creating the shared library.  The choice of version script is
2110dnl       controlled by 'style'.
2111dnl --disable-symvers does not.
2112dnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
2113dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2114dnl       defaults to `no'.  Passing `yes' tries to choose a default style
2115dnl       based on linker characteristics.  Passing 'no' disables versioning.
2116AC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
2117define([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
2118AC_ARG_ENABLE(symvers,
2119changequote(<<, >>)dnl
2120<<  --enable-symvers=style  enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
2121changequote([, ])dnl
2122[case "$enableval" in
2123 yes) enable_symvers=yes ;;
2124 no)  enable_symvers=no ;;
2125 # other names here, just as sanity checks
2126 #gnu|sun|etcetera) enable_symvers=$enableval ;;
2127 gnu) enable_symvers=$enableval ;;
2128 *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
2129 esac],
2130enable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
2131
2132# If we never went through the GLIBCPP_CHECK_LINKER_FEATURES macro, then we
2133# don't know enough about $LD to do tricks... 
2134if test x$enable_shared = xno || 
2135	test x$LD = x || 
2136	test x$glibcpp_gnu_ld_version = x; then
2137  enable_symvers=no
2138fi
2139
2140# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2141AC_MSG_CHECKING([for shared libgcc])
2142ac_save_CFLAGS="$CFLAGS"
2143CFLAGS=' -lgcc_s'
2144AC_TRY_LINK( , [return 0], glibcpp_shared_libgcc=yes, glibcpp_shared_libgcc=no)
2145CFLAGS="$ac_save_CFLAGS"
2146AC_MSG_RESULT($glibcpp_shared_libgcc)
2147
2148# For GNU ld, we need at least this version.  It's 2.12 in the same format
2149# as the tested-for version.  See GLIBCPP_CHECK_LINKER_FEATURES for more.
2150glibcpp_min_gnu_ld_version=21200
2151
2152# Check to see if unspecified "yes" value can win, given results
2153# above.  
2154if test $enable_symvers = yes ; then
2155  if test $with_gnu_ld = yes &&
2156    test $glibcpp_shared_libgcc = yes ;
2157  then
2158    if test $glibcpp_gnu_ld_version -ge $glibcpp_min_gnu_ld_version ; then
2159        enable_symvers=gnu
2160    else
2161      ac_test_CFLAGS="${CFLAGS+set}"
2162      ac_save_CFLAGS="$CFLAGS"
2163      CFLAGS='-shared -Wl,--version-script,conftest.map'
2164      enable_symvers=no
2165      changequote(,)
2166      echo 'FOO { global: f[a-z]o; local: *; };' > conftest.map
2167      changequote([,])
2168      AC_TRY_LINK([int foo;],, enable_symvers=gnu)
2169      if test "$ac_test_CFLAGS" = set; then
2170	CFLAGS="$ac_save_CFLAGS"
2171      else
2172	# this is the suspicious part
2173	CFLAGS=''
2174      fi
2175      rm -f conftest.map
2176    fi
2177  else
2178    # just fail for now
2179    enable_symvers=no
2180  fi
2181fi
2182
2183dnl Everything parsed; figure out what file to use.
2184case $enable_symvers in
2185  no)
2186      LINKER_MAP=config/linker-map.dummy
2187      ;;
2188  gnu)
2189      LINKER_MAP=config/linker-map.gnu
2190      ;;
2191esac
2192
2193AC_LINK_FILES($LINKER_MAP, src/linker.map)
2194AM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
2195AC_MSG_CHECKING([versioning on shared library symbols])
2196AC_MSG_RESULT($enable_symvers)
2197])
2198
2199
2200#serial 1
2201# This test replaces the one in autoconf.
2202# Currently this macro should have the same name as the autoconf macro
2203# because gettext's gettext.m4 (distributed in the automake package)
2204# still uses it.  Otherwise, the use in gettext.m4 makes autoheader
2205# give these diagnostics:
2206#   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
2207#   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
2208
2209undefine([AC_ISC_POSIX])
2210
2211AC_DEFUN([AC_ISC_POSIX],
2212  [
2213    dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
2214    AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
2215  ]
2216)
2217
2218# Add --enable-maintainer-mode option to configure.
2219# From Jim Meyering
2220
2221# serial 1
2222
2223AC_DEFUN([AM_MAINTAINER_MODE],
2224[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
2225  dnl maintainer-mode is disabled by default
2226  AC_ARG_ENABLE(maintainer-mode,
2227[  --enable-maintainer-mode enable make rules and dependencies not useful
2228                          (and sometimes confusing) to the casual installer],
2229      USE_MAINTAINER_MODE=$enableval,
2230      USE_MAINTAINER_MODE=no)
2231  AC_MSG_RESULT($USE_MAINTAINER_MODE)
2232  AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
2233  MAINT=$MAINTAINER_MODE_TRUE
2234  AC_SUBST(MAINT)dnl
2235]
2236)
2237
2238# Define a conditional.
2239
2240AC_DEFUN([AM_CONDITIONAL],
2241[AC_SUBST($1_TRUE)
2242AC_SUBST($1_FALSE)
2243if $2; then
2244  $1_TRUE=
2245  $1_FALSE='#'
2246else
2247  $1_TRUE='#'
2248  $1_FALSE=
2249fi])
2250
2251# Macro to add for using GNU gettext.
2252# Ulrich Drepper <drepper@cygnus.com>, 1995.
2253#
2254# This file can be copied and used freely without restrictions.  It can
2255# be used in projects which are not available under the GNU Public License
2256# but which still want to provide support for the GNU gettext functionality.
2257# Please note that the actual code is *not* freely available.
2258
2259# serial 9
2260
2261dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
2262dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
2263dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
2264dnl    depending on --{enable,disable}-{shared,static} and on the presence of
2265dnl    AM-DISABLE-SHARED). Otherwise, a static library
2266dnl    $(top_builddir)/intl/libintl.a will be created.
2267dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
2268dnl    implementations (in libc or libintl) without the ngettext() function
2269dnl    will be ignored.
2270dnl LIBDIR is used to find the intl libraries.  If empty,
2271dnl    the value `$(top_builddir)/intl/' is used.
2272dnl
2273dnl The result of the configuration is one of three cases:
2274dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
2275dnl    and used.
2276dnl    Catalog format: GNU --> install in $(datadir)
2277dnl    Catalog extension: .mo after installation, .gmo in source tree
2278dnl 2) GNU gettext has been found in the system's C library.
2279dnl    Catalog format: GNU --> install in $(datadir)
2280dnl    Catalog extension: .mo after installation, .gmo in source tree
2281dnl 3) No internationalization, always use English msgid.
2282dnl    Catalog format: none
2283dnl    Catalog extension: none
2284dnl The use of .gmo is historical (it was needed to avoid overwriting the
2285dnl GNU format catalogs when building on a platform with an X/Open gettext),
2286dnl but we keep it in order not to force irrelevant filename changes on the
2287dnl maintainers.
2288dnl
2289AC_DEFUN([AM_WITH_NLS],
2290  [AC_MSG_CHECKING([whether NLS is requested])
2291    dnl Default is enabled NLS
2292    AC_ARG_ENABLE(nls,
2293      [  --disable-nls           do not use Native Language Support],
2294      USE_NLS=$enableval, USE_NLS=yes)
2295    AC_MSG_RESULT($USE_NLS)
2296    AC_SUBST(USE_NLS)
2297
2298    BUILD_INCLUDED_LIBINTL=no
2299    USE_INCLUDED_LIBINTL=no
2300    INTLLIBS=
2301
2302    dnl If we use NLS figure out what method
2303    if test "$USE_NLS" = "yes"; then
2304      AC_DEFINE(ENABLE_NLS, 1,
2305        [Define to 1 if translation of program messages to the user's native language
2306   is requested.])
2307      AC_MSG_CHECKING([whether included gettext is requested])
2308      AC_ARG_WITH(included-gettext,
2309        [  --with-included-gettext use the GNU gettext library included here],
2310        nls_cv_force_use_gnu_gettext=$withval,
2311        nls_cv_force_use_gnu_gettext=no)
2312      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
2313
2314      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
2315      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
2316        dnl User does not insist on using GNU NLS library.  Figure out what
2317        dnl to use.  If GNU gettext is available we use this.  Else we have
2318        dnl to fall back to GNU NLS library.
2319	CATOBJEXT=NONE
2320
2321        dnl Add a version number to the cache macros.
2322        define(gt_cv_func_gnugettext_libc, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libc])
2323        define(gt_cv_func_gnugettext_libintl, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libintl])
2324
2325	AC_CHECK_HEADER(libintl.h,
2326	  [AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
2327	    [AC_TRY_LINK([#include <libintl.h>
2328extern int _nl_msg_cat_cntr;],
2329	       [bindtextdomain ("", "");
2330return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
2331	       gt_cv_func_gnugettext_libc=yes,
2332	       gt_cv_func_gnugettext_libc=no)])
2333
2334	   if test "$gt_cv_func_gnugettext_libc" != "yes"; then
2335	     AC_CACHE_CHECK([for GNU gettext in libintl],
2336	       gt_cv_func_gnugettext_libintl,
2337	       [gt_save_LIBS="$LIBS"
2338		LIBS="$LIBS -lintl $LIBICONV"
2339		AC_TRY_LINK([#include <libintl.h>
2340extern int _nl_msg_cat_cntr;],
2341		  [bindtextdomain ("", "");
2342return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
2343		  gt_cv_func_gnugettext_libintl=yes,
2344		  gt_cv_func_gnugettext_libintl=no)
2345		LIBS="$gt_save_LIBS"])
2346	   fi
2347
2348	   dnl If an already present or preinstalled GNU gettext() is found,
2349	   dnl use it.  But if this macro is used in GNU gettext, and GNU
2350	   dnl gettext is already preinstalled in libintl, we update this
2351	   dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
2352	   if test "$gt_cv_func_gnugettext_libc" = "yes" \
2353	      || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
2354		   && test "$PACKAGE" != gettext; }; then
2355	     AC_DEFINE(HAVE_GETTEXT, 1,
2356               [Define if the GNU gettext() function is already present or preinstalled.])
2357
2358	     if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
2359	       dnl If iconv() is in a separate libiconv library, then anyone
2360	       dnl linking with libintl{.a,.so} also needs to link with
2361	       dnl libiconv.
2362	       INTLLIBS="-lintl $LIBICONV"
2363	     fi
2364
2365	     gt_save_LIBS="$LIBS"
2366	     LIBS="$LIBS $INTLLIBS"
2367	     AC_CHECK_FUNCS(dcgettext)
2368	     LIBS="$gt_save_LIBS"
2369
2370	     AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2371	       [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
2372	     if test "$MSGFMT" != "no"; then
2373	       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2374	     fi
2375
2376	     AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2377	       [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2378
2379	     CATOBJEXT=.gmo
2380	   fi
2381	])
2382
2383        if test "$CATOBJEXT" = "NONE"; then
2384	  dnl GNU gettext is not found in the C library.
2385	  dnl Fall back on GNU gettext library.
2386	  nls_cv_use_gnu_gettext=yes
2387        fi
2388      fi
2389
2390      if test "$nls_cv_use_gnu_gettext" = "yes"; then
2391        dnl Mark actions used to generate GNU NLS library.
2392        INTLOBJS="\$(GETTOBJS)"
2393        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
2394	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
2395        AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
2396        AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
2397	  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
2398        AC_SUBST(MSGFMT)
2399	BUILD_INCLUDED_LIBINTL=yes
2400	USE_INCLUDED_LIBINTL=yes
2401        CATOBJEXT=.gmo
2402	INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
2403	LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
2404      fi
2405
2406      dnl Test whether we really found GNU xgettext.
2407      if test "$XGETTEXT" != ":"; then
2408	dnl If it is no GNU xgettext we define it as : so that the
2409	dnl Makefiles still can work.
2410	if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
2411	  : ;
2412	else
2413	  AC_MSG_RESULT(
2414	    [found xgettext program is not GNU xgettext; ignore it])
2415	  XGETTEXT=":"
2416	fi
2417      fi
2418
2419      dnl We need to process the po/ directory.
2420      POSUB=po
2421    fi
2422    AC_OUTPUT_COMMANDS(
2423     [for ac_file in $CONFIG_FILES; do
2424        # Support "outfile[:infile[:infile...]]"
2425        case "$ac_file" in
2426          *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
2427        esac
2428        # PO directories have a Makefile.in generated from Makefile.in.in.
2429        case "$ac_file" in */Makefile.in)
2430          # Adjust a relative srcdir.
2431          ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
2432          ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
2433          ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
2434          case "$ac_given_srcdir" in
2435            .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
2436            /*) top_srcdir="$ac_given_srcdir" ;;
2437            *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
2438          esac
2439          if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
2440            rm -f "$ac_dir/POTFILES"
2441            echo creating "$ac_dir/POTFILES"
2442            sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
2443            echo creating "$ac_dir/Makefile"
2444            sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
2445          fi
2446          ;;
2447        esac
2448      done])
2449
2450
2451    dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
2452    dnl to 'yes' because some of the testsuite requires it.
2453    if test "$PACKAGE" = gettext; then
2454      BUILD_INCLUDED_LIBINTL=yes
2455    fi
2456
2457    dnl intl/plural.c is generated from intl/plural.y. It requires bison,
2458    dnl because plural.y uses bison specific features. It requires at least
2459    dnl bison-1.26 because earlier versions generate a plural.c that doesn't
2460    dnl compile.
2461    dnl bison is only needed for the maintainer (who touches plural.y). But in
2462    dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
2463    dnl the rule in general Makefile. Now, some people carelessly touch the
2464    dnl files or have a broken "make" program, hence the plural.c rule will
2465    dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
2466    dnl present or too old.
2467    AC_CHECK_PROGS([INTLBISON], [bison])
2468    if test -z "$INTLBISON"; then
2469      ac_verc_fail=yes
2470    else
2471      dnl Found it, now check the version.
2472      AC_MSG_CHECKING([version of bison])
2473changequote(<<,>>)dnl
2474      ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison .* \([0-9]*\.[0-9.]*\).*$/\1/p'`
2475      case $ac_prog_version in
2476        '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
2477        1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
2478changequote([,])dnl
2479           ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
2480        *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
2481      esac
2482      AC_MSG_RESULT([$ac_prog_version])
2483    fi
2484    if test $ac_verc_fail = yes; then
2485      INTLBISON=:
2486    fi
2487
2488    dnl These rules are solely for the distribution goal.  While doing this
2489    dnl we only have to keep exactly one list of the available catalogs
2490    dnl in configure.in.
2491    for lang in $ALL_LINGUAS; do
2492      GMOFILES="$GMOFILES $lang.gmo"
2493      POFILES="$POFILES $lang.po"
2494    done
2495
2496    dnl Make all variables we use known to autoconf.
2497    AC_SUBST(BUILD_INCLUDED_LIBINTL)
2498    AC_SUBST(USE_INCLUDED_LIBINTL)
2499    AC_SUBST(CATALOGS)
2500    AC_SUBST(CATOBJEXT)
2501    AC_SUBST(GMOFILES)
2502    AC_SUBST(INTLLIBS)
2503    AC_SUBST(INTLOBJS)
2504    AC_SUBST(POFILES)
2505    AC_SUBST(POSUB)
2506
2507    dnl For backward compatibility. Some configure.ins may be using this.
2508    nls_cv_header_intl=
2509    nls_cv_header_libgt=
2510
2511    dnl For backward compatibility. Some Makefiles may be using this.
2512    DATADIRNAME=share
2513    AC_SUBST(DATADIRNAME)
2514
2515    dnl For backward compatibility. Some Makefiles may be using this.
2516    INSTOBJEXT=.mo
2517    AC_SUBST(INSTOBJEXT)
2518
2519    dnl For backward compatibility. Some Makefiles may be using this.
2520    GENCAT=gencat
2521    AC_SUBST(GENCAT)
2522  ])
2523
2524dnl Usage: Just like AM_WITH_NLS, which see.
2525AC_DEFUN([AM_GNU_GETTEXT],
2526  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
2527   AC_REQUIRE([AC_PROG_CC])dnl
2528   AC_REQUIRE([AC_CANONICAL_HOST])dnl
2529   AC_REQUIRE([AC_PROG_RANLIB])dnl
2530   AC_REQUIRE([AC_ISC_POSIX])dnl
2531   AC_REQUIRE([AC_HEADER_STDC])dnl
2532   AC_REQUIRE([AC_C_CONST])dnl
2533   AC_REQUIRE([AC_C_INLINE])dnl
2534   AC_REQUIRE([AC_TYPE_OFF_T])dnl
2535   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
2536   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
2537   AC_REQUIRE([AC_FUNC_MMAP])dnl
2538   AC_REQUIRE([jm_GLIBC21])dnl
2539
2540   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
2541stdlib.h string.h unistd.h sys/param.h])
2542   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
2543getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
2544strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
2545
2546   AM_ICONV
2547   AM_LANGINFO_CODESET
2548   AM_LC_MESSAGES
2549   AM_WITH_NLS([$1],[$2],[$3])
2550
2551   if test "x$CATOBJEXT" != "x"; then
2552     if test "x$ALL_LINGUAS" = "x"; then
2553       LINGUAS=
2554     else
2555       AC_MSG_CHECKING(for catalogs to be installed)
2556       NEW_LINGUAS=
2557       for presentlang in $ALL_LINGUAS; do
2558         useit=no
2559         for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
2560           # Use the presentlang catalog if desiredlang is
2561           #   a. equal to presentlang, or
2562           #   b. a variant of presentlang (because in this case,
2563           #      presentlang can be used as a fallback for messages
2564           #      which are not translated in the desiredlang catalog).
2565           case "$desiredlang" in
2566             "$presentlang"*) useit=yes;;
2567           esac
2568         done
2569         if test $useit = yes; then
2570           NEW_LINGUAS="$NEW_LINGUAS $presentlang"
2571         fi
2572       done
2573       LINGUAS=$NEW_LINGUAS
2574       AC_MSG_RESULT($LINGUAS)
2575     fi
2576
2577     dnl Construct list of names of catalog files to be constructed.
2578     if test -n "$LINGUAS"; then
2579       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
2580     fi
2581   fi
2582
2583   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
2584   dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
2585   dnl Try to locate is.
2586   MKINSTALLDIRS=
2587   if test -n "$ac_aux_dir"; then
2588     MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
2589   fi
2590   if test -z "$MKINSTALLDIRS"; then
2591     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
2592   fi
2593   AC_SUBST(MKINSTALLDIRS)
2594
2595   dnl Enable libtool support if the surrounding package wishes it.
2596   INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
2597   AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
2598  ])
2599
2600# Search path for a program which passes the given test.
2601# Ulrich Drepper <drepper@cygnus.com>, 1996.
2602#
2603# This file can be copied and used freely without restrictions.  It can
2604# be used in projects which are not available under the GNU Public License
2605# but which still want to provide support for the GNU gettext functionality.
2606# Please note that the actual code is *not* freely available.
2607
2608# serial 1
2609
2610dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
2611dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
2612AC_DEFUN([AM_PATH_PROG_WITH_TEST],
2613[# Extract the first word of "$2", so it can be a program name with args.
2614set dummy $2; ac_word=[$]2
2615AC_MSG_CHECKING([for $ac_word])
2616AC_CACHE_VAL(ac_cv_path_$1,
2617[case "[$]$1" in
2618  /*)
2619  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
2620  ;;
2621  *)
2622  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2623  for ac_dir in ifelse([$5], , $PATH, [$5]); do
2624    test -z "$ac_dir" && ac_dir=.
2625    if test -f $ac_dir/$ac_word; then
2626      if [$3]; then
2627	ac_cv_path_$1="$ac_dir/$ac_word"
2628	break
2629      fi
2630    fi
2631  done
2632  IFS="$ac_save_ifs"
2633dnl If no 4th arg is given, leave the cache variable unset,
2634dnl so AC_PATH_PROGS will keep looking.
2635ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
2636])dnl
2637  ;;
2638esac])dnl
2639$1="$ac_cv_path_$1"
2640if test -n "[$]$1"; then
2641  AC_MSG_RESULT([$]$1)
2642else
2643  AC_MSG_RESULT(no)
2644fi
2645AC_SUBST($1)dnl
2646])
2647
2648#serial 2
2649
2650# Test for the GNU C Library, version 2.1 or newer.
2651# From Bruno Haible.
2652
2653AC_DEFUN([jm_GLIBC21],
2654  [
2655    AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
2656      ac_cv_gnu_library_2_1,
2657      [AC_EGREP_CPP([Lucky GNU user],
2658	[
2659#include <features.h>
2660#ifdef __GNU_LIBRARY__
2661 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
2662  Lucky GNU user
2663 #endif
2664#endif
2665	],
2666	ac_cv_gnu_library_2_1=yes,
2667	ac_cv_gnu_library_2_1=no)
2668      ]
2669    )
2670    AC_SUBST(GLIBC21)
2671    GLIBC21="$ac_cv_gnu_library_2_1"
2672  ]
2673)
2674
2675#serial AM2
2676
2677dnl From Bruno Haible.
2678
2679AC_DEFUN([AM_ICONV],
2680[
2681  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
2682  dnl those with the standalone portable GNU libiconv installed).
2683
2684  AC_ARG_WITH([libiconv-prefix],
2685[  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
2686    for dir in `echo "$withval" | tr : ' '`; do
2687      if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
2688      if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
2689    done
2690   ])
2691
2692  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
2693    am_cv_func_iconv="no, consider installing GNU libiconv"
2694    am_cv_lib_iconv=no
2695    AC_TRY_LINK([#include <stdlib.h>
2696#include <iconv.h>],
2697      [iconv_t cd = iconv_open("","");
2698       iconv(cd,NULL,NULL,NULL,NULL);
2699       iconv_close(cd);],
2700      am_cv_func_iconv=yes)
2701    if test "$am_cv_func_iconv" != yes; then
2702      am_save_LIBS="$LIBS"
2703      LIBS="$LIBS -liconv"
2704      AC_TRY_LINK([#include <stdlib.h>
2705#include <iconv.h>],
2706        [iconv_t cd = iconv_open("","");
2707         iconv(cd,NULL,NULL,NULL,NULL);
2708         iconv_close(cd);],
2709        am_cv_lib_iconv=yes
2710        am_cv_func_iconv=yes)
2711      LIBS="$am_save_LIBS"
2712    fi
2713  ])
2714  if test "$am_cv_func_iconv" = yes; then
2715    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
2716    AC_MSG_CHECKING([for iconv declaration])
2717    AC_CACHE_VAL(am_cv_proto_iconv, [
2718      AC_TRY_COMPILE([
2719#include <stdlib.h>
2720#include <iconv.h>
2721extern
2722#ifdef __cplusplus
2723"C"
2724#endif
2725#if defined(__STDC__) || defined(__cplusplus)
2726size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
2727#else
2728size_t iconv();
2729#endif
2730], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
2731      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
2732    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
2733    AC_MSG_RESULT([$]{ac_t:-
2734         }[$]am_cv_proto_iconv)
2735    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
2736      [Define as const if the declaration of iconv() needs const.])
2737  fi
2738  LIBICONV=
2739  if test "$am_cv_lib_iconv" = yes; then
2740    LIBICONV="-liconv"
2741  fi
2742  AC_SUBST(LIBICONV)
2743])
2744
2745#serial AM1
2746
2747dnl From Bruno Haible.
2748
2749AC_DEFUN([AM_LANGINFO_CODESET],
2750[
2751  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
2752    [AC_TRY_LINK([#include <langinfo.h>],
2753      [char* cs = nl_langinfo(CODESET);],
2754      am_cv_langinfo_codeset=yes,
2755      am_cv_langinfo_codeset=no)
2756    ])
2757  if test $am_cv_langinfo_codeset = yes; then
2758    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
2759      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
2760  fi
2761])
2762
2763# Check whether LC_MESSAGES is available in <locale.h>.
2764# Ulrich Drepper <drepper@cygnus.com>, 1995.
2765#
2766# This file can be copied and used freely without restrictions.  It can
2767# be used in projects which are not available under the GNU Public License
2768# but which still want to provide support for the GNU gettext functionality.
2769# Please note that the actual code is *not* freely available.
2770
2771# serial 2
2772
2773AC_DEFUN([AM_LC_MESSAGES],
2774  [if test $ac_cv_header_locale_h = yes; then
2775    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2776      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2777       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
2778    if test $am_cv_val_LC_MESSAGES = yes; then
2779      AC_DEFINE(HAVE_LC_MESSAGES, 1,
2780        [Define if your <locale.h> file defines LC_MESSAGES.])
2781    fi
2782  fi])
2783
2784# Do all the work for Automake.  This macro actually does too much --
2785# some checks are only needed if your package does certain things.
2786# But this isn't really a big deal.
2787
2788# serial 1
2789
2790dnl Usage:
2791dnl AM_INIT_AUTOMAKE(package,version, [no-define])
2792
2793AC_DEFUN([AM_INIT_AUTOMAKE],
2794[AC_REQUIRE([AC_PROG_INSTALL])
2795PACKAGE=[$1]
2796AC_SUBST(PACKAGE)
2797VERSION=[$2]
2798AC_SUBST(VERSION)
2799dnl test to see if srcdir already configured
2800if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
2801  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
2802fi
2803ifelse([$3],,
2804AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
2805AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
2806AC_REQUIRE([AM_SANITY_CHECK])
2807AC_REQUIRE([AC_ARG_PROGRAM])
2808dnl FIXME This is truly gross.
2809missing_dir=`cd $ac_aux_dir && pwd`
2810AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
2811AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
2812AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
2813AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
2814AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
2815AC_REQUIRE([AC_PROG_MAKE_SET])])
2816
2817#
2818# Check to make sure that the build environment is sane.
2819#
2820
2821AC_DEFUN([AM_SANITY_CHECK],
2822[AC_MSG_CHECKING([whether build environment is sane])
2823# Just in case
2824sleep 1
2825echo timestamp > conftestfile
2826# Do `set' in a subshell so we don't clobber the current shell's
2827# arguments.  Must try -L first in case configure is actually a
2828# symlink; some systems play weird games with the mod time of symlinks
2829# (eg FreeBSD returns the mod time of the symlink's containing
2830# directory).
2831if (
2832   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
2833   if test "[$]*" = "X"; then
2834      # -L didn't work.
2835      set X `ls -t $srcdir/configure conftestfile`
2836   fi
2837   if test "[$]*" != "X $srcdir/configure conftestfile" \
2838      && test "[$]*" != "X conftestfile $srcdir/configure"; then
2839
2840      # If neither matched, then we have a broken ls.  This can happen
2841      # if, for instance, CONFIG_SHELL is bash and it inherits a
2842      # broken ls alias from the environment.  This has actually
2843      # happened.  Such a system could not be considered "sane".
2844      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
2845alias in your environment])
2846   fi
2847
2848   test "[$]2" = conftestfile
2849   )
2850then
2851   # Ok.
2852   :
2853else
2854   AC_MSG_ERROR([newly created file is older than distributed files!
2855Check your system clock])
2856fi
2857rm -f conftest*
2858AC_MSG_RESULT(yes)])
2859
2860dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
2861dnl The program must properly implement --version.
2862AC_DEFUN([AM_MISSING_PROG],
2863[AC_MSG_CHECKING(for working $2)
2864# Run test in a subshell; some versions of sh will print an error if
2865# an executable is not found, even if stderr is redirected.
2866# Redirect stdin to placate older versions of autoconf.  Sigh.
2867if ($2 --version) < /dev/null > /dev/null 2>&1; then
2868   $1=$2
2869   AC_MSG_RESULT(found)
2870else
2871   $1="$3/missing $2"
2872   AC_MSG_RESULT(missing)
2873fi
2874AC_SUBST($1)])
2875
2876# Like AC_CONFIG_HEADER, but automatically create stamp file.
2877
2878AC_DEFUN([AM_CONFIG_HEADER],
2879[AC_PREREQ([2.12])
2880AC_CONFIG_HEADER([$1])
2881dnl When config.status generates a header, we must update the stamp-h file.
2882dnl This file resides in the same directory as the config header
2883dnl that is generated.  We must strip everything past the first ":",
2884dnl and everything past the last "/".
2885AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
2886ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
2887<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
2888<<am_indx=1
2889for am_file in <<$1>>; do
2890  case " <<$>>CONFIG_HEADERS " in
2891  *" <<$>>am_file "*<<)>>
2892    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
2893    ;;
2894  esac
2895  am_indx=`expr "<<$>>am_indx" + 1`
2896done<<>>dnl>>)
2897changequote([,]))])
2898
2899