Enhanced configure tests for iconv. Now aborting if not available.

This commit is contained in:
Thomas Schmitt 2010-04-15 12:16:41 +02:00
parent 1a7ab679cd
commit 9dc894584d
2 changed files with 56 additions and 1 deletions

View File

@ -50,8 +50,9 @@ dnl From Bruno Haible.
dnl dnl
AC_DEFUN([LIBBURNIA_CHECK_ICONV], AC_DEFUN([LIBBURNIA_CHECK_ICONV],
[ [
dnl Check whether it is allowed to link with -liconv dnl Check whether it is allowed to link with -liconv
AC_MSG_CHECKING([for separate -liconv ]) AC_MSG_CHECKING([for iconv() in separate -liconv ])
libburnia_liconv="no" libburnia_liconv="no"
libburnia_save_LIBS="$LIBS" libburnia_save_LIBS="$LIBS"
LIBS="$LIBS -liconv" LIBS="$LIBS -liconv"
@ -65,6 +66,13 @@ AC_DEFUN([LIBBURNIA_CHECK_ICONV],
) )
AC_MSG_RESULT([$libburnia_liconv]) AC_MSG_RESULT([$libburnia_liconv])
if test x"$libburnia_save_LIBS" = x"$LIBS"
then
dnl GNU iconv has no function iconv() but libiconv() and a macro iconv()
dnl It is not tested whether this is detected by above macro.
AC_CHECK_LIB(iconv, libiconv, , )
fi
dnl Check for iconv(..., const char **inbuf, ...) dnl Check for iconv(..., const char **inbuf, ...)
AC_MSG_CHECKING([for const qualifier with iconv() ]) AC_MSG_CHECKING([for const qualifier with iconv() ])
AC_TRY_COMPILE([ AC_TRY_COMPILE([
@ -79,6 +87,50 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si
]) ])
dnl LIBBURNIA_ASSERT_ICONV is by Thomas Schmitt, libburnia project
dnl
AC_DEFUN([LIBBURNIA_ASSERT_ICONV],
[
if test x$LIBISOFS_ASSUME_ICONV = x
then
dnl Check for the essential gestures of libisofs/util.c
AC_MSG_CHECKING([for iconv() to be accessible now ])
AC_TRY_LINK([
#include <stdlib.h>
#include <wchar.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <stdio.h>
#include <limits.h>
#include <iconv.h>
#include <locale.h>
#include <langinfo.h>
#include <unistd.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
], [iconv_test="yes"], [iconv_test="no"]
)
AC_MSG_RESULT([$iconv_test])
if test x$iconv_test = xno
then
echo >&2
echo "Cannot get function iconv() to work. Configuration aborted." >&2
echo "Check whether your system needs a separate libiconv installed." >&2
echo "If it is installed but not found, try something like" >&2
echo ' export LDFLAGS="$LDFLAGS -L/usr/local/lib"' >&2
echo ' export CPPFLAGS="$CPPFLAGS -I/usr/local/include"' >&2
echo ' export LIBS="$LIBS -liconv"' >&2
echo "You may override this test by exporting variable" >&2
echo " LIBISOFS_ASSUME_ICONV=yes" >&2
echo >&2
(exit 1); exit 1;
fi
fi
])
dnl LIBBURNIA_SET_PKGCONFIG determines the install directory for the *.pc file. dnl LIBBURNIA_SET_PKGCONFIG determines the install directory for the *.pc file.
dnl Important: Must be performed _after_ TARGET_SHIZZLE dnl Important: Must be performed _after_ TARGET_SHIZZLE
dnl dnl

View File

@ -91,6 +91,9 @@ dnl If iconv(3) is in an extra lib, then it gets added to variable LIBS.
dnl If not, then no -liconv will be added. dnl If not, then no -liconv will be added.
LIBBURNIA_CHECK_ICONV LIBBURNIA_CHECK_ICONV
dnl To abort configuration if iconv() still cannot be compiled
LIBBURNIA_ASSERT_ICONV
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS) AC_SUBST(LIBTOOL_DEPS)