Commit 94933c9c authored by Philip Chimento's avatar Philip Chimento 🚮

build: Move locale choosing into separate script

In order to port to Meson in the future, we'll need to have this
functionality in a separate script. Splitting it out now and using the
script in the Autotools build will be handy if we decide to keep the two
build systems in parallel for a while.
parent be687283
......@@ -166,6 +166,7 @@ include Makefile-insttest.am
EXTRA_DIST += \
autogen.sh \
build/choose-tests-locale.sh \
COPYING.LGPL \
doc/ByteArray.md \
doc/cairo.md \
......
#!/bin/sh
locales=$(locale -a)
case $locales in
# Prefer C.UTF-8 although it is only available with newer libc
*C.UTF-8*) tests_locale=C.UTF-8 ;;
# Most systems will probably have this
*en_US.UTF-8*) tests_locale=en_US.UTF-8 ;;
*en_US.utf8*) tests_locale=en_US.utf8 ;;
# If not, fall back to any English UTF-8 locale or any UTF-8 locale at all
*en_*.UTF-8*) tests_locale=$(echo $locales | grep -m1 en_.\*\\.UTF-8) ;;
*en_*.utf8*) tests_locale=$(echo $locales | grep -m1 en_.\*\\.utf8) ;;
*.UTF-8*) tests_locale=$(echo $locales | grep -m1 \\.UTF-8) ;;
*.utf8*) tests_locale=$(echo $locales | grep -m1 \\.utf8) ;;
*) tests_locale=C ;;
esac
echo $tests_locale
......@@ -339,22 +339,7 @@ AS_IF([test "x$with_dbus_tests" != "xno"], [
AM_CONDITIONAL([DBUS_TESTS], [test "x$with_dbus_tests" != "xno"])
AC_MSG_CHECKING([for a suitable UTF-8 locale to run the tests in])
LOCALES=$(locale -a)
AS_CASE([$LOCALES],
dnl Prefer C.UTF-8 although it is only available with newer libc
[*C.UTF-8*], [TESTS_LOCALE=C.UTF-8],
dnl Most systems will probably have this
[*en_US.UTF-8*], [TESTS_LOCALE=en_US.UTF-8],
[*en_US.utf8*], [TESTS_LOCALE=en_US.utf8],
dnl If not, fall back to any English UTF-8 locale or any UTF-8 locale at all
[*en_*.UTF-8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 en_.\*\\.UTF-8)],
[*en_*.utf8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 en_.\*\\.utf8)],
[*.UTF-8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 \\.UTF-8)],
[*.utf8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 \\.utf8)],
[TESTS_LOCALE=C])
TESTS_LOCALE=$($srcdir/build/choose-tests-locale.sh)
AC_MSG_RESULT([$TESTS_LOCALE])
AC_SUBST([TESTS_LOCALE])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment