Use Gnulib's `nproc'.
[bpt/guile.git] / m4 / locale-fr.m4
CommitLineData
0f00f2c3 1# locale-fr.m4 serial 12
61cd9dc9 2dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc.
7f8e40b7
NJ
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl Determine the name of a french locale with traditional encoding.
10AC_DEFUN([gt_LOCALE_FR],
11[
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET])
f240aacb
LC
14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([
7f8e40b7
NJ
16changequote(,)dnl
17#include <locale.h>
18#include <time.h>
19#if HAVE_LANGINFO_CODESET
20# include <langinfo.h>
21#endif
22#include <stdlib.h>
23#include <string.h>
24struct tm t;
25char buf[16];
26int main () {
27 /* Check whether the given locale name is recognized by the system. */
28 if (setlocale (LC_ALL, "") == NULL) return 1;
29 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
30 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
31 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
32 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
33 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
0f00f2c3
LC
34 some unit tests fail.
35 On MirBSD 10, when an unsupported locale is specified, setlocale()
36 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
7f8e40b7
NJ
37#if HAVE_LANGINFO_CODESET
38 {
39 const char *cs = nl_langinfo (CODESET);
0f00f2c3
LC
40 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
41 || strcmp (cs, "UTF-8") == 0)
7f8e40b7
NJ
42 return 1;
43 }
44#endif
45#ifdef __CYGWIN__
46 /* On Cygwin, avoid locale names without encoding suffix, because the
47 locale_charset() function relies on the encoding suffix. Note that
48 LC_ALL is set on the command line. */
49 if (strchr (getenv ("LC_ALL"), '.') == NULL) 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 /* Check whether the decimal separator is a comma.
57 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
58 are nl_langinfo(RADIXCHAR) are both ".". */
59 if (localeconv () ->decimal_point[0] != ',') return 1;
60 return 0;
61}
62changequote([,])dnl
f240aacb
LC
63 ])])
64 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
65 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
66 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
67 # configure script would override the LC_ALL setting. Likewise for
68 # LC_CTYPE, which is also set at the beginning of the configure script.
69 # Test for the usual locale name.
70 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
71 gt_cv_locale_fr=fr_FR
72 else
73 # Test for the locale name with explicit encoding suffix.
74 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
75 gt_cv_locale_fr=fr_FR.ISO-8859-1
7f8e40b7 76 else
f240aacb
LC
77 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
78 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
79 gt_cv_locale_fr=fr_FR.ISO8859-1
7f8e40b7 80 else
f240aacb
LC
81 # Test for the HP-UX locale name.
82 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
83 gt_cv_locale_fr=fr_FR.iso88591
7f8e40b7 84 else
f240aacb
LC
85 # Test for the Solaris 7 locale name.
86 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
87 gt_cv_locale_fr=fr
7f8e40b7 88 else
f240aacb
LC
89 # None found.
90 gt_cv_locale_fr=none
7f8e40b7
NJ
91 fi
92 fi
93 fi
94 fi
95 fi
7f8e40b7 96 fi
f240aacb 97 rm -fr conftest*
7f8e40b7
NJ
98 ])
99 LOCALE_FR=$gt_cv_locale_fr
100 AC_SUBST([LOCALE_FR])
101])
102
103dnl Determine the name of a french locale with UTF-8 encoding.
104AC_DEFUN([gt_LOCALE_FR_UTF8],
105[
106 AC_REQUIRE([AM_LANGINFO_CODESET])
f240aacb 107 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
7f8e40b7
NJ
108 AC_LANG_CONFTEST([AC_LANG_SOURCE([
109changequote(,)dnl
110#include <locale.h>
111#include <time.h>
112#if HAVE_LANGINFO_CODESET
113# include <langinfo.h>
114#endif
115#include <stdlib.h>
116#include <string.h>
117struct tm t;
118char buf[16];
119int main () {
120 /* On BeOS and Haiku, 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__ || defined __HAIKU__)
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 and not "ASCII" or "646".
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 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
130 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
131 some unit tests fail. */
132# if HAVE_LANGINFO_CODESET
133 {
134 const char *cs = nl_langinfo (CODESET);
135 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
136 return 1;
137 }
138# endif
139# ifdef __CYGWIN__
140 /* On Cygwin, avoid locale names without encoding suffix, because the
141 locale_charset() function relies on the encoding suffix. Note that
142 LC_ALL is set on the command line. */
143 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
144# endif
145 /* Check whether in the abbreviation of the second month, the second
146 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
147 two bytes long, with UTF-8 encoding. */
148 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
149 if (strftime (buf, sizeof (buf), "%b", &t) < 4
150 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
151 return 1;
152#endif
153 /* Check whether the decimal separator is a comma.
154 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
155 are nl_langinfo(RADIXCHAR) are both ".". */
156 if (localeconv () ->decimal_point[0] != ',') return 1;
157 return 0;
158}
159changequote([,])dnl
160 ])])
161 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
162 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
163 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
164 # configure script would override the LC_ALL setting. Likewise for
165 # LC_CTYPE, which is also set at the beginning of the configure script.
166 # Test for the usual locale name.
167 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
168 gt_cv_locale_fr_utf8=fr_FR
169 else
170 # Test for the locale name with explicit encoding suffix.
171 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
172 gt_cv_locale_fr_utf8=fr_FR.UTF-8
173 else
174 # Test for the Solaris 7 locale name.
175 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
176 gt_cv_locale_fr_utf8=fr.UTF-8
177 else
178 # None found.
179 gt_cv_locale_fr_utf8=none
180 fi
181 fi
182 fi
183 fi
184 rm -fr conftest*
185 ])
186 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
187 AC_SUBST([LOCALE_FR_UTF8])
188])