OSDN Git Service

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