Bump to 1.14.1
[platform/upstream/augeas.git] / m4 / duplocale.m4
1 # duplocale.m4 serial 8
2 dnl Copyright (C) 2009-2016 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_DUPLOCALE],
8 [
9   AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
10   AC_REQUIRE([AC_CANONICAL_HOST])
11   AC_CHECK_FUNCS_ONCE([duplocale])
12   if test $ac_cv_func_duplocale = yes; then
13     dnl Check against glibc bug where duplocale crashes.
14     dnl See <http://sourceware.org/bugzilla/show_bug.cgi?id=10969>.
15     dnl Also, on AIX 7.1, duplocale(LC_GLOBAL_LOCALE) returns (locale_t)0 with
16     dnl errno set to EINVAL.
17     AC_REQUIRE([gl_LOCALE_H])
18     AC_CACHE_CHECK([whether duplocale(LC_GLOBAL_LOCALE) works],
19       [gl_cv_func_duplocale_works],
20       [AC_RUN_IFELSE(
21          [AC_LANG_SOURCE([[
22 #include <locale.h>
23 #if HAVE_XLOCALE_H
24 # include <xlocale.h>
25 #endif
26 int main ()
27 {
28   locale_t loc = duplocale (LC_GLOBAL_LOCALE);
29   if (!loc)
30     return 1;
31   freelocale (loc);
32   return 0;
33 }]])],
34          [gl_cv_func_duplocale_works=yes],
35          [gl_cv_func_duplocale_works=no],
36          [dnl Guess it works except on glibc < 2.12, uClibc, and AIX.
37           case "$host_os" in
38             aix*) gl_cv_func_duplocale_works="guessing no";;
39             *-gnu*)
40               AC_EGREP_CPP([Unlucky], [
41 #include <features.h>
42 #ifdef __GNU_LIBRARY__
43  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)
44   Unlucky GNU user
45  #endif
46 #endif
47 #ifdef __UCLIBC__
48  Unlucky user
49 #endif
50                 ],
51                 [gl_cv_func_duplocale_works="guessing no"],
52                 [gl_cv_func_duplocale_works="guessing yes"])
53               ;;
54             *) gl_cv_func_duplocale_works="guessing yes";;
55           esac
56          ])
57       ])
58     case "$gl_cv_func_duplocale_works" in
59       *no) REPLACE_DUPLOCALE=1 ;;
60     esac
61   else
62     HAVE_DUPLOCALE=0
63   fi
64 ])
65
66 # Prerequisites of lib/duplocale.c.
67 AC_DEFUN([gl_PREREQ_DUPLOCALE],
68 [
69   :
70 ])