OSDN Git Service

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