+# Check for printf hook support.
+AC_MSG_CHECKING([whether printf hooks are supported])
+AC_TRY_COMPILE([
+#include <printf.h>
+#include <stdarg.h>
+#include <stdlib.h>
+extern void flt128_va (void *, va_list *);
+extern int flt128_ais (const struct printf_info *, size_t, int *, int *);
+extern int flt128_printf_fp (FILE *, const struct printf_info *, const void *const *);
+],[
+int pa_flt128 = register_printf_type (flt128_va);
+int mod_Q = register_printf_modifier (L"Q");
+int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais);
+struct printf_info info = { .user = -1 };
+],
+[quadmath_printf_hooks=yes],[quadmath_printf_hooks=no])
+AC_MSG_RESULT($quadmath_printf_hooks)
+if test x$quadmath_printf_hooks = xyes; then
+ AC_DEFINE([HAVE_PRINTF_HOOKS],[1],[GNU C Library stype printf hooks supported])
+fi
+
+# Check for whether locale support for quadmath_snprintf or Q printf hooks
+# should be provided.
+AC_MSG_CHECKING([whether nl_langinfo should be used])
+AC_TRY_COMPILE([#include <langinfo.h>],[
+const char *s;
+s = nl_langinfo (DECIMAL_POINT);
+s = nl_langinfo (MON_DECIMAL_POINT);
+s = nl_langinfo (GROUPING);
+s = nl_langinfo (MON_GROUPING);
+s = nl_langinfo (THOUSANDS_SEP);
+s = nl_langinfo (MON_THOUSANDS_SEP);
+(void) s;
+],
+[quadmath_use_nl_langinfo=yes],[quadmath_use_nl_langinfo=no])
+AC_MSG_RESULT($quadmath_use_nl_langinfo)
+if test x$quadmath_use_nl_langinfo = xyes; then
+ AC_DEFINE([USE_NL_LANGINFO],[1],[whether nl_langinfo should be used])
+fi
+
+AC_MSG_CHECKING([whether nl_langinfo should be used for wide char locale info])
+AC_TRY_COMPILE([#include <langinfo.h>],[
+const char *s;
+s = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC);
+s = nl_langinfo (_NL_MONETARY_DECIMAL_POINT_WC);
+s = nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC);
+s = nl_langinfo (_NL_MONETARY_THOUSANDS_SEP_WC);
+(void) s;
+],
+[quadmath_use_nl_langinfo_wc=yes],[quadmath_use_nl_langinfo_wc=no])
+AC_MSG_RESULT($quadmath_use_nl_langinfo_wc)
+if test x$quadmath_use_nl_langinfo_wc = xyes; then
+ AC_DEFINE([USE_NL_LANGINFO_WC],[1],[whether nl_langinfo should be used for wide char locale info])
+fi
+
+AC_MSG_CHECKING([whether localeconv should be used])
+AC_TRY_COMPILE([#include <locale.h>],[
+const struct lconv *l = localeconv ();
+const char *s;
+s = l->decimal_point;
+s = l->mon_decimal_point;
+s = l->grouping;
+s = l->mon_grouping;
+s = l->thousands_sep;
+s = l->mon_thousands_sep;
+(void) s;
+],
+[quadmath_use_localeconv=yes],[quadmath_use_localeconv=no])
+AC_MSG_RESULT($quadmath_use_localeconv)
+if test x$quadmath_use_localeconv = xyes; then
+ AC_DEFINE([USE_LOCALECONV],[1],[whether localeconv should be used])
+fi
+
+# Check for whether i18n number rewriting support for quadmath_snprintf
+# or Q printf hooks should be provided.
+AC_MSG_CHECKING([whether i18n number rewriting support for quadmath_snprintf should be added])
+AC_TRY_COMPILE([#include <langinfo.h>
+#include <limits.h>
+#include <string.h>
+#include <wchar.h>
+#include <wctype.h>],[
+const char *s;
+char decimal[MB_LEN_MAX];
+wctrans_t map = wctrans ("to_outpunct");
+wint_t wdecimal = towctrans (L'.', map);
+mbstate_t state;
+memset (&state, '\0', sizeof (state));
+wcrtomb (decimal, wdecimal, &state);
+s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
+s = nl_langinfo (_NL_CTYPE_OUTDIGIT0_WC);
+s = nl_langinfo (_NL_CTYPE_MB_CUR_MAX);
+(void) s;
+],
+[quadmath_use_i18n_number_h=yes],[quadmath_use_i18n_number_h=no])
+AC_MSG_RESULT($quadmath_use_i18n_number_h)
+if test x$quadmath_use_i18n_number_h = xyes; then
+ AC_DEFINE([USE_I18N_NUMBER_H],[1],[whether i18n number rewriting can be supported])
+fi
+