OSDN Git Service

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