aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/configure
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-07-31 09:29:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-07-31 09:29:13 +0000
commit89a1a1be54eefe77cc04401526ea22323c644115 (patch)
tree8071c288f5714fd1fbb80b7a53e500e58014b3e7 /configure
parent7f6377086cfbc884dfcb75e0a4075d0f0cf8b73d (diff)
downloadmandoc-89a1a1be54eefe77cc04401526ea22323c644115.tar.gz
mandoc-89a1a1be54eefe77cc04401526ea22323c644115.tar.zst
mandoc-89a1a1be54eefe77cc04401526ea22323c644115.zip
Autodetect a suitable locale for -Tutf8 mode,
and allow overriding it manually. Based on a patch from Svyatoslav Mishyn <juef at openmailbox dot org> tweaked by me. The idea originally came up in a conversation with Markus Waldeck.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure31
1 files changed, 29 insertions, 2 deletions
diff --git a/configure b/configure
index 64a61f2b..a2f6174f 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: configure,v 1.47 2016/07/20 14:03:06 schwarze Exp $
+# $Id: configure,v 1.48 2016/07/31 09:29:13 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -35,6 +35,7 @@ echo "config.log: writing..."
MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
OSNAME=
+UTF8_LOCALE=
CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -f -`
CFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings"
@@ -176,6 +177,23 @@ runtest() {
return 1
}
+# Select a UTF-8 locale.
+get_locale() {
+ [ -n "${HAVE_WCHAR}" ] && [ "${HAVE_WCHAR}" -eq 0 ] && return 0
+ ismanual UTF8_LOCALE "$UTF8_LOCALE" && return 0
+ echo "UTF8_LOCALE: testing..." 1>&3
+ UTF8_LOCALE=`locale -a | grep -i '^en_US\.UTF-*8$' | head -n 1`
+ if [ -z "${UTF8_LOCALE}" ]; then
+ UTF8_LOCALE=`locale -a | grep -i '\.UTF-*8' | head -n 1`
+ [ -n "${UTF8_LOCALE}" ] || return 1
+ fi
+ echo "UTF8_LOCALE=${UTF8_LOCALE}" 1>&2
+ echo "UTF8_LOCALE=${UTF8_LOCALE}" 1>&3
+ echo 1>&3
+ return 0;
+}
+
+
# --- library functions ---
runtest dirent-namlen DIRENT_NAMLEN || true
runtest EFTYPE EFTYPE || true
@@ -199,7 +217,15 @@ runtest strptime STRPTIME || true
runtest strsep STRSEP || true
runtest strtonum STRTONUM || true
runtest vasprintf VASPRINTF || true
-runtest wchar WCHAR || true
+
+# --- wide character and locale support ---
+if get_locale; then
+ runtest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true
+else
+ HAVE_WCHAR=0
+ echo "wchar: no (no UTF8_LOCALE)" 1>&2
+ echo "wchar: no (no UTF8_LOCALE)" 1>&3
+fi
# --- nanosleep ---
if [ -n "${LD_NANOSLEEP}" ]; then
@@ -264,6 +290,7 @@ echo
echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\""
echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
[ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
+[ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
[ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
[ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"