configure.ac 13 KB

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