]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/aclocal.m4
testsuite_allocator.h: New file.
[thirdparty/gcc.git] / libstdc++-v3 / aclocal.m4
CommitLineData
162c7cd9 1dnl aclocal.m4 generated automatically by aclocal 1.4-p5
b2dad0e3 2
9a56333e 3dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
b2dad0e3
BK
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11dnl PARTICULAR PURPOSE.
12
13dnl
38cca750 14dnl Initialize basic configure bits, set toplevel_srcdir for Makefiles.
b2dad0e3 15dnl
aebb8c22
DD
16dnl GLIBCPP_TOPREL_CONFIGURE
17AC_DEFUN(GLIBCPP_TOPREL_CONFIGURE, [
2c839a4e
PE
18 dnl Default to --enable-multilib (this is also passed by default
19 dnl from the ubercommon-top-level configure)
b2dad0e3
BK
20 AC_ARG_ENABLE(multilib,
21 [ --enable-multilib build hella library versions (default)],
22 [case "${enableval}" in
23 yes) multilib=yes ;;
24 no) multilib=no ;;
25 *) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
26 esac], [multilib=yes])dnl
27
d2caef2e
PE
28 # When building with srcdir == objdir, links to the source files will
29 # be created in directories within the target_subdir. We have to
30 # adjust toplevel_srcdir accordingly, so that configure finds
31 # install-sh and other auxiliary files that live in the top-level
32 # source directory.
33 if test "${srcdir}" = "."; then
34 if test -z "${with_target_subdir}"; then
35 toprel=".."
33590f13 36 else
d2caef2e
PE
37 if test "${with_target_subdir}" != "."; then
38 toprel="${with_multisrctop}../.."
39 else
40 toprel="${with_multisrctop}.."
41 fi
33590f13 42 fi
d2caef2e
PE
43 else
44 toprel=".."
33590f13 45 fi
d2caef2e
PE
46 AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
47 toplevel_srcdir=\${top_srcdir}/$toprel
48 AC_SUBST(toplevel_srcdir)
aebb8c22
DD
49])
50
51dnl
38cca750 52dnl Initialize the rest of the library configury.
aebb8c22
DD
53dnl
54dnl GLIBCPP_CONFIGURE
55AC_DEFUN(GLIBCPP_CONFIGURE, [
d2caef2e
PE
56 # Export build and source directories.
57 # These need to be absolute paths, yet at the same time need to
58 # canonicalize only relative paths, because then amd will not unmount
59 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
1e6347d8 60 glibcpp_builddir=`${PWDCMD-pwd}`
d2caef2e
PE
61 case $srcdir in
62 [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
63 *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
64 esac
65 AC_SUBST(glibcpp_builddir)
66 AC_SUBST(glibcpp_srcdir)
33590f13 67
d2caef2e
PE
68 dnl This is here just to satisfy automake.
69 ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)])
33590f13 70
d2caef2e
PE
71 AC_PROG_AWK
72 # Will set LN_S to either 'ln -s' or 'ln'. With autoconf 2.5x, can also
2c839a4e
PE
73 # be 'cp -p' if linking isn't available. Uncomment the next line to
74 # force a particular method.
d2caef2e
PE
75 #ac_cv_prog_LN_S='cp -p'
76 AC_PROG_LN_S
33590f13 77
d2caef2e
PE
78 # We use these options to decide which functions to include.
79 AC_ARG_WITH(target-subdir,
80 [ --with-target-subdir=SUBDIR
81 configuring in a subdirectory])
82 AC_ARG_WITH(cross-host,
83 [ --with-cross-host=HOST configuring with a cross compiler])
33590f13 84
1de9b822 85 glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
b2dad0e3
BK
86 AC_SUBST(glibcpp_basedir)
87
28861379
BK
88 # Never versions of autoconf add an underscore to these functions.
89 # Prevent future problems ...
90 ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
91 ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
92 ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
93 ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
5780a46b 94
d2caef2e
PE
95 # AC_PROG_CC
96 # FIXME: We temporarily define our own version of AC_PROG_CC. This is
97 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
98 # are probably using a cross compiler, which will not be able to fully
99 # link an executable. This is addressed in later versions of autoconf.
100
101 AC_DEFUN(LIB_AC_PROG_CC,
102 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
103 dnl Fool anybody using AC_PROG_CC.
104 AC_PROVIDE([AC_PROG_CC])
105 AC_CHECK_PROG(CC, gcc, gcc)
106 if test -z "$CC"; then
107 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
108 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
109 fi
110
111 AC_PROG_CC_GNU
b2dad0e3 112
d2caef2e
PE
113 if test $ac_cv_prog_gcc = yes; then
114 GCC=yes
115 dnl Check whether -g works, even if CFLAGS is set, in case the package
116 dnl plays around with CFLAGS (such as to build both debugging and
117 dnl normal versions of a library), tasteless as that idea is.
118 ac_test_CFLAGS="${CFLAGS+set}"
119 ac_save_CFLAGS="$CFLAGS"
120 CFLAGS=
121 AC_PROG_CC_G
122 if test "$ac_test_CFLAGS" = set; then
123 CFLAGS="$ac_save_CFLAGS"
124 elif test $ac_cv_prog_cc_g = yes; then
125 CFLAGS="-g -O2"
126 else
127 CFLAGS="-O2"
128 fi
b2dad0e3 129 else
d2caef2e
PE
130 GCC=
131 test "${CFLAGS+set}" = set || CFLAGS="-g"
b2dad0e3 132 fi
d2caef2e 133 ])
b2dad0e3 134
d2caef2e
PE
135 LIB_AC_PROG_CC
136
137 # Likewise for AC_PROG_CXX. We can't just call it directly because g++
138 # will try to link in libstdc++.
139 AC_DEFUN(LIB_AC_PROG_CXX,
140 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
141 dnl Fool anybody using AC_PROG_CXX.
142 AC_PROVIDE([AC_PROG_CXX])
143 # Use glibcpp_CXX so that we do not cause CXX to be cached with the
144 # flags that come in CXX while configuring libstdc++. They're different
145 # from those used for all other target libraries. If CXX is set in
146 # the environment, respect that here.
147 glibcpp_CXX=$CXX
148 AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
149 AC_SUBST(glibcpp_CXX)
150 CXX=$glibcpp_CXX
151 test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
152
153 AC_PROG_CXX_GNU
154
155 if test $ac_cv_prog_gxx = yes; then
156 GXX=yes
157 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
158 dnl plays around with CXXFLAGS (such as to build both debugging and
159 dnl normal versions of a library), tasteless as that idea is.
160 ac_test_CXXFLAGS="${CXXFLAGS+set}"
161 ac_save_CXXFLAGS="$CXXFLAGS"
162 CXXFLAGS=
163 AC_PROG_CXX_G
164 if test "$ac_test_CXXFLAGS" = set; then
165 CXXFLAGS="$ac_save_CXXFLAGS"
166 elif test $ac_cv_prog_cxx_g = yes; then
167 CXXFLAGS="-g -O2"
168 else
169 CXXFLAGS="-O2"
170 fi
b2dad0e3 171 else
d2caef2e
PE
172 GXX=
173 test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
b2dad0e3 174 fi
d2caef2e 175 ])
b2dad0e3 176
d2caef2e 177 LIB_AC_PROG_CXX
b2dad0e3 178
2f235b6d
PE
179 # For directory versioning (e.g., headers) and other variables.
180 AC_MSG_CHECKING([for GCC version number])
181 gcc_version=`$glibcpp_CXX -dumpversion`
182 AC_MSG_RESULT($gcc_version)
183
d2caef2e
PE
184 # For some reason, gettext needs this.
185 AC_ISC_POSIX
33590f13 186
5780a46b
BK
187 AC_CHECK_TOOL(AS, as)
188 AC_CHECK_TOOL(AR, ar)
46840bcd 189 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
5780a46b 190 AC_PROG_INSTALL
b2dad0e3 191
5780a46b 192 AM_MAINTAINER_MODE
b2dad0e3 193
5780a46b
BK
194 # We need AC_EXEEXT to keep automake happy in cygnus mode. However,
195 # at least currently, we never actually build a program, so we never
196 # need to use $(EXEEXT). Moreover, the test for EXEEXT normally
197 # fails, because we are probably configuring with a cross compiler
c5504edb
JM
198 # which can't create executables. So we include AC_EXEEXT to keep
199 # automake happy, but we don't execute it, since we don't care about
5780a46b
BK
200 # the result.
201 if false; then
61c71946
BK
202 # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
203 # to nothing, so nothing would remain between `then' and `fi' if it
204 # were not for the `:' below.
205 :
5780a46b
BK
206 AC_EXEEXT
207 fi
b2dad0e3 208
5780a46b 209 case [$]{glibcpp_basedir} in
6f87af20 210 /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
5780a46b
BK
211 *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
212 esac
b2dad0e3 213
2c839a4e 214 # Find platform-specific directories containing configuration info. In
5e3cbe0b 215 # addition to possibly modifying the same flags, it also sets up symlinks.
d0941a31 216 GLIBCPP_CHECK_TARGET
b2dad0e3
BK
217])
218
219
220dnl
8bd636c5 221dnl Check to see if g++ can compile this library, and if so, if any version-
c470c17d
BK
222dnl specific precautions need to be taken.
223dnl
224dnl GLIBCPP_CHECK_COMPILER_VERSION
225AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
44382959
BK
226if test ! -f stamp-sanity-compiler; then
227 AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
228 AC_LANG_SAVE
229 AC_LANG_CPLUSPLUS
1d855e87
BK
230 AC_TRY_COMPILE(, [
231 #if __GNUC__ < 3
232 not_ok
c470c17d 233 #endif
6a163d7c 234 ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
44382959 235 AC_LANG_RESTORE
c470c17d 236 AC_MSG_RESULT($gpp_satisfactory)
44382959
BK
237 touch stamp-sanity-compiler
238fi
c470c17d
BK
239])
240
241
242dnl
52b55e7d
PE
243dnl Tests for newer compiler features, or features that are present in newer
244dnl compiler versions but not older compiler versions still in use, should
245dnl be placed here.
b2dad0e3 246dnl
7f586614
BK
247dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
248dnl new inlining code or the new system_header pragma will die on -Werror.
249dnl Leave it out by default and use maint-mode to use it.
b2dad0e3 250dnl
c470c17d 251dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
c21b6f87
PE
252dnl compiler supports it and the user has not requested debug mode.
253dnl
c470c17d
BK
254dnl GLIBCPP_CHECK_COMPILER_FEATURES
255AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
a4e99046 256 # All these tests are for C++; save the language and the compiler flags.
52b55e7d 257 # The CXXFLAGS thing is suspicious, but based on similar bits previously
a4e99046
PE
258 # found in GLIBCPP_CONFIGURE.
259 AC_LANG_SAVE
260 AC_LANG_CPLUSPLUS
261 ac_test_CXXFLAGS="${CXXFLAGS+set}"
262 ac_save_CXXFLAGS="$CXXFLAGS"
a4e99046 263
7f586614
BK
264 # Check for maintainer-mode bits.
265 if test x"$USE_MAINTAINER_MODE" = xno; then
266 WERROR=''
8bd636c5 267 else
7f586614 268 WERROR='-Werror'
8bd636c5
PE
269 fi
270
c470c17d
BK
271 # Check for -ffunction-sections -fdata-sections
272 AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
0517cb99 273 CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
c470c17d
BK
274 AC_TRY_COMPILE(, [int foo;
275 ], [ac_fdsections=yes], [ac_fdsections=no])
276 if test "$ac_test_CXXFLAGS" = set; then
277 CXXFLAGS="$ac_save_CXXFLAGS"
278 else
279 # this is the suspicious part
280 CXXFLAGS=''
281 fi
a0cb1aa7
PE
282 if test x"$ac_fdsections" = x"yes" &&
283 test x"$enable_debug" = x"no"; then
c470c17d
BK
284 SECTION_FLAGS='-ffunction-sections -fdata-sections'
285 fi
286 AC_MSG_RESULT($ac_fdsections)
287
a4e99046 288 AC_LANG_RESTORE
8bd636c5 289 AC_SUBST(WERROR)
c470c17d 290 AC_SUBST(SECTION_FLAGS)
b2dad0e3
BK
291])
292
c470c17d
BK
293
294dnl
421173e6
PE
295dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
296dnl the native linker is in use, all variables will be defined to something
297dnl safe (like an empty string).
298dnl
299dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
300dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
c98b201b
PE
301dnl Define LD, with_gnu_ld, and (possibly) glibcpp_gnu_ld_version as
302dnl side-effects of testing.
c470c17d 303dnl
c470c17d
BK
304dnl GLIBCPP_CHECK_LINKER_FEATURES
305AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
421173e6
PE
306 # If we're not using GNU ld, then there's no point in even trying these
307 # tests. Check for that first. We should have already tested for gld
308 # by now (in libtool), but require it now just to be safe...
654421eb
DE
309 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
310 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
421173e6 311 AC_REQUIRE([AC_PROG_LD])
e7140677 312
c98b201b
PE
313 # The name set by libtool depends on the version of libtool. Shame on us
314 # for depending on an impl detail, but c'est la vie. Older versions used
315 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
316 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
317 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
318 # set (hence we're using an older libtool), then set it.
319 if test x${with_gnu_ld+set} != xset; then
320 if test x${ac_cv_prog_gnu_ld+set} != xset; then
321 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
322 with_gnu_ld=no
323 else
324 with_gnu_ld=$ac_cv_prog_gnu_ld
325 fi
326 fi
327
328 # Start by getting the version number. I think the libtool test already
329 # does some of this, but throws away the result.
330 changequote(,)
331 ldver=`$LD --version 2>/dev/null | head -1 | \
332 sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
333 changequote([,])
334 glibcpp_gnu_ld_version=`echo $ldver | \
335 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
336
e7140677 337 # Set --gc-sections.
c98b201b 338 if test "$with_gnu_ld" = "notbroken"; then
a9117427 339 # GNU ld it is! Joy and bunny rabbits!
421173e6
PE
340
341 # All these tests are for C++; save the language and the compiler flags.
342 # Need to do this so that g++ won't try to link in libstdc++
343 ac_test_CFLAGS="${CFLAGS+set}"
344 ac_save_CFLAGS="$CFLAGS"
e7140677 345 CFLAGS='-x c++ -Wl,--gc-sections'
421173e6
PE
346
347 # Check for -Wl,--gc-sections
e466dc8a
BK
348 # XXX This test is broken at the moment, as symbols required for
349 # linking are now in libsupc++ (not built yet.....). In addition,
a9117427
BK
350 # this test has cored on solaris in the past. In addition,
351 # --gc-sections doesn't really work at the moment (keeps on discarding
352 # used sections, first .eh_frame and now some of the glibc sections for
353 # iconv). Bzzzzt. Thanks for playing, maybe next time.
421173e6
PE
354 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
355 AC_TRY_RUN([
356 int main(void)
357 {
a9117427
BK
358 try { throw 1; }
359 catch (...) { };
421173e6
PE
360 return 0;
361 }
c0abb59e 362 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
421173e6
PE
363 if test "$ac_test_CFLAGS" = set; then
364 CFLAGS="$ac_save_CFLAGS"
365 else
366 # this is the suspicious part
367 CFLAGS=''
368 fi
369 if test "$ac_sectionLDflags" = "yes"; then
654421eb 370 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
421173e6
PE
371 fi
372 AC_MSG_RESULT($ac_sectionLDflags)
e7140677 373 fi
a9117427 374
e7140677 375 # Set linker optimization flags.
cdfda668 376 if test x"$with_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
654421eb 377 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
421173e6 378 fi
e7140677 379
c470c17d 380 AC_SUBST(SECTION_LDFLAGS)
421173e6 381 AC_SUBST(OPT_LDFLAGS)
c470c17d
BK
382])
383
384
b2dad0e3 385dnl
11fc1858 386dnl Check to see if the (math function) argument passed is
f8db4f20 387dnl declared when using the c++ compiler
38bd7296
BK
388dnl ASSUMES argument is a math function with ONE parameter
389dnl
f8db4f20
BK
390dnl GLIBCPP_CHECK_MATH_DECL_1
391AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
38bd7296 392 AC_MSG_CHECKING([for $1 declaration])
f84ef7fb
PE
393 if test x${glibcpp_cv_func_$1_use+set} != xset; then
394 AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
395 AC_LANG_SAVE
396 AC_LANG_CPLUSPLUS
01a49191
RB
397 AC_TRY_COMPILE([#include <math.h>
398 #ifdef HAVE_IEEEFP_H
399 #include <ieeefp.h>
400 #endif
401 ],
f84ef7fb
PE
402 [ $1(0);],
403 [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
404 AC_LANG_RESTORE
405 ])
406 fi
421173e6 407 AC_MSG_RESULT($glibcpp_cv_func_$1_use)
f8db4f20
BK
408])
409
410dnl
411dnl Check to see if the (math function) argument passed is
412dnl 1) declared when using the c++ compiler
413dnl 2) has "C" linkage
414dnl 3) if not, see if 1) and 2) for argument prepended with '_'
415dnl
416dnl Define HAVE_CARGF etc if "cargf" is declared and links
417dnl
418dnl argument 1 is name of function to check
419dnl
420dnl ASSUMES argument is a math function with ONE parameter
421dnl
422dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
423AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
424 GLIBCPP_CHECK_MATH_DECL_1($1)
421173e6 425 if test x$glibcpp_cv_func_$1_use = x"yes"; then
38bd7296 426 AC_CHECK_FUNCS($1)
f8db4f20
BK
427 else
428 GLIBCPP_CHECK_MATH_DECL_1(_$1)
429 if test x$glibcpp_cv_func__$1_use = x"yes"; then
430 AC_CHECK_FUNCS(_$1)
a0cb1aa7 431 fi
38bd7296
BK
432 fi
433])
434
f8db4f20 435
20b11783
MM
436dnl
437dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
438dnl of functions at once. It's an all-or-nothing check -- either
9b8fd32c 439dnl HAVE_XYZ is defined for each of the functions, or for none of them.
20b11783
MM
440dnl Doing it this way saves significant configure time.
441AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
442 AC_MSG_CHECKING([for $1 functions])
443 AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
444 AC_LANG_SAVE
445 AC_LANG_CPLUSPLUS
446 AC_TRY_COMPILE([#include <math.h>],
447 [ `for x in $3; do echo "$x (0);"; done` ],
9b8fd32c
PE
448 [glibcpp_cv_func_$2_use=yes],
449 [glibcpp_cv_func_$2_use=no])
20b11783
MM
450 AC_LANG_RESTORE])
451 AC_MSG_RESULT($glibcpp_cv_func_$2_use)
452 if test x$glibcpp_cv_func_$2_use = x"yes"; then
453 AC_CHECK_FUNCS($3)
454 fi
455])
38bd7296
BK
456
457dnl
11fc1858 458dnl Check to see if the (math function) argument passed is
f8db4f20 459dnl declared when using the c++ compiler
52b55e7d 460dnl ASSUMES argument is a math function with TWO parameters
38bd7296 461dnl
f8db4f20
BK
462dnl GLIBCPP_CHECK_MATH_DECL_2
463AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
38bd7296 464 AC_MSG_CHECKING([for $1 declaration])
f84ef7fb
PE
465 if test x${glibcpp_cv_func_$1_use+set} != xset; then
466 AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
467 AC_LANG_SAVE
468 AC_LANG_CPLUSPLUS
469 AC_TRY_COMPILE([#include <math.h>],
470 [ $1(0, 0);],
471 [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
472 AC_LANG_RESTORE
473 ])
474 fi
421173e6 475 AC_MSG_RESULT($glibcpp_cv_func_$1_use)
38bd7296
BK
476])
477
38bd7296 478dnl
11fc1858 479dnl Check to see if the (math function) argument passed is
38bd7296
BK
480dnl 1) declared when using the c++ compiler
481dnl 2) has "C" linkage
482dnl
483dnl Define HAVE_CARGF etc if "cargf" is declared and links
484dnl
485dnl argument 1 is name of function to check
486dnl
f8db4f20 487dnl ASSUMES argument is a math function with TWO parameters
38bd7296 488dnl
f8db4f20
BK
489dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
490AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
491 GLIBCPP_CHECK_MATH_DECL_2($1)
492 if test x$glibcpp_cv_func_$1_use = x"yes"; then
493 AC_CHECK_FUNCS($1)
494 else
495 GLIBCPP_CHECK_MATH_DECL_2(_$1)
496 if test x$glibcpp_cv_func__$1_use = x"yes"; then
497 AC_CHECK_FUNCS(_$1)
a0cb1aa7 498 fi
f8db4f20
BK
499 fi
500])
501
502
503dnl
504dnl Check to see if the (math function) argument passed is
505dnl declared when using the c++ compiler
52b55e7d 506dnl ASSUMES argument is a math function with THREE parameters
f8db4f20
BK
507dnl
508dnl GLIBCPP_CHECK_MATH_DECL_3
509AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
38bd7296 510 AC_MSG_CHECKING([for $1 declaration])
f84ef7fb
PE
511 if test x${glibcpp_cv_func_$1_use+set} != xset; then
512 AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
513 AC_LANG_SAVE
514 AC_LANG_CPLUSPLUS
515 AC_TRY_COMPILE([#include <math.h>],
516 [ $1(0, 0, 0);],
517 [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
518 AC_LANG_RESTORE
519 ])
520 fi
421173e6 521 AC_MSG_RESULT($glibcpp_cv_func_$1_use)
f8db4f20
BK
522])
523
524dnl
525dnl Check to see if the (math function) argument passed is
526dnl 1) declared when using the c++ compiler
527dnl 2) has "C" linkage
528dnl
529dnl Define HAVE_CARGF etc if "cargf" is declared and links
530dnl
531dnl argument 1 is name of function to check
532dnl
533dnl ASSUMES argument is a math function with THREE parameters
534dnl
535dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
536AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
537 GLIBCPP_CHECK_MATH_DECL_3($1)
421173e6 538 if test x$glibcpp_cv_func_$1_use = x"yes"; then
38bd7296 539 AC_CHECK_FUNCS($1)
f8db4f20
BK
540 else
541 GLIBCPP_CHECK_MATH_DECL_3(_$1)
542 if test x$glibcpp_cv_func__$1_use = x"yes"; then
543 AC_CHECK_FUNCS(_$1)
a0cb1aa7 544 fi
38bd7296
BK
545 fi
546])
547
548
e7140677
BK
549dnl
550dnl Check to see if the (stdlib function) argument passed is
551dnl 1) declared when using the c++ compiler
552dnl 2) has "C" linkage
553dnl
e7140677
BK
554dnl argument 1 is name of function to check
555dnl
556dnl ASSUMES argument is a math function with TWO parameters
557dnl
558dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
559AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
560 AC_MSG_CHECKING([for $1 declaration])
f84ef7fb
PE
561 if test x${glibcpp_cv_func_$1_use+set} != xset; then
562 AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
563 AC_LANG_SAVE
564 AC_LANG_CPLUSPLUS
565 AC_TRY_COMPILE([#include <stdlib.h>],
566 [ $1(0, 0);],
567 [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
568 AC_LANG_RESTORE
569 ])
570 fi
e7140677
BK
571 AC_MSG_RESULT($glibcpp_cv_func_$1_use)
572 if test x$glibcpp_cv_func_$1_use = x"yes"; then
573 AC_CHECK_FUNCS($1)
574 fi
575])
576
577
380f343b
RO
578dnl
579dnl Check to see if the (stdlib function) argument passed is
580dnl 1) declared when using the c++ compiler
581dnl 2) has "C" linkage
582dnl
583dnl argument 1 is name of function to check
584dnl
585dnl ASSUMES argument is a function with THREE parameters
586dnl
587dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3
588AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
589 AC_MSG_CHECKING([for $1 declaration])
590 if test x${glibcpp_cv_func_$1_use+set} != xset; then
591 AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
592 AC_LANG_SAVE
593 AC_LANG_CPLUSPLUS
594 AC_TRY_COMPILE([#include <stdlib.h>],
595 [ $1(0, 0, 0);],
596 [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
597 AC_LANG_RESTORE
598 ])
599 fi
600 AC_MSG_RESULT($glibcpp_cv_func_$1_use)
601 if test x$glibcpp_cv_func_$1_use = x"yes"; then
602 AC_CHECK_FUNCS($1)
603 fi
604])
605
74af99e5
PC
606dnl
607dnl Check to see if the (unistd function) argument passed is
608dnl 1) declared when using the c++ compiler
609dnl 2) has "C" linkage
610dnl
611dnl argument 1 is name of function to check
612dnl
613dnl ASSUMES argument is a function with ONE parameter
614dnl
615dnl GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1
616AC_DEFUN(GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1, [
617 AC_MSG_CHECKING([for $1 declaration])
618 if test x${glibcpp_cv_func_$1_use+set} != xset; then
619 AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
620 AC_LANG_SAVE
621 AC_LANG_CPLUSPLUS
622 AC_TRY_COMPILE([#include <unistd.h>],
623 [ $1(0);],
624 [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
625 AC_LANG_RESTORE
626 ])
627 fi
628 AC_MSG_RESULT($glibcpp_cv_func_$1_use)
629 if test x$glibcpp_cv_func_$1_use = x"yes"; then
630 AC_CHECK_FUNCS($1)
631 fi
632])
380f343b 633
11fc1858
BK
634dnl
635dnl Because the builtins are picky picky picky about the arguments they take,
636dnl do an explict linkage tests here.
637dnl Check to see if the (math function) argument passed is
638dnl 1) declared when using the c++ compiler
639dnl 2) has "C" linkage
640dnl
641dnl Define HAVE_CARGF etc if "cargf" is declared and links
642dnl
643dnl argument 1 is name of function to check
644dnl
645dnl ASSUMES argument is a math function with ONE parameter
646dnl
647dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
648AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
11fc1858 649 AC_MSG_CHECKING([for $1 declaration])
f84ef7fb
PE
650 if test x${glibcpp_cv_func_$1_use+set} != xset; then
651 AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
652 AC_LANG_SAVE
653 AC_LANG_CPLUSPLUS
654 AC_TRY_COMPILE([#include <math.h>],
655 [ $1(0);],
656 [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
657 AC_LANG_RESTORE
658 ])
659 fi
421173e6
PE
660 AC_MSG_RESULT($glibcpp_cv_func_$1_use)
661 if test x$glibcpp_cv_func_$1_use = x"yes"; then
11fc1858 662 AC_MSG_CHECKING([for $1 linkage])
f84ef7fb
PE
663 if test x${glibcpp_cv_func_$1_link+set} != xset; then
664 AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
665 AC_TRY_LINK([#include <math.h>],
666 [ $1(0);],
667 [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
668 ])
669 fi
421173e6
PE
670 AC_MSG_RESULT($glibcpp_cv_func_$1_link)
671 if test x$glibcpp_cv_func_$1_link = x"yes"; then
11fc1858
BK
672 ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
673 AC_DEFINE_UNQUOTED(${ac_tr_func})
674 fi
675 fi
676])
677
678
679dnl
680dnl Check to see what builtin math functions are supported
681dnl
682dnl check for __builtin_abs
683dnl check for __builtin_fabsf
684dnl check for __builtin_fabs
685dnl check for __builtin_fabl
686dnl check for __builtin_labs
687dnl check for __builtin_sqrtf
688dnl check for __builtin_sqrtl
dc6f4158 689dnl check for __builtin_sqrt
11fc1858
BK
690dnl check for __builtin_sinf
691dnl check for __builtin_sin
692dnl check for __builtin_sinl
693dnl check for __builtin_cosf
694dnl check for __builtin_cos
695dnl check for __builtin_cosl
696dnl
697dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
698AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
699 dnl Test for builtin math functions.
700 dnl These are made in gcc/c-common.c
701 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
702 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
703 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
704 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
705 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
706
707 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
dc6f4158 708 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
11fc1858
BK
709 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
710
711 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
712 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
713 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
714
715 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
716 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
717 GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
718
719 dnl There is, without a doubt, a more elegant way to have these
720 dnl names exported so that they won't be stripped out of acconfig.h by
721 dnl autoheader. I leave this as an exercise to somebody less frustrated
722 dnl than I.... please email the libstdc++ list if you can figure out a
723 dnl more elegant approach (see autoconf/acgen.m4 and specifically
724 dnl AC_CHECK_FUNC for things to steal.)
725 dummyvar=no
726 if test x$dummyvar = x"yes"; then
727 AC_DEFINE(HAVE___BUILTIN_ABS)
728 AC_DEFINE(HAVE___BUILTIN_LABS)
729 AC_DEFINE(HAVE___BUILTIN_COS)
730 AC_DEFINE(HAVE___BUILTIN_COSF)
731 AC_DEFINE(HAVE___BUILTIN_COSL)
732 AC_DEFINE(HAVE___BUILTIN_FABS)
733 AC_DEFINE(HAVE___BUILTIN_FABSF)
734 AC_DEFINE(HAVE___BUILTIN_FABSL)
735 AC_DEFINE(HAVE___BUILTIN_SIN)
736 AC_DEFINE(HAVE___BUILTIN_SINF)
737 AC_DEFINE(HAVE___BUILTIN_SINL)
dc6f4158 738 AC_DEFINE(HAVE___BUILTIN_SQRT)
11fc1858
BK
739 AC_DEFINE(HAVE___BUILTIN_SQRTF)
740 AC_DEFINE(HAVE___BUILTIN_SQRTL)
741 fi
742])
743
e7140677 744dnl
74af99e5 745dnl Check to see what the underlying c library is like
e7140677
BK
746dnl These checks need to do two things:
747dnl 1) make sure the name is declared when using the c++ compiler
748dnl 2) make sure the name has "C" linkage
749dnl This might seem like overkill but experience has shown that it's not...
750dnl
7cda84dc
BK
751dnl Define HAVE_STRTOLD if "strtold" is declared and links
752dnl Define HAVE_STRTOF if "strtof" is declared and links
753dnl Define HAVE_DRAND48 if "drand48" is declared and links
e7140677
BK
754dnl
755dnl GLIBCPP_CHECK_STDLIB_SUPPORT
756AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
757 ac_test_CXXFLAGS="${CXXFLAGS+set}"
758 ac_save_CXXFLAGS="$CXXFLAGS"
759 CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
760
e7140677 761 GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
99a4deb8 762 GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
7cda84dc 763 AC_CHECK_FUNCS(drand48)
e7140677
BK
764
765 CXXFLAGS="$ac_save_CXXFLAGS"
766])
767
74af99e5
PC
768dnl
769dnl Check to see what the underlying c library is like
770dnl These checks need to do two things:
771dnl 1) make sure the name is declared when using the c++ compiler
772dnl 2) make sure the name has "C" linkage
773dnl This might seem like overkill but experience has shown that it's not...
774dnl
775dnl Define HAVE_ISATTY if "isatty" is declared and links
776dnl
777dnl GLIBCPP_CHECK_UNISTD_SUPPORT
778AC_DEFUN(GLIBCPP_CHECK_UNISTD_SUPPORT, [
779 ac_test_CXXFLAGS="${CXXFLAGS+set}"
780 ac_save_CXXFLAGS="$CXXFLAGS"
781 CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
782
783 GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1(isatty)
784
785 CXXFLAGS="$ac_save_CXXFLAGS"
786])
e7140677 787
2f103494
BK
788dnl
789dnl Check to see what the underlying c library or math library is like.
38bd7296
BK
790dnl These checks need to do two things:
791dnl 1) make sure the name is declared when using the c++ compiler
792dnl 2) make sure the name has "C" linkage
793dnl This might seem like overkill but experience has shown that it's not...
2f103494
BK
794dnl
795dnl Define HAVE_CARGF etc if "cargf" is found.
796dnl
797dnl GLIBCPP_CHECK_MATH_SUPPORT
798AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
38bd7296
BK
799 ac_test_CXXFLAGS="${CXXFLAGS+set}"
800 ac_save_CXXFLAGS="$CXXFLAGS"
4f76382d 801 CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
aac350aa
BK
802
803 dnl Check libm
2f103494 804 AC_CHECK_LIB(m, sin, libm="-lm")
38bd7296 805 ac_save_LIBS="$LIBS"
2f103494
BK
806 LIBS="$LIBS $libm"
807
38bd7296
BK
808 dnl Check to see if certain C math functions exist.
809 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
810 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
811 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
812 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
813 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
814 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
815 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
d38cd8ae 816 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
38bd7296
BK
817
818 dnl Check to see if basic C math functions have float versions.
20b11783 819 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
9b8fd32c
PE
820 float_trig,
821 acosf asinf atanf \
20b11783 822 cosf sinf tanf \
9b8fd32c 823 coshf sinhf tanhf)
20b11783 824 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
9b8fd32c 825 float_round,
20b11783 826 ceilf floorf)
34ff0b99 827 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
38bd7296
BK
828 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
829 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
d38cd8ae 830 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
38bd7296 831 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
38bd7296
BK
832 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
833 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
d38cd8ae 834 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
38bd7296
BK
835 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
836 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
837 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
838 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
839 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
38bd7296 840 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
38bd7296
BK
841 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
842 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
843
844 dnl Check to see if basic C math functions have long double versions.
20b11783 845 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
9b8fd32c
PE
846 long_double_trig,
847 acosl asinl atanl \
20b11783 848 cosl sinl tanl \
9b8fd32c 849 coshl sinhl tanhl)
20b11783 850 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
9b8fd32c 851 long_double_round,
20b11783 852 ceill floorl)
38bd7296
BK
853 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
854 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
11fc1858 855 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
38bd7296 856 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
38bd7296
BK
857 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
858 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
38bd7296
BK
859 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
860 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
d38cd8ae 861 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
38bd7296
BK
862 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
863 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
864 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
865 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
866 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
38bd7296 867 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
38bd7296
BK
868 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
869 GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
870
871 dnl Some runtimes have these functions with a preceding underscore. Please
872 dnl keep this sync'd with the one above. And if you add any new symbol,
873 dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
874 dnl Check to see if certain C math functions exist.
38bd7296
BK
875
876 dnl Check to see if basic C math functions have float versions.
20b11783 877 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
9b8fd32c
PE
878 _float_trig,
879 _acosf _asinf _atanf \
20b11783 880 _cosf _sinf _tanf \
9b8fd32c 881 _coshf _sinhf _tanhf)
20b11783 882 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
9b8fd32c 883 _float_round,
20b11783 884 _ceilf _floorf)
38bd7296
BK
885
886 dnl Check to see if basic C math functions have long double versions.
20b11783 887 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
9b8fd32c
PE
888 _long_double_trig,
889 _acosl _asinl _atanl \
20b11783 890 _cosl _sinl _tanl \
9b8fd32c 891 _coshl _sinhl _tanhl)
20b11783 892 GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
9b8fd32c 893 _long_double_round,
20b11783 894 _ceill _floorl)
38bd7296
BK
895
896 LIBS="$ac_save_LIBS"
897 CXXFLAGS="$ac_save_CXXFLAGS"
2f103494
BK
898])
899
900
901dnl
902dnl Check to see if there is native support for complex
903dnl
904dnl Don't compile bits in math/* if native support exits.
905dnl
d38cd8ae 906dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
2f103494
BK
907dnl
908dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
909AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
910 dnl Check for complex versions of math functions of platform.
b4b2a487 911 AC_CHECK_LIB(m, main)
d38cd8ae 912 AC_REPLACE_MATHFUNCS(nan copysignf)
11fc1858 913
34ff0b99
BK
914 dnl For __signbit to signbit conversions.
915 AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
916 AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
917
11fc1858
BK
918 dnl Compile the long double complex functions only if the function
919 dnl provides the non-complex long double functions that are needed.
d38cd8ae 920 dnl Currently this includes copysignl, which should be
11fc1858 921 dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
d38cd8ae 922 if test x$ac_cv_func_copysignl = x"yes"; then
34ff0b99 923 AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
11fc1858
BK
924 fi
925
34ff0b99 926 AC_SUBST(LIBMATHOBJS)
2f103494
BK
927])
928
54fa7415 929
d0941a31
PE
930dnl Check to see what architecture and operating system we are compiling
931dnl for. Also, if architecture- or OS-specific flags are required for
932dnl compilation, pick them up here.
e974e9cc 933dnl
d0941a31
PE
934dnl GLIBCPP_CHECK_TARGET
935AC_DEFUN(GLIBCPP_CHECK_TARGET, [
974e336b
PE
936 . [$]{glibcpp_basedir}/configure.target
937 AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
938 AC_MSG_RESULT(OS config directory is $os_include_dir)
e974e9cc
BK
939])
940
941
b2dad0e3
BK
942dnl
943dnl Check to see if this target can enable the wchar_t parts of libstdc++.
8b8ab21c
BK
944dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled. (This
945dnl must have been previously checked.)
b2dad0e3
BK
946dnl
947dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found
7b331228 948dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
b2dad0e3
BK
949dnl
950dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
951AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
7b331228
BK
952
953 dnl Test wchar.h for mbstate_t, which is needed for char_traits and
954 dnl others even if wchar_t support is not on.
955 AC_MSG_CHECKING([for mbstate_t])
956 AC_TRY_COMPILE([#include <wchar.h>],
957 [mbstate_t teststate;],
958 have_mbstate_t=yes, have_mbstate_t=no)
959 AC_MSG_RESULT($have_mbstate_t)
960 if test x"$have_mbstate_t" = xyes; then
961 AC_DEFINE(HAVE_MBSTATE_T)
962 fi
963
964 dnl Sanity check for existence of ISO C99 headers for extended encoding.
965 AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
31f93f90 966 AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
b2dad0e3 967
7b331228 968 dnl Only continue checking if the ISO C99 headers exist and support is on.
a0cb1aa7
PE
969 if test x"$ac_has_wchar_h" = xyes &&
970 test x"$ac_has_wctype_h" = xyes &&
971 test x"$enable_c_mbchar" != xno; then
7b331228
BK
972
973 dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
974 dnl numeric_limits can instantiate type_traits<wchar_t>
975 AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
976 AC_TRY_COMPILE([#include <wchar.h>],
977 [int i = WCHAR_MIN; int j = WCHAR_MAX;],
978 has_wchar_minmax=yes, has_wchar_minmax=no)
979 AC_MSG_RESULT($has_wchar_minmax)
8b8ab21c 980
7b331228
BK
981 dnl Test wchar.h for WEOF, which is what we use to determine whether
982 dnl to specialize for char_traits<wchar_t> or not.
983 AC_MSG_CHECKING([for WEOF])
984 AC_TRY_COMPILE([
985 #include <wchar.h>
986 #include <stddef.h>],
987 [wint_t i = WEOF;],
988 has_weof=yes, has_weof=no)
989 AC_MSG_RESULT($has_weof)
8b8ab21c 990
7b331228 991 dnl Tests for wide character functions used in char_traits<wchar_t>.
68fe6226
BK
992 ac_wfuncs=yes
993 AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
994 ac_wfuncs=no)
8b8ab21c 995
68fe6226
BK
996 dnl Checks for names injected into std:: by the c_std headers.
997 AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
998 fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
999 vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
1000 mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
1001 wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
1002 wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
1003 ac_wfuncs=no)
df7b1359 1004
7b331228 1005 AC_MSG_CHECKING([for ISO C99 wchar_t support])
a0cb1aa7
PE
1006 if test x"$has_weof" = xyes &&
1007 test x"$has_wchar_minmax" = xyes &&
1008 test x"$ac_wfuncs" = xyes; then
7b331228
BK
1009 ac_isoC99_wchar_t=yes
1010 else
1011 ac_isoC99_wchar_t=no
1012 fi
1013 AC_MSG_RESULT($ac_isoC99_wchar_t)
8b8ab21c 1014
7b331228
BK
1015 dnl Use iconv for wchar_t to char conversions. As such, check for
1016 dnl X/Open Portability Guide, version 2 features (XPG2).
1017 AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
1018 AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
1019
1020 dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
1021 AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
1022 ac_save_LIBS="$LIBS"
1023 LIBS="$LIBS $libiconv"
1024
1025 AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
1026 ac_XPG2funcs=yes, ac_XPG2funcs=no)
8b8ab21c 1027
7b331228 1028 LIBS="$ac_save_LIBS"
5b20f7a0 1029
7b331228 1030 AC_MSG_CHECKING([for XPG2 wchar_t support])
a0cb1aa7
PE
1031 if test x"$ac_has_iconv_h" = xyes &&
1032 test x"$ac_has_langinfo_h" = xyes &&
1033 test x"$ac_XPG2funcs" = xyes; then
7b331228
BK
1034 ac_XPG2_wchar_t=yes
1035 else
1036 ac_XPG2_wchar_t=no
1037 fi
1038 AC_MSG_RESULT($ac_XPG2_wchar_t)
b2dad0e3 1039
7b331228
BK
1040 dnl At the moment, only enable wchar_t specializations if all the
1041 dnl above support is present.
1042 AC_MSG_CHECKING([for enabled wchar_t specializations])
a0cb1aa7
PE
1043 if test x"$ac_isoC99_wchar_t" = xyes &&
1044 test x"$ac_XPG2_wchar_t" = xyes; then
7b331228
BK
1045 AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
1046 AC_MSG_RESULT("yes")
3840fa2a 1047 else
7b331228 1048 AC_MSG_RESULT("no")
3840fa2a 1049 fi
b2dad0e3 1050 else
7b331228
BK
1051 dnl Wide characters disabled by the user.
1052 AC_MSG_WARN([wchar_t support disabled.])
b2dad0e3 1053 fi
b2dad0e3
BK
1054])
1055
1056
b2dad0e3 1057dnl
8bd636c5 1058dnl Check for special debugging mode; not for production use.
b2dad0e3
BK
1059dnl
1060dnl GLIBCPP_ENABLE_DEBUG
34791641 1061dnl --enable-debug sets '-ggdb3 -O0'.
b2dad0e3
BK
1062dnl --disable-debug sets '-g' and whatever optimization options the
1063dnl compiler can handle.
7f586614 1064dnl + --enable-maintainer-mode automatically defaults this to on.
b2dad0e3
BK
1065dnl + Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
1066dnl + Usage: GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
1067dnl Where DEFAULT is either `yes' or `no'. If ommitted, it
1068dnl defaults to `no'.
1069AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
1070define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
1071AC_ARG_ENABLE(debug,
1072changequote(<<, >>)dnl
1073<< --enable-debug extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
1074changequote([, ])dnl
5780a46b 1075[case "${enableval}" in
b2dad0e3
BK
1076 yes) enable_debug=yes ;;
1077 no) enable_debug=no ;;
1078 *) AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1079 esac],
1080enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
5780a46b 1081
b2dad0e3 1082dnl Option parsed, now set things appropriately
5780a46b 1083case "${enable_debug}" in
cde28f0d 1084 yes)
34791641 1085 DEBUG_FLAGS='-O0 -ggdb3'
6abd2230 1086 ;;
f3b004d8 1087 no)
8b8ab21c 1088 DEBUG_FLAGS='-g'
f3b004d8 1089 ;;
b2dad0e3 1090esac
c470c17d 1091AC_SUBST(DEBUG_FLAGS)
b2dad0e3
BK
1092])
1093
1094
dcfa0bc8
PE
1095dnl
1096dnl Check for "unusual" flags to pass to the compiler while building.
1097dnl
1098dnl GLIBCPP_ENABLE_CXX_FLAGS
1099dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1100dnl experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1101dnl Somehow this same set of flags must be passed when [re]building
1102dnl libgcc.
1103dnl --disable-cxx-flags passes nothing.
a9ab8db1
JM
1104dnl + See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1105dnl http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1106dnl http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
dcfa0bc8 1107dnl + Usage: GLIBCPP_ENABLE_CXX_FLAGS(default flags)
32a4595e
PE
1108dnl If "default flags" is an empty string (or "none"), the effect is
1109dnl the same as --disable or --enable=no.
dcfa0bc8
PE
1110AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1111define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1112AC_ARG_ENABLE(cxx-flags,
1113changequote(<<, >>)dnl
1114<< --enable-cxx-flags=FLAGS pass compiler FLAGS when building library;
1115 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1116changequote([, ])dnl
1117[case "x$enableval" in
5780a46b 1118 xyes)
8b8ab21c 1119 AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
5780a46b 1120 xno|x)
8b8ab21c 1121 enable_cxx_flags='' ;;
5780a46b 1122 *)
8b8ab21c 1123 enable_cxx_flags="$enableval" ;;
dcfa0bc8 1124 esac],
5780a46b
BK
1125enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1126
32a4595e 1127dnl Thinko on my part during design. This kludge is the workaround.
5780a46b
BK
1128if test "$enable_cxx_flags" = "none"; then
1129 enable_cxx_flags='';
1130fi
1131
32a4595e
PE
1132dnl Run through flags (either default or command-line) and set anything
1133dnl extra (e.g., #defines) that must accompany particular g++ options.
dcfa0bc8 1134if test -n "$enable_cxx_flags"; then
974e336b
PE
1135 for f in $enable_cxx_flags; do
1136 case "$f" in
1137 -fhonor-std) ;;
1138 -*) ;;
1139 *) # and we're trying to pass /what/ exactly?
1140 AC_MSG_ERROR([compiler flags start with a -]) ;;
1141 esac
1142 done
dcfa0bc8
PE
1143fi
1144EXTRA_CXX_FLAGS="$enable_cxx_flags"
1145AC_SUBST(EXTRA_CXX_FLAGS)
1146])
1147
1148
0214010c
BK
1149dnl
1150dnl Check for which locale library to use: gnu or generic.
1151dnl
1152dnl GLIBCPP_ENABLE_CLOCALE
33590f13
BK
1153dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1154dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
0214010c
BK
1155dnl
1156dnl default is generic
1157dnl
1158AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1159 AC_MSG_CHECKING([for clocale to use])
1160 AC_ARG_ENABLE(clocale,
572051a2
PE
1161 [ --enable-clocale enable model for target locale package.
1162 --enable-clocale=MODEL use MODEL target-speific locale package. [default=generic]
0214010c
BK
1163 ],
1164 if test x$enable_clocale = xno; then
56deb74c 1165 enable_clocale=no
0214010c 1166 fi,
56deb74c 1167 enable_clocale=no)
0214010c
BK
1168
1169 enable_clocale_flag=$enable_clocale
1170
56deb74c
BK
1171 dnl Probe for locale support if no specific model is specified.
1172 dnl Default to "generic"
1173 if test x$enable_clocale_flag = xno; then
1174 case x${target_os} in
1175 xlinux* | xgnu*)
1451a492 1176 AC_EGREP_CPP([_GLIBCPP_ok], [
56deb74c
BK
1177 #include <features.h>
1178 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
1451a492 1179 _GLIBCPP_ok
56deb74c
BK
1180 #endif
1181 ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1451a492
BK
1182
1183 # Test for bugs early in glibc-2.2.x series
1184 if test x$enable_clocale_flag = xgnu; then
1185 AC_TRY_RUN([
1186 #define _GNU_SOURCE 1
1187 #include <locale.h>
89671b70
JJ
1188 #include <string.h>
1189 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
1190 extern __typeof(newlocale) __newlocale;
1191 extern __typeof(duplocale) __duplocale;
1192 extern __typeof(strcoll_l) __strcoll_l;
1193 #endif
1451a492
BK
1194 int main()
1195 {
1196