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