1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal && autoconf && autoheader && automake
5 AC_INIT([GCC Quad-precision Math Library], 0.1,,[libquadmath])
6 AC_CONFIG_HEADER(config.h)
8 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
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/.
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. :-)
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.
21 # Do not delete or change the following two lines. For why, see
22 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
24 ACX_NONCANONICAL_TARGET
26 target_alias=${target_alias-$host_alias}
27 AC_SUBST(target_alias)
29 AM_INIT_AUTOMAKE([1.9.0 foreign subdir-objects no-dist -Wall -Wno-override -Werror])
31 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
32 AC_ARG_ENABLE(version-specific-runtime-libs,
33 AS_HELP_STRING([--enable-version-specific-runtime-libs],
34 [specify that runtime libraries should be installed in a compiler-specific directory]),
36 yes) version_specific_libs=yes ;;
37 no) version_specific_libs=no ;;
38 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
40 [version_specific_libs=no])
41 AC_MSG_RESULT($version_specific_libs)
45 AC_USE_SYSTEM_EXTENSIONS
47 # See if makeinfo has been installed and is modern enough
49 ACX_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]*])
52 AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
54 ACX_BUGURL([http://gcc.gnu.org/bugs.html])
59 AC_SUBST(enable_shared)
60 AC_SUBST(enable_static)
63 AM_ENABLE_MULTILIB(, ..)
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],[])
74 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
80 if test "x$GCC" != "xyes"; then
81 AC_MSG_ERROR([libquadmath must be built with GCC])
85 # Calculate toolexeclibdir
86 # Also toolexecdir, though it's only used in toolexeclibdir
87 case ${version_specific_libs} in
89 # Need the gcc compiler version to know where to install libraries
90 # and header files if --enable-version-specific-runtime-libs option
92 toolexecdir='$(libdir)/gcc/$(target_alias)'
93 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
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'
102 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
103 toolexeclibdir='$(libdir)'
105 multi_os_directory=`$CC -print-multi-os-directory`
106 case $multi_os_directory in
107 .) ;; # Avoid trailing /.
108 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
112 AC_SUBST(toolexecdir)
113 AC_SUBST(toolexeclibdir)
115 AC_CHECK_HEADERS(fenv.h langinfo.h wchar.h wctype.h limits.h ctype.h printf.h errno.h)
117 # If available, sqrtl and cbrtl speed up the calculation -
118 # but they are not required
119 if 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])])
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])])
128 if test "x$ac_cv_lib_m_sqrtl" = x""yes; then
129 AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])
131 if test "x$ac_cv_lib_m_cbrtl" = x""yes; then
132 AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])
134 if test "x$ac_cv_lib_m_feholdexcept" = x""yes; then
135 AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept])
137 if test "x$ac_cv_lib_m_fesetround" = x""yes; then
138 AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround])
140 if test "x$ac_cv_lib_m_feupdateenv" = x""yes; then
141 AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv])
143 if test "x$ac_cv_lib_m_fesetenv" = x""yes; then
144 AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv])
146 if test "x$ac_cv_lib_m_fetestexcept" = x""yes; then
147 AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept])
151 # Check for hidden visibility (copied from libssp).
152 saved_CFLAGS="$CFLAGS"
153 CFLAGS="$CFLAGS -Werror"
154 AC_MSG_CHECKING([whether hidden visibility is supported])
156 void __attribute__((visibility ("hidden"))) bar (void) {}],,
157 [quadmath_hidden=yes],[quadmath_hidden=no])
158 AC_MSG_RESULT($quadmath_hidden)
159 if test x$quadmath_hidden = xyes; then
160 AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported])
162 CFLAGS="$saved_CFLAGS"
164 # Check for symbol versioning (copied from libssp).
165 AC_MSG_CHECKING([whether symbol versioning is supported])
166 if test x$gcc_no_link = xyes; then
167 # If we cannot link, we cannot build shared libraries, so do not use
169 quadmath_use_symver=no
171 save_LDFLAGS="$LDFLAGS"
172 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
173 cat > conftest.map <<EOF
175 global: *foo*; bar; local: *;
178 AC_TRY_LINK([int foo;],[],[quadmath_use_symver=gnu],[quadmath_use_symver=no])
179 if test x$quadmath_use_symver = xno; then
182 LDFLAGS="$save_LDFLAGS"
183 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
184 # Sun ld cannot handle wildcards and treats all entries as undefined.
185 cat > conftest.map <<EOF
187 global: foo; local: *;
190 AC_TRY_LINK([int foo;],[],[quadmath_use_symver=sun],[quadmath_use_symver=no])
194 LDFLAGS="$save_LDFLAGS"
196 AC_MSG_RESULT($quadmath_use_symver)
197 AM_CONDITIONAL(LIBQUAD_USE_SYMVER, [test "x$quadmath_use_symver" != xno])
198 AM_CONDITIONAL(LIBQUAD_USE_SYMVER_GNU, [test "x$quadmath_use_symver" = xgnu])
199 AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun])
201 AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128],
202 [GCC_TRY_COMPILE_OR_LINK([
203 typedef _Complex float __attribute__((mode(TC))) __complex128;
205 __float128 foo (__float128 x)
214 return (__float128) z2;
217 __float128 bar (__float128 x)
219 return x * __builtin_huge_valq ();
225 libquad_cv_have_float128=yes
227 libquad_cv_have_float128=no
229 AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_cv_have_float128" = xyes])
231 # Check for printf hook support.
232 AC_MSG_CHECKING([whether printf hooks are supported])
237 extern void flt128_va (void *, va_list *);
238 extern int flt128_ais (const struct printf_info *, size_t, int *, int *);
239 extern int flt128_printf_fp (FILE *, const struct printf_info *, const void *const *);
241 int pa_flt128 = register_printf_type (flt128_va);
242 int mod_Q = register_printf_modifier (L"Q");
243 int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais);
244 struct printf_info info = { .user = -1 };
246 [quadmath_printf_hooks=yes],[quadmath_printf_hooks=no])
247 AC_MSG_RESULT($quadmath_printf_hooks)
248 if test x$quadmath_printf_hooks = xyes; then
249 AC_DEFINE([HAVE_PRINTF_HOOKS],[1],[GNU C Library stype printf hooks supported])
252 # Check for whether locale support for quadmath_snprintf or Q printf hooks
253 # should be provided.
254 AC_MSG_CHECKING([whether locale support for quadmath_snprintf should be added])
255 AC_TRY_COMPILE([#include <langinfo.h>],[
257 s = nl_langinfo (DECIMAL_POINT);
258 s = nl_langinfo (MON_DECIMAL_POINT);
259 s = nl_langinfo (GROUPING);
260 s = nl_langinfo (MON_GROUPING);
261 s = nl_langinfo (THOUSANDS_SEP);
262 s = nl_langinfo (MON_THOUSANDS_SEP);
263 s = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC);
264 s = nl_langinfo (_NL_MONETARY_DECIMAL_POINT_WC);
265 s = nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC);
266 s = nl_langinfo (_NL_MONETARY_THOUSANDS_SEP_WC);
267 s = nl_langinfo (_NL_CTYPE_MB_CUR_MAX);
270 [quadmath_use_locale_support=yes],[quadmath_use_locale_support=no])
271 AC_MSG_RESULT($quadmath_use_locale_support)
272 if test x$quadmath_use_locale_support = xyes; then
273 AC_DEFINE([USE_LOCALE_SUPPORT],[1],[whether nl_langinfo is sufficiently supported])
276 # Check for whether i18n number rewriting support for quadmath_snprintf
277 # or Q printf hooks should be provided.
278 AC_MSG_CHECKING([whether i18n number rewriting support for quadmath_snprintf should be added])
279 AC_TRY_COMPILE([#include <langinfo.h>
283 #include <wctype.h>],[
285 char decimal[MB_LEN_MAX];
286 wctrans_t map = wctrans ("to_outpunct");
287 wint_t wdecimal = towctrans (L'.', map);
289 memset (&state, '\0', sizeof (state));
290 wcrtomb (decimal, wdecimal, &state);
291 s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
292 s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_WC);
295 [quadmath_use_i18n_number_h=yes],[quadmath_use_i18n_number_h=no])
296 AC_MSG_RESULT($quadmath_use_i18n_number_h)
297 if test x$quadmath_use_i18n_number_h = xyes; then
298 AC_DEFINE([USE_I18N_NUMBER_H],[1],[whether i18n number rewriting can be supported])
303 if test ${multilib} = yes; then
304 multilib_arg="--enable-multilib"
310 # We would like our source tree to be readonly. However when releases or
311 # pre-releases are generated, the flex/bison generated files as well as the
312 # various formats of manuals need to be included along with the rest of the
313 # sources. Therefore we have --enable-generated-files-in-srcdir to do
315 AC_MSG_CHECKING(generated-files-in-srcdir)
316 AC_ARG_ENABLE(generated-files-in-srcdir,
317 AS_HELP_STRING([--enable-generated-files-in-srcdir],
318 [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]),
319 [case "$enableval" in
320 yes) enable_generated_files_in_srcdir=yes ;;
321 no) enable_generated_files_in_srcdir=no ;;
322 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
324 [enable_generated_files_in_srcdir=no])
325 AC_MSG_RESULT($enable_generated_files_in_srcdir)
326 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
329 AC_CONFIG_FILES(Makefile)