OSDN Git Service

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