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 24ACX_NONCANONICAL_TARGET 25 26AM_ENABLE_MULTILIB(, ..) 27 28target_alias=${target_alias-$host_alias} 29AC_SUBST(target_alias) 30 31AM_INIT_AUTOMAKE([1.9.0 foreign subdir-objects no-dist -Wall -Wno-override -Werror]) 32 33AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) 34AC_ARG_ENABLE(version-specific-runtime-libs, 35AS_HELP_STRING([--enable-version-specific-runtime-libs], 36 [specify that runtime libraries should be installed in a compiler-specific directory]), 37[case "$enableval" in 38 yes) version_specific_libs=yes ;; 39 no) version_specific_libs=no ;; 40 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; 41 esac], 42[version_specific_libs=no]) 43AC_MSG_RESULT($version_specific_libs) 44 45GCC_NO_EXECUTABLES 46 47AC_USE_SYSTEM_EXTENSIONS 48 49# See if makeinfo has been installed and is modern enough 50# that we can use it. 51ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version], 52 [GNU texinfo.* \([0-9][0-9.]*\)], 53 [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*]) 54AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes") 55 56ACX_BUGURL([http://gcc.gnu.org/bugs.html]) 57 58# Configure libtool 59AM_PROG_LIBTOOL 60ACX_LT_HOST_FLAGS 61AC_SUBST(enable_shared) 62AC_SUBST(enable_static) 63 64AM_MAINTAINER_MODE 65 66AC_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 72m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) 73m4_define([_AC_ARG_VAR_PRECIOUS],[]) 74AC_PROG_CC 75m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) 76 77AC_SUBST(CFLAGS) 78 79AM_PROG_CC_C_O 80 81if test "x$GCC" != "xyes"; then 82 AC_MSG_ERROR([libquadmath must be built with GCC]) 83fi 84AC_PROG_CPP 85 86# Calculate toolexeclibdir 87# Also toolexecdir, though it's only used in toolexeclibdir 88case ${version_specific_libs} in 89 yes) 90 # Need the gcc compiler version to know where to install libraries 91 # and header files if --enable-version-specific-runtime-libs option 92 # is selected. 93 toolexecdir='$(libdir)/gcc/$(target_alias)' 94 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' 95 ;; 96 no) 97 if test -n "$with_cross_host" && 98 test x"$with_cross_host" != x"no"; then 99 # Install a library built with a cross compiler in tooldir, not libdir. 100 toolexecdir='$(exec_prefix)/$(target_alias)' 101 toolexeclibdir='$(toolexecdir)/lib' 102 else 103 toolexecdir='$(libdir)/gcc-lib/$(target_alias)' 104 toolexeclibdir='$(libdir)' 105 fi 106 multi_os_directory=`$CC -print-multi-os-directory` 107 case $multi_os_directory in 108 .) ;; # Avoid trailing /. 109 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; 110 esac 111 ;; 112esac 113AC_SUBST(toolexecdir) 114AC_SUBST(toolexeclibdir) 115 116AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h) 117LIBQUAD_CHECK_MATH_H_SIGNGAM 118 119# If available, sqrtl and cbrtl speed up the calculation - 120# but they are not required 121if test x$gcc_no_link != xyes; then 122 AC_CHECK_LIB([m],[sqrtl],[AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])]) 123 AC_CHECK_LIB([m],[cbrtl],[AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])]) 124 AC_CHECK_LIB([m],[feholdexcept],[AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept])]) 125 AC_CHECK_LIB([m],[fesetround],[AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround])]) 126 AC_CHECK_LIB([m],[feupdateenv],[AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv])]) 127 AC_CHECK_LIB([m],[fesetenv],[AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv])]) 128 AC_CHECK_LIB([m],[fetestexcept],[AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept])]) 129 AC_CHECK_FUNCS(strtoull) 130else 131 if test "x$ac_cv_lib_m_sqrtl" = x""yes; then 132 AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl]) 133 fi 134 if test "x$ac_cv_lib_m_cbrtl" = x""yes; then 135 AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl]) 136 fi 137 if test "x$ac_cv_lib_m_feholdexcept" = x""yes; then 138 AC_DEFINE([HAVE_FEHOLDEXCEPT],[1],[libm includes feholdexcept]) 139 fi 140 if test "x$ac_cv_lib_m_fesetround" = x""yes; then 141 AC_DEFINE([HAVE_FESETROUND],[1],[libm includes fesetround]) 142 fi 143 if test "x$ac_cv_lib_m_feupdateenv" = x""yes; then 144 AC_DEFINE([HAVE_FEUPDATEENV],[1],[libm includes feupdateenv]) 145 fi 146 if test "x$ac_cv_lib_m_fesetenv" = x""yes; then 147 AC_DEFINE([HAVE_FESETENV],[1],[libm includes fesetenv]) 148 fi 149 if test "x$ac_cv_lib_m_fetestexcept" = x""yes; then 150 AC_DEFINE([HAVE_FETESTEXCEPT],[1],[libm includes fetestexcept]) 151 fi 152fi 153 154# Check for hidden visibility (copied from libssp). 155saved_CFLAGS="$CFLAGS" 156CFLAGS="$CFLAGS -Werror" 157AC_MSG_CHECKING([whether hidden visibility is supported]) 158AC_TRY_COMPILE([ 159void __attribute__((visibility ("hidden"))) bar (void) {}],, 160[quadmath_hidden=yes],[quadmath_hidden=no]) 161AC_MSG_RESULT($quadmath_hidden) 162if test x$quadmath_hidden = xyes; then 163 AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported]) 164fi 165CFLAGS="$saved_CFLAGS" 166 167# Check for symbol versioning (copied from libssp). 168AC_MSG_CHECKING([whether symbol versioning is supported]) 169AC_ARG_ENABLE(symvers, 170AS_HELP_STRING([--disable-symvers], 171 [disable symbol versioning for libquadmath]), 172quadmath_use_symver=$enableval, 173quadmath_use_symver=yes) 174if test "x$quadmath_use_symver" != xno; then 175 if test x$gcc_no_link = xyes; then 176 # If we cannot link, we cannot build shared libraries, so do not use 177 # symbol versioning. 178 quadmath_use_symver=no 179 else 180 save_LDFLAGS="$LDFLAGS" 181 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map" 182 cat > conftest.map <<EOF 183FOO_1.0 { 184 global: *foo*; bar; local: *; 185}; 186EOF 187 AC_TRY_LINK([int foo;],[],[quadmath_use_symver=gnu],[quadmath_use_symver=no]) 188 if test x$quadmath_use_symver = xno; then 189 case "$target_os" in 190 solaris2*) 191 LDFLAGS="$save_LDFLAGS" 192 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map" 193 # Sun ld cannot handle wildcards and treats all entries as undefined. 194 cat > conftest.map <<EOF 195FOO_1.0 { 196 global: foo; local: *; 197}; 198EOF 199 AC_TRY_LINK([int foo;],[],[quadmath_use_symver=sun],[quadmath_use_symver=no]) 200 ;; 201 esac 202 fi 203 LDFLAGS="$save_LDFLAGS" 204 fi 205fi 206AC_MSG_RESULT($quadmath_use_symver) 207AM_CONDITIONAL(LIBQUAD_USE_SYMVER, [test "x$quadmath_use_symver" != xno]) 208AM_CONDITIONAL(LIBQUAD_USE_SYMVER_GNU, [test "x$quadmath_use_symver" = xgnu]) 209AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun]) 210 211AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128], 212 [GCC_TRY_COMPILE_OR_LINK([ 213 typedef _Complex float __attribute__((mode(TC))) __complex128; 214 215 __float128 foo (__float128 x) 216 { 217 218 __complex128 z1, z2; 219 220 z1 = x; 221 z2 = x / 7.Q; 222 z2 /= z1; 223 224 return (__float128) z2; 225 } 226 227 __float128 bar (__float128 x) 228 { 229 return x * __builtin_huge_valq (); 230 } 231 ],[ 232 foo (1.2Q); 233 bar (1.2Q); 234 ],[ 235 libquad_cv_have_float128=yes 236 ],[ 237 libquad_cv_have_float128=no 238])]) 239AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_cv_have_float128" = xyes]) 240 241# Check for printf hook support. 242AC_MSG_CHECKING([whether printf hooks are supported]) 243AC_TRY_COMPILE([ 244#include <printf.h> 245#include <stdarg.h> 246#include <stdlib.h> 247extern void flt128_va (void *, va_list *); 248extern int flt128_ais (const struct printf_info *, size_t, int *, int *); 249extern int flt128_printf_fp (FILE *, const struct printf_info *, const void *const *); 250],[ 251int pa_flt128 = register_printf_type (flt128_va); 252int mod_Q = register_printf_modifier (L"Q"); 253int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais); 254struct printf_info info = { .user = -1 }; 255], 256[quadmath_printf_hooks=yes],[quadmath_printf_hooks=no]) 257AC_MSG_RESULT($quadmath_printf_hooks) 258if test x$quadmath_printf_hooks = xyes; then 259 AC_DEFINE([HAVE_PRINTF_HOOKS],[1],[GNU C Library stype printf hooks supported]) 260fi 261 262# Check for whether locale support for quadmath_snprintf or Q printf hooks 263# should be provided. 264AC_MSG_CHECKING([whether nl_langinfo should be used]) 265AC_TRY_COMPILE([#include <langinfo.h>],[ 266const char *s; 267s = nl_langinfo (DECIMAL_POINT); 268s = nl_langinfo (MON_DECIMAL_POINT); 269s = nl_langinfo (GROUPING); 270s = nl_langinfo (MON_GROUPING); 271s = nl_langinfo (THOUSANDS_SEP); 272s = nl_langinfo (MON_THOUSANDS_SEP); 273(void) s; 274], 275[quadmath_use_nl_langinfo=yes],[quadmath_use_nl_langinfo=no]) 276AC_MSG_RESULT($quadmath_use_nl_langinfo) 277if test x$quadmath_use_nl_langinfo = xyes; then 278 AC_DEFINE([USE_NL_LANGINFO],[1],[whether nl_langinfo should be used]) 279fi 280 281AC_MSG_CHECKING([whether nl_langinfo should be used for wide char locale info]) 282AC_TRY_COMPILE([#include <langinfo.h>],[ 283const char *s; 284s = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC); 285s = nl_langinfo (_NL_MONETARY_DECIMAL_POINT_WC); 286s = nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC); 287s = nl_langinfo (_NL_MONETARY_THOUSANDS_SEP_WC); 288(void) s; 289], 290[quadmath_use_nl_langinfo_wc=yes],[quadmath_use_nl_langinfo_wc=no]) 291AC_MSG_RESULT($quadmath_use_nl_langinfo_wc) 292if test x$quadmath_use_nl_langinfo_wc = xyes; then 293 AC_DEFINE([USE_NL_LANGINFO_WC],[1],[whether nl_langinfo should be used for wide char locale info]) 294fi 295 296AC_MSG_CHECKING([whether localeconv should be used]) 297AC_TRY_COMPILE([#include <locale.h>],[ 298const struct lconv *l = localeconv (); 299const char *s; 300s = l->decimal_point; 301s = l->mon_decimal_point; 302s = l->grouping; 303s = l->mon_grouping; 304s = l->thousands_sep; 305s = l->mon_thousands_sep; 306(void) s; 307], 308[quadmath_use_localeconv=yes],[quadmath_use_localeconv=no]) 309AC_MSG_RESULT($quadmath_use_localeconv) 310if test x$quadmath_use_localeconv = xyes; then 311 AC_DEFINE([USE_LOCALECONV],[1],[whether localeconv should be used]) 312fi 313 314# Check for whether i18n number rewriting support for quadmath_snprintf 315# or Q printf hooks should be provided. 316AC_MSG_CHECKING([whether i18n number rewriting support for quadmath_snprintf should be added]) 317AC_TRY_COMPILE([#include <langinfo.h> 318#include <limits.h> 319#include <string.h> 320#include <wchar.h> 321#include <wctype.h>],[ 322const char *s; 323char decimal[MB_LEN_MAX]; 324wctrans_t map = wctrans ("to_outpunct"); 325wint_t wdecimal = towctrans (L'.', map); 326mbstate_t state; 327memset (&state, '\0', sizeof (state)); 328wcrtomb (decimal, wdecimal, &state); 329s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB); 330s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_WC); 331s = nl_langinfo (_NL_CTYPE_MB_CUR_MAX); 332(void) s; 333], 334[quadmath_use_i18n_number_h=yes],[quadmath_use_i18n_number_h=no]) 335AC_MSG_RESULT($quadmath_use_i18n_number_h) 336if test x$quadmath_use_i18n_number_h = xyes; then 337 AC_DEFINE([USE_I18N_NUMBER_H],[1],[whether i18n number rewriting can be supported]) 338fi 339 340AC_CACHE_SAVE 341 342if test ${multilib} = yes; then 343 multilib_arg="--enable-multilib" 344else 345 multilib_arg= 346fi 347 348 349# We would like our source tree to be readonly. However when releases or 350# pre-releases are generated, the flex/bison generated files as well as the 351# various formats of manuals need to be included along with the rest of the 352# sources. Therefore we have --enable-generated-files-in-srcdir to do 353# just that. 354AC_MSG_CHECKING(generated-files-in-srcdir) 355AC_ARG_ENABLE(generated-files-in-srcdir, 356AS_HELP_STRING([--enable-generated-files-in-srcdir], 357 [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]), 358[case "$enableval" in 359 yes) enable_generated_files_in_srcdir=yes ;; 360 no) enable_generated_files_in_srcdir=no ;; 361 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; 362 esac], 363[enable_generated_files_in_srcdir=no]) 364AC_MSG_RESULT($enable_generated_files_in_srcdir) 365AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes) 366 367 368AC_CONFIG_FILES(Makefile) 369AC_OUTPUT 370