]> git.ipfire.org Git - thirdparty/gcc.git/blame - libquadmath/configure.ac
* printf/quadmath-printf.c (quadmath_snprintf): Make sure
[thirdparty/gcc.git] / libquadmath / configure.ac
CommitLineData
87969c8c 1# Process this file with autoconf to produce a configure script, like so:
2# aclocal && autoconf && autoheader && automake
3
4AC_PREREQ(2.64)
5AC_INIT([GCC Quad-precision Math Library], 0.1,,[libquadmath])
6AC_CONFIG_HEADER(config.h)
7
8# Gets build, host, target, *_vendor, *_cpu, *_os, etc.
9#
10# You will slowly go insane if you do not grok the following fact: when
11# building this library, the top-level /target/ becomes the library's /host/.
12#
13# configure then causes --target to default to --host, exactly like any
14# other package using autoconf. Therefore, 'target' and 'host' will
15# always be the same. This makes sense both for native and cross compilers
16# just think about it for a little while. :-)
17#
18# Also, if this library is being configured as part of a cross compiler, the
19# top-level configure script will pass the "real" host as $with_cross_host.
20#
21# Do not delete or change the following two lines. For why, see
22# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
23AC_CANONICAL_SYSTEM
cb3103a1 24ACX_NONCANONICAL_TARGET
25
87969c8c 26target_alias=${target_alias-$host_alias}
cb3103a1 27AC_SUBST(target_alias)
87969c8c 28
d7887345 29AM_INIT_AUTOMAKE([1.9.0 foreign subdir-objects no-dist -Wall -Wno-override -Werror])
87969c8c 30
87969c8c 31AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
32AC_ARG_ENABLE(version-specific-runtime-libs,
d6580113 33AS_HELP_STRING([--enable-version-specific-runtime-libs],
34 [specify that runtime libraries should be installed in a compiler-specific directory]),
87969c8c 35[case "$enableval" in
36 yes) version_specific_libs=yes ;;
37 no) version_specific_libs=no ;;
38 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
39 esac],
40[version_specific_libs=no])
41AC_MSG_RESULT($version_specific_libs)
42
cb3103a1 43GCC_NO_EXECUTABLES
87969c8c 44
0c0fb0a6 45AC_USE_SYSTEM_EXTENSIONS
46
d6580113 47# See if makeinfo has been installed and is modern enough
48# that we can use it.
49ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
50 [GNU texinfo.* \([0-9][0-9.]*\)],
51 [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
52AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
53
95cdaa86 54ACX_BUGURL([http://gcc.gnu.org/bugs.html])
d6580113 55
87969c8c 56# Configure libtool
57AM_PROG_LIBTOOL
8c35d268 58ACX_LT_HOST_FLAGS
87969c8c 59AC_SUBST(enable_shared)
60AC_SUBST(enable_static)
61
62AM_MAINTAINER_MODE
63AM_ENABLE_MULTILIB(, ..)
64
cb3103a1 65AC_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.
70
71m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
72m4_define([_AC_ARG_VAR_PRECIOUS],[])
73AC_PROG_CC
74m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
75
76AC_SUBST(CFLAGS)
77
78AM_PROG_CC_C_O
79
80if test "x$GCC" != "xyes"; then
81 AC_MSG_ERROR([libquadmath must be built with GCC])
82fi
83AC_PROG_CPP
84
87969c8c 85# Calculate toolexeclibdir
86# Also toolexecdir, though it's only used in toolexeclibdir
87case ${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 ;;
111esac
112AC_SUBST(toolexecdir)
113AC_SUBST(toolexeclibdir)
114
1aca2b0f 115AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h)
bcaa791f 116
5edfcfbd 117# If available, sqrtl and cbrtl speed up the calculation -
118# but they are not required
119if test x$gcc_no_link != xyes; then
120 AC_CHECK_LIB([m],[sqrtl],[AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])])
121 AC_CHECK_LIB([m],[cbrtl],[AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])])
bcaa791f 122 AC_CHECK_LIB([m],[feholdexcept],[AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept])])
123 AC_CHECK_LIB([m],[fesetround],[AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround])])
124 AC_CHECK_LIB([m],[feupdateenv],[AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv])])
125 AC_CHECK_LIB([m],[fesetenv],[AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv])])
126 AC_CHECK_LIB([m],[fetestexcept],[AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept])])
abb2a4bd 127 AC_CHECK_FUNCS(strtoull)
5edfcfbd 128else
129 if test "x$ac_cv_lib_m_sqrtl" = x""yes; then
130 AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])
131 fi
132 if test "x$ac_cv_lib_m_cbrtl" = x""yes; then
133 AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])
134 fi
bcaa791f 135 if test "x$ac_cv_lib_m_feholdexcept" = x""yes; then
136 AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept])
137 fi
138 if test "x$ac_cv_lib_m_fesetround" = x""yes; then
139 AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround])
140 fi
141 if test "x$ac_cv_lib_m_feupdateenv" = x""yes; then
142 AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv])
143 fi
144 if test "x$ac_cv_lib_m_fesetenv" = x""yes; then
145 AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv])
146 fi
147 if test "x$ac_cv_lib_m_fetestexcept" = x""yes; then
148 AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept])
149 fi
5edfcfbd 150fi
87969c8c 151
0c0fb0a6 152# Check for hidden visibility (copied from libssp).
1e95c98e 153saved_CFLAGS="$CFLAGS"
154CFLAGS="$CFLAGS -Werror"
0c0fb0a6 155AC_MSG_CHECKING([whether hidden visibility is supported])
156AC_TRY_COMPILE([
157void __attribute__((visibility ("hidden"))) bar (void) {}],,
158[quadmath_hidden=yes],[quadmath_hidden=no])
159AC_MSG_RESULT($quadmath_hidden)
160if test x$quadmath_hidden = xyes; then
161 AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported])
162fi
1e95c98e 163CFLAGS="$saved_CFLAGS"
0c0fb0a6 164
87969c8c 165# Check for symbol versioning (copied from libssp).
166AC_MSG_CHECKING([whether symbol versioning is supported])
cb3103a1 167if test x$gcc_no_link = xyes; then
168 # If we cannot link, we cannot build shared libraries, so do not use
169 # symbol versioning.
170 quadmath_use_symver=no
171else
172 save_LDFLAGS="$LDFLAGS"
173 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
174 cat > conftest.map <<EOF
87969c8c 175FOO_1.0 {
176 global: *foo*; bar; local: *;
177};
178EOF
cb3103a1 179 AC_TRY_LINK([int foo;],[],[quadmath_use_symver=gnu],[quadmath_use_symver=no])
180 if test x$quadmath_use_symver = xno; then
181 case "$target_os" in
182 solaris2*)
183 LDFLAGS="$save_LDFLAGS"
184 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
185 # Sun ld cannot handle wildcards and treats all entries as undefined.
186 cat > conftest.map <<EOF
87969c8c 187FOO_1.0 {
188 global: foo; local: *;
189};
190EOF
cb3103a1 191 AC_TRY_LINK([int foo;],[],[quadmath_use_symver=sun],[quadmath_use_symver=no])
192 ;;
193 esac
194 fi
195 LDFLAGS="$save_LDFLAGS"
87969c8c 196fi
87969c8c 197AC_MSG_RESULT($quadmath_use_symver)
198AM_CONDITIONAL(LIBQUAD_USE_SYMVER, [test "x$quadmath_use_symver" != xno])
199AM_CONDITIONAL(LIBQUAD_USE_SYMVER_GNU, [test "x$quadmath_use_symver" = xgnu])
200AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun])
201
eac55a56 202AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128],
203 [GCC_TRY_COMPILE_OR_LINK([
87969c8c 204 typedef _Complex float __attribute__((mode(TC))) __complex128;
205
206 __float128 foo (__float128 x)
207 {
208
209 __complex128 z1, z2;
210
211 z1 = x;
212 z2 = x / 7.Q;
213 z2 /= z1;
214
215 return (__float128) z2;
216 }
217
218 __float128 bar (__float128 x)
219 {
220 return x * __builtin_huge_valq ();
221 }
222 ],[
223 foo (1.2Q);
224 bar (1.2Q);
225 ],[
eac55a56 226 libquad_cv_have_float128=yes
87969c8c 227 ],[
eac55a56 228 libquad_cv_have_float128=no
229])])
230AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_cv_have_float128" = xyes])
87969c8c 231
0c0fb0a6 232# Check for printf hook support.
233AC_MSG_CHECKING([whether printf hooks are supported])
234AC_TRY_COMPILE([
235#include <printf.h>
236#include <stdarg.h>
237#include <stdlib.h>
238extern void flt128_va (void *, va_list *);
239extern int flt128_ais (const struct printf_info *, size_t, int *, int *);
240extern int flt128_printf_fp (FILE *, const struct printf_info *, const void *const *);
241],[
242int pa_flt128 = register_printf_type (flt128_va);
243int mod_Q = register_printf_modifier (L"Q");
244int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais);
aa44ed84 245struct printf_info info = { .user = -1 };
0c0fb0a6 246],
247[quadmath_printf_hooks=yes],[quadmath_printf_hooks=no])
248AC_MSG_RESULT($quadmath_printf_hooks)
249if test x$quadmath_printf_hooks = xyes; then
250 AC_DEFINE([HAVE_PRINTF_HOOKS],[1],[GNU C Library stype printf hooks supported])
251fi
252
253# Check for whether locale support for quadmath_snprintf or Q printf hooks
254# should be provided.
1aca2b0f 255AC_MSG_CHECKING([whether nl_langinfo should be used])
0c0fb0a6 256AC_TRY_COMPILE([#include <langinfo.h>],[
257const char *s;
258s = nl_langinfo (DECIMAL_POINT);
259s = nl_langinfo (MON_DECIMAL_POINT);
260s = nl_langinfo (GROUPING);
261s = nl_langinfo (MON_GROUPING);
262s = nl_langinfo (THOUSANDS_SEP);
263s = nl_langinfo (MON_THOUSANDS_SEP);
1aca2b0f 264(void) s;
265],
266[quadmath_use_nl_langinfo=yes],[quadmath_use_nl_langinfo=no])
267AC_MSG_RESULT($quadmath_use_nl_langinfo)
268if test x$quadmath_use_nl_langinfo = xyes; then
269 AC_DEFINE([USE_NL_LANGINFO],[1],[whether nl_langinfo should be used])
270fi
271
272AC_MSG_CHECKING([whether nl_langinfo should be used for wide char locale info])
273AC_TRY_COMPILE([#include <langinfo.h>],[
274const char *s;
0c0fb0a6 275s = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC);
276s = nl_langinfo (_NL_MONETARY_DECIMAL_POINT_WC);
277s = nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC);
278s = nl_langinfo (_NL_MONETARY_THOUSANDS_SEP_WC);
0c0fb0a6 279(void) s;
280],
1aca2b0f 281[quadmath_use_nl_langinfo_wc=yes],[quadmath_use_nl_langinfo_wc=no])
282AC_MSG_RESULT($quadmath_use_nl_langinfo_wc)
283if test x$quadmath_use_nl_langinfo_wc = xyes; then
284 AC_DEFINE([USE_NL_LANGINFO_WC],[1],[whether nl_langinfo should be used for wide char locale info])
285fi
286
287AC_MSG_CHECKING([whether localeconv should be used])
288AC_TRY_COMPILE([#include <locale.h>],[
289const struct lconv *l = localeconv ();
290const char *s;
291s = l->decimal_point;
292s = l->mon_decimal_point;
293s = l->grouping;
294s = l->mon_grouping;
295s = l->thousands_sep;
296s = l->mon_thousands_sep;
297(void) s;
298],
299[quadmath_use_localeconv=yes],[quadmath_use_localeconv=no])
300AC_MSG_RESULT($quadmath_use_localeconv)
301if test x$quadmath_use_localeconv = xyes; then
302 AC_DEFINE([USE_LOCALECONV],[1],[whether localeconv should be used])
0c0fb0a6 303fi
304
305# Check for whether i18n number rewriting support for quadmath_snprintf
306# or Q printf hooks should be provided.
307AC_MSG_CHECKING([whether i18n number rewriting support for quadmath_snprintf should be added])
308AC_TRY_COMPILE([#include <langinfo.h>
309#include <limits.h>
310#include <string.h>
311#include <wchar.h>
312#include <wctype.h>],[
313const char *s;
314char decimal[MB_LEN_MAX];
315wctrans_t map = wctrans ("to_outpunct");
316wint_t wdecimal = towctrans (L'.', map);
317mbstate_t state;
318memset (&state, '\0', sizeof (state));
319wcrtomb (decimal, wdecimal, &state);
320s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
321s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_WC);
1aca2b0f 322s = nl_langinfo (_NL_CTYPE_MB_CUR_MAX);
0c0fb0a6 323(void) s;
324],
325[quadmath_use_i18n_number_h=yes],[quadmath_use_i18n_number_h=no])
326AC_MSG_RESULT($quadmath_use_i18n_number_h)
327if test x$quadmath_use_i18n_number_h = xyes; then
328 AC_DEFINE([USE_I18N_NUMBER_H],[1],[whether i18n number rewriting can be supported])
329fi
330
87969c8c 331AC_CACHE_SAVE
332
333if test ${multilib} = yes; then
334 multilib_arg="--enable-multilib"
335else
336 multilib_arg=
337fi
338
d6580113 339
340# We would like our source tree to be readonly. However when releases or
341# pre-releases are generated, the flex/bison generated files as well as the
342# various formats of manuals need to be included along with the rest of the
343# sources. Therefore we have --enable-generated-files-in-srcdir to do
344# just that.
345AC_MSG_CHECKING(generated-files-in-srcdir)
346AC_ARG_ENABLE(generated-files-in-srcdir,
347AS_HELP_STRING([--enable-generated-files-in-srcdir],
348 [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]),
349[case "$enableval" in
350 yes) enable_generated_files_in_srcdir=yes ;;
351 no) enable_generated_files_in_srcdir=no ;;
352 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
353 esac],
354[enable_generated_files_in_srcdir=no])
355AC_MSG_RESULT($enable_generated_files_in_srcdir)
356AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
357
358
87969c8c 359AC_CONFIG_FILES(Makefile)
360AC_OUTPUT