summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2023-12-28 01:08:10 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2023-12-30 01:37:15 +0100
commit7c07ae2431668dd92c4417b0f4d3d0a88d4cf9da (patch)
tree9f01d84fd5e942d67e97ba8fb0900af0c776e5bf /configure.ac
parent3ac33673869b6f1ae1a29a329e5fa5c100bdd562 (diff)
Search for libiconv before libc
In BSD systems where libiconv provides /usr/local/include/iconv.h and libc provides /usr/include/iconv.h there is a problem when we can use the headers of libiconv but end up linking with libc. The workaround is to search first for libiconv, and if not found assume it is safe to link with the libc.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac17
1 files changed, 12 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 7317245f..6dfdf9a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -427,13 +427,20 @@ fi
AM_CONDITIONAL([USE_OPENSSL], [test "x$openssl_ok" = "xyes"])
AM_CONDITIONAL([USE_MBEDTLS], [test "x$mbedtls_ok" = "xyes"])
-dnl --------------------------------------------------------------
-dnl Test for iconv functionality in libc or for libiconv usability
-dnl --------------------------------------------------------------
+dnl ----------------------------------------------------------------
+dnl Test for iconv implementation first in libiconv and then in libc
+dnl ----------------------------------------------------------------
AC_CHECK_HEADER(iconv.h, iconv_ok=yes, iconv_ok=no)
if test "x$iconv_ok" = "xyes"; then
- AC_CHECK_LIB(c, iconv_open, LIBICONV_LIBS="",
- AC_CHECK_LIB(iconv, iconv_open, LIBICONV_LIBS="-liconv", iconv_ok=no))
+ dnl First try to link with the libiconv library if available, otherwise
+ dnl fall back to the implementation of libc. It is required to be done
+ dnl in this order because FreeBSD distributes libiconv headers in
+ dnl /usr/include/local/iconv.h, in the same place the headers for FLTK
+ dnl are placed. If we select to link with libc, the headers provided by
+ dnl libiconv will be used while linking with libc. This causes a linkage
+ dnl error.
+ AC_CHECK_LIB(iconv, iconv_open, LIBICONV_LIBS="-liconv",
+ AC_CHECK_LIB(c, iconv_open, LIBICONV_LIBS="", iconv_ok=no))
fi
if test "x$iconv_ok" = "xno"; then
dnl Test for OpenBSD