OSDN Git Service

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