Fix an m4 quoting bug.
[gnulib.git] / m4 / locale-fr.m4
1 # locale-fr.m4 serial 4 (gettext-0.16.2)
2 dnl Copyright (C) 2003, 2005-2007 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 dnl From Bruno Haible.
8
9 dnl Determine the name of a french locale with traditional encoding.
10 AC_DEFUN([gt_LOCALE_FR],
11 [
12   AC_REQUIRE([AC_CANONICAL_HOST])
13   AC_REQUIRE([AM_LANGINFO_CODESET])
14   AC_CACHE_CHECK([for a traditional french locale], gt_cv_locale_fr, [
15     macosx=
16 changequote(,)dnl
17     case "$host_os" in
18       darwin[56]*) ;;
19       darwin*) macosx=yes;;
20     esac
21 changequote([,])dnl
22     if test -n "$macosx"; then
23       # On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
24       # encodings, but the kernel does not support them. The documentation
25       # says:
26       #   "... all code that calls BSD system routines should ensure
27       #    that the const *char parameters of these routines are in UTF-8
28       #    encoding. All BSD system functions expect their string
29       #    parameters to be in UTF-8 encoding and nothing else."
30       # See the comments in config.charset. Therefore we bypass the test.
31       gt_cv_locale_fr=none
32     else
33       AC_LANG_CONFTEST([AC_LANG_SOURCE([
34 changequote(,)dnl
35 #include <locale.h>
36 #include <time.h>
37 #if HAVE_LANGINFO_CODESET
38 # include <langinfo.h>
39 #endif
40 struct tm t;
41 char buf[16];
42 int main () {
43   /* Check whether the given locale name is recognized by the system.  */
44   if (setlocale (LC_ALL, "") == NULL) return 1;
45   /* Check whether nl_langinfo(CODESET) is nonempty.
46      On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
47      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.  */
48 #if HAVE_LANGINFO_CODESET
49   if (nl_langinfo (CODESET) [0] == '\0') return 1;
50 #endif
51   /* Check whether in the abbreviation of the second month, the second
52      character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
53      one byte long. This excludes the UTF-8 encoding.  */
54   t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
55   if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
56   return 0;
57 }
58 changequote([,])dnl
59         ])])
60       if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
61         # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
62         # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
63         # configure script would override the LC_ALL setting. Likewise for
64         # LC_CTYPE, which is also set at the beginning of the configure script.
65         # Test for the usual locale name.
66         if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
67           gt_cv_locale_fr=fr_FR
68         else
69           # Test for the locale name with explicit encoding suffix.
70           if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
71             gt_cv_locale_fr=fr_FR.ISO-8859-1
72           else
73             # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
74             if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
75               gt_cv_locale_fr=fr_FR.ISO8859-1
76             else
77               # Test for the HP-UX locale name.
78               if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
79                 gt_cv_locale_fr=fr_FR.iso88591
80               else
81                 # Test for the Solaris 7 locale name.
82                 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
83                   gt_cv_locale_fr=fr
84                 else
85                   # Special test for NetBSD 1.6.
86                   if test -f /usr/share/locale/fr_FR.ISO8859-1/LC_CTYPE; then
87                     gt_cv_locale_fr=fr_FR.ISO8859-1
88                   else
89                     # None found.
90                     gt_cv_locale_fr=none
91                   fi
92                 fi
93               fi
94             fi
95           fi
96         fi
97       fi
98       rm -fr conftest*
99     fi
100   ])
101   LOCALE_FR=$gt_cv_locale_fr
102   AC_SUBST([LOCALE_FR])
103 ])
104
105 dnl Determine the name of a french locale with UTF-8 encoding.
106 AC_DEFUN([gt_LOCALE_FR_UTF8],
107 [
108   AC_REQUIRE([AM_LANGINFO_CODESET])
109   AC_CACHE_CHECK([for a french Unicode locale], gt_cv_locale_fr_utf8, [
110     AC_LANG_CONFTEST([AC_LANG_SOURCE([
111 changequote(,)dnl
112 #include <locale.h>
113 #include <time.h>
114 #if HAVE_LANGINFO_CODESET
115 # include <langinfo.h>
116 #endif
117 struct tm t;
118 char buf[16];
119 int main () {
120   /* On BeOS, locales are not implemented in libc.  Rather, libintl
121      imitates locale dependent behaviour by looking at the environment
122      variables, and all locales use the UTF-8 encoding.  */
123 #if !defined(__BEOS__)
124   /* Check whether the given locale name is recognized by the system.  */
125   if (setlocale (LC_ALL, "") == NULL) return 1;
126   /* Check whether nl_langinfo(CODESET) is nonempty.
127      On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
128      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.  */
129 # if HAVE_LANGINFO_CODESET
130   if (nl_langinfo (CODESET) [0] == '\0') return 1;
131 # endif
132   /* Check whether in the abbreviation of the second month, the second
133      character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
134      two bytes long, with UTF-8 encoding.  */
135   t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
136   if (strftime (buf, sizeof (buf), "%b", &t) < 4
137       || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
138     return 1;
139 #endif
140   return 0;
141 }
142 changequote([,])dnl
143       ])])
144     if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
145       # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
146       # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
147       # configure script would override the LC_ALL setting. Likewise for
148       # LC_CTYPE, which is also set at the beginning of the configure script.
149       # Test for the usual locale name.
150       if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
151         gt_cv_locale_fr_utf8=fr_FR
152       else
153         # Test for the locale name with explicit encoding suffix.
154         if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
155           gt_cv_locale_fr_utf8=fr_FR.UTF-8
156         else
157           # Test for the Solaris 7 locale name.
158           if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
159             gt_cv_locale_fr_utf8=fr.UTF-8
160           else
161             # None found.
162             gt_cv_locale_fr_utf8=none
163           fi
164         fi
165       fi
166     fi
167     rm -fr conftest*
168   ])
169   LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
170   AC_SUBST([LOCALE_FR_UTF8])
171 ])