OSDN Git Service

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