Skip to content

Commit 4b22f63

Browse files
author
Junio C Hamano
committed
Merge branch 'fk/autoconf'
* fk/autoconf: New autoconf test for iconv
2 parents 5ead60e + e63ccb8 commit 4b22f63

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

configure.ac

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,32 @@ AC_CHECK_LIB([expat], [XML_ParserCreate],
114114
[NO_EXPAT=YesPlease])
115115
AC_SUBST(NO_EXPAT)
116116
#
117-
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
117+
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin and
118+
# some Solaris installations).
118119
# Define NO_ICONV if neither libc nor libiconv support iconv.
119-
AC_CHECK_LIB([c], [iconv],
120-
[NEEDS_LIBICONV=],
121-
AC_CHECK_LIB([iconv], [iconv],
122-
[NEEDS_LIBICONV=YesPlease],
123-
[NO_ICONV=YesPlease]))
120+
AC_DEFUN([ICONVTEST_SRC], [
121+
#include <iconv.h>
122+
123+
int main(void)
124+
{
125+
iconv_open("", "");
126+
return 0;
127+
}
128+
])
129+
AC_MSG_CHECKING([for iconv in -lc])
130+
AC_LINK_IFELSE(ICONVTEST_SRC,
131+
[AC_MSG_RESULT([yes])
132+
NEEDS_LIBICONV=],
133+
[AC_MSG_RESULT([no])
134+
old_LIBS="$LIBS"
135+
LIBS="$LIBS -liconv"
136+
AC_MSG_CHECKING([for iconv in -liconv])
137+
AC_LINK_IFELSE(ICONVTEST_SRC,
138+
[AC_MSG_RESULT([yes])
139+
NEEDS_LIBICONV=YesPlease],
140+
[AC_MSG_RESULT([no])
141+
NO_ICONV=YesPlease])
142+
LIBS="$old_LIBS"])
124143
AC_SUBST(NEEDS_LIBICONV)
125144
AC_SUBST(NO_ICONV)
126145
test -n "$NEEDS_LIBICONV" && LIBS="$LIBS -liconv"

0 commit comments

Comments
 (0)