OSDN Git Service

Daily bump.
[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" &&
372      test x"$enable_debug" = x"no"; then
373     OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
374   fi
375
376   AC_SUBST(SECTION_LDFLAGS)
377   AC_SUBST(OPT_LDFLAGS)
378 ])
379
380
381 dnl
382 dnl Check to see if the (math function) argument passed is
383 dnl declared when using the c++ compiler
384 dnl ASSUMES argument is a math function with ONE parameter
385 dnl
386 dnl GLIBCPP_CHECK_MATH_DECL_1
387 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
388   AC_MSG_CHECKING([for $1 declaration])
389   if test x${glibcpp_cv_func_$1_use+set} != xset; then
390     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
391       AC_LANG_SAVE
392       AC_LANG_CPLUSPLUS
393       AC_TRY_COMPILE([#include <math.h>
394                       #ifdef HAVE_IEEEFP_H
395                       #include <ieeefp.h>
396                       #endif
397                      ], 
398                      [ $1(0);], 
399                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
400       AC_LANG_RESTORE
401     ])
402   fi
403   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
404 ])
405
406 dnl
407 dnl Check to see if the (math function) argument passed is
408 dnl 1) declared when using the c++ compiler
409 dnl 2) has "C" linkage
410 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
411 dnl
412 dnl Define HAVE_CARGF etc if "cargf" is declared and links
413 dnl
414 dnl argument 1 is name of function to check
415 dnl
416 dnl ASSUMES argument is a math function with ONE parameter
417 dnl
418 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
419 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
420   GLIBCPP_CHECK_MATH_DECL_1($1)
421   if test x$glibcpp_cv_func_$1_use = x"yes"; then
422     AC_CHECK_FUNCS($1)    
423   else
424     GLIBCPP_CHECK_MATH_DECL_1(_$1)
425     if test x$glibcpp_cv_func__$1_use = x"yes"; then
426       AC_CHECK_FUNCS(_$1)    
427     fi
428   fi
429 ])
430
431
432 dnl
433 dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
434 dnl of functions at once.  It's an all-or-nothing check -- either 
435 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
436 dnl Doing it this way saves significant configure time.
437 AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
438   AC_MSG_CHECKING([for $1 functions])
439   AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
440     AC_LANG_SAVE
441     AC_LANG_CPLUSPLUS
442     AC_TRY_COMPILE([#include <math.h>],
443                    [ `for x in $3; do echo "$x (0);"; done` ],
444                    [glibcpp_cv_func_$2_use=yes],
445                    [glibcpp_cv_func_$2_use=no])
446     AC_LANG_RESTORE])
447   AC_MSG_RESULT($glibcpp_cv_func_$2_use)
448   if test x$glibcpp_cv_func_$2_use = x"yes"; then
449     AC_CHECK_FUNCS($3)
450   fi
451 ])
452
453 dnl
454 dnl Check to see if the (math function) argument passed is
455 dnl declared when using the c++ compiler
456 dnl ASSUMES argument is a math function with TWO parameters
457 dnl
458 dnl GLIBCPP_CHECK_MATH_DECL_2
459 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
460   AC_MSG_CHECKING([for $1 declaration])
461   if test x${glibcpp_cv_func_$1_use+set} != xset; then
462     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
463       AC_LANG_SAVE
464       AC_LANG_CPLUSPLUS
465       AC_TRY_COMPILE([#include <math.h>], 
466                      [ $1(0, 0);], 
467                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
468       AC_LANG_RESTORE
469     ])
470   fi
471   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
472 ])
473
474 dnl
475 dnl Check to see if the (math function) argument passed is
476 dnl 1) declared when using the c++ compiler
477 dnl 2) has "C" linkage
478 dnl
479 dnl Define HAVE_CARGF etc if "cargf" is declared and links
480 dnl
481 dnl argument 1 is name of function to check
482 dnl
483 dnl ASSUMES argument is a math function with TWO parameters
484 dnl
485 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
486 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
487   GLIBCPP_CHECK_MATH_DECL_2($1)
488   if test x$glibcpp_cv_func_$1_use = x"yes"; then
489     AC_CHECK_FUNCS($1)    
490   else
491     GLIBCPP_CHECK_MATH_DECL_2(_$1)
492     if test x$glibcpp_cv_func__$1_use = x"yes"; then
493       AC_CHECK_FUNCS(_$1)    
494     fi
495   fi
496 ])
497
498
499 dnl
500 dnl Check to see if the (math function) argument passed is
501 dnl declared when using the c++ compiler
502 dnl ASSUMES argument is a math function with THREE parameters
503 dnl
504 dnl GLIBCPP_CHECK_MATH_DECL_3
505 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
506   AC_MSG_CHECKING([for $1 declaration])
507   if test x${glibcpp_cv_func_$1_use+set} != xset; then
508     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
509       AC_LANG_SAVE
510       AC_LANG_CPLUSPLUS
511       AC_TRY_COMPILE([#include <math.h>], 
512                      [ $1(0, 0, 0);], 
513                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
514       AC_LANG_RESTORE
515     ])
516   fi
517   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
518 ])
519
520 dnl
521 dnl Check to see if the (math function) argument passed is
522 dnl 1) declared when using the c++ compiler
523 dnl 2) has "C" linkage
524 dnl
525 dnl Define HAVE_CARGF etc if "cargf" is declared and links
526 dnl
527 dnl argument 1 is name of function to check
528 dnl
529 dnl ASSUMES argument is a math function with THREE parameters
530 dnl
531 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
532 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
533   GLIBCPP_CHECK_MATH_DECL_3($1)
534   if test x$glibcpp_cv_func_$1_use = x"yes"; then
535     AC_CHECK_FUNCS($1)    
536   else
537     GLIBCPP_CHECK_MATH_DECL_3(_$1)
538     if test x$glibcpp_cv_func__$1_use = x"yes"; then
539       AC_CHECK_FUNCS(_$1)    
540     fi
541   fi
542 ])
543
544
545 dnl
546 dnl Check to see if the (stdlib function) argument passed is
547 dnl 1) declared when using the c++ compiler
548 dnl 2) has "C" linkage
549 dnl
550 dnl argument 1 is name of function to check
551 dnl
552 dnl ASSUMES argument is a math function with TWO parameters
553 dnl
554 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
555 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
556   AC_MSG_CHECKING([for $1 declaration])
557   if test x${glibcpp_cv_func_$1_use+set} != xset; then
558     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
559       AC_LANG_SAVE
560       AC_LANG_CPLUSPLUS
561       AC_TRY_COMPILE([#include <stdlib.h>], 
562                      [ $1(0, 0);], 
563                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
564       AC_LANG_RESTORE
565     ])
566   fi
567   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
568   if test x$glibcpp_cv_func_$1_use = x"yes"; then
569     AC_CHECK_FUNCS($1)    
570   fi
571 ])
572
573
574 dnl
575 dnl Because the builtins are picky picky picky about the arguments they take, 
576 dnl do an explict linkage tests here.
577 dnl Check to see if the (math function) argument passed is
578 dnl 1) declared when using the c++ compiler
579 dnl 2) has "C" linkage
580 dnl
581 dnl Define HAVE_CARGF etc if "cargf" is declared and links
582 dnl
583 dnl argument 1 is name of function to check
584 dnl
585 dnl ASSUMES argument is a math function with ONE parameter
586 dnl
587 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
588 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
589   AC_MSG_CHECKING([for $1 declaration])
590   if test x${glibcpp_cv_func_$1_use+set} != xset; then
591     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
592       AC_LANG_SAVE
593       AC_LANG_CPLUSPLUS
594       AC_TRY_COMPILE([#include <math.h>], 
595                      [ $1(0);], 
596                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
597       AC_LANG_RESTORE
598     ])
599   fi
600   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
601   if test x$glibcpp_cv_func_$1_use = x"yes"; then
602     AC_MSG_CHECKING([for $1 linkage])
603     if test x${glibcpp_cv_func_$1_link+set} != xset; then
604       AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
605         AC_TRY_LINK([#include <math.h>], 
606                     [ $1(0);], 
607                     [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
608       ])
609     fi
610     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
611     if test x$glibcpp_cv_func_$1_link = x"yes"; then
612       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
613       AC_DEFINE_UNQUOTED(${ac_tr_func})
614     fi
615   fi
616 ])
617
618
619 dnl
620 dnl Check to see what builtin math functions are supported
621 dnl
622 dnl check for __builtin_abs
623 dnl check for __builtin_fabsf
624 dnl check for __builtin_fabs
625 dnl check for __builtin_fabl
626 dnl check for __builtin_labs
627 dnl check for __builtin_sqrtf
628 dnl check for __builtin_sqrtl
629 dnl check for __builtin_sqrt
630 dnl check for __builtin_sinf
631 dnl check for __builtin_sin
632 dnl check for __builtin_sinl
633 dnl check for __builtin_cosf
634 dnl check for __builtin_cos
635 dnl check for __builtin_cosl
636 dnl
637 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
638 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
639   dnl Test for builtin math functions.
640   dnl These are made in gcc/c-common.c 
641   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
642   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
643   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
644   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
645   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
646
647   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
648   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
649   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
650
651   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
652   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
653   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
654
655   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
656   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
657   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
658
659   dnl There is, without a doubt, a more elegant way to have these
660   dnl names exported so that they won't be stripped out of acconfig.h by
661   dnl autoheader. I leave this as an exercise to somebody less frustrated
662   dnl than I.... please email the libstdc++ list if you can figure out a
663   dnl more elegant approach (see autoconf/acgen.m4 and specifically
664   dnl AC_CHECK_FUNC for things to steal.)
665   dummyvar=no
666   if test x$dummyvar = x"yes"; then
667     AC_DEFINE(HAVE___BUILTIN_ABS)
668     AC_DEFINE(HAVE___BUILTIN_LABS)
669     AC_DEFINE(HAVE___BUILTIN_COS)
670     AC_DEFINE(HAVE___BUILTIN_COSF)
671     AC_DEFINE(HAVE___BUILTIN_COSL)
672     AC_DEFINE(HAVE___BUILTIN_FABS)
673     AC_DEFINE(HAVE___BUILTIN_FABSF)
674     AC_DEFINE(HAVE___BUILTIN_FABSL)
675     AC_DEFINE(HAVE___BUILTIN_SIN)
676     AC_DEFINE(HAVE___BUILTIN_SINF)
677     AC_DEFINE(HAVE___BUILTIN_SINL)
678     AC_DEFINE(HAVE___BUILTIN_SQRT)
679     AC_DEFINE(HAVE___BUILTIN_SQRTF)
680     AC_DEFINE(HAVE___BUILTIN_SQRTL)
681   fi
682 ])
683
684
685 dnl
686 dnl Check to see what the underlying c library 
687 dnl These checks need to do two things: 
688 dnl 1) make sure the name is declared when using the c++ compiler
689 dnl 2) make sure the name has "C" linkage
690 dnl This might seem like overkill but experience has shown that it's not...
691 dnl
692 dnl Define HAVE_STRTOLD if "strtold" is declared and links
693 dnl Define HAVE_STRTOF if "strtof" is declared and links
694 dnl Define HAVE_DRAND48 if "drand48" is declared and links
695 dnl
696 dnl GLIBCPP_CHECK_STDLIB_SUPPORT
697 AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
698   ac_test_CXXFLAGS="${CXXFLAGS+set}"
699   ac_save_CXXFLAGS="$CXXFLAGS"
700   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
701
702   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
703   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
704   AC_CHECK_FUNCS(drand48)
705
706   CXXFLAGS="$ac_save_CXXFLAGS"
707 ])
708
709
710 dnl
711 dnl Check to see what the underlying c library or math library is like.
712 dnl These checks need to do two things: 
713 dnl 1) make sure the name is declared when using the c++ compiler
714 dnl 2) make sure the name has "C" linkage
715 dnl This might seem like overkill but experience has shown that it's not...
716 dnl
717 dnl Define HAVE_CARGF etc if "cargf" is found.
718 dnl
719 dnl GLIBCPP_CHECK_MATH_SUPPORT
720 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
721   ac_test_CXXFLAGS="${CXXFLAGS+set}"
722   ac_save_CXXFLAGS="$CXXFLAGS"
723   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
724
725   dnl Check libm
726   AC_CHECK_LIB(m, sin, libm="-lm")
727   ac_save_LIBS="$LIBS"
728   LIBS="$LIBS $libm"
729
730   dnl Check to see if certain C math functions exist.
731   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
732   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
733   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
734   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
735   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
736   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
737   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
738   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
739
740   dnl Check to see if basic C math functions have float versions.
741   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
742                                           float_trig,
743                                           acosf asinf atanf \
744                                           cosf sinf tanf \
745                                           coshf sinhf tanhf)
746   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
747                                           float_round,
748                                           ceilf floorf)
749   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
750   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
751   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
752   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
753   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
754   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
755   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
756   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
757   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
758   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
759   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
760   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
761   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
762   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
763   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
764
765   dnl Check to see if basic C math functions have long double versions.
766   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
767                                           long_double_trig,
768                                           acosl asinl atanl \
769                                           cosl sinl tanl \
770                                           coshl sinhl tanhl)
771   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
772                                           long_double_round,
773                                           ceill floorl)
774   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
775   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
776   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
777   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
778   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
779   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
780   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
781   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
782   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
783   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
784   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
785   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
786   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
787   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
788   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
789   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
790   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
791
792   dnl Some runtimes have these functions with a preceding underscore. Please
793   dnl keep this sync'd with the one above. And if you add any new symbol,
794   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
795   dnl Check to see if certain C math functions exist.
796
797   dnl Check to see if basic C math functions have float versions.
798   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
799                                           _float_trig,
800                                           _acosf _asinf _atanf \
801                                           _cosf _sinf _tanf \
802                                           _coshf _sinhf _tanhf)
803   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
804                                           _float_round,
805                                           _ceilf _floorf)
806
807   dnl Check to see if basic C math functions have long double versions.
808   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
809                                           _long_double_trig,
810                                           _acosl _asinl _atanl \
811                                           _cosl _sinl _tanl \
812                                           _coshl _sinhl _tanhl)
813   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
814                                           _long_double_round,
815                                           _ceill _floorl)
816
817   LIBS="$ac_save_LIBS"
818   CXXFLAGS="$ac_save_CXXFLAGS"
819 ])
820
821
822 dnl
823 dnl Check to see if there is native support for complex 
824 dnl
825 dnl Don't compile bits in math/* if native support exits.
826 dnl
827 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
828 dnl
829 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
830 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
831   dnl Check for complex versions of math functions of platform.
832   AC_CHECK_LIB(m, main)
833   AC_REPLACE_MATHFUNCS(nan copysignf)
834
835   dnl Compile the long double complex functions only if the function 
836   dnl provides the non-complex long double functions that are needed.
837   dnl Currently this includes copysignl, which should be
838   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
839   USE_COMPLEX_LONG_DOUBLE=no
840   if test x$ac_cv_func_copysignl = x"yes"; then
841     USE_COMPLEX_LONG_DOUBLE=yes
842     AC_REPLACE_MATHFUNCS(signbitl)
843   fi
844
845   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
846 ])
847
848
849 dnl Check to see what architecture and operating system we are compiling
850 dnl for.  Also, if architecture- or OS-specific flags are required for
851 dnl compilation, pick them up here.
852 dnl 
853 dnl GLIBCPP_CHECK_TARGET
854 AC_DEFUN(GLIBCPP_CHECK_TARGET, [
855     . [$]{glibcpp_basedir}/configure.target
856     AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
857     AC_MSG_RESULT(OS config directory is $os_include_dir)
858 ])
859
860
861 dnl
862 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
863 dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
864 dnl must have been previously checked.)
865 dnl
866 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
867 dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
868 dnl
869 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
870 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
871
872   dnl Test wchar.h for mbstate_t, which is needed for char_traits and
873   dnl others even if wchar_t support is not on.
874   AC_MSG_CHECKING([for mbstate_t])
875   AC_TRY_COMPILE([#include <wchar.h>],
876   [mbstate_t teststate;], 
877   have_mbstate_t=yes, have_mbstate_t=no)
878   AC_MSG_RESULT($have_mbstate_t)
879   if test x"$have_mbstate_t" = xyes; then
880     AC_DEFINE(HAVE_MBSTATE_T)
881   fi
882
883   dnl Sanity check for existence of ISO C99 headers for extended encoding.
884   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
885   AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
886   
887   dnl Only continue checking if the ISO C99 headers exist and support is on.
888   if test x"$ac_has_wchar_h" = xyes &&
889      test x"$ac_has_wctype_h" = xyes &&
890      test x"$enable_c_mbchar" != xno; then
891       
892     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
893     dnl numeric_limits can instantiate type_traits<wchar_t>
894     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
895     AC_TRY_COMPILE([#include <wchar.h>],
896     [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
897     has_wchar_minmax=yes, has_wchar_minmax=no)
898     AC_MSG_RESULT($has_wchar_minmax)
899     
900     dnl Test wchar.h for WEOF, which is what we use to determine whether
901     dnl to specialize for char_traits<wchar_t> or not.
902     AC_MSG_CHECKING([for WEOF])
903     AC_TRY_COMPILE([
904       #include <wchar.h>
905       #include <stddef.h>],
906     [wint_t i = WEOF;],
907     has_weof=yes, has_weof=no)
908     AC_MSG_RESULT($has_weof)
909   
910     dnl Tests for wide character functions used in char_traits<wchar_t>.
911     ac_wfuncs=yes
912     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
913     ac_wfuncs=no)
914   
915     dnl Checks for names injected into std:: by the c_std headers.
916     AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
917     fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
918     vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
919     mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
920     wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
921     wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
922     ac_wfuncs=no)
923
924     AC_MSG_CHECKING([for ISO C99 wchar_t support])
925     if test x"$has_weof" = xyes &&
926        test x"$has_wchar_minmax" = xyes &&
927        test x"$ac_wfuncs" = xyes; then
928       ac_isoC99_wchar_t=yes
929     else
930       ac_isoC99_wchar_t=no
931     fi
932     AC_MSG_RESULT($ac_isoC99_wchar_t)
933   
934     dnl Use iconv for wchar_t to char conversions. As such, check for 
935     dnl X/Open Portability Guide, version 2 features (XPG2).
936     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
937     AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
938
939     dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
940     AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
941     ac_save_LIBS="$LIBS"
942     LIBS="$LIBS $libiconv"
943
944     AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
945     ac_XPG2funcs=yes, ac_XPG2funcs=no)
946   
947     LIBS="$ac_save_LIBS"
948
949     AC_MSG_CHECKING([for XPG2 wchar_t support])
950     if test x"$ac_has_iconv_h" = xyes &&
951        test x"$ac_has_langinfo_h" = xyes &&
952        test x"$ac_XPG2funcs" = xyes; then
953       ac_XPG2_wchar_t=yes
954     else
955       ac_XPG2_wchar_t=no
956     fi
957     AC_MSG_RESULT($ac_XPG2_wchar_t)
958   
959     dnl At the moment, only enable wchar_t specializations if all the
960     dnl above support is present.
961     AC_MSG_CHECKING([for enabled wchar_t specializations])
962     if test x"$ac_isoC99_wchar_t" = xyes &&
963        test x"$ac_XPG2_wchar_t" = xyes; then
964       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
965       AC_MSG_RESULT("yes")
966     else
967       AC_MSG_RESULT("no")
968     fi
969   else
970     dnl Wide characters disabled by the user. 
971     AC_MSG_WARN([wchar_t support disabled.])
972   fi
973 ])
974
975
976 dnl
977 dnl Check for special debugging mode; not for production use.
978 dnl
979 dnl GLIBCPP_ENABLE_DEBUG
980 dnl --enable-debug sets '-ggdb3 -O0'.
981 dnl --disable-debug sets '-g' and whatever optimization options the
982 dnl     compiler can handle.
983 dnl  +  --enable-maintainer-mode automatically defaults this to on.
984 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
985 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
986 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
987 dnl       defaults to `no'.
988 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
989 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
990 AC_ARG_ENABLE(debug,
991 changequote(<<, >>)dnl
992 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
993 changequote([, ])dnl
994 [case "${enableval}" in
995  yes) enable_debug=yes ;;
996  no)  enable_debug=no ;;
997  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
998  esac],
999 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1000
1001 dnl Option parsed, now set things appropriately
1002 case "${enable_debug}" in
1003     yes) 
1004         DEBUG_FLAGS='-O0 -ggdb3'                        
1005         ;; 
1006     no)   
1007         DEBUG_FLAGS='-g'
1008         ;;
1009 esac
1010 AC_SUBST(DEBUG_FLAGS)
1011 ])
1012
1013
1014 dnl
1015 dnl Check for "unusual" flags to pass to the compiler while building.
1016 dnl
1017 dnl GLIBCPP_ENABLE_CXX_FLAGS
1018 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1019 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1020 dnl     Somehow this same set of flags must be passed when [re]building
1021 dnl     libgcc.
1022 dnl --disable-cxx-flags passes nothing.
1023 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1024 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1025 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
1026 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1027 dnl       If "default flags" is an empty string (or "none"), the effect is
1028 dnl       the same as --disable or --enable=no.
1029 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1030 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1031 AC_ARG_ENABLE(cxx-flags,
1032 changequote(<<, >>)dnl
1033 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
1034                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1035 changequote([, ])dnl
1036 [case "x$enableval" in
1037  xyes)   
1038         AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1039  xno|x)  
1040         enable_cxx_flags='' ;;
1041  *)      
1042         enable_cxx_flags="$enableval" ;;
1043  esac],
1044 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1045
1046 dnl Thinko on my part during design.  This kludge is the workaround.
1047 if test "$enable_cxx_flags" = "none"; then 
1048   enable_cxx_flags=''; 
1049 fi
1050
1051 dnl Run through flags (either default or command-line) and set anything
1052 dnl extra (e.g., #defines) that must accompany particular g++ options.
1053 if test -n "$enable_cxx_flags"; then
1054     for f in $enable_cxx_flags; do
1055         case "$f" in
1056             -fhonor-std)  ;;
1057             -*)  ;;
1058             *)   # and we're trying to pass /what/ exactly?
1059                  AC_MSG_ERROR([compiler flags start with a -]) ;;
1060         esac
1061     done
1062 fi
1063 EXTRA_CXX_FLAGS="$enable_cxx_flags"
1064 AC_SUBST(EXTRA_CXX_FLAGS)
1065 ])
1066
1067
1068 dnl
1069 dnl Check for which locale library to use:  gnu or generic.
1070 dnl
1071 dnl GLIBCPP_ENABLE_CLOCALE
1072 dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1073 dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
1074 dnl 
1075 dnl default is generic
1076 dnl
1077 AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1078   AC_MSG_CHECKING([for clocale to use])
1079   AC_ARG_ENABLE(clocale,
1080   [  --enable-clocale        enable model for target locale package. 
1081   --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
1082   ], 
1083   if test x$enable_clocale = xno; then
1084      enable_clocale=no
1085   fi,
1086      enable_clocale=no)
1087
1088   enable_clocale_flag=$enable_clocale
1089
1090   dnl Probe for locale support if no specific model is specified.
1091   dnl Default to "generic"
1092   if test x$enable_clocale_flag = xno; then
1093     case x${target_os} in
1094       xlinux* | xgnu*)
1095         AC_EGREP_CPP([_GLIBCPP_ok], [
1096         #include <features.h>
1097         #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1098           _GLIBCPP_ok
1099         #endif
1100         ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1101
1102         # Test for bugs early in glibc-2.2.x series
1103         if test x$enable_clocale_flag = xgnu; then
1104           AC_TRY_RUN([
1105           #define _GNU_SOURCE 1
1106           #include <locale.h>
1107           int main()
1108           {
1109             const char __one[] = "Äuglein Augmen";
1110             const char __two[] = "Äuglein";
1111             int i;
1112             int j;
1113             __locale_t  loc;
1114             __locale_t  loc_dup;
1115             loc = __newlocale(1 << LC_ALL, "de_DE", 0);
1116             loc_dup = __duplocale(loc);
1117             i = __strcoll_l(__one, __two, loc);
1118             j = __strcoll_l(__one, __two, loc_dup);
1119             return 0;
1120           }
1121           ], 
1122           [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
1123           [enable_clocale_flag=generic])
1124         fi
1125
1126         # ... at some point put __strxfrm_l tests in as well.
1127         ;;
1128       *)
1129         enable_clocale_flag=generic
1130         ;;
1131     esac
1132   fi
1133
1134   dnl Set configure bits for specified locale package
1135   case x${enable_clocale_flag} in
1136     xgeneric)
1137       AC_MSG_RESULT(generic)
1138
1139       # Don't use gettext.
1140       USE_NLS=no
1141
1142       CLOCALE_H=config/locale/generic/c_locale.h
1143       CLOCALE_CC=config/locale/generic/c_locale.cc
1144       CCODECVT_H=config/locale/generic/codecvt_specializations.h
1145       CCOLLATE_CC=config/locale/generic/collate_members.cc
1146       CCTYPE_CC=config/locale/generic/ctype_members.cc
1147       CMESSAGES_H=config/locale/generic/messages_members.h
1148       CMESSAGES_CC=config/locale/generic/messages_members.cc
1149       CMONEY_CC=config/locale/generic/monetary_members.cc
1150       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1151       CTIME_CC=config/locale/generic/time_members.cc
1152       ;;
1153     xgnu)
1154       AC_MSG_RESULT(gnu)
1155
1156       # Declare intention to use gettext, and add support for specific
1157       # languages.
1158       # For some reason, ALL_LINGUAS has to be before AM_GNU_GETTEXT
1159       ALL_LINGUAS="de fr"
1160       # Don't call AM_GNU_GETTEXT here. Instead, assume glibc.
1161       # Need to deal with MSGFMT, USE_NLS, and glibcpp_[P,M]OFILES
1162       USE_NLS=yes
1163
1164       # Export the build objects.
1165       for ling in $ALL_LINGUAS; do \
1166         glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
1167         glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
1168       done
1169       AC_SUBST(glibcpp_MOFILES)
1170       AC_SUBST(glibcpp_POFILES)
1171
1172       CLOCALE_H=config/locale/gnu/c_locale.h
1173       CLOCALE_CC=config/locale/gnu/c_locale.cc
1174       CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1175       CCOLLATE_CC=config/locale/gnu/collate_members.cc
1176       CCTYPE_CC=config/locale/gnu/ctype_members.cc
1177       CMESSAGES_H=config/locale/gnu/messages_members.h
1178       CMESSAGES_CC=config/locale/gnu/messages_members.cc
1179       CMONEY_CC=config/locale/gnu/monetary_members.cc
1180       CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1181       CTIME_CC=config/locale/gnu/time_members.cc
1182       ;;
1183     xieee_1003.1)
1184       AC_MSG_RESULT(generic)
1185
1186       # Don't use gettext.
1187       USE_NLS=no
1188
1189       CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1190       CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
1191       CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1192       CCOLLATE_CC=config/locale/generic/collate_members.cc
1193       CCTYPE_CC=config/locale/generic/ctype_members.cc
1194       CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1195       CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1196       CMONEY_CC=config/locale/generic/monetary_members.cc
1197       CNUMERIC_CC=config/locale/generic/numeric_members.cc
1198       CTIME_CC=config/locale/generic/time_members.cc
1199       ;;
1200     *)
1201       echo "$enable_clocale is an unknown locale package" 1>&2
1202       exit 1
1203       ;;
1204   esac
1205
1206   # This is where the testsuite looks for locale catalogs, using the
1207   # -DLOCALEDIR define during testsuite compilation.
1208   glibcpp_localedir=${glibcpp_builddir}/po/share/locale
1209   AC_SUBST(glibcpp_localedir)
1210
1211   AC_SUBST(USE_NLS)
1212   AC_SUBST(CLOCALE_H)
1213   AC_SUBST(CCODECVT_H)
1214   AC_SUBST(CMESSAGES_H)
1215   AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1216   AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
1217   AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
1218   AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
1219   AC_LINK_FILES($CMONEY_CC, src/monetary.cc)
1220   AC_LINK_FILES($CNUMERIC_CC, src/numeric.cc)
1221   AC_LINK_FILES($CTIME_CC, src/time.cc)
1222 ])
1223
1224
1225 dnl
1226 dnl Check for which I/O library to use:  libio, or something specific.
1227 dnl
1228 dnl GLIBCPP_ENABLE_CSTDIO
1229 dnl --enable-cstdio=libio sets config/io/c_io_libio.h and friends
1230 dnl 
1231 dnl default is stdio
1232 dnl
1233 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1234   AC_MSG_CHECKING([for cstdio to use])
1235   AC_ARG_ENABLE(cstdio,
1236   [  --enable-cstdio         enable stdio for target io package. 
1237   --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
1238   ], 
1239   if test x$enable_cstdio = xno; then
1240      enable_cstdio=stdio
1241   fi,
1242      enable_cstdio=stdio)
1243
1244   enable_cstdio_flag=$enable_cstdio
1245
1246   dnl Check if a valid I/O package
1247   case x${enable_cstdio_flag} in
1248     xlibio)
1249       CSTDIO_H=config/io/c_io_libio.h
1250       BASIC_FILE_H=config/io/basic_file_libio.h
1251       BASIC_FILE_CC=config/io/basic_file_libio.cc
1252       AC_MSG_RESULT(libio)
1253
1254       # see if we are on a system with libio native (ie, linux)
1255       AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1256
1257       # Need to check and see what version of glibc is being used. If
1258       # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1259       # compile most of libio for linux systems.
1260       if test x$has_libio = x"yes"; then
1261         case "$target" in
1262           *-*-linux*)
1263               AC_MSG_CHECKING([for glibc version >= 2.2])
1264               AC_EGREP_CPP([ok], [
1265             #include <features.h>
1266               #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1267                     ok
1268               #endif
1269               ], glibc_satisfactory=yes, glibc_satisfactory=no)
1270               AC_MSG_RESULT($glibc_satisfactory)
1271             ;;
1272         esac
1273
1274         # XXX at the moment, admit defeat and force the recompilation
1275         # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1276         glibc_satisfactory=no        
1277
1278         if test x$glibc_satisfactory = x"yes"; then
1279            need_libio=no
1280            need_wlibio=no        
1281         else
1282            need_libio=yes
1283            # bkoz XXX need to add checks to enable this
1284            # pme XXX here's a first pass at such a check
1285            if test x$enable_c_mbchar != xno; then
1286               need_wlibio=yes
1287            else
1288               need_wlibio=no
1289            fi
1290         fi
1291
1292       else
1293          # Using libio, but <libio.h> doesn't exist on the target system. . .
1294          need_libio=yes
1295          # bkoz XXX need to add checks to enable this
1296          # pme XXX here's a first pass at such a check
1297          if test x$enable_c_mbchar != xno; then
1298              need_wlibio=yes
1299          else
1300              need_wlibio=no
1301          fi
1302       fi
1303       ;;
1304     xstdio | x | xno | xnone | xyes)
1305       # default
1306       CSTDIO_H=config/io/c_io_stdio.h
1307       BASIC_FILE_H=config/io/basic_file_stdio.h
1308       BASIC_FILE_CC=config/io/basic_file_stdio.cc
1309       AC_MSG_RESULT(stdio)
1310
1311       # We're not using stdio.
1312       need_libio=no
1313       need_wlibio=no
1314       ;;
1315     *)
1316       echo "$enable_cstdio is an unknown io package" 1>&2
1317       exit 1
1318       ;;
1319   esac
1320   AC_SUBST(CSTDIO_H)
1321   AC_SUBST(BASIC_FILE_H)
1322   AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
1323
1324   # 2000-08-04 bkoz hack
1325   CCODECVT_C=config/io/c_io_libio_codecvt.c
1326   AC_SUBST(CCODECVT_C)
1327   # 2000-08-04 bkoz hack
1328
1329   AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1330                  test "$need_libio" = yes || test "$need_wlibio" = yes)
1331   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1332   AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1333   if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1334     libio_la=../libio/libio.la
1335   else
1336     libio_la=
1337   fi
1338   AC_SUBST(libio_la)
1339 ])
1340
1341
1342 dnl
1343 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1344 dnl We must stage the required headers so that they will be installed
1345 dnl with the library (unlike libgcc, the STL implementation is provided
1346 dnl solely within headers).  Since we must not inject random user-space
1347 dnl macro names into user-provided C++ code, we first stage into <file>-in
1348 dnl and process to <file> with an output command.  The reason for a two-
1349 dnl stage process here is to correctly handle $srcdir!=$objdir without
1350 dnl having to write complex code (the sed commands to clean the macro
1351 dnl namespace are complex and fragile enough as it is).  We must also
1352 dnl add a relative path so that -I- is supported properly.
1353 dnl
1354 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1355   AC_MSG_CHECKING([for thread model used by GCC])
1356   target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1357   AC_MSG_RESULT([$target_thread_file])
1358
1359   if test $target_thread_file != single; then
1360     AC_DEFINE(HAVE_GTHR_DEFAULT)
1361     AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1362   fi
1363
1364   glibcpp_thread_h=gthr-$target_thread_file.h
1365   AC_SUBST(glibcpp_thread_h)
1366 ])
1367
1368
1369 dnl
1370 dnl Check for exception handling support.  If an explicit enable/disable
1371 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1372 dnl target may or may not support call frame exceptions.
1373 dnl
1374 dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1375 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1376 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1377 dnl
1378 dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1379 dnl
1380 AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1381   AC_MSG_CHECKING([for exception model to use])
1382   AC_LANG_SAVE
1383   AC_LANG_CPLUSPLUS
1384   AC_ARG_ENABLE(sjlj-exceptions,
1385   [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1386   [:],
1387   [dnl Botheration.  Now we've got to detect the exception model.
1388    dnl Link tests against libgcc.a are problematic since -- at least
1389    dnl as of this writing -- we've not been given proper -L bits for
1390    dnl single-tree newlib and libgloss.
1391    dnl
1392    dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1393    dnl conftest files before we got a change to grep them first.
1394    cat > conftest.$ac_ext << EOF
1395 [#]line __oline__ "configure"
1396 struct S { ~S(); };
1397 void bar();
1398 void foo()
1399 {
1400   S s;
1401   bar();
1402 }
1403 EOF
1404    old_CXXFLAGS="$CXXFLAGS"  
1405    CXXFLAGS=-S
1406    if AC_TRY_EVAL(ac_compile); then
1407      if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1408        enable_sjlj_exceptions=yes
1409      elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1410        enable_sjlj_exceptions=no
1411      fi
1412    fi
1413    CXXFLAGS="$old_CXXFLAGS"
1414    rm -f conftest*])
1415    if test x$enable_sjlj_exceptions = xyes; then
1416      AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1417         [Define if the compiler is configured for setjmp/longjmp exceptions.])
1418      ac_exception_model_name=sjlj
1419    elif test x$enable_sjlj_exceptions = xno; then
1420      ac_exception_model_name="call frame"
1421    else
1422      AC_MSG_ERROR([unable to detect exception model])
1423    fi
1424    AC_LANG_RESTORE
1425    AC_MSG_RESULT($ac_exception_model_name)
1426 ])
1427
1428
1429 dnl
1430 dnl Check for ISO/IEC 9899:1999 "C99" support.
1431 dnl
1432 dnl GLIBCPP_ENABLE_C99
1433 dnl --enable-c99 defines _GLIBCPP_USE_C99
1434 dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1435 dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1436 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1437 dnl       defaults to `no'.
1438 dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1439 dnl
1440 dnl GLIBCPP_ENABLE_C99
1441 AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1442   define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1443
1444   AC_ARG_ENABLE(c99,
1445   changequote(<<, >>)dnl
1446   <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1447   changequote([, ])dnl
1448   [case "$enableval" in
1449    yes) enable_c99=yes ;;
1450    no)  enable_c99=no ;;
1451    *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1452    esac],
1453   enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1454  
1455   AC_LANG_SAVE
1456   AC_LANG_CPLUSPLUS
1457
1458   # Check for the existence of <math.h> functions used if C99 is enabled.
1459   ac_c99_math=yes;
1460   AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1461   AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1462   AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1463   AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1464   AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1465   AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1466   AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1467   AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1468   AC_TRY_COMPILE([#include <math.h>],
1469                  [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1470   AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1471   AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1472   AC_TRY_COMPILE([#include <math.h>],
1473                  [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1474   AC_TRY_COMPILE([#include <math.h>],
1475                  [isunordered(0.0,0.0);],, [ac_c99_math=no])
1476   AC_MSG_RESULT($ac_c99_math)
1477
1478   # Check for the existence in <stdio.h> of vscanf, et. al.
1479   ac_c99_stdio=yes;
1480   AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1481   AC_TRY_COMPILE([#include <stdio.h>],
1482                  [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
1483   AC_TRY_COMPILE([#include <stdio.h>
1484                   #include <stdarg.h>
1485                   void foo(char* fmt, ...)
1486                   {va_list args; va_start(args, fmt);
1487                   vfscanf(stderr, "%i", args);}],
1488                   [],, [ac_c99_stdio=no])
1489   AC_TRY_COMPILE([#include <stdio.h>
1490                   #include <stdarg.h>
1491                   void foo(char* fmt, ...)
1492                   {va_list args; va_start(args, fmt);
1493                   vscanf("%i", args);}],
1494                   [],, [ac_c99_stdio=no])
1495   AC_TRY_COMPILE([#include <stdio.h>
1496                   #include <stdarg.h>
1497                   void foo(char* fmt, ...)
1498                   {va_list args; va_start(args, fmt);
1499                   vsnprintf(fmt, 0, "%i", args);}],
1500                   [],, [ac_c99_stdio=no])
1501   AC_TRY_COMPILE([#include <stdio.h>
1502                   #include <stdarg.h>
1503                   void foo(char* fmt, ...)
1504                   {va_list args; va_start(args, fmt);
1505                   vsscanf(fmt, "%i", args);}],
1506                   [],, [ac_c99_stdio=no])
1507   AC_MSG_RESULT($ac_c99_stdio)
1508
1509   # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1510   ac_c99_stdlib=yes;
1511   AC_MSG_CHECKING([for lldiv_t declaration])
1512   AC_CACHE_VAL(ac_c99_lldiv_t, [
1513   AC_TRY_COMPILE([#include <stdlib.h>], 
1514                    [ lldiv_t mydivt;], 
1515                    [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1516   ])
1517   AC_MSG_RESULT($ac_c99_lldiv_t)
1518
1519   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1520   AC_TRY_COMPILE([#include <stdlib.h>],
1521                  [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1522   AC_TRY_COMPILE([#include <stdlib.h>],
1523                  [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1524   AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1525   AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1526   AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1527   AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1528   if test x"$ac_c99_lldiv_t" = x"no"; then
1529     ac_c99_stdlib=no; 
1530   fi; 
1531   AC_MSG_RESULT($ac_c99_stdlib)
1532
1533   # Check for the existence of <wchar.h> functions used if C99 is enabled.
1534   # XXX the wchar.h checks should be rolled into the general C99 bits.
1535   ac_c99_wchar=yes;
1536   AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1537   AC_TRY_COMPILE([#include <wchar.h>], 
1538                  [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1539   AC_TRY_COMPILE([#include <wchar.h>], 
1540                  [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1541   AC_TRY_COMPILE([#include <wchar.h>], 
1542                  [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1543   AC_MSG_RESULT($ac_c99_wchar)
1544
1545   AC_MSG_CHECKING([for enabled ISO C99 support])
1546   if test x"$ac_c99_math" = x"no" ||
1547      test x"$ac_c99_stdio" = x"no" ||
1548      test x"$ac_c99_stdlib" = x"no" ||
1549      test x"$ac_c99_wchar" = x"no"; then
1550     enable_c99=no; 
1551   fi; 
1552   AC_MSG_RESULT($enable_c99)
1553
1554   # Option parsed, now set things appropriately
1555   if test x"$enable_c99" = x"yes"; then
1556     AC_DEFINE(_GLIBCPP_USE_C99)
1557   fi
1558
1559   AC_LANG_RESTORE
1560 ])
1561
1562
1563 dnl
1564 dnl Check for template specializations for the 'long long' type extension.
1565 dnl The result determines only whether 'long long' I/O is enabled; things
1566 dnl like numeric_limits<> specializations are always available.
1567 dnl
1568 dnl GLIBCPP_ENABLE_LONG_LONG
1569 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1570 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1571 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1572 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1573 dnl       defaults to `no'.
1574 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1575 dnl
1576 dnl GLIBCPP_ENABLE_LONG_LONG
1577 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1578   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1579
1580   AC_ARG_ENABLE(long-long,
1581   changequote(<<, >>)dnl
1582   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1583   changequote([, ])dnl
1584   [case "$enableval" in
1585    yes) enable_long_long=yes ;;
1586    no)  enable_long_long=no ;;
1587    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1588    esac],
1589   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1590
1591   AC_LANG_SAVE
1592   AC_LANG_CPLUSPLUS
1593
1594   AC_MSG_CHECKING([for enabled long long I/O support])
1595   # iostreams require strtoll, strtoull to compile
1596   AC_TRY_COMPILE([#include <stdlib.h>],
1597                  [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
1598   AC_TRY_COMPILE([#include <stdlib.h>],
1599                  [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
1600
1601   # Option parsed, now set things appropriately
1602   if test x"$enable_long_long" = xyes; then
1603     AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1604   fi
1605   AC_MSG_RESULT($enable_long_long)
1606
1607   AC_LANG_RESTORE
1608 ])
1609
1610
1611 dnl
1612 dnl Check for what kind of C headers to use.
1613 dnl
1614 dnl GLIBCPP_ENABLE_CHEADERS
1615 dnl --enable-cheaders= [does stuff].
1616 dnl --disable-cheaders [does not do anything, really].
1617 dnl  +  This will eventually need to be 'c_shadow' by default.
1618 dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1619 dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1620 dnl       If ommitted, it defaults to `c_std'.
1621 AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1622 define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1623 AC_MSG_CHECKING([for c header strategy to use])
1624 AC_ARG_ENABLE(cheaders,
1625 changequote(<<, >>)dnl
1626 <<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1627 changequote([, ])
1628   [case "$enableval" in
1629    c) 
1630         enable_cheaders=c 
1631         ;;
1632    c_std)  
1633         enable_cheaders=c_std 
1634         ;;
1635    c_shadow)  
1636         enable_cheaders=c_shadow 
1637         ;;
1638    *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1639         ;;
1640   esac],
1641   enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1642   AC_MSG_RESULT($enable_cheaders)
1643
1644   dnl Option parsed, now set things appropriately
1645   case "$enable_cheaders" in
1646     c_shadow) 
1647         CSHADOW_FLAGS="-fno-builtin"
1648         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
1649         AC_DEFINE(_GLIBCPP_USE_SHADOW_HEADERS)
1650         ;;
1651     c_std)   
1652         CSHADOW_FLAGS=""
1653         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1654         ;;
1655     c)   
1656         CSHADOW_FLAGS=""
1657         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1658         ;;
1659   esac
1660
1661   AC_SUBST(CSHADOW_FLAGS)
1662   AC_SUBST(C_INCLUDE_DIR)
1663   AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cheaders" = c_shadow)
1664 ])
1665
1666
1667 dnl
1668 dnl Check for wide character support.  Has the same effect as the option
1669 dnl in gcc's configure, but in a form that autoconf can mess with.
1670 dnl
1671 dnl GLIBCPP_ENABLE_C_MBCHAR
1672 dnl --enable-c-mbchar requests all the wchar_t stuff.
1673 dnl --disable-c-mbchar doesn't.
1674 dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1675 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1676 dnl       defaults to `no'.
1677 AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1678 define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1679 AC_ARG_ENABLE(c-mbchar,
1680 changequote(<<, >>)dnl
1681 <<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1682 changequote([, ])dnl
1683 [case "$enableval" in
1684  yes) enable_c_mbchar=yes ;;
1685  no)  enable_c_mbchar=no ;;
1686  *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1687  esac],
1688 enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1689 dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1690 ])
1691
1692
1693 dnl
1694 dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1695 dnl
1696 dnl TOPLEVEL_INCLUDES
1697 dnl LIBMATH_INCLUDES
1698 dnl LIBSUPCXX_INCLUDES
1699 dnl LIBIO_INCLUDES
1700 dnl CSHADOW_INCLUDES
1701 dnl
1702 dnl GLIBCPP_EXPORT_INCLUDES
1703 AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1704   # Root level of the build directory include sources.
1705   GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1706
1707   # Passed down for canadian crosses.
1708   if test x"$CANADIAN" = xyes; then
1709     TOPLEVEL_INCLUDES='-I$(includedir)'
1710   fi
1711
1712   LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1713
1714   LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1715
1716   if test x"$need_libio" = xyes; then
1717     LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1718     AC_SUBST(LIBIO_INCLUDES)
1719   fi
1720
1721   # Now, export this to all the little Makefiles....
1722   AC_SUBST(GLIBCPP_INCLUDES)
1723   AC_SUBST(TOPLEVEL_INCLUDES)
1724   AC_SUBST(LIBMATH_INCLUDES)
1725   AC_SUBST(LIBSUPCXX_INCLUDES)
1726 ])
1727
1728
1729 dnl
1730 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1731 dnl
1732 AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1733   # Optimization flags that are probably a good idea for thrill-seekers. Just
1734   # uncomment the lines below and make, everything else is ready to go... 
1735   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1736   OPTIMIZE_CXXFLAGS=
1737   AC_SUBST(OPTIMIZE_CXXFLAGS)
1738
1739   WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1740   AC_SUBST(WARN_FLAGS)
1741 ])
1742
1743 dnl
1744 dnl  GLIBCPP_EXPORT_INSTALL_INFO
1745 dnl  calculates gxx_install_dir
1746 dnl  exports glibcpp_toolexecdir
1747 dnl  exports glibcpp_toolexeclibdir
1748 dnl  exports glibcpp_prefixdir
1749 dnl
1750 dnl Assumes cross_compiling bits already done, and with_cross_host in
1751 dnl particular
1752 dnl
1753 dnl GLIBCPP_EXPORT_INSTALL_INFO
1754 AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1755 # Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
1756 # exported correctly in GLIBCPP_CONFIGURE.
1757 glibcpp_toolexecdir=no
1758 glibcpp_toolexeclibdir=no
1759 glibcpp_prefixdir=${prefix}
1760
1761 AC_MSG_CHECKING([for interface version number])
1762 libstdcxx_interface=$INTERFACE
1763 AC_MSG_RESULT($libstdcxx_interface)
1764
1765 # Process the option --with-gxx-include-dir=<path to include-files directory>
1766 AC_MSG_CHECKING([for --with-gxx-include-dir])
1767 AC_ARG_WITH(gxx-include-dir,
1768 [  --with-gxx-include-dir  the installation directory for include files],
1769 [case "${withval}" in
1770   yes)
1771     AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1772     gxx_include_dir=no
1773     ;;
1774   no)
1775     gxx_include_dir=no
1776     ;;
1777   *)
1778     gxx_include_dir=${withval}
1779     ;;
1780 esac], [gxx_include_dir=no])
1781 AC_MSG_RESULT($gxx_include_dir)
1782
1783 # Process the option "--enable-version-specific-runtime-libs"
1784 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1785 AC_ARG_ENABLE(version-specific-runtime-libs,
1786 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1787 [case "$enableval" in
1788  yes) version_specific_libs=yes ;;
1789  no)  version_specific_libs=no ;;
1790  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1791  esac],
1792 version_specific_libs=no)dnl
1793 # Option set, now we can test it.
1794 AC_MSG_RESULT($version_specific_libs)
1795
1796 if test $version_specific_libs = yes; then
1797   # Need the gcc compiler version to know where to install libraries
1798   # and header files if --enable-version-specific-runtime-libs option
1799   # is selected.
1800   changequote(,)dnl
1801   gcc_version_trigger=${srcdir}/../gcc/version.c
1802   gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
1803   gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
1804   gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/g++
1805   glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1806   glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1807   changequote([,])dnl
1808 fi
1809
1810 # Default case for install directory for include files.
1811 if test $version_specific_libs = no &&
1812    test $gxx_include_dir = no; then
1813   gxx_include_dir='$(prefix)'/include/g++-${libstdcxx_interface}
1814 fi
1815
1816 # Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
1817 # Install a library built with a cross compiler in tooldir, not libdir.
1818 if test x"$glibcpp_toolexecdir" = x"no"; then 
1819   if test -n "$with_cross_host" &&
1820      test x"$with_cross_host" != x"no"; then
1821     glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1822     glibcpp_toolexeclibdir='$(toolexecdir)/lib$(MULTISUBDIR)'
1823   else
1824     glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1825     glibcpp_toolexeclibdir='$(libdir)$(MULTISUBDIR)'
1826   fi
1827 fi
1828
1829 AC_MSG_CHECKING([for install location])
1830 AC_MSG_RESULT($gxx_include_dir)
1831
1832 AC_SUBST(glibcpp_prefixdir)
1833 AC_SUBST(gxx_include_dir)
1834 AC_SUBST(glibcpp_toolexecdir)
1835 AC_SUBST(glibcpp_toolexeclibdir)
1836 ])
1837
1838
1839 # Check for functions in math library.
1840 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1841 #
1842 # This file can be copied and used freely without restrictions.  It can
1843 # be used in projects which are not available under the GNU Public License
1844 # but which still want to provide support for the GNU gettext functionality.
1845 # Please note that the actual code is *not* freely available.
1846
1847 # serial 1
1848
1849 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1850 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1851 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1852 AC_SUBST(LIBMATHOBJS)dnl
1853 ])
1854
1855
1856
1857 dnl This macro searches for a GNU version of make.  If a match is found, the
1858 dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1859 dnl set to "#". This is useful for  including a special features in a Makefile,
1860 dnl which cannot be handled by other versions of make.  The variable
1861 dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1862 dnl the empty string otherwise.
1863 dnl
1864 dnl Here is an example of its use:
1865 dnl
1866 dnl Makefile.in might contain:
1867 dnl
1868 dnl     # A failsafe way of putting a dependency rule into a makefile
1869 dnl     $(DEPEND):
1870 dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1871 dnl
1872 dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1873 dnl     @ifGNUmake@ include $(DEPEND)
1874 dnl     @ifGNUmake@ endif
1875 dnl
1876 dnl Then configure.in would normally contain:
1877 dnl
1878 dnl     CHECK_GNU_MAKE()
1879 dnl     AC_OUTPUT(Makefile)
1880 dnl
1881 dnl Then perhaps to cause gnu make to override any other make, we could do
1882 dnl something like this (note that GNU make always looks for GNUmakefile first):
1883 dnl
1884 dnl     if  ! test x$_cv_gnu_make_command = x ; then
1885 dnl             mv Makefile GNUmakefile
1886 dnl             echo .DEFAULT: > Makefile ;
1887 dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1888 dnl     fi
1889 dnl
1890 dnl Then, if any (well almost any) other make is called, and GNU make also
1891 dnl exists, then the other make wraps the GNU make.
1892 dnl
1893 dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1894 dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1895 dnl
1896 dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1897 dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1898 dnl #### conditional's subshell (" --version" is not a command), using a
1899 dnl #### different option to grep(1).
1900 dnl #### -pme
1901 dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
1902 dnl #### ${MAKE:-make}).
1903 dnl #### -msokolov
1904 AC_DEFUN(
1905   GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1906           _cv_gnu_make_command='' ;
1907 dnl Search all the common names for GNU make
1908           for a in "${MAKE-make}" make gmake gnumake ; do
1909                   if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
1910                   then
1911                           _cv_gnu_make_command=$a ;
1912                           break;
1913                   fi
1914           done ;
1915   ) ;
1916 dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1917 dnl string, '#' otherwise
1918   if test  "x$_cv_gnu_make_command" != "x"  ; then
1919           ifGNUmake='' ;
1920   else
1921           ifGNUmake='#' ;
1922   fi
1923   AC_SUBST(ifGNUmake)
1924 ])
1925
1926
1927 dnl Check for headers for, and arguments to, the setrlimit() function.
1928 dnl Used only in testsuite_hooks.h.
1929 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
1930   AC_TRY_COMPILE([#include <sys/resource.h>
1931                   #include <unistd.h>
1932                  ], [ int f = RLIMIT_$1 ; ],
1933                  [glibcpp_mresult=1], [glibcpp_mresult=0])
1934   AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
1935                      [Only used in build directory testsuite_hooks.h.])
1936 ])
1937 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
1938   setrlimit_have_headers=yes
1939   AC_CHECK_HEADERS(sys/resource.h unistd.h,
1940                    [],
1941                    setrlimit_have_headers=no)
1942   # If don't have the headers, then we can't run the tests now, and we
1943   # won't be seeing any of these during testsuite compilation.
1944   if test $setrlimit_have_headers = yes; then
1945     # Can't do these in a loop, else the resulting syntax is wrong.
1946     GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
1947     GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
1948     GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
1949     GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
1950
1951     # Check for rlimit, setrlimit.
1952     AC_CACHE_VAL(ac_setrlimit, [
1953       AC_TRY_COMPILE([#include <sys/resource.h>
1954                       #include <unistd.h>
1955                      ], 
1956                      [ struct rlimit r; setrlimit(0, &r);], 
1957                      [ac_setrlimit=yes], [ac_setrlimit=no])
1958     ])
1959   fi
1960
1961   AC_MSG_CHECKING([for testsuite memory limit support])
1962   if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
1963     ac_mem_limits=yes
1964     AC_DEFINE(_GLIBCPP_MEM_LIMITS)
1965   else
1966     ac_mem_limits=no
1967   fi
1968   AC_MSG_RESULT($ac_mem_limits)
1969 ])
1970
1971
1972 dnl
1973 dnl Does any necessary configuration of the testsuite directory.  Generates
1974 dnl the testsuite_hooks.h header.
1975 dnl
1976 dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
1977 AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
1978   GLIBCPP_CHECK_SETRLIMIT
1979
1980   # Look for setenv, so that extended locale tests can be performed.
1981   AC_CHECK_FUNCS(setenv)
1982 ])
1983
1984
1985 sinclude(../libtool.m4)
1986 dnl The lines below arrange for aclocal not to bring an installed
1987 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
1988 dnl add a definition of LIBTOOL to Makefile.in.
1989 ifelse(,,,[AC_SUBST(LIBTOOL)
1990 AC_DEFUN([AM_PROG_LIBTOOL])
1991 AC_DEFUN([AC_LIBTOOL_DLOPEN])
1992 AC_DEFUN([AC_PROG_LD])
1993 ])
1994
1995
1996 # Check whether LC_MESSAGES is available in <locale.h>.
1997 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1998 #
1999 # This file file be copied and used freely without restrictions.  It can
2000 # be used in projects which are not available under the GNU Public License
2001 # but which still want to provide support for the GNU gettext functionality.
2002 # Please note that the actual code is *not* freely available.
2003
2004 # serial 1
2005
2006 AC_DEFUN(AC_LC_MESSAGES, [
2007   AC_CHECK_HEADER(locale.h, [
2008     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
2009       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2010        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
2011     if test $ac_cv_val_LC_MESSAGES = yes; then
2012       AC_DEFINE(HAVE_LC_MESSAGES)
2013     fi
2014   ])
2015 ])
2016
2017
2018 dnl
2019 dnl Check for whether the Boost-derived checks should be turned on.
2020 dnl
2021 dnl GLIBCPP_ENABLE_CONCEPT_CHECKS
2022 dnl --enable-concept-checks turns them on.
2023 dnl --disable-concept-checks leaves them off.
2024 dnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2025 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2026 dnl       defaults to `no'.
2027 AC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
2028 define([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
2029 AC_ARG_ENABLE(concept-checks,
2030 changequote(<<, >>)dnl
2031 <<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
2032 changequote([, ])dnl
2033 [case "$enableval" in
2034  yes) enable_concept_checks=yes ;;
2035  no)  enable_concept_checks=no ;;
2036  *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
2037  esac],
2038 enable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
2039 dnl Option parsed, now set things appropriately
2040 if test x"$enable_concept_checks" = xyes; then
2041   AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
2042 fi
2043 ])
2044
2045
2046 dnl
2047 dnl Add version tags to symbols in shared library (or not), additionally
2048 dnl marking other symbols as private/local (or not).
2049 dnl
2050 dnl GLIBCPP_ENABLE_SYMVERS
2051 dnl --enable-symvers=style adds a version script to the linker call when
2052 dnl       creating the shared library.  The choice of version script is
2053 dnl       controlled by 'style'.
2054 dnl --disable-symvers does not.
2055 dnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
2056 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2057 dnl       defaults to `no'.  Passing `yes' tries to choose a default style
2058 dnl       based on linker characteristics.  Passing 'no' disables versioning.
2059 AC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
2060 define([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
2061 AC_ARG_ENABLE(symvers,
2062 changequote(<<, >>)dnl
2063 <<  --enable-symvers=style  enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
2064 changequote([, ])dnl
2065 [case "$enableval" in
2066  yes) enable_symvers=yes ;;
2067  no)  enable_symvers=no ;;
2068  # other names here, just as sanity checks
2069  #gnu|sun|etcetera) enable_symvers=$enableval ;;
2070  gnu) enable_symvers=$enableval ;;
2071  *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
2072  esac],
2073 enable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
2074
2075 # If we never went through the GLIBCPP_CHECK_LINKER_FEATURES macro, then we
2076 # don't know enough about $LD to do tricks... 
2077 if test $enable_shared = no || test x$LD = x ; then
2078   enable_symvers=no
2079 fi
2080
2081 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2082 AC_MSG_CHECKING([for shared libgcc])
2083 ac_save_CFLAGS="$CFLAGS"
2084 CFLAGS=' -lgcc_s'
2085 AC_TRY_LINK( , [return 0], glibcpp_shared_libgcc=yes, glibcpp_shared_libgcc=no)
2086 CFLAGS="$ac_save_CFLAGS"
2087 AC_MSG_RESULT($glibcpp_shared_libgcc)
2088
2089 # For GNU ld, we need at least this version.  It's 2.12 in the same format
2090 # as the tested-for version.  See GLIBCPP_CHECK_LINKER_FEATURES for more.
2091 glibcpp_min_gnu_ld_version=21200
2092
2093 # Check to see if unspecified "yes" value can win, given results
2094 # above.  
2095 if test $enable_symvers = yes ; then
2096   if test $with_gnu_ld = yes &&
2097     test $glibcpp_shared_libgcc = yes ;
2098   then
2099     if test $glibcpp_gnu_ld_version -ge $glibcpp_min_gnu_ld_version ; then
2100         enable_symvers=gnu
2101     else
2102       ac_test_CFLAGS="${CFLAGS+set}"
2103       ac_save_CFLAGS="$CFLAGS"
2104       CFLAGS='-shared -Wl,--version-script,conftest.map'
2105       enable_symvers=no
2106       changequote(,)
2107       echo 'FOO { global: f[a-z]o; local: *; };' > conftest.map
2108       changequote([,])
2109       AC_TRY_LINK([int foo;],, enable_symvers=gnu)
2110       if test "$ac_test_CFLAGS" = set; then
2111         CFLAGS="$ac_save_CFLAGS"
2112       else
2113         # this is the suspicious part
2114         CFLAGS=''
2115       fi
2116       rm -f conftest.map
2117     fi
2118   else
2119     # just fail for now
2120     enable_symvers=no
2121   fi
2122 fi
2123
2124 dnl Everything parsed; figure out what file to use.
2125 case $enable_symvers in
2126   no)
2127       LINKER_MAP=config/linker-map.dummy
2128       ;;
2129   gnu)
2130       LINKER_MAP=config/linker-map.gnu
2131       ;;
2132 esac
2133
2134 AC_LINK_FILES($LINKER_MAP, src/linker.map)
2135 AM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
2136 AC_MSG_CHECKING([versioning on shared library symbols])
2137 AC_MSG_RESULT($enable_symvers)
2138 ])
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