]>
Commit | Line | Data |
---|---|---|
1 | # Process this file with autoconf to produce a configure script, like so: | |
2 | # aclocal && autoconf && autoheader && automake | |
3 | ||
4 | AC_INIT([GCC Quad-precision Math Library], 0.1,,[libquadmath]) | |
5 | AC_CONFIG_HEADER(config.h) | |
6 | ||
7 | # Gets build, host, target, *_vendor, *_cpu, *_os, etc. | |
8 | # | |
9 | # You will slowly go insane if you do not grok the following fact: when | |
10 | # building this library, the top-level /target/ becomes the library's /host/. | |
11 | # | |
12 | # configure then causes --target to default to --host, exactly like any | |
13 | # other package using autoconf. Therefore, 'target' and 'host' will | |
14 | # always be the same. This makes sense both for native and cross compilers | |
15 | # just think about it for a little while. :-) | |
16 | # | |
17 | # Also, if this library is being configured as part of a cross compiler, the | |
18 | # top-level configure script will pass the "real" host as $with_cross_host. | |
19 | # | |
20 | # Do not delete or change the following two lines. For why, see | |
21 | # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html | |
22 | AC_CANONICAL_SYSTEM | |
23 | ACX_NONCANONICAL_TARGET | |
24 | ||
25 | AM_ENABLE_MULTILIB(, ..) | |
26 | ||
27 | target_alias=${target_alias-$host_alias} | |
28 | AC_SUBST(target_alias) | |
29 | ||
30 | AM_INIT_AUTOMAKE([1.9.0 foreign subdir-objects no-dist -Wall -Wno-override -Werror]) | |
31 | ||
32 | AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) | |
33 | AC_ARG_ENABLE(version-specific-runtime-libs, | |
34 | AS_HELP_STRING([--enable-version-specific-runtime-libs], | |
35 | [specify that runtime libraries should be installed in a compiler-specific directory]), | |
36 | [case "$enableval" in | |
37 | yes) version_specific_libs=yes ;; | |
38 | no) version_specific_libs=no ;; | |
39 | *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; | |
40 | esac], | |
41 | [version_specific_libs=no]) | |
42 | AC_MSG_RESULT($version_specific_libs) | |
43 | ||
44 | GCC_NO_EXECUTABLES | |
45 | ||
46 | AC_USE_SYSTEM_EXTENSIONS | |
47 | ||
48 | # See if makeinfo has been installed and is modern enough | |
49 | # that we can use it. | |
50 | ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version], | |
51 | [GNU texinfo.* \([0-9][0-9.]*\)], | |
52 | [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*]) | |
53 | AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes") | |
54 | ||
55 | ACX_BUGURL([https://gcc.gnu.org/bugs/]) | |
56 | ||
57 | # Configure libtool | |
58 | AM_PROG_LIBTOOL | |
59 | ACX_LT_HOST_FLAGS | |
60 | AC_SUBST(enable_shared) | |
61 | AC_SUBST(enable_static) | |
62 | AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes]) | |
63 | ||
64 | AM_MAINTAINER_MODE | |
65 | ||
66 | AC_LANG_C | |
67 | # The same as in boehm-gc and libstdc++. Have to borrow it from there. | |
68 | # We must force CC to /not/ be precious variables; otherwise | |
69 | # the wrong, non-multilib-adjusted value will be used in multilibs. | |
70 | # As a side effect, we have to subst CFLAGS ourselves. | |
71 | ||
72 | m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) | |
73 | m4_define([_AC_ARG_VAR_PRECIOUS],[]) | |
74 | AC_PROG_CC | |
75 | m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) | |
76 | ||
77 | AC_SUBST(CFLAGS) | |
78 | ||
79 | AM_PROG_CC_C_O | |
80 | ||
81 | if test "x$GCC" != "xyes"; then | |
82 | AC_MSG_ERROR([libquadmath must be built with GCC]) | |
83 | fi | |
84 | AC_PROG_CPP | |
85 | ||
86 | GCC_WITH_TOOLEXECLIBDIR | |
87 | ||
88 | # Calculate toolexeclibdir | |
89 | # Also toolexecdir, though it's only used in toolexeclibdir | |
90 | case ${version_specific_libs} in | |
91 | yes) | |
92 | # Need the gcc compiler version to know where to install libraries | |
93 | # and header files if --enable-version-specific-runtime-libs option | |
94 | # is selected. | |
95 | toolexecdir='$(libdir)/gcc/$(target_alias)' | |
96 | toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' | |
97 | ;; | |
98 | no) | |
99 | if test -n "$with_cross_host" && | |
100 | test x"$with_cross_host" != x"no"; then | |
101 | # Install a library built with a cross compiler in tooldir, not libdir. | |
102 | toolexecdir='$(exec_prefix)/$(target_alias)' | |
103 | case ${with_toolexeclibdir} in | |
104 | no) | |
105 | toolexeclibdir='$(toolexecdir)/lib' | |
106 | ;; | |
107 | *) | |
108 | toolexeclibdir=${with_toolexeclibdir} | |
109 | ;; | |
110 | esac | |
111 | else | |
112 | toolexecdir='$(libdir)/gcc-lib/$(target_alias)' | |
113 | toolexeclibdir='$(libdir)' | |
114 | fi | |
115 | multi_os_directory=`$CC -print-multi-os-directory` | |
116 | case $multi_os_directory in | |
117 | .) ;; # Avoid trailing /. | |
118 | *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; | |
119 | esac | |
120 | ;; | |
121 | esac | |
122 | AC_SUBST(toolexecdir) | |
123 | AC_SUBST(toolexeclibdir) | |
124 | ||
125 | # AC_CHECK_LIBM variant which avoids AC_CHECK_LIB (that doesn't work | |
126 | # on bare metal). In the past we've used -lm in Makefile.am unconditionally, | |
127 | # let's use it there unless target knows it doesn't need that. | |
128 | LIBM= | |
129 | case $host in | |
130 | *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) | |
131 | # These system don't have libm, or don't need it | |
132 | ;; | |
133 | *) | |
134 | LIBM=-lm | |
135 | ;; | |
136 | esac | |
137 | AC_SUBST([LIBM]) | |
138 | ||
139 | AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h) | |
140 | LIBQUAD_CHECK_MATH_H_SIGNGAM | |
141 | ||
142 | # If available, sqrtl and cbrtl speed up the calculation - | |
143 | # but they are not required | |
144 | if test x$gcc_no_link != xyes; then | |
145 | AC_CHECK_LIB([m],[sqrtl],[AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])]) | |
146 | AC_CHECK_LIB([m],[cbrtl],[AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])]) | |
147 | AC_CHECK_LIB([m],[feholdexcept],[AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept])]) | |
148 | AC_CHECK_LIB([m],[fesetround],[AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround])]) | |
149 | AC_CHECK_LIB([m],[feupdateenv],[AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv])]) | |
150 | AC_CHECK_LIB([m],[fesetenv],[AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv])]) | |
151 | AC_CHECK_LIB([m],[fetestexcept],[AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept])]) | |
152 | AC_CHECK_FUNCS(strtoull) | |
153 | else | |
154 | if test "x$ac_cv_lib_m_sqrtl" = x""yes; then | |
155 | AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl]) | |
156 | fi | |
157 | if test "x$ac_cv_lib_m_cbrtl" = x""yes; then | |
158 | AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl]) | |
159 | fi | |
160 | if test "x$ac_cv_lib_m_feholdexcept" = x""yes; then | |
161 | AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept]) | |
162 | fi | |
163 | if test "x$ac_cv_lib_m_fesetround" = x""yes; then | |
164 | AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround]) | |
165 | fi | |
166 | if test "x$ac_cv_lib_m_feupdateenv" = x""yes; then | |
167 | AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv]) | |
168 | fi | |
169 | if test "x$ac_cv_lib_m_fesetenv" = x""yes; then | |
170 | AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv]) | |
171 | fi | |
172 | if test "x$ac_cv_lib_m_fetestexcept" = x""yes; then | |
173 | AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept]) | |
174 | fi | |
175 | fi | |
176 | ||
177 | # Check for hidden visibility (copied from libssp). | |
178 | saved_CFLAGS="$CFLAGS" | |
179 | CFLAGS="$CFLAGS -Werror" | |
180 | AC_MSG_CHECKING([whether hidden visibility is supported]) | |
181 | AC_TRY_COMPILE([ | |
182 | void __attribute__((visibility ("hidden"))) bar (void) {}],, | |
183 | [quadmath_hidden=yes],[quadmath_hidden=no]) | |
184 | AC_MSG_RESULT($quadmath_hidden) | |
185 | if test x$quadmath_hidden = xyes; then | |
186 | AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported]) | |
187 | fi | |
188 | CFLAGS="$saved_CFLAGS" | |
189 | ||
190 | # Check for symbol versioning (copied from libssp). | |
191 | AC_MSG_CHECKING([whether symbol versioning is supported]) | |
192 | AC_ARG_ENABLE(symvers, | |
193 | AS_HELP_STRING([--disable-symvers], | |
194 | [disable symbol versioning for libquadmath]), | |
195 | quadmath_use_symver=$enableval, | |
196 | quadmath_use_symver=yes) | |
197 | if test "x$quadmath_use_symver" != xno; then | |
198 | if test x$gcc_no_link = xyes; then | |
199 | # If we cannot link, we cannot build shared libraries, so do not use | |
200 | # symbol versioning. | |
201 | quadmath_use_symver=no | |
202 | else | |
203 | save_LDFLAGS="$LDFLAGS" | |
204 | LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map" | |
205 | cat > conftest.map <<EOF | |
206 | FOO_1.0 { | |
207 | global: *foo*; bar; local: *; | |
208 | }; | |
209 | EOF | |
210 | AC_TRY_LINK([int foo;],[],[quadmath_use_symver=gnu],[quadmath_use_symver=no]) | |
211 | if test x$quadmath_use_symver = xno; then | |
212 | case "$target_os" in | |
213 | solaris2*) | |
214 | LDFLAGS="$save_LDFLAGS" | |
215 | LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map" | |
216 | # Sun ld cannot handle wildcards and treats all entries as undefined. | |
217 | cat > conftest.map <<EOF | |
218 | FOO_1.0 { | |
219 | global: foo; local: *; | |
220 | }; | |
221 | EOF | |
222 | AC_TRY_LINK([int foo;],[],[quadmath_use_symver=sun],[quadmath_use_symver=no]) | |
223 | ;; | |
224 | esac | |
225 | fi | |
226 | LDFLAGS="$save_LDFLAGS" | |
227 | fi | |
228 | fi | |
229 | AC_MSG_RESULT($quadmath_use_symver) | |
230 | AM_CONDITIONAL(LIBQUAD_USE_SYMVER, [test "x$quadmath_use_symver" != xno]) | |
231 | AM_CONDITIONAL(LIBQUAD_USE_SYMVER_GNU, [test "x$quadmath_use_symver" = xgnu]) | |
232 | AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun]) | |
233 | ||
234 | AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128], | |
235 | [GCC_TRY_COMPILE_OR_LINK([ | |
236 | #ifdef __loongarch__ | |
237 | #error On LoongArch we should use long double instead; __float128 is only for porting existing code easier. | |
238 | #endif | |
239 | ||
240 | #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) | |
241 | typedef _Complex float __attribute__((mode(TC))) __complex128; | |
242 | #else | |
243 | typedef _Complex float __attribute__((mode(KC))) __complex128; | |
244 | #endif | |
245 | ||
246 | __float128 foo (__float128 x) | |
247 | { | |
248 | ||
249 | __complex128 z1, z2; | |
250 | ||
251 | z1 = x; | |
252 | z2 = x / 7.Q; | |
253 | z2 /= z1; | |
254 | ||
255 | return (__float128) z2; | |
256 | } | |
257 | ||
258 | __float128 bar (__float128 x) | |
259 | { | |
260 | return x * __builtin_huge_valq (); | |
261 | } | |
262 | ],[ | |
263 | foo (1.2Q); | |
264 | bar (1.2Q); | |
265 | ],[ | |
266 | libquad_cv_have_float128=yes | |
267 | ],[ | |
268 | libquad_cv_have_float128=no | |
269 | ])]) | |
270 | AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_cv_have_float128" = xyes]) | |
271 | ||
272 | # Check for printf hook support. | |
273 | AC_MSG_CHECKING([whether printf hooks are supported]) | |
274 | AC_TRY_COMPILE([ | |
275 | #include <printf.h> | |
276 | #include <stdarg.h> | |
277 | #include <stdlib.h> | |
278 | extern void flt128_va (void *, va_list *); | |
279 | extern int flt128_ais (const struct printf_info *, size_t, int *, int *); | |
280 | extern int flt128_printf_fp (FILE *, const struct printf_info *, const void *const *); | |
281 | ],[ | |
282 | int pa_flt128 = register_printf_type (flt128_va); | |
283 | int mod_Q = register_printf_modifier (L"Q"); | |
284 | int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais); | |
285 | struct printf_info info = { .user = -1 }; | |
286 | ], | |
287 | [quadmath_printf_hooks=yes],[quadmath_printf_hooks=no]) | |
288 | AC_MSG_RESULT($quadmath_printf_hooks) | |
289 | if test x$quadmath_printf_hooks = xyes; then | |
290 | AC_DEFINE([HAVE_PRINTF_HOOKS],[1],[GNU C Library stype printf hooks supported]) | |
291 | fi | |
292 | ||
293 | # Check for whether locale support for quadmath_snprintf or Q printf hooks | |
294 | # should be provided. | |
295 | AC_MSG_CHECKING([whether nl_langinfo should be used]) | |
296 | AC_TRY_COMPILE([#include <langinfo.h>],[ | |
297 | const char *s; | |
298 | s = nl_langinfo (DECIMAL_POINT); | |
299 | s = nl_langinfo (MON_DECIMAL_POINT); | |
300 | s = nl_langinfo (GROUPING); | |
301 | s = nl_langinfo (MON_GROUPING); | |
302 | s = nl_langinfo (THOUSANDS_SEP); | |
303 | s = nl_langinfo (MON_THOUSANDS_SEP); | |
304 | (void) s; | |
305 | ], | |
306 | [quadmath_use_nl_langinfo=yes],[quadmath_use_nl_langinfo=no]) | |
307 | AC_MSG_RESULT($quadmath_use_nl_langinfo) | |
308 | if test x$quadmath_use_nl_langinfo = xyes; then | |
309 | AC_DEFINE([USE_NL_LANGINFO],[1],[whether nl_langinfo should be used]) | |
310 | fi | |
311 | ||
312 | AC_MSG_CHECKING([whether nl_langinfo should be used for wide char locale info]) | |
313 | AC_TRY_COMPILE([#include <langinfo.h>],[ | |
314 | const char *s; | |
315 | s = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC); | |
316 | s = nl_langinfo (_NL_MONETARY_DECIMAL_POINT_WC); | |
317 | s = nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC); | |
318 | s = nl_langinfo (_NL_MONETARY_THOUSANDS_SEP_WC); | |
319 | (void) s; | |
320 | ], | |
321 | [quadmath_use_nl_langinfo_wc=yes],[quadmath_use_nl_langinfo_wc=no]) | |
322 | AC_MSG_RESULT($quadmath_use_nl_langinfo_wc) | |
323 | if test x$quadmath_use_nl_langinfo_wc = xyes; then | |
324 | AC_DEFINE([USE_NL_LANGINFO_WC],[1],[whether nl_langinfo should be used for wide char locale info]) | |
325 | fi | |
326 | ||
327 | AC_MSG_CHECKING([whether localeconv should be used]) | |
328 | AC_TRY_COMPILE([#include <locale.h>],[ | |
329 | const struct lconv *l = localeconv (); | |
330 | const char *s; | |
331 | s = l->decimal_point; | |
332 | s = l->mon_decimal_point; | |
333 | s = l->grouping; | |
334 | s = l->mon_grouping; | |
335 | s = l->thousands_sep; | |
336 | s = l->mon_thousands_sep; | |
337 | (void) s; | |
338 | ], | |
339 | [quadmath_use_localeconv=yes],[quadmath_use_localeconv=no]) | |
340 | AC_MSG_RESULT($quadmath_use_localeconv) | |
341 | if test x$quadmath_use_localeconv = xyes; then | |
342 | AC_DEFINE([USE_LOCALECONV],[1],[whether localeconv should be used]) | |
343 | fi | |
344 | ||
345 | # Check for whether i18n number rewriting support for quadmath_snprintf | |
346 | # or Q printf hooks should be provided. | |
347 | AC_MSG_CHECKING([whether i18n number rewriting support for quadmath_snprintf should be added]) | |
348 | AC_TRY_COMPILE([#include <langinfo.h> | |
349 | #include <limits.h> | |
350 | #include <string.h> | |
351 | #include <wchar.h> | |
352 | #include <wctype.h>],[ | |
353 | const char *s; | |
354 | char decimal[MB_LEN_MAX]; | |
355 | wctrans_t map = wctrans ("to_outpunct"); | |
356 | wint_t wdecimal = towctrans (L'.', map); | |
357 | mbstate_t state; | |
358 | memset (&state, '\0', sizeof (state)); | |
359 | wcrtomb (decimal, wdecimal, &state); | |
360 | s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB); | |
361 | s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_WC); | |
362 | s = nl_langinfo (_NL_CTYPE_MB_CUR_MAX); | |
363 | (void) s; | |
364 | ], | |
365 | [quadmath_use_i18n_number_h=yes],[quadmath_use_i18n_number_h=no]) | |
366 | AC_MSG_RESULT($quadmath_use_i18n_number_h) | |
367 | if test x$quadmath_use_i18n_number_h = xyes; then | |
368 | AC_DEFINE([USE_I18N_NUMBER_H],[1],[whether i18n number rewriting can be supported]) | |
369 | fi | |
370 | ||
371 | # Add CET specific flags if CET is enabled | |
372 | GCC_CET_FLAGS(CET_FLAGS) | |
373 | XCFLAGS="$XCFLAGS $CET_FLAGS" | |
374 | ||
375 | case x$target in | |
376 | xpowerpc64le*-linux*) | |
377 | AC_PREPROC_IFELSE( | |
378 | [AC_LANG_PROGRAM([[#if __SIZEOF_LONG_DOUBLE__ != 16 | |
379 | #error long double is double | |
380 | #endif]], | |
381 | [[(void) 0;]])], | |
382 | [XCFLAGS="$XCFLAGS -mno-gnu-attribute"]) | |
383 | ;; | |
384 | *) | |
385 | ;; | |
386 | esac | |
387 | AC_SUBST(XCFLAGS) | |
388 | ||
389 | AC_CACHE_SAVE | |
390 | ||
391 | if test ${multilib} = yes; then | |
392 | multilib_arg="--enable-multilib" | |
393 | else | |
394 | multilib_arg= | |
395 | fi | |
396 | ||
397 | ||
398 | # We would like our source tree to be readonly. However when releases or | |
399 | # pre-releases are generated, the flex/bison generated files as well as the | |
400 | # various formats of manuals need to be included along with the rest of the | |
401 | # sources. Therefore we have --enable-generated-files-in-srcdir to do | |
402 | # just that. | |
403 | AC_MSG_CHECKING(generated-files-in-srcdir) | |
404 | AC_ARG_ENABLE(generated-files-in-srcdir, | |
405 | AS_HELP_STRING([--enable-generated-files-in-srcdir], | |
406 | [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]), | |
407 | [case "$enableval" in | |
408 | yes) enable_generated_files_in_srcdir=yes ;; | |
409 | no) enable_generated_files_in_srcdir=no ;; | |
410 | *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; | |
411 | esac], | |
412 | [enable_generated_files_in_srcdir=no]) | |
413 | AC_MSG_RESULT($enable_generated_files_in_srcdir) | |
414 | AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes) | |
415 | ||
416 | # Determine what GCC version number to use in filesystem paths. | |
417 | GCC_BASE_VER | |
418 | ||
419 | AC_CONFIG_FILES(Makefile) | |
420 | AC_OUTPUT |