summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2020-02-16 14:25:06 +0100
committerMichael Stapelberg <michael@stapelberg.de>2020-02-16 18:38:44 +0100
commit91b00c5605955ec8167fbbedd5dfe7d722ac9639 (patch)
tree3d93bddcda6a0d596eb54d521cb4999fd50e7156
parentf517b5aa57216a6c55fc00053dfaad378d9392fa (diff)
downloadi3-91b00c5605955ec8167fbbedd5dfe7d722ac9639.tar.gz
i3-91b00c5605955ec8167fbbedd5dfe7d722ac9639.zip
configure.ac: test for iconv_open with #include <iconv.h>
The previously used AC_SEARCH_LIBS uses AC_LANG_CALL, which is discouraged because it intentionally violates the C type system: it has no way of specifying function parameters, so it does not include the required headers to suppress type warnings: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Generating-Sources.html The new code does what AC_SEARCH_LIBS does, but uses AC_LANG_PROGRAM instead of AC_LANG_CALL. It explicitly includes iconv.h and calls iconv_open with the correct number and type of arguments. This fixes compilation on systems where libiconv’s iconv.h is discovered first, but glibc also provides iconv. Previously, this would result in configure discovering glibc’s iconv, and make failing to compile because -liconv wasn’t specified, but iconv.h pulled in libiconv.
-rw-r--r--configure.ac7
1 files changed, 5 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 0b99cf80..3ab6345e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,8 +84,11 @@ AC_SEARCH_LIBS([ev_run], [ev], , [AC_MSG_FAILURE([cannot find the required ev_ru
AC_SEARCH_LIBS([shm_open], [rt], [], [], [-pthread])
-AC_SEARCH_LIBS([iconv_open], [iconv], ,
-AC_SEARCH_LIBS([libiconv_open], [iconv], , [AC_MSG_FAILURE([cannot find the required iconv_open() function despite trying to link with -liconv])]))
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <iconv.h>], [iconv_open(0, 0)])], ,
+ [LIBS="-liconv $LIBS"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <iconv.h>], [iconv_open(0, 0)])], ,
+ [AC_MSG_FAILURE([cannot find the required iconv_open() function despite trying to link with -liconv])])]
+)
AX_PTHREAD