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