OSDN Git Service

2001-02-06 Benjamin Kosnik <bkoz@redhat.com>
[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 Define OPTLEVEL='-O2' if new inlining code present.
17 dnl
18 dnl GLIBCPP_CONFIGURE
19 AC_DEFUN(GLIBCPP_CONFIGURE, [
20   dnl Default to --enable-multilib
21   AC_ARG_ENABLE(multilib,
22   [  --enable-multilib       build hella library versions (default)],
23   [case "${enableval}" in
24     yes) multilib=yes ;;
25     no)  multilib=no ;;
26     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
27    esac], [multilib=yes])dnl
28
29   glibcpp_basedir=$auxdir/$1/libstdc++-v3
30   AC_SUBST(glibcpp_basedir)
31
32   AM_INIT_AUTOMAKE(libstdc++, 2.90.8)
33
34   # Never versions of autoconf add an underscore to these functions.
35   # Prevent future problems ...
36   ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
37   ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
38   ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
39   ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
40
41 #  AC_PROG_CC
42
43 # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
44 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
45 # are probably using a cross compiler, which will not be able to fully
46 # link an executable.  This should really be fixed in autoconf
47 # itself.
48
49 AC_DEFUN(LIB_AC_PROG_CC,
50 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
51 dnl Fool anybody using AC_PROG_CC.
52 AC_PROVIDE([AC_PROG_CC])
53 AC_CHECK_PROG(CC, gcc, gcc)
54 if test -z "$CC"; then
55   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
56   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
57 fi
58
59 AC_PROG_CC_GNU
60
61 if test $ac_cv_prog_gcc = yes; then
62   GCC=yes
63 dnl Check whether -g works, even if CFLAGS is set, in case the package
64 dnl plays around with CFLAGS (such as to build both debugging and
65 dnl normal versions of a library), tasteless as that idea is.
66   ac_test_CFLAGS="${CFLAGS+set}"
67   ac_save_CFLAGS="$CFLAGS"
68   CFLAGS=
69   AC_PROG_CC_G
70   if test "$ac_test_CFLAGS" = set; then
71     CFLAGS="$ac_save_CFLAGS"
72   elif test $ac_cv_prog_cc_g = yes; then
73     CFLAGS="-g -O2"
74   else
75     CFLAGS="-O2"
76   fi
77 else
78   GCC=
79   test "${CFLAGS+set}" = set || CFLAGS="-g"
80 fi
81 ])
82
83 LIB_AC_PROG_CC
84
85 # Can't just call these here as g++ requires libstc++ to be built....
86 #  AC_PROG_CXX
87
88 # Likewise for AC_PROG_CXX.
89 AC_DEFUN(LIB_AC_PROG_CXX,
90 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
91 dnl Fool anybody using AC_PROG_CXX.
92 AC_PROVIDE([AC_PROG_CXX])
93 # Use CXX_libstdcxx so that we do not cause CXX to be cached with the
94 # flags that come in CXX while configuring libstdc++.  They're different
95 # from those used for all other target libraries.  If CXX is set in
96 # the environment, respect that here.
97 CXX_libstdcxx=$CXX
98 AC_CHECK_PROGS(CXX_libstdcxx, $CCC c++ g++ gcc CC cxx cc++, gcc)
99 CXX=$CXX_libstdcxx
100 AC_SUBST(CXX)
101 test -z "$CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
102
103 AC_PROG_CXX_GNU
104
105 if test $ac_cv_prog_gxx = yes; then
106   GXX=yes
107 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
108 dnl plays around with CXXFLAGS (such as to build both debugging and
109 dnl normal versions of a library), tasteless as that idea is.
110   ac_test_CXXFLAGS="${CXXFLAGS+set}"
111   ac_save_CXXFLAGS="$CXXFLAGS"
112   CXXFLAGS=
113   AC_PROG_CXX_G
114   if test "$ac_test_CXXFLAGS" = set; then
115     CXXFLAGS="$ac_save_CXXFLAGS"
116   elif test $ac_cv_prog_cxx_g = yes; then
117     CXXFLAGS="-g -O2"
118   else
119     CXXFLAGS="-O2"
120   fi
121 else
122   GXX=
123   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
124 fi
125 ])
126
127 LIB_AC_PROG_CXX
128
129   AC_CHECK_TOOL(AS, as)
130   AC_CHECK_TOOL(AR, ar)
131   AC_CHECK_TOOL(RANLIB, ranlib, :)
132
133   AC_PROG_INSTALL
134
135   AM_MAINTAINER_MODE
136
137   # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
138   # at least currently, we never actually build a program, so we never
139   # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
140   # fails, because we are probably configuring with a cross compiler
141   # which cant create executables.  So we include AC_EXEEXT to keep
142   # automake happy, but we dont execute it, since we dont care about
143   # the result.
144   if false; then
145     AC_EXEEXT
146   fi
147
148   # configure.host sets the following important variables
149   #        glibcpp_cflags    - host specific C compiler flags
150   #        glibcpp_cxxflags  - host specific C++ compiler flags
151   glibcpp_cflags=
152   glibcpp_cxxflags=
153
154   . [$]{glibcpp_basedir}/configure.host
155
156   case [$]{glibcpp_basedir} in
157     /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
158     *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
159   esac
160
161   # This does for the target what configure.host does for the host.  In
162   # addition to modifying the same flags, it also sets up symlinks.
163   GLIBCPP_CHECK_TARGET
164
165   GLIBCPP_CFLAGS="[$]{glibcpp_cflags}"
166   GLIBCPP_CXXFLAGS="[$]{glibcpp_cxxflags}"
167   AC_SUBST(GLIBCPP_CFLAGS)
168   AC_SUBST(GLIBCPP_CXXFLAGS)
169 ])
170
171
172 dnl
173 dnl Check to see if g++ can compile this library, and if so, if any version-
174 dnl specific precautions need to be taken. 
175 dnl 
176 dnl GLIBCPP_CHECK_COMPILER_VERSION
177 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
178 if test ! -f stamp-sanity-compiler; then
179   AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
180   AC_LANG_SAVE
181   AC_LANG_CPLUSPLUS
182   AC_EGREP_CPP(ok, [
183   #if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 
184     ok
185   #endif
186   ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to gcc-2.95 or above]))
187   AC_LANG_RESTORE
188   AC_MSG_RESULT($gpp_satisfactory)
189   touch stamp-sanity-compiler
190 fi
191 ])
192
193
194 dnl
195 dnl Test for newer compiler features, or features that are present in newer
196 dnl compiler version but not older compiler versions should be placed
197 dnl here.
198 dnl
199 dnl Define WFMT_FLAGS='-fdiagnostics-show-location=once' if possible
200 dnl 
201 dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
202 dnl new inlining code or the new system_header pragma will die on -Werror.
203 dnl Leave it out by default and use maint-mode to use it.
204 dnl
205 dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
206 dnl compiler supports it.  
207 dnl GLIBCPP_CHECK_COMPILER_FEATURES
208 AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
209   # All these tests are for C++; save the language and the compiler flags.
210   # The CXXFLAGS thing is suspicious, but based on similar bits 
211   # found in GLIBCPP_CONFIGURE.
212   AC_LANG_SAVE
213   AC_LANG_CPLUSPLUS
214   ac_test_CXXFLAGS="${CXXFLAGS+set}"
215   ac_save_CXXFLAGS="$CXXFLAGS"
216
217   # Check for maintainer-mode bits.
218   if test x"$USE_MAINTAINER_MODE" = xno; then
219     WERROR=''
220   else
221     WERROR='-Werror'
222   fi
223
224   # Check for more sophisticated diagnostic control.
225   AC_MSG_CHECKING([for g++ that supports -fdiagnostics-show-location=once])
226   CXXFLAGS='-Werror -fdiagnostics-show-location=once'
227   AC_TRY_COMPILE(, [int foo;
228   ], [ac_gabydiags=yes], [ac_gabydiags=no])
229   if test "$ac_test_CXXFLAGS" = set; then
230     CXXFLAGS="$ac_save_CXXFLAGS"
231   else
232     # this is the suspicious part
233     CXXFLAGS=''
234   fi
235   if test x"$ac_gabydiags" = x"yes"; then
236     WFMT_FLAGS='-fdiagnostics-show-location=once'
237   fi
238   AC_MSG_RESULT($ac_gabydiags)
239
240   # Check for -ffunction-sections -fdata-sections
241   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
242   CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
243   AC_TRY_COMPILE(, [int foo;
244   ], [ac_fdsections=yes], [ac_fdsections=no])
245   if test "$ac_test_CXXFLAGS" = set; then
246     CXXFLAGS="$ac_save_CXXFLAGS"
247   else
248     # this is the suspicious part
249     CXXFLAGS=''
250   fi
251   if test x"$ac_fdsections" = x"yes" && test x"$enable_debug" = x"no"; then
252     SECTION_FLAGS='-ffunction-sections -fdata-sections'
253   fi
254   AC_MSG_RESULT($ac_fdsections)
255
256   AC_LANG_RESTORE
257   AC_SUBST(WERROR)
258   AC_SUBST(WFMT_FLAGS)
259   AC_SUBST(SECTION_FLAGS)
260 ])
261
262
263 dnl
264 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
265 dnl the native linker is in use, all variables will be defined to something
266 dnl safe (like an empty string).
267 dnl
268 dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
269 dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
270 dnl
271 dnl GLIBCPP_CHECK_LINKER_FEATURES
272 AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
273   # If we're not using GNU ld, then there's no point in even trying these
274   # tests.  Check for that first.  We should have already tested for gld
275   # by now (in libtool), but require it now just to be safe...
276   SECTION_LDFLAGS=''
277   OPT_LDFLAGS=''
278   AC_REQUIRE([AC_PROG_LD])
279
280   # Set --gc-sections.
281   if test "$ac_cv_prog_gnu_ld" = "notbroken"; then
282     # GNU ld it is!  Joy and bunny rabbits!
283
284     # All these tests are for C++; save the language and the compiler flags.
285     # Need to do this so that g++ won't try to link in libstdc++
286     ac_test_CFLAGS="${CFLAGS+set}"
287     ac_save_CFLAGS="$CFLAGS"
288     CFLAGS='-x c++  -Wl,--gc-sections'
289
290     # Check for -Wl,--gc-sections
291     # XXX This test is broken at the moment, as symbols required for
292     # linking are now in libsupc++ (not built yet.....). In addition, 
293     # this test has cored on solaris in the past. In addition,
294     # --gc-sections doesn't really work at the moment (keeps on discarding
295     # used sections, first .eh_frame and now some of the glibc sections for
296     # iconv). Bzzzzt. Thanks for playing, maybe next time.
297     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
298     AC_TRY_RUN([
299      int main(void) 
300      {
301        try { throw 1; }
302        catch (...) { };
303        return 0;
304      }
305     ], [ac_sectionLDflags=yes],[ac_sectionLFflags=no], [ac_sectionLDflags=yes])
306     if test "$ac_test_CFLAGS" = set; then
307       CFLAGS="$ac_save_CFLAGS"
308     else
309       # this is the suspicious part
310       CFLAGS=''
311     fi
312     if test "$ac_sectionLDflags" = "yes"; then
313       SECTION_LDFLAGS='-Wl,--gc-sections'
314     fi
315     AC_MSG_RESULT($ac_sectionLDflags)
316   fi
317
318   # Set linker optimization flags.
319   if test x"$ac_cv_prog_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
320     OPT_LDFLAGS='-Wl,-O1'
321   fi
322
323   AC_SUBST(SECTION_LDFLAGS)
324   AC_SUBST(OPT_LDFLAGS)
325 ])
326
327
328 dnl
329 dnl Check to see if the (math function) argument passed is
330 dnl declared when using the c++ compiler
331 dnl ASSUMES argument is a math function with ONE parameter
332 dnl
333 dnl GLIBCPP_CHECK_MATH_DECL_1
334 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
335   AC_MSG_CHECKING([for $1 declaration])
336   if test x${glibcpp_cv_func_$1_use+set} != xset; then
337     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
338       AC_LANG_SAVE
339       AC_LANG_CPLUSPLUS
340       AC_TRY_COMPILE([#include <math.h>], 
341                      [ $1(0);], 
342                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
343       AC_LANG_RESTORE
344     ])
345   fi
346   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
347 ])
348
349 dnl
350 dnl Check to see if the (math function) argument passed is
351 dnl 1) declared when using the c++ compiler
352 dnl 2) has "C" linkage
353 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
354 dnl
355 dnl Define HAVE_CARGF etc if "cargf" is declared and links
356 dnl
357 dnl argument 1 is name of function to check
358 dnl
359 dnl ASSUMES argument is a math function with ONE parameter
360 dnl
361 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
362 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
363   GLIBCPP_CHECK_MATH_DECL_1($1)
364   if test x$glibcpp_cv_func_$1_use = x"yes"; then
365     AC_CHECK_FUNCS($1)    
366   else
367     GLIBCPP_CHECK_MATH_DECL_1(_$1)
368     if test x$glibcpp_cv_func__$1_use = x"yes"; then
369       AC_CHECK_FUNCS(_$1)    
370     fi  
371   fi
372 ])
373
374
375 dnl
376 dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
377 dnl of functions at once.  It's an all-or-nothing check -- either 
378 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
379 dnl Doing it this way saves significant configure time.
380 AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
381   AC_MSG_CHECKING([for $1 functions])
382   AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
383     AC_LANG_SAVE
384     AC_LANG_CPLUSPLUS
385     AC_TRY_COMPILE([#include <math.h>],
386                    [ `for x in $3; do echo "$x (0);"; done` ],
387                    [glibcpp_cv_func_$2_use=yes],
388                    [glibcpp_cv_func_$2_use=no])
389     AC_LANG_RESTORE])
390   AC_MSG_RESULT($glibcpp_cv_func_$2_use)
391   if test x$glibcpp_cv_func_$2_use = x"yes"; then
392     AC_CHECK_FUNCS($3)
393   fi
394 ])
395
396 dnl
397 dnl Check to see if the (math function) argument passed is
398 dnl declared when using the c++ compiler
399 dnl ASSUMES argument is a math function with ONE parameter
400 dnl
401 dnl GLIBCPP_CHECK_MATH_DECL_2
402 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
403   AC_MSG_CHECKING([for $1 declaration])
404   if test x${glibcpp_cv_func_$1_use+set} != xset; then
405     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
406       AC_LANG_SAVE
407       AC_LANG_CPLUSPLUS
408       AC_TRY_COMPILE([#include <math.h>], 
409                      [ $1(0, 0);], 
410                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
411       AC_LANG_RESTORE
412     ])
413   fi
414   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
415 ])
416
417 dnl
418 dnl Check to see if the (math function) argument passed is
419 dnl 1) declared when using the c++ compiler
420 dnl 2) has "C" linkage
421 dnl
422 dnl Define HAVE_CARGF etc if "cargf" is declared and links
423 dnl
424 dnl argument 1 is name of function to check
425 dnl
426 dnl ASSUMES argument is a math function with TWO parameters
427 dnl
428 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
429 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
430   GLIBCPP_CHECK_MATH_DECL_2($1)
431   if test x$glibcpp_cv_func_$1_use = x"yes"; then
432     AC_CHECK_FUNCS($1)    
433   else
434     GLIBCPP_CHECK_MATH_DECL_2(_$1)
435     if test x$glibcpp_cv_func__$1_use = x"yes"; then
436       AC_CHECK_FUNCS(_$1)    
437     fi  
438   fi
439 ])
440
441
442 dnl
443 dnl Check to see if the (math function) argument passed is
444 dnl declared when using the c++ compiler
445 dnl ASSUMES argument is a math function with ONE parameter
446 dnl
447 dnl GLIBCPP_CHECK_MATH_DECL_3
448 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
449   AC_MSG_CHECKING([for $1 declaration])
450   if test x${glibcpp_cv_func_$1_use+set} != xset; then
451     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
452       AC_LANG_SAVE
453       AC_LANG_CPLUSPLUS
454       AC_TRY_COMPILE([#include <math.h>], 
455                      [ $1(0, 0, 0);], 
456                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
457       AC_LANG_RESTORE
458     ])
459   fi
460   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
461 ])
462
463 dnl
464 dnl Check to see if the (math function) argument passed is
465 dnl 1) declared when using the c++ compiler
466 dnl 2) has "C" linkage
467 dnl
468 dnl Define HAVE_CARGF etc if "cargf" is declared and links
469 dnl
470 dnl argument 1 is name of function to check
471 dnl
472 dnl ASSUMES argument is a math function with THREE parameters
473 dnl
474 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
475 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
476   GLIBCPP_CHECK_MATH_DECL_3($1)
477   if test x$glibcpp_cv_func_$1_use = x"yes"; then
478     AC_CHECK_FUNCS($1)    
479   else
480     GLIBCPP_CHECK_MATH_DECL_3(_$1)
481     if test x$glibcpp_cv_func__$1_use = x"yes"; then
482       AC_CHECK_FUNCS(_$1)    
483     fi  
484   fi
485 ])
486
487
488 dnl
489 dnl Check to see if the (stdlib function) argument passed is
490 dnl 1) declared when using the c++ compiler
491 dnl 2) has "C" linkage
492 dnl
493 dnl Define HAVE_STRTOLD if "strtold" is declared and links
494 dnl Define HAVE_STRTOF if "strtof" is declared and links
495 dnl
496 dnl argument 1 is name of function to check
497 dnl
498 dnl ASSUMES argument is a math function with TWO parameters
499 dnl
500 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
501 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
502   AC_MSG_CHECKING([for $1 declaration])
503   if test x${glibcpp_cv_func_$1_use+set} != xset; then
504     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
505       AC_LANG_SAVE
506       AC_LANG_CPLUSPLUS
507       AC_TRY_COMPILE([#include <stdlib.h>], 
508                      [ $1(0, 0);], 
509                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
510       AC_LANG_RESTORE
511     ])
512   fi
513   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
514   if test x$glibcpp_cv_func_$1_use = x"yes"; then
515     AC_CHECK_FUNCS($1)    
516   fi
517 ])
518
519
520 dnl
521 dnl Because the builtins are picky picky picky about the arguments they take, 
522 dnl do an explict linkage tests here.
523 dnl Check to see if the (math function) argument passed is
524 dnl 1) declared when using the c++ compiler
525 dnl 2) has "C" linkage
526 dnl
527 dnl Define HAVE_CARGF etc if "cargf" is declared and links
528 dnl
529 dnl argument 1 is name of function to check
530 dnl
531 dnl ASSUMES argument is a math function with ONE parameter
532 dnl
533 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
534 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
535   AC_MSG_CHECKING([for $1 declaration])
536   if test x${glibcpp_cv_func_$1_use+set} != xset; then
537     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
538       AC_LANG_SAVE
539       AC_LANG_CPLUSPLUS
540       AC_TRY_COMPILE([#include <math.h>], 
541                      [ $1(0);], 
542                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
543       AC_LANG_RESTORE
544     ])
545   fi
546   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
547   if test x$glibcpp_cv_func_$1_use = x"yes"; then
548     AC_MSG_CHECKING([for $1 linkage])
549     if test x${glibcpp_cv_func_$1_link+set} != xset; then
550       AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
551         AC_TRY_LINK([#include <math.h>], 
552                     [ $1(0);], 
553                     [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
554       ])
555     fi
556     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
557     if test x$glibcpp_cv_func_$1_link = x"yes"; then
558       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
559       AC_DEFINE_UNQUOTED(${ac_tr_func})
560     fi
561   fi
562 ])
563
564
565 dnl
566 dnl Check to see what builtin math functions are supported
567 dnl
568 dnl check for __builtin_abs
569 dnl check for __builtin_fabsf
570 dnl check for __builtin_fabs
571 dnl check for __builtin_fabl
572 dnl check for __builtin_labs
573 dnl check for __builtin_sqrtf
574 dnl check for __builtin_sqrtl
575 dnl check for __builtin_fsqrt
576 dnl check for __builtin_sinf
577 dnl check for __builtin_sin
578 dnl check for __builtin_sinl
579 dnl check for __builtin_cosf
580 dnl check for __builtin_cos
581 dnl check for __builtin_cosl
582 dnl
583 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
584 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
585   dnl Test for builtin math functions.
586   dnl These are made in gcc/c-common.c 
587   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
588   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
589   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
590   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
591   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
592
593   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
594   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fsqrt)
595   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
596
597   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
598   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
599   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
600
601   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
602   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
603   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
604
605   dnl There is, without a doubt, a more elegant way to have these
606   dnl names exported so that they won't be stripped out of acconfig.h by
607   dnl autoheader. I leave this as an exercise to somebody less frustrated
608   dnl than I.... please email the libstdc++ list if you can figure out a
609   dnl more elegant approach (see autoconf/acgen.m4 and specifically
610   dnl AC_CHECK_FUNC for things to steal.)
611   dummyvar=no
612   if test x$dummyvar = x"yes"; then
613     AC_DEFINE(HAVE___BUILTIN_ABS)
614     AC_DEFINE(HAVE___BUILTIN_LABS)
615     AC_DEFINE(HAVE___BUILTIN_COS)
616     AC_DEFINE(HAVE___BUILTIN_COSF)
617     AC_DEFINE(HAVE___BUILTIN_COSL)
618     AC_DEFINE(HAVE___BUILTIN_FABS)
619     AC_DEFINE(HAVE___BUILTIN_FABSF)
620     AC_DEFINE(HAVE___BUILTIN_FABSL)
621     AC_DEFINE(HAVE___BUILTIN_SIN)
622     AC_DEFINE(HAVE___BUILTIN_SINF)
623     AC_DEFINE(HAVE___BUILTIN_SINL)
624     AC_DEFINE(HAVE___BUILTIN_FSQRT)
625     AC_DEFINE(HAVE___BUILTIN_SQRTF)
626     AC_DEFINE(HAVE___BUILTIN_SQRTL)
627   fi
628 ])
629
630
631 dnl
632 dnl Check to see what the underlying c library 
633 dnl These checks need to do two things: 
634 dnl 1) make sure the name is declared when using the c++ compiler
635 dnl 2) make sure the name has "C" linkage
636 dnl This might seem like overkill but experience has shown that it's not...
637 dnl
638 dnl Define HAVE_STRTOF etc if "strtof" is found.
639 dnl Define HAVE_STRTOLD etc if "strtold" is found.
640 dnl
641 dnl GLIBCPP_CHECK_STDLIB_SUPPORT
642 AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
643   ac_test_CXXFLAGS="${CXXFLAGS+set}"
644   ac_save_CXXFLAGS="$CXXFLAGS"
645   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
646
647   AC_CHECK_FUNCS(strtof)
648   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
649
650   CXXFLAGS="$ac_save_CXXFLAGS"
651 ])
652
653
654 dnl
655 dnl Check to see what the underlying c library or math library is like.
656 dnl These checks need to do two things: 
657 dnl 1) make sure the name is declared when using the c++ compiler
658 dnl 2) make sure the name has "C" linkage
659 dnl This might seem like overkill but experience has shown that it's not...
660 dnl
661 dnl Define HAVE_CARGF etc if "cargf" is found.
662 dnl
663 dnl GLIBCPP_CHECK_MATH_SUPPORT
664 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
665   ac_test_CXXFLAGS="${CXXFLAGS+set}"
666   ac_save_CXXFLAGS="$CXXFLAGS"
667   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
668
669   dnl Check libm
670   AC_CHECK_LIB(m, sin, libm="-lm")
671   ac_save_LIBS="$LIBS"
672   LIBS="$LIBS $libm"
673
674   dnl Check to see if certain C math functions exist.
675   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
676   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
677   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
678   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
679   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
680   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
681   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
682
683   dnl Check to see if basic C math functions have float versions.
684   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
685                                           float_trig,
686                                           acosf asinf atanf \
687                                           cosf sinf tanf \
688                                           coshf sinhf tanhf)
689   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
690                                           float_round,
691                                           ceilf floorf)
692   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
693   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
694   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
695   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
696   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
697   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
698   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
699   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
700   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
701   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
702   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
703   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
704   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
705
706   dnl Check to see if basic C math functions have long double versions.
707   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
708                                           long_double_trig,
709                                           acosl asinl atanl \
710                                           cosl sinl tanl \
711                                           coshl sinhl tanhl)
712   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
713                                           long_double_round,
714                                           ceill floorl)
715   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
716   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
717   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
718   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
719   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
720   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
721   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
722   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
723   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
724   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
725   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
726   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
727   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
728   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
729   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
730   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
731
732   dnl Some runtimes have these functions with a preceding underscore. Please
733   dnl keep this sync'd with the one above. And if you add any new symbol,
734   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
735   dnl Check to see if certain C math functions exist.
736
737   dnl Check to see if basic C math functions have float versions.
738   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
739                                           _float_trig,
740                                           _acosf _asinf _atanf \
741                                           _cosf _sinf _tanf \
742                                           _coshf _sinhf _tanhf)
743   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
744                                           _float_round,
745                                           _ceilf _floorf)
746
747   dnl Check to see if basic C math functions have long double versions.
748   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
749                                           _long_double_trig,
750                                           _acosl _asinl _atanl \
751                                           _cosl _sinl _tanl \
752                                           _coshl _sinhl _tanhl)
753   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
754                                           _long_double_round,
755                                           _ceill _floorl)
756
757   LIBS="$ac_save_LIBS"
758   CXXFLAGS="$ac_save_CXXFLAGS"
759 ])
760
761
762 dnl
763 dnl Check to see if there is native support for complex 
764 dnl
765 dnl Don't compile bits in math/* if native support exits.
766 dnl
767 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "atan2l/copysignl" is found.
768 dnl
769 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
770 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
771   dnl Check for complex versions of math functions of platform.
772   AC_CHECK_LIB(m, main)
773   AC_REPLACE_MATHFUNCS(nan hypot hypotf atan2f expf copysignf)
774
775   dnl Compile the long double complex functions only if the function 
776   dnl provides the non-complex long double functions that are needed.
777   dnl Currently this includes copysignl and atan2l, which should be
778   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
779   USE_COMPLEX_LONG_DOUBLE=no
780   if test x$ac_cv_func_atan2l = x"yes" \
781      && test x$ac_cv_func_copysignl = x"yes"; then
782     USE_COMPLEX_LONG_DOUBLE=yes
783     AC_REPLACE_MATHFUNCS(hypotl signbitl)
784   fi
785
786   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
787 ])
788
789
790 dnl Check to see what architecture and operating system we are compiling
791 dnl for.  Also, if architecture- or OS-specific flags are required for
792 dnl compilation, pick them up here.
793 dnl 
794 dnl GLIBCPP_CHECK_TARGET
795 AC_DEFUN(GLIBCPP_CHECK_TARGET, [
796     . [$]{glibcpp_basedir}/configure.target
797     AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
798     AC_MSG_RESULT(OS config directory is $os_include_dir)
799     AC_LINK_FILES($os_include_dir/bits/os_defines.h, include/bits/os_defines.h)
800 ])
801
802
803 dnl
804 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
805 dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
806 dnl must have been previously checked.)
807 dnl
808 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
809 dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
810 dnl
811 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
812 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
813
814   dnl Test wchar.h for mbstate_t, which is needed for char_traits and
815   dnl others even if wchar_t support is not on.
816   AC_MSG_CHECKING([for mbstate_t])
817   AC_TRY_COMPILE([#include <wchar.h>],
818   [mbstate_t teststate;], 
819   have_mbstate_t=yes, have_mbstate_t=no)
820   AC_MSG_RESULT($have_mbstate_t)
821   if test x"$have_mbstate_t" = xyes; then
822     AC_DEFINE(HAVE_MBSTATE_T)
823   fi
824
825   dnl Sanity check for existence of ISO C99 headers for extended encoding.
826   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
827   AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
828   
829   dnl Only continue checking if the ISO C99 headers exist and support is on.
830   if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes \
831      && test x"$enable_c_mbchar" != xno; then
832       
833     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
834     dnl numeric_limits can instantiate type_traits<wchar_t>
835     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
836     AC_TRY_COMPILE([#include <wchar.h>],
837     [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
838     has_wchar_minmax=yes, has_wchar_minmax=no)
839     AC_MSG_RESULT($has_wchar_minmax)
840     
841     dnl Test wchar.h for WEOF, which is what we use to determine whether
842     dnl to specialize for char_traits<wchar_t> or not.
843     AC_MSG_CHECKING([for WEOF])
844     AC_TRY_COMPILE([
845       #include <wchar.h>
846       #include <stddef.h>],
847     [wint_t i = WEOF;],
848     has_weof=yes, has_weof=no)
849     AC_MSG_RESULT($has_weof)
850   
851     dnl Tests for wide character functions used in char_traits<wchar_t>.
852     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \
853     wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no)
854   
855     AC_MSG_CHECKING([for ISO C99 wchar_t support])
856     if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
857        && test x"$ac_wfuncs" = xyes; then
858       ac_isoC99_wchar_t=yes
859     else
860       ac_isoC99_wchar_t=no
861     fi
862     AC_MSG_RESULT($ac_isoC99_wchar_t)
863   
864     dnl Use iconv for wchar_t to char conversions. As such, check for 
865     dnl X/Open Portability Guide, version 2 features (XPG2).
866     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
867     AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
868
869     dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
870     AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
871     ac_save_LIBS="$LIBS"
872     LIBS="$LIBS $libiconv"
873
874     AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
875     ac_XPG2funcs=yes, ac_XPG2funcs=no)
876   
877     LIBS="$ac_save_LIBS"
878
879     AC_MSG_CHECKING([for XPG2 wchar_t support])
880     if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
881        && test x"$ac_XPG2funcs" = xyes; then
882       ac_XPG2_wchar_t=yes
883     else
884       ac_XPG2_wchar_t=no
885     fi
886     AC_MSG_RESULT($ac_XPG2_wchar_t)
887   
888     dnl At the moment, only enable wchar_t specializations if all the
889     dnl above support is present.
890     AC_MSG_CHECKING([for enabled wchar_t specializations])
891     if test x"$ac_isoC99_wchar_t" = xyes \
892        && test x"$ac_XPG2_wchar_t" = xyes; then
893       libinst_wstring_la="libinst-wstring.la"
894       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
895       AC_MSG_RESULT("yes")
896     else
897       libinst_wstring_la=""
898       AC_MSG_RESULT("no")
899     fi
900     AC_SUBST(libinst_wstring_la)
901   
902   else
903     dnl Wide characters disabled by the user. 
904     AC_MSG_WARN([wchar_t support disabled.])
905   fi
906 ])
907
908
909 dnl
910 dnl Check to see if this version of GNU C++ is afflicted by bugs in
911 dnl __complex__ float support.
912 dnl
913 dnl Define _GLIBCPP_BUGGY_FLOAT_COMPLEX if buggy.
914 dnl
915 dnl Check to see if this version of GNU C++ is afflicted by bugs in 
916 dnl __complex__ support.Check for buggy __complex__ that will cause ICE in
917 dnl gcc-2.95.x when using the library, unless we define the default copy
918 dnl ctor in the specializations of complex<>. 
919 dnl 
920 dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
921 dnl GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT
922 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT, [
923   AC_REQUIRE([AC_PROG_CXX])
924
925   AC_MSG_CHECKING([for GNU C++ __complex__ support])
926   AC_CACHE_VAL(glibcpp_cv_complex, [
927     AC_LANG_SAVE
928     AC_LANG_CPLUSPLUS
929     AC_TRY_COMPILE([struct dcomplex { __complex__ double x; }; \
930                     dcomplex f(const dcomplex& x) { return dcomplex(x); }], \
931                     [ dcomplex x; f(x); ],
932       glibcpp_cv_complex=ok,
933       glibcpp_cv_complex=buggy
934     )
935     AC_LANG_RESTORE
936   ])
937   AC_MSG_RESULT($glibcpp_cv_complex)
938   if test $glibcpp_cv_complex = buggy; then
939     AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
940   fi
941
942   AC_MSG_CHECKING([for GNU C++ __complex__ float support])
943   AC_CACHE_VAL(glibcpp_cv_float_complex, [
944     AC_LANG_SAVE
945     AC_LANG_CPLUSPLUS
946     rm -f conftest.h
947     cat > conftest.h <<EOB
948       //
949       // Check for buggy __complex__ that causes ICE in most versions of egcs
950       // and gcc-2.95.x on certain platforms (eg., x86-win32).
951       //
952       // See http://gcc.gnu.org/ml/gcc-bugs/1999-07n/msg00845.html for
953       // more info on the bug itself.
954       //
955       struct
956       float_complex
957       {
958        __complex__ float m_value;
959        float_complex (float = 0.0f, float = 0.0f);
960        float_complex (__complex__ float val) : m_value (val) {}
961        float_complex foo (const float_complex &val)
962          { return float_complex (~val.m_value); }
963       };
964 EOB
965     AC_TRY_COMPILE([#include "conftest.h"], ,
966       glibcpp_cv_float_complex=ok,
967       glibcpp_cv_float_complex=buggy
968     )
969     AC_LANG_RESTORE
970   ])
971   AC_MSG_RESULT($glibcpp_cv_float_complex)
972   if test $glibcpp_cv_float_complex = buggy; then
973     AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
974   fi
975 ])
976
977
978 dnl
979 dnl Check for special debugging mode; not for production use.
980 dnl
981 dnl GLIBCPP_ENABLE_DEBUG
982 dnl --enable-debug sets '-ggdb3 -O0'.
983 dnl --disable-debug sets '-g' and whatever optimization options the
984 dnl     compiler can handle.
985 dnl  +  --enable-maintainer-mode automatically defaults this to on.
986 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
987 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
988 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
989 dnl       defaults to `no'.
990 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
991 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
992 AC_ARG_ENABLE(debug,
993 changequote(<<, >>)dnl
994 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
995 changequote([, ])dnl
996 [case "${enableval}" in
997  yes) enable_debug=yes ;;
998  no)  enable_debug=no ;;
999  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1000  esac],
1001 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1002
1003 dnl Option parsed, now set things appropriately
1004 case "${enable_debug}" in
1005     yes) 
1006         DEBUG_FLAGS='-O0 -ggdb3'                        
1007         ;; 
1008     no)   
1009         DEBUG_FLAGS='-g'
1010         ;;
1011 esac
1012 AC_SUBST(DEBUG_FLAGS)
1013 ])
1014
1015
1016 dnl
1017 dnl Check for "unusual" flags to pass to the compiler while building.
1018 dnl
1019 dnl GLIBCPP_ENABLE_CXX_FLAGS
1020 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1021 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1022 dnl     Somehow this same set of flags must be passed when [re]building
1023 dnl     libgcc.
1024 dnl --disable-cxx-flags passes nothing.
1025 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1026 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1027 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
1028 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1029 dnl       If "default flags" is an empty string (or "none"), the effect is
1030 dnl       the same as --disable or --enable=no.
1031 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1032 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1033 AC_ARG_ENABLE(cxx-flags,
1034 changequote(<<, >>)dnl
1035 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
1036                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1037 changequote([, ])dnl
1038 [case "x$enableval" in
1039  xyes)   
1040         AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1041  xno|x)  
1042         enable_cxx_flags='' ;;
1043  *)      
1044         enable_cxx_flags="$enableval" ;;
1045  esac],
1046 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1047
1048 dnl Thinko on my part during design.  This kludge is the workaround.
1049 if test "$enable_cxx_flags" = "none"; then 
1050   enable_cxx_flags=''; 
1051 fi
1052
1053 dnl Run through flags (either default or command-line) and set anything
1054 dnl extra (e.g., #defines) that must accompany particular g++ options.
1055 if test -n "$enable_cxx_flags"; then
1056     for f in $enable_cxx_flags; do
1057         case "$f" in
1058             -fhonor-std)  ;;
1059             -*)  ;;
1060             *)   # and we're trying to pass /what/ exactly?
1061                  AC_MSG_ERROR([compiler flags start with a -]) ;;
1062         esac
1063     done
1064 fi
1065 EXTRA_CXX_FLAGS="$enable_cxx_flags"
1066 AC_SUBST(EXTRA_CXX_FLAGS)
1067 ])
1068
1069
1070 dnl
1071 dnl Check for which locale library to use:  gnu or generic.
1072 dnl
1073 dnl GLIBCPP_ENABLE_CLOCALE
1074 dnl --enable-clocale=gnu sets config/c_locale_gnu.cc and friends
1075 dnl --enable-clocale=generic sets config/c_locale_generic.cc and friends
1076 dnl 
1077 dnl default is generic
1078 dnl
1079 AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1080   AC_MSG_CHECKING([for clocale to use])
1081   AC_ARG_ENABLE(clocale,
1082   [  --enable-clocale       enable model for target locale package. 
1083      --enable-clocale=MODEL use MODEL target-speific locale package. [default=generic]
1084   ], 
1085   if test x$enable_clocale = xno; then
1086      enable_clocale=generic
1087   fi,
1088      enable_clocale=generic)
1089
1090   enable_clocale_flag=$enable_clocale
1091
1092   dnl Check if a valid locale package
1093   case x${enable_clocale_flag} in
1094     xgnu)
1095       CLOCALE_H=config/c_locale_gnu.h
1096       CLOCALE_CC=config/c_locale_gnu.cc
1097       AC_MSG_RESULT(gnu)
1098       ;;
1099     xgeneric)
1100       CLOCALE_H=config/c_locale_generic.h
1101       CLOCALE_CC=config/c_locale_generic.cc
1102       AC_MSG_RESULT(generic)
1103       ;;
1104     *)
1105       echo "$enable_clocale is an unknown locale package" 1>&2
1106       exit 1
1107       ;;
1108   esac
1109
1110   AC_LINK_FILES($CLOCALE_H, include/bits/c++locale.h)
1111   AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1112 ])
1113
1114
1115 dnl
1116 dnl Check for which I/O library to use:  libio, or something specific.
1117 dnl
1118 dnl GLIBCPP_ENABLE_CSTDIO
1119 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
1120 dnl 
1121 dnl default is stdio
1122 dnl
1123 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1124   AC_MSG_CHECKING([for cstdio to use])
1125   AC_ARG_ENABLE(cstdio,
1126   [  --enable-cstdio        enable stdio for target io package. 
1127      --enable-cstdio=LIB    use LIB target-speific io package. [default=stdio]
1128   ], 
1129   if test x$enable_cstdio = xno; then
1130      enable_cstdio=stdio
1131   fi,
1132      enable_cstdio=stdio)
1133
1134   enable_cstdio_flag=$enable_cstdio
1135
1136   dnl Check if a valid I/O package
1137   case x${enable_cstdio_flag} in
1138     xlibio)
1139       CSTDIO_H=config/c_io_libio.h
1140       CSTDIO_CC=config/c_io_libio.cc
1141       AC_MSG_RESULT(libio)
1142
1143       # see if we are on a system with libio native (ie, linux)
1144       AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1145
1146       # Need to check and see what version of glibc is being used. If
1147       # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1148       # compile most of libio for linux systems.
1149       if test x$has_libio = x"yes"; then
1150         case "$target" in
1151           *-*-linux*)
1152               AC_MSG_CHECKING([for glibc version >= 2.2])
1153               AC_EGREP_CPP([ok], [
1154             #include <features.h>
1155               #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1156                     ok
1157               #endif
1158               ], glibc_satisfactory=yes, glibc_satisfactory=no)
1159               AC_MSG_RESULT($glibc_satisfactory)
1160             ;;
1161         esac
1162
1163         # XXX at the moment, admit defeat and force the recompilation
1164         # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1165         glibc_satisfactory=no        
1166
1167         if test x$glibc_satisfactory = x"yes"; then
1168            need_libio=no
1169            need_wlibio=no        
1170         else
1171            need_libio=yes
1172            # bkoz XXX need to add checks to enable this
1173            # pme XXX here's a first pass at such a check
1174            if test x$enable_c_mbchar != xno; then
1175               need_wlibio=yes
1176            else
1177               need_wlibio=no
1178            fi
1179         fi
1180
1181       else
1182          # Using libio, but <libio.h> doesn't exist on the target system. . .
1183          need_libio=yes
1184          # bkoz XXX need to add checks to enable this
1185          # pme XXX here's a first pass at such a check
1186          if test x$enable_c_mbchar != xno; then
1187              need_wlibio=yes
1188          else
1189              need_wlibio=no
1190          fi
1191       fi
1192       ;;
1193     xstdio | x | xno | xnone | xyes)
1194       # default
1195       CSTDIO_H=config/c_io_stdio.h
1196       CSTDIO_CC=config/c_io_stdio.cc
1197       AC_MSG_RESULT(stdio)
1198
1199       # We're not using stdio.
1200       need_libio=no
1201       need_wlibio=no
1202       # Wide characters are not supported with this package.
1203       enable_c_mbchar=no
1204       ;;
1205     *)
1206       echo "$enable_cstdio is an unknown io package" 1>&2
1207       exit 1
1208       ;;
1209   esac
1210   AC_LINK_FILES($CSTDIO_H, include/bits/c++io.h)
1211   AC_LINK_FILES($CSTDIO_CC, src/c++io.cc)
1212
1213   # 2000-08-04 bkoz hack
1214   CCODECVT_C=config/c_io_libio_codecvt.c
1215   AC_LINK_FILES($CCODECVT_C, libio/c_codecvt.c)
1216   # 2000-08-04 bkoz hack
1217
1218   AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1219                  test "$need_libio" = yes || test "$need_wlibio" = yes)
1220   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1221   AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1222   if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1223     libio_la=../libio/libio.la
1224   else
1225     libio_la=
1226   fi
1227   AC_SUBST(libio_la)
1228 ])
1229
1230
1231 dnl
1232 dnl Check for which threading library to use.
1233 dnl
1234 dnl GLIBCPP_ENABLE_THREADS
1235 dnl --enable-threads=posix sets config/threads-posix.h et. al.
1236 dnl 
1237 dnl Default is no threads, which also disables _IO_MTSAFE_IO in
1238 dnl libio.  Any actual thread package will enable it.
1239 dnl
1240 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1241   dnl Note this comes from the gcc/config.in and libjava/config.in
1242   dnl Efforts should be made to keep this in sync.
1243   AC_MSG_CHECKING([for threads package to use])
1244   AC_ARG_ENABLE(threads,
1245   [  --enable-threads       enable thread usage for target GCC.
1246      --enable-threads=LIB   use LIB thread package for target GCC. [default=no]
1247   ],
1248   if test x$enable_threads = xno; then
1249     enable_threads=''
1250   fi,
1251     enable_threads='')
1252
1253   enable_threads_flag=$enable_threads
1254
1255   dnl Check if a valid thread package
1256   case x${enable_threads_flag} in
1257         x | xno | xnone)
1258                 # No threads
1259                 target_thread_file='single'
1260                 ;;
1261         xyes)
1262                 # default
1263                 target_thread_file='posix'
1264                 ;;
1265         xdecosf1 | xirix | xmach | xos2 | xposix | xpthreads | xsingle | \
1266         xsolaris | xwin32 | xdce | xvxworks)
1267                 target_thread_file=$enable_threads_flag
1268                 ;;
1269         *)
1270                 echo "$enable_threads is an unknown thread package" 1>&2
1271                 exit 1
1272                 ;;
1273   esac
1274
1275   dnl Check for thread package actually supported in libstdc++ 
1276   THREADH=
1277   case "$target_thread_file" in
1278     no | none | single)
1279       THREADH=threads-no.h
1280       ;;
1281     posix | pthreads)
1282       THREADH=threads-posix.h
1283       ;;
1284     decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
1285       AC_MSG_ERROR(thread package $THREADS not yet supported)
1286       ;;
1287     *)
1288       AC_MSG_ERROR($THREADS is an unsupported/unknown thread package)
1289       ;;
1290   esac
1291   AC_MSG_RESULT($THREADH)
1292
1293   AC_LINK_FILES(config/$THREADH, include/bits/c++threads.h)
1294   if test $THREADH != threads-no.h; then
1295     AC_DEFINE(_GLIBCPP_USE_THREADS)
1296   fi
1297 ])
1298
1299
1300 dnl
1301 dnl Check for template specializations for the 'long long' type extension.
1302 dnl
1303 dnl GLIBCPP_ENABLE_LONG_LONG
1304 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1305 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1306 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1307 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1308 dnl       defaults to `no'.
1309 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1310 dnl
1311 dnl GLIBCPP_ENABLE_LONG_LONG
1312 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1313   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1314
1315   AC_ARG_ENABLE(long-long,
1316   changequote(<<, >>)dnl
1317   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1318   changequote([, ])dnl
1319   [case "$enableval" in
1320    yes) enable_long_long=yes ;;
1321    no)  enable_long_long=no ;;
1322    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1323    esac],
1324   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1325  
1326   # Allow use of os-dependent settings, so that macros that turn on
1327   # C99 capabilities can be defined and used in a consistent way.
1328   OS_INC_PATH=${srcdir}/$os_include_dir
1329   ac_test_CFLAGS="${CFLAGS+set}"
1330   ac_save_CFLAGS="$CFLAGS"
1331   CFLAGS="-I$OS_INC_PATH"
1332
1333   # Check for the existence of functions used if long long is enabled.
1334   AC_CHECK_FUNC(strtoll,,ac_strtoll=no)
1335   AC_CHECK_FUNC(strtoull,,ac_strtoull=no)
1336
1337   # Check for lldiv_t, et. al.
1338   AC_MSG_CHECKING([for lldiv_t declaration])
1339   AC_CACHE_VAL(glibcpp_lldiv_t_use, [
1340   AC_TRY_COMPILE([#include <bits/os_defines.h>
1341                   #include <stdlib.h>], 
1342                    [ lldiv_t mydivt;], 
1343                    [glibcpp_lldiv_t_use=yes], [glibcpp_lldiv_t_use=no])
1344   ])
1345   AC_MSG_RESULT($glibcpp_lldiv_t_use)
1346   if test x$glibcpp_lldiv_t_use = x"yes"; then
1347     AC_DEFINE(HAVE_LLDIV_T)
1348   fi
1349
1350   AC_MSG_CHECKING([for enabled long long])
1351   if test x"$ac_strtoll" = xno || test x"$ac_strtoull" = xno; then 
1352     enable_long_long=no; 
1353   fi; 
1354   AC_MSG_RESULT($enable_long_long)
1355
1356   # Option parsed, now set things appropriately
1357   if test x"$enable_long_long" = xyes; then
1358     AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1359   fi
1360
1361   # Reset CFLAGS
1362   CFLAGS="$ac_save_CFLAGS"
1363 ])
1364
1365
1366 dnl
1367 dnl Check for what kind of C headers to use.
1368 dnl
1369 dnl GLIBCPP_ENABLE_CHEADERS
1370 dnl --enable-cheaders= [does stuff].
1371 dnl --disable-cheaders [does not do anything, really].
1372 dnl  +  This will eventually need to be 'c_shadow' by default.
1373 dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1374 dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1375 dnl       If ommitted, it defaults to `c_std'.
1376 AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1377 define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1378 AC_MSG_CHECKING([for c header strategy to use])
1379 AC_ARG_ENABLE(cheaders,
1380 changequote(<<, >>)dnl
1381 <<  --enable-cheaders construct "C" header files for
1382                            g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1383 changequote([, ])
1384   [case "$enableval" in
1385    c) 
1386         enable_cheaders=c 
1387         ;;
1388    c_std)  
1389         enable_cheaders=c_std 
1390         ;;
1391    c_shadow)  
1392         enable_cheaders=c_shadow 
1393         ;;
1394    *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1395         ;;
1396   esac],
1397   enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1398   AC_MSG_RESULT($enable_cheaders)
1399
1400   dnl Option parsed, now set things appropriately
1401   case "$enable_cheaders" in
1402     c_shadow) 
1403         CSHADOW_FLAGS="-fno-builtin"
1404         C_INCLUDE_DIR='${top_srcdir}/include/c_shadow'
1405         AC_DEFINE(_GLIBCPP_USE_SHADOW_HEADERS)
1406         ;;
1407     c_std)   
1408         CSHADOW_FLAGS=""
1409         C_INCLUDE_DIR='${top_srcdir}/include/c_std'
1410         ;;
1411     c)   
1412         CSHADOW_FLAGS=""
1413         C_INCLUDE_DIR='${top_srcdir}/include/c'
1414         ;;
1415   esac
1416
1417   AC_SUBST(CSHADOW_FLAGS)
1418   AC_SUBST(C_INCLUDE_DIR)
1419   AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cheaders" = c_shadow)
1420 ])
1421
1422
1423 dnl
1424 dnl Check for wide character support.  Has the same effect as the option
1425 dnl in gcc's configure, but in a form that autoconf can mess with.
1426 dnl
1427 dnl GLIBCPP_ENABLE_C_MBCHAR
1428 dnl --enable-c-mbchar requests all the wchar_t stuff.
1429 dnl --disable-c-mbchar doesn't.
1430 dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1431 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1432 dnl       defaults to `no'.
1433 AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1434 define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1435 AC_ARG_ENABLE(c-mbchar,
1436 changequote(<<, >>)dnl
1437 <<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1438 changequote([, ])dnl
1439 [case "$enableval" in
1440  yes) enable_c_mbchar=yes ;;
1441  no)  enable_c_mbchar=no ;;
1442  *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1443  esac],
1444 enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1445 dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1446 ])
1447
1448
1449 dnl
1450 dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1451 dnl
1452 dnl GLIBCPP_INCLUDE_DIR
1453 dnl C_INCLUDE_DIR
1454 dnl TOPLEVEL_INCLUDES
1455 dnl LIBMATH_INCLUDES
1456 dnl LIBSUPCXX_INCLUDES
1457 dnl LIBIO_INCLUDES
1458 dnl CSHADOW_INCLUDES
1459 dnl
1460 dnl GLIBCPP_EXPORT_INCLUDE
1461 AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1462   # Root level of the include sources.
1463   GLIBCPP_INCLUDE_DIR='$(top_srcdir)/include'
1464
1465   # Can either use include/c or include/c_std to grab "C" headers. This
1466   # variable is set to the include directory currently in use.
1467   # set with C_INCLUDE_DIR in GLIBCPP_ENABLE_CHEADERS
1468    
1469   # Passed down for canadian crosses.
1470   if  test x"$CANADIAN" = xyes; then
1471     TOPLEVEL_INCLUDES='-I$(includedir)'
1472   fi
1473
1474   LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1475
1476   LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1477
1478   #if GLIBCPP_NEED_LIBIO
1479   LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1480   #else
1481   #LIBIO_INCLUDES='-I$(top_srcdir)/libio'
1482   #endif
1483
1484   #if GLIBCPP_USE_CSHADOW
1485   #  CSHADOW_INCLUDES='-I$(GLIBCPP_INCLUDE_DIR)/std -I$(C_INCLUDE_DIR) \
1486   #                   -I$(top_blddir)/cshadow'
1487   #else
1488   CSTD_INCLUDES='-I$(GLIBCPP_INCLUDE_DIR)/std -I$(C_INCLUDE_DIR)'
1489   #endif
1490
1491   # Now, export this to all the little Makefiles....
1492   AC_SUBST(GLIBCPP_INCLUDE_DIR)
1493   AC_SUBST(TOPLEVEL_INCLUDES)
1494   AC_SUBST(LIBMATH_INCLUDES)
1495   AC_SUBST(LIBSUPCXX_INCLUDES)
1496   AC_SUBST(LIBIO_INCLUDES)
1497   AC_SUBST(CSTD_INCLUDES)
1498 ])
1499
1500
1501 dnl
1502 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1503 dnl
1504 AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1505   # Optimization flags that are probably a good idea for thrill-seekers. Just
1506   # uncomment the lines below and make, everything else is ready to go... 
1507   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1508   OPTIMIZE_CXXFLAGS=
1509   AC_SUBST(OPTIMIZE_CXXFLAGS)
1510
1511   WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1512   AC_SUBST(WARN_FLAGS)
1513 ])
1514
1515
1516 dnl  GLIBCPP_EXPORT_INSTALL_INFO
1517 dnl  calculates gxx_install_dir
1518 dnl
1519 AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1520
1521 AC_MSG_CHECKING([for interface version number])
1522 libstdcxx_interface=$INTERFACE
1523 AC_MSG_RESULT($libstdcxx_interface)
1524
1525 # Process the option --with-gxx-include-dir=<path to include-files directory>
1526 AC_MSG_CHECKING([for --with-gxx-include-dir])
1527 AC_ARG_WITH(gxx-include-dir,
1528 [ --with-gxx-include-dir  the installation directory for include files],
1529 [case "${withval}" in
1530   yes)
1531     AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1532     gxx_include_dir=no
1533     ;;
1534   no)
1535     gxx_include_dir=no
1536     ;;
1537   *)
1538     gxx_include_dir=${withval}
1539     ;;
1540 esac], [gxx_include_dir=no])
1541 AC_MSG_RESULT($gxx_include_dir)
1542
1543 # Process the option "--enable-version-specific-runtime-libs"
1544 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1545 AC_ARG_ENABLE(version-specific-runtime-libs,
1546 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1547 [  version_specific_libs=yes
1548 # Need the gcc compiler version to know where to install libraries
1549 # and header files if --enable-version-specific-runtime-libs option
1550 # is selected.
1551 changequote(,)dnl
1552 gcc_tmp=`grep version_string ${srcdir}/../gcc/version.c | awk '{print $6}'`
1553 gcc_num=`echo ${gcc_tmp} | sed 's/\"//g'`
1554 gcc_version=$gcc_num
1555 gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/$(gcc_version)/include/g++'
1556 changequote([,])dnl
1557 AC_SUBST(gcc_version)
1558 AM_CONDITIONAL(VERSION_SPECIFIC_LIBS, test x"$version_specific_libs" = x"yes")
1559 ],version_specific_libs=no)
1560 AC_MSG_RESULT($version_specific_libs)
1561
1562 AC_MSG_CHECKING([for install location])
1563 if test x"$version_specific_libs" = x"no" \
1564    && test x"$gxx_include_dir"=x"no"; then
1565   gxx_include_dir=${prefix}/include/g++-${libstdcxx_interface}
1566 fi
1567 AC_MSG_RESULT($gxx_include_dir)
1568 AC_SUBST(gxx_include_dir)
1569 ])
1570
1571
1572 # Check whether LC_MESSAGES is available in <locale.h>.
1573 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1574 #
1575 # This file file be copied and used freely without restrictions.  It can
1576 # be used in projects which are not available under the GNU Public License
1577 # but which still want to provide support for the GNU gettext functionality.
1578 # Please note that the actual code is *not* freely available.
1579
1580 # serial 1
1581
1582 AC_DEFUN(AC_LC_MESSAGES, [
1583   AC_CHECK_HEADER(locale.h, [
1584     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
1585       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1586        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
1587     if test $ac_cv_val_LC_MESSAGES = yes; then
1588       AC_DEFINE(HAVE_LC_MESSAGES)
1589     fi
1590   ])
1591 ])
1592
1593
1594 # Check for functions in math library.
1595 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1596 #
1597 # This file can be copied and used freely without restrictions.  It can
1598 # be used in projects which are not available under the GNU Public License
1599 # but which still want to provide support for the GNU gettext functionality.
1600 # Please note that the actual code is *not* freely available.
1601
1602 # serial 1
1603
1604 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1605 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1606 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1607 AC_SUBST(LIBMATHOBJS)dnl
1608 ])
1609
1610
1611 # Check for string functions.
1612 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1613 #
1614 # This file can be copied and used freely without restrictions.  It can
1615 # be used in projects which are not available under the GNU Public License
1616 # but which still want to provide support for the GNU gettext functionality.
1617 # Please note that the actual code is *not* freely available.
1618
1619 # serial 1
1620
1621 dnl AC_REPLACE_STRINGFUNCS(FUNCTION...)
1622 AC_DEFUN(AC_REPLACE_STRINGFUNCS,
1623 [AC_CHECK_FUNCS([$1], , [LIBSTRINGOBJS="$LIBSTRINGOBJS ${ac_func}.lo"])
1624 AC_SUBST(LIBSTRINGOBJS)dnl
1625 ])
1626
1627
1628 dnl This macro searches for a GNU version of make.  If a match is found, the
1629 dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1630 dnl set to "#". This is useful for  including a special features in a Makefile,
1631 dnl which cannot be handled by other versions of make.  The variable
1632 dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1633 dnl the empty string otherwise.
1634 dnl
1635 dnl Here is an example of its use:
1636 dnl
1637 dnl Makefile.in might contain:
1638 dnl
1639 dnl     # A failsafe way of putting a dependency rule into a makefile
1640 dnl     $(DEPEND):
1641 dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1642 dnl
1643 dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1644 dnl     @ifGNUmake@ include $(DEPEND)
1645 dnl     @ifGNUmake@ endif
1646 dnl
1647 dnl Then configure.in would normally contain:
1648 dnl
1649 dnl     CHECK_GNU_MAKE()
1650 dnl     AC_OUTPUT(Makefile)
1651 dnl
1652 dnl Then perhaps to cause gnu make to override any other make, we could do
1653 dnl something like this (note that GNU make always looks for GNUmakefile first):
1654 dnl
1655 dnl     if  ! test x$_cv_gnu_make_command = x ; then
1656 dnl             mv Makefile GNUmakefile
1657 dnl             echo .DEFAULT: > Makefile ;
1658 dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1659 dnl     fi
1660 dnl
1661 dnl Then, if any (well almost any) other make is called, and GNU make also
1662 dnl exists, then the other make wraps the GNU make.
1663 dnl
1664 dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1665 dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1666 dnl
1667 dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1668 dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1669 dnl #### conditional's subshell (" --version" is not a command), using a
1670 dnl #### different option to grep(1).
1671 dnl #### -pme
1672 dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
1673 dnl #### ${MAKE:-make}).
1674 dnl #### -msokolov
1675 AC_DEFUN(
1676   GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1677           _cv_gnu_make_command='' ;
1678 dnl Search all the common names for GNU make
1679           for a in "${MAKE-make}" make gmake gnumake ; do
1680                   if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
1681                   then
1682                           _cv_gnu_make_command=$a ;
1683                           break;
1684                   fi
1685           done ;
1686   ) ;
1687 dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1688 dnl string, '#' otherwise
1689   if test  "x$_cv_gnu_make_command" != "x"  ; then
1690           ifGNUmake='' ;
1691   else
1692           ifGNUmake='#' ;
1693   fi
1694   AC_SUBST(ifGNUmake)
1695 ])
1696
1697 sinclude(../libtool.m4)
1698 dnl The lines below arrange for aclocal not to bring an installed
1699 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
1700 dnl add a definition of LIBTOOL to Makefile.in.
1701 ifelse(,,,[AC_SUBST(LIBTOOL)
1702 AC_DEFUN([AM_PROG_LIBTOOL])
1703 AC_DEFUN([AC_LIBTOOL_DLOPEN])
1704 AC_DEFUN([AC_PROG_LD])
1705 ])
1706
1707
1708 # Do all the work for Automake.  This macro actually does too much --
1709 # some checks are only needed if your package does certain things.
1710 # But this isn't really a big deal.
1711
1712 # serial 1
1713
1714 dnl Usage:
1715 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
1716
1717 AC_DEFUN(AM_INIT_AUTOMAKE,
1718 [AC_REQUIRE([AC_PROG_INSTALL])
1719 PACKAGE=[$1]
1720 AC_SUBST(PACKAGE)
1721 VERSION=[$2]
1722 AC_SUBST(VERSION)
1723 dnl test to see if srcdir already configured
1724 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
1725   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
1726 fi
1727 ifelse([$3],,
1728 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
1729 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
1730 AC_REQUIRE([AM_SANITY_CHECK])
1731 AC_REQUIRE([AC_ARG_PROGRAM])
1732 dnl FIXME This is truly gross.
1733 missing_dir=`cd $ac_aux_dir && pwd`
1734 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
1735 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
1736 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
1737 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
1738 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
1739 AC_REQUIRE([AC_PROG_MAKE_SET])])
1740
1741 #
1742 # Check to make sure that the build environment is sane.
1743 #
1744
1745 AC_DEFUN(AM_SANITY_CHECK,
1746 [AC_MSG_CHECKING([whether build environment is sane])
1747 # Just in case
1748 sleep 1
1749 echo timestamp > conftestfile
1750 # Do `set' in a subshell so we don't clobber the current shell's
1751 # arguments.  Must try -L first in case configure is actually a
1752 # symlink; some systems play weird games with the mod time of symlinks
1753 # (eg FreeBSD returns the mod time of the symlink's containing
1754 # directory).
1755 if (
1756    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
1757    if test "[$]*" = "X"; then
1758       # -L didn't work.
1759       set X `ls -t $srcdir/configure conftestfile`
1760    fi
1761    if test "[$]*" != "X $srcdir/configure conftestfile" \
1762       && test "[$]*" != "X conftestfile $srcdir/configure"; then
1763
1764       # If neither matched, then we have a broken ls.  This can happen
1765       # if, for instance, CONFIG_SHELL is bash and it inherits a
1766       # broken ls alias from the environment.  This has actually
1767       # happened.  Such a system could not be considered "sane".
1768       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
1769 alias in your environment])
1770    fi
1771
1772    test "[$]2" = conftestfile
1773    )
1774 then
1775    # Ok.
1776    :
1777 else
1778    AC_MSG_ERROR([newly created file is older than distributed files!
1779 Check your system clock])
1780 fi
1781 rm -f conftest*
1782 AC_MSG_RESULT(yes)])
1783
1784 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
1785 dnl The program must properly implement --version.
1786 AC_DEFUN(AM_MISSING_PROG,
1787 [AC_MSG_CHECKING(for working $2)
1788 # Run test in a subshell; some versions of sh will print an error if
1789 # an executable is not found, even if stderr is redirected.
1790 # Redirect stdin to placate older versions of autoconf.  Sigh.
1791 if ($2 --version) < /dev/null > /dev/null 2>&1; then
1792    $1=$2
1793    AC_MSG_RESULT(found)
1794 else
1795    $1="$3/missing $2"
1796    AC_MSG_RESULT(missing)
1797 fi
1798 AC_SUBST($1)])
1799
1800 # Add --enable-maintainer-mode option to configure.
1801 # From Jim Meyering
1802
1803 # serial 1
1804
1805 AC_DEFUN(AM_MAINTAINER_MODE,
1806 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
1807   dnl maintainer-mode is disabled by default
1808   AC_ARG_ENABLE(maintainer-mode,
1809 [  --enable-maintainer-mode enable make rules and dependencies not useful
1810                           (and sometimes confusing) to the casual installer],
1811       USE_MAINTAINER_MODE=$enableval,
1812       USE_MAINTAINER_MODE=no)
1813   AC_MSG_RESULT($USE_MAINTAINER_MODE)
1814   AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
1815   MAINT=$MAINTAINER_MODE_TRUE
1816   AC_SUBST(MAINT)dnl
1817 ]
1818 )
1819
1820 # Define a conditional.
1821
1822 AC_DEFUN(AM_CONDITIONAL,
1823 [AC_SUBST($1_TRUE)
1824 AC_SUBST($1_FALSE)
1825 if $2; then
1826   $1_TRUE=
1827   $1_FALSE='#'
1828 else
1829   $1_TRUE='#'
1830   $1_FALSE=
1831 fi])
1832
1833 # Like AC_CONFIG_HEADER, but automatically create stamp file.
1834
1835 AC_DEFUN(AM_CONFIG_HEADER,
1836 [AC_PREREQ([2.12])
1837 AC_CONFIG_HEADER([$1])
1838 dnl When config.status generates a header, we must update the stamp-h file.
1839 dnl This file resides in the same directory as the config header
1840 dnl that is generated.  We must strip everything past the first ":",
1841 dnl and everything past the last "/".
1842 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
1843 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
1844 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
1845 <<am_indx=1
1846 for am_file in <<$1>>; do
1847   case " <<$>>CONFIG_HEADERS " in
1848   *" <<$>>am_file "*<<)>>
1849     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
1850     ;;
1851   esac
1852   am_indx=`expr "<<$>>am_indx" + 1`
1853 done<<>>dnl>>)
1854 changequote([,]))])
1855