| 1 |
# getlocalename_l.m4 |
| 2 |
# serial 3 |
| 3 |
dnl Copyright (C) 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_GETLOCALENAME_L_SIMPLE], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) |
| 12 |
|
| 13 |
dnl Persuade glibc <locale.h> to declare getlocalename_l(). |
| 14 |
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 15 |
|
| 16 |
AC_REQUIRE([gl_FUNC_GETLOCALENAME_L_UNSAFE]) |
| 17 |
]) |
| 18 |
|
| 19 |
# Prerequisites of lib/getlocalename_l.c. |
| 20 |
AC_DEFUN([gl_PREREQ_GETLOCALENAME_L_SIMPLE], |
| 21 |
[ |
| 22 |
: |
| 23 |
]) |
| 24 |
|
| 25 |
AC_DEFUN_ONCE([gl_FUNC_GETLOCALENAME_L_UNSAFE], |
| 26 |
[ |
| 27 |
AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) |
| 28 |
AC_CHECK_FUNCS_ONCE([getlocalename_l]) |
| 29 |
if test $ac_cv_func_getlocalename_l = yes; then |
| 30 |
dnl Check against the Cygwin 3.6.0 bug: It returns an invalid pointer when |
| 31 |
dnl the second argument is LC_GLOBAL_LOCALE. |
| 32 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 33 |
AC_CACHE_CHECK([whether getlocalename_l works], |
| 34 |
[gl_cv_func_getlocalename_l_works], |
| 35 |
[AC_RUN_IFELSE( |
| 36 |
[AC_LANG_SOURCE([[ |
| 37 |
#include <locale.h> |
| 38 |
#include <string.h> |
| 39 |
int main () |
| 40 |
{ |
| 41 |
const char *ret = getlocalename_l (LC_COLLATE, LC_GLOBAL_LOCALE); |
| 42 |
return strlen (ret) == 0; |
| 43 |
}]])], |
| 44 |
[gl_cv_func_getlocalename_l_works=yes], |
| 45 |
[gl_cv_func_getlocalename_l_works=no], |
| 46 |
[case "$host_os" in |
| 47 |
cygwin*) # Guess no on Cygwin. |
| 48 |
gl_cv_func_getlocalename_l_works="guessing no" ;; |
| 49 |
*) # Guess yes otherwise. |
| 50 |
gl_cv_func_getlocalename_l_works="guessing yes" ;; |
| 51 |
esac |
| 52 |
]) |
| 53 |
]) |
| 54 |
case "$gl_cv_func_getlocalename_l_works" in |
| 55 |
*yes) ;; |
| 56 |
*) REPLACE_GETLOCALENAME_L=1 ;; |
| 57 |
esac |
| 58 |
else |
| 59 |
HAVE_GETLOCALENAME_L=0 |
| 60 |
fi |
| 61 |
if test $HAVE_GETLOCALENAME_L = 0 || test $REPLACE_GETLOCALENAME_L = 1; then |
| 62 |
GETLOCALENAME_L_LIB="$SETLOCALE_NULL_LIB" |
| 63 |
else |
| 64 |
GETLOCALENAME_L_LIB= |
| 65 |
fi |
| 66 |
dnl GETLOCALENAME_L_LIB is expected to be '-pthread' or '-lpthread' on AIX |
| 67 |
dnl with gcc or xlc, and empty otherwise. |
| 68 |
AC_SUBST([GETLOCALENAME_L_LIB]) |
| 69 |
]) |
| 70 |
|
| 71 |
# Prerequisites of lib/getlocalename_l-unsafe.c. |
| 72 |
AC_DEFUN([gl_PREREQ_GETLOCALENAME_L_UNSAFE], |
| 73 |
[ |
| 74 |
AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) |
| 75 |
AC_REQUIRE([gl_LOCALE_T]) |
| 76 |
AC_REQUIRE([gt_INTL_THREAD_LOCALE_NAME]) |
| 77 |
AC_CHECK_HEADERS_ONCE([langinfo.h]) |
| 78 |
if test $HAVE_LOCALE_T = 1; then |
| 79 |
gl_CHECK_FUNCS_ANDROID([newlocale], [[#include <locale.h>]]) |
| 80 |
gl_CHECK_FUNCS_ANDROID([duplocale], [[#include <locale.h>]]) |
| 81 |
gl_CHECK_FUNCS_ANDROID([freelocale], [[#include <locale.h>]]) |
| 82 |
gl_func_newlocale="$ac_cv_func_newlocale" |
| 83 |
gl_func_duplocale="$ac_cv_func_duplocale" |
| 84 |
gl_func_freelocale="$ac_cv_func_freelocale" |
| 85 |
else |
| 86 |
dnl In 2019, some versions of z/OS lack the locale_t type and have broken |
| 87 |
dnl newlocale, duplocale, freelocale functions. |
| 88 |
gl_cv_onwards_func_newlocale='future OS version' |
| 89 |
gl_cv_onwards_func_duplocale='future OS version' |
| 90 |
gl_cv_onwards_func_freelocale='future OS version' |
| 91 |
gl_func_newlocale=no |
| 92 |
gl_func_duplocale=no |
| 93 |
gl_func_freelocale=no |
| 94 |
fi |
| 95 |
if test $gl_func_newlocale != yes; then |
| 96 |
HAVE_NEWLOCALE=0 |
| 97 |
case "$gl_cv_onwards_func_newlocale" in |
| 98 |
future*) REPLACE_NEWLOCALE=1 ;; |
| 99 |
esac |
| 100 |
fi |
| 101 |
if test $gl_func_duplocale != yes; then |
| 102 |
HAVE_DUPLOCALE=0 |
| 103 |
case "$gl_cv_onwards_func_duplocale" in |
| 104 |
future*) REPLACE_DUPLOCALE=1 ;; |
| 105 |
esac |
| 106 |
fi |
| 107 |
if test $gl_func_freelocale != yes; then |
| 108 |
HAVE_FREELOCALE=0 |
| 109 |
case "$gl_cv_onwards_func_freelocale" in |
| 110 |
future*) REPLACE_FREELOCALE=1 ;; |
| 111 |
esac |
| 112 |
fi |
| 113 |
if test $gt_localename_enhances_locale_funcs = yes; then |
| 114 |
REPLACE_NEWLOCALE=1 |
| 115 |
REPLACE_DUPLOCALE=1 |
| 116 |
REPLACE_FREELOCALE=1 |
| 117 |
fi |
| 118 |
]) |