configure.ac 12 KB

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