| 1 |
# setlocale.m4 |
| 2 |
# serial 11 |
| 3 |
dnl Copyright (C) 2011-2025 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_FUNC_SETLOCALE], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) |
| 12 |
AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) |
| 13 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 14 |
|
| 15 |
dnl Test whether we need to improve on the general working of setlocale. |
| 16 |
NEED_SETLOCALE_IMPROVED=0 |
| 17 |
case "$host_os" in |
| 18 |
dnl On native Windows systems, setlocale(category,NULL) does not look at |
| 19 |
dnl the environment variables LC_ALL, category, and LANG. |
| 20 |
mingw* | windows*) NEED_SETLOCALE_IMPROVED=1 ;; |
| 21 |
dnl On Android, setlocale(category,name) treats all categories as equivalent |
| 22 |
dnl to LC_CTYPE. And on Android 4.3, setlocale(category,"C") always fails. |
| 23 |
*-android*) NEED_SETLOCALE_IMPROVED=1 ;; |
| 24 |
dnl On Cygwin 1.5.x, setlocale always succeeds but setlocale(LC_CTYPE,NULL) |
| 25 |
dnl is then still "C". |
| 26 |
cygwin*) |
| 27 |
case `uname -r` in |
| 28 |
1.5.*) NEED_SETLOCALE_IMPROVED=1 ;; |
| 29 |
esac |
| 30 |
;; |
| 31 |
esac |
| 32 |
AC_DEFINE_UNQUOTED([NEED_SETLOCALE_IMPROVED], [$NEED_SETLOCALE_IMPROVED], |
| 33 |
[Define to 1 to enable general improvements of setlocale.]) |
| 34 |
|
| 35 |
dnl Test whether we need a multithread-safe setlocale(category,NULL). |
| 36 |
NEED_SETLOCALE_MTSAFE=0 |
| 37 |
if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then |
| 38 |
NEED_SETLOCALE_MTSAFE=1 |
| 39 |
fi |
| 40 |
AC_DEFINE_UNQUOTED([NEED_SETLOCALE_MTSAFE], [$NEED_SETLOCALE_MTSAFE], |
| 41 |
[Define to 1 to enable a multithread-safety fix of setlocale.]) |
| 42 |
|
| 43 |
if test $NEED_SETLOCALE_IMPROVED = 1 || test $NEED_SETLOCALE_MTSAFE = 1; then |
| 44 |
REPLACE_SETLOCALE=1 |
| 45 |
fi |
| 46 |
|
| 47 |
if test $NEED_SETLOCALE_MTSAFE = 1; then |
| 48 |
SETLOCALE_LIB="$SETLOCALE_NULL_LIB" |
| 49 |
else |
| 50 |
SETLOCALE_LIB= |
| 51 |
fi |
| 52 |
dnl SETLOCALE_LIB is expected to be '-pthread' or '-lpthread' on AIX with gcc |
| 53 |
dnl or xlc, and empty otherwise. |
| 54 |
AC_SUBST([SETLOCALE_LIB]) |
| 55 |
dnl For backward compatibility. |
| 56 |
LIB_SETLOCALE="$SETLOCALE_LIB" |
| 57 |
AC_SUBST([LIB_SETLOCALE]) |
| 58 |
]) |
| 59 |
|
| 60 |
# Prerequisites of lib/setlocale.c. |
| 61 |
AC_DEFUN([gl_PREREQ_SETLOCALE], |
| 62 |
[ |
| 63 |
dnl No need to check for CFLocaleCopyPreferredLanguages and |
| 64 |
dnl CFPreferencesCopyAppValue because lib/setlocale.c is not used on Mac OS X. |
| 65 |
dnl (The Mac OS X specific code is only used in libintl.) |
| 66 |
: |
| 67 |
]) |