[PATCH 2/3] configure.ac: define ICONV_OMITS_BOM if necessary
- From
Doan Tran Cong Danh <congdanhqx@gmail.com>
- Date
- Oct 31, 2019, 09:26 UTC
- Message-ID
- <20191031092618.29073-3-congdanhqx@gmail.com>
- In-Reply-To
- <20191031092618.29073-1-congdanhqx@gmail.com>
From commit 79444c9294, ("utf8: handle systems that don't write BOM for UTF-16", 2019-02-12), we're supporting those systems with iconv that omits BOM with:
make ICONV_OMITS_BOM=Yes
However, typing the flag all the time is cumbersome and error-prone.
Add a checking into configure script to detect this flag automatically.
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com> ---
Notes:
We deliberately fail for ac_cv_iconv_omits_bom on cross-compiling,
in order to ask builder provide the value for the target.
We're relied on this technik for ac_cv_fread_reads_directories and
ac_cv_snprintf_returns_bogus.
Adding one more failure for configuring on cross-compiling
is not going to be a burden for distro.configure.ac | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/configure.ac b/configure.ac index a43b476402..790b53bbdc 100644 --- a/configure.ac +++ b/configure.ac @@ -690,6 +690,28 @@ fi fi +# +# Define ICONV_OMITS_BOM if you are on a system which +# iconv omits bom for utf-{16,32} +if test -z "$NO_ICONV"; then +AC_CACHE_CHECK([whether iconv omits bom for utf-16 and utf-32], + [ac_cv_iconv_omits_bom], +[ +if test "x$cross_compiling" = xyes; then + AC_MSG_FAILURE([please provide ac_cv_iconv_omits_bom]) +elif test `printf a | iconv -f utf-8 -t utf-16 | wc -c` = 2; then + ac_cv_iconv_omits_bom=yes +else + ac_cv_iconv_omits_bom=no +fi +]) +if test "x$ac_cv_iconv_omits_bom" = xyes; then + ICONV_OMITS_BOM=Yes +else + ICONV_OMITS_BOM= +fi +GIT_CONF_SUBST([ICONV_OMITS_BOM]) +fi # # Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
-- 2.24.0.rc1.3.g89530838a3.dirty