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