PR rtl-optimization/88018
[official-gcc.git] / libquadmath / configure.ac
blobb75465bee8d187ea91807281205f275deea5fbd5
1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal && autoconf && autoheader && automake
4 AC_INIT([GCC Quad-precision Math Library], 0.1,,[libquadmath])
5 AC_CONFIG_HEADER(config.h)
7 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
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/.
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.  :-)
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.
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
25 AM_ENABLE_MULTILIB(, ..)
27 target_alias=${target_alias-$host_alias}
28 AC_SUBST(target_alias)
30 AM_INIT_AUTOMAKE([1.9.0 foreign subdir-objects no-dist -Wall -Wno-override -Werror])
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)
44 GCC_NO_EXECUTABLES
46 AC_USE_SYSTEM_EXTENSIONS
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")
55 ACX_BUGURL([https://gcc.gnu.org/bugs/])
57 # Configure libtool
58 AM_PROG_LIBTOOL
59 ACX_LT_HOST_FLAGS
60 AC_SUBST(enable_shared)
61 AC_SUBST(enable_static)
63 AM_MAINTAINER_MODE
65 AC_LANG_C
66 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
67 # We must force CC to /not/ be precious variables; otherwise
68 # the wrong, non-multilib-adjusted value will be used in multilibs.
69 # As a side effect, we have to subst CFLAGS ourselves.
71 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
72 m4_define([_AC_ARG_VAR_PRECIOUS],[])
73 AC_PROG_CC
74 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
76 AC_SUBST(CFLAGS)
78 AM_PROG_CC_C_O
80 if test "x$GCC" != "xyes"; then
81   AC_MSG_ERROR([libquadmath must be built with GCC])
83 AC_PROG_CPP
85 # Calculate toolexeclibdir
86 # Also toolexecdir, though it's only used in toolexeclibdir
87 case ${version_specific_libs} in
88   yes)
89     # Need the gcc compiler version to know where to install libraries
90     # and header files if --enable-version-specific-runtime-libs option
91     # is selected.
92     toolexecdir='$(libdir)/gcc/$(target_alias)'
93     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
94     ;;
95   no)
96     if test -n "$with_cross_host" &&
97        test x"$with_cross_host" != x"no"; then
98       # Install a library built with a cross compiler in tooldir, not libdir.
99       toolexecdir='$(exec_prefix)/$(target_alias)'
100       toolexeclibdir='$(toolexecdir)/lib'
101     else
102       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
103       toolexeclibdir='$(libdir)'
104     fi
105     multi_os_directory=`$CC -print-multi-os-directory`
106     case $multi_os_directory in
107       .) ;; # Avoid trailing /.
108       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
109     esac
110     ;;
111 esac
112 AC_SUBST(toolexecdir)
113 AC_SUBST(toolexeclibdir)
115 AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h)
116 LIBQUAD_CHECK_MATH_H_SIGNGAM
118 # If available, sqrtl and cbrtl speed up the calculation -
119 # but they are not required
120 if test x$gcc_no_link != xyes; then
121   AC_CHECK_LIB([m],[sqrtl],[AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])])
122   AC_CHECK_LIB([m],[cbrtl],[AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])])
123   AC_CHECK_LIB([m],[feholdexcept],[AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept])])
124   AC_CHECK_LIB([m],[fesetround],[AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround])])
125   AC_CHECK_LIB([m],[feupdateenv],[AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv])])
126   AC_CHECK_LIB([m],[fesetenv],[AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv])])
127   AC_CHECK_LIB([m],[fetestexcept],[AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept])])
128   AC_CHECK_FUNCS(strtoull)
129 else
130   if test "x$ac_cv_lib_m_sqrtl" = x""yes; then
131     AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])  
132   fi
133   if test "x$ac_cv_lib_m_cbrtl" = x""yes; then
134     AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])  
135   fi
136   if test "x$ac_cv_lib_m_feholdexcept" = x""yes; then
137     AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept])
138   fi
139   if test "x$ac_cv_lib_m_fesetround" = x""yes; then
140     AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround])
141   fi
142   if test "x$ac_cv_lib_m_feupdateenv" = x""yes; then
143     AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv])
144   fi
145   if test "x$ac_cv_lib_m_fesetenv" = x""yes; then
146     AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv])
147   fi
148   if test "x$ac_cv_lib_m_fetestexcept" = x""yes; then
149     AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept])
150   fi
153 # Check for hidden visibility (copied from libssp).
154 saved_CFLAGS="$CFLAGS"
155 CFLAGS="$CFLAGS -Werror"
156 AC_MSG_CHECKING([whether hidden visibility is supported])
157 AC_TRY_COMPILE([
158 void __attribute__((visibility ("hidden"))) bar (void) {}],,
159 [quadmath_hidden=yes],[quadmath_hidden=no])
160 AC_MSG_RESULT($quadmath_hidden)
161 if test x$quadmath_hidden = xyes; then
162   AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported])
164 CFLAGS="$saved_CFLAGS"
166 # Check for symbol versioning (copied from libssp).
167 AC_MSG_CHECKING([whether symbol versioning is supported])
168 AC_ARG_ENABLE(symvers,
169 AS_HELP_STRING([--disable-symvers],
170   [disable symbol versioning for libquadmath]),
171 quadmath_use_symver=$enableval,
172 quadmath_use_symver=yes)
173 if test "x$quadmath_use_symver" != xno; then
174   if test x$gcc_no_link = xyes; then
175     # If we cannot link, we cannot build shared libraries, so do not use
176     # symbol versioning.
177     quadmath_use_symver=no
178   else
179     save_LDFLAGS="$LDFLAGS"
180     LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
181     cat > conftest.map <<EOF
182 FOO_1.0 {
183   global: *foo*; bar; local: *;
186     AC_TRY_LINK([int foo;],[],[quadmath_use_symver=gnu],[quadmath_use_symver=no])
187     if test x$quadmath_use_symver = xno; then
188       case "$target_os" in
189         solaris2*)
190           LDFLAGS="$save_LDFLAGS"
191           LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
192           # Sun ld cannot handle wildcards and treats all entries as undefined.
193           cat > conftest.map <<EOF
194 FOO_1.0 {
195   global: foo; local: *;
198           AC_TRY_LINK([int foo;],[],[quadmath_use_symver=sun],[quadmath_use_symver=no])
199           ;;
200       esac
201     fi
202     LDFLAGS="$save_LDFLAGS"
203   fi
205 AC_MSG_RESULT($quadmath_use_symver)
206 AM_CONDITIONAL(LIBQUAD_USE_SYMVER, [test "x$quadmath_use_symver" != xno])
207 AM_CONDITIONAL(LIBQUAD_USE_SYMVER_GNU, [test "x$quadmath_use_symver" = xgnu])
208 AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun])
210 AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128],
211   [GCC_TRY_COMPILE_OR_LINK([
212     #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
213     typedef _Complex float __attribute__((mode(TC))) __complex128;
214     #else
215     typedef _Complex float __attribute__((mode(KC))) __complex128;
216     #endif
218     __float128 foo (__float128 x)
219     {
221      __complex128 z1, z2;
223      z1 = x;
224      z2 = x / 7.Q;
225      z2 /= z1;
227      return (__float128) z2;
228     }
230     __float128 bar (__float128 x)
231     {
232       return x * __builtin_huge_valq ();
233     }
234   ],[
235     foo (1.2Q);
236     bar (1.2Q);
237   ],[
238     libquad_cv_have_float128=yes
239   ],[
240     libquad_cv_have_float128=no
241 ])])
242 AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_cv_have_float128" = xyes])
244 # Check for printf hook support.
245 AC_MSG_CHECKING([whether printf hooks are supported])
246 AC_TRY_COMPILE([
247 #include <printf.h>
248 #include <stdarg.h>
249 #include <stdlib.h>
250 extern void flt128_va (void *, va_list *);
251 extern int flt128_ais (const struct printf_info *, size_t, int *, int *);
252 extern int flt128_printf_fp (FILE *, const struct printf_info *, const void *const *);
254 int pa_flt128 = register_printf_type (flt128_va);
255 int mod_Q = register_printf_modifier (L"Q");
256 int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais);
257 struct printf_info info = { .user = -1 };
259 [quadmath_printf_hooks=yes],[quadmath_printf_hooks=no])
260 AC_MSG_RESULT($quadmath_printf_hooks)
261 if test x$quadmath_printf_hooks = xyes; then
262   AC_DEFINE([HAVE_PRINTF_HOOKS],[1],[GNU C Library stype printf hooks supported])
265 # Check for whether locale support for quadmath_snprintf or Q printf hooks
266 # should be provided.
267 AC_MSG_CHECKING([whether nl_langinfo should be used])
268 AC_TRY_COMPILE([#include <langinfo.h>],[
269 const char *s;
270 s = nl_langinfo (DECIMAL_POINT);
271 s = nl_langinfo (MON_DECIMAL_POINT);
272 s = nl_langinfo (GROUPING);
273 s = nl_langinfo (MON_GROUPING);
274 s = nl_langinfo (THOUSANDS_SEP);
275 s = nl_langinfo (MON_THOUSANDS_SEP);
276 (void) s;
278 [quadmath_use_nl_langinfo=yes],[quadmath_use_nl_langinfo=no])
279 AC_MSG_RESULT($quadmath_use_nl_langinfo)
280 if test x$quadmath_use_nl_langinfo = xyes; then
281   AC_DEFINE([USE_NL_LANGINFO],[1],[whether nl_langinfo should be used])
284 AC_MSG_CHECKING([whether nl_langinfo should be used for wide char locale info])
285 AC_TRY_COMPILE([#include <langinfo.h>],[
286 const char *s;
287 s = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC);
288 s = nl_langinfo (_NL_MONETARY_DECIMAL_POINT_WC);
289 s = nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC);
290 s = nl_langinfo (_NL_MONETARY_THOUSANDS_SEP_WC);
291 (void) s;
293 [quadmath_use_nl_langinfo_wc=yes],[quadmath_use_nl_langinfo_wc=no])
294 AC_MSG_RESULT($quadmath_use_nl_langinfo_wc)
295 if test x$quadmath_use_nl_langinfo_wc = xyes; then
296   AC_DEFINE([USE_NL_LANGINFO_WC],[1],[whether nl_langinfo should be used for wide char locale info])
299 AC_MSG_CHECKING([whether localeconv should be used])
300 AC_TRY_COMPILE([#include <locale.h>],[
301 const struct lconv *l = localeconv ();
302 const char *s;
303 s = l->decimal_point;
304 s = l->mon_decimal_point;
305 s = l->grouping;
306 s = l->mon_grouping;
307 s = l->thousands_sep;
308 s = l->mon_thousands_sep;
309 (void) s;
311 [quadmath_use_localeconv=yes],[quadmath_use_localeconv=no])
312 AC_MSG_RESULT($quadmath_use_localeconv)
313 if test x$quadmath_use_localeconv = xyes; then
314   AC_DEFINE([USE_LOCALECONV],[1],[whether localeconv should be used])
317 # Check for whether i18n number rewriting support for quadmath_snprintf
318 # or Q printf hooks should be provided.
319 AC_MSG_CHECKING([whether i18n number rewriting support for quadmath_snprintf should be added])
320 AC_TRY_COMPILE([#include <langinfo.h>
321 #include <limits.h>
322 #include <string.h>
323 #include <wchar.h>
324 #include <wctype.h>],[
325 const char *s;
326 char decimal[MB_LEN_MAX];
327 wctrans_t map = wctrans ("to_outpunct");
328 wint_t wdecimal = towctrans (L'.', map);
329 mbstate_t state;
330 memset (&state, '\0', sizeof (state));
331 wcrtomb (decimal, wdecimal, &state);
332 s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
333 s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_WC);
334 s = nl_langinfo (_NL_CTYPE_MB_CUR_MAX);
335 (void) s;
337 [quadmath_use_i18n_number_h=yes],[quadmath_use_i18n_number_h=no])
338 AC_MSG_RESULT($quadmath_use_i18n_number_h)
339 if test x$quadmath_use_i18n_number_h = xyes; then
340   AC_DEFINE([USE_I18N_NUMBER_H],[1],[whether i18n number rewriting can be supported])
343 # Add CET specific flags if CET is enabled
344 GCC_CET_FLAGS(CET_FLAGS)
345 XCFLAGS="$XCFLAGS $CET_FLAGS"
346 AC_SUBST(XCFLAGS)
348 AC_CACHE_SAVE
350 if test ${multilib} = yes; then
351   multilib_arg="--enable-multilib"
352 else
353   multilib_arg=
357 # We would like our source tree to be readonly. However when releases or
358 # pre-releases are generated, the flex/bison generated files as well as the
359 # various formats of manuals need to be included along with the rest of the
360 # sources.  Therefore we have --enable-generated-files-in-srcdir to do 
361 # just that.
362 AC_MSG_CHECKING(generated-files-in-srcdir)
363 AC_ARG_ENABLE(generated-files-in-srcdir,
364 AS_HELP_STRING([--enable-generated-files-in-srcdir],
365  [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]),
366 [case "$enableval" in
367  yes) enable_generated_files_in_srcdir=yes ;;
368  no)  enable_generated_files_in_srcdir=no ;;
369  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
370  esac],
371 [enable_generated_files_in_srcdir=no])
372 AC_MSG_RESULT($enable_generated_files_in_srcdir)
373 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
375 # Determine what GCC version number to use in filesystem paths.
376 GCC_BASE_VER
378 AC_CONFIG_FILES(Makefile)
379 AC_OUTPUT