New module 'iconv_open'.
[gnulib.git] / m4 / iconv_open.m4
1 # iconv_open.m4 serial 1
2 dnl Copyright (C) 2007 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_ICONV_OPEN],
8 [
9   AC_REQUIRE([AM_ICONV])
10   AC_REQUIRE([AC_CANONICAL_HOST])
11   AC_REQUIRE([gl_ICONV_H_DEFAULTS])
12   if test "$am_cv_func_iconv" = yes; then
13     dnl Test whether iconv_open accepts standardized encoding names.
14     dnl We know that GNU libiconv and GNU libc do.
15     AC_EGREP_CPP([gnu_iconv], [
16       #include <iconv.h>
17       #if defined _LIBICONV_VERSION || defined __GLIBC__
18        gnu_iconv
19       #endif
20       ], [gl_func_iconv_gnu=yes], [gl_func_iconv_gnu=no])
21     if test $gl_func_iconv_gnu = no; then
22       iconv_flavor=
23       case "$host_os" in
24         aix*)  iconv_flavor=ICONV_FLAVOR_AIX ;;
25         irix*) iconv_flavor=ICONV_FLAVOR_IRIX ;;
26         hpux*) iconv_flavor=ICONV_FLAVOR_HPUX ;;
27         osf*)  iconv_flavor=ICONV_FLAVOR_OSF ;;
28       esac
29       if test -n "$iconv_flavor"; then
30         AC_DEFINE_UNQUOTED([ICONV_FLAVOR], [$iconv_flavor],
31           [Define to a symbolic name denoting the flavor of iconv_open()
32            implementation.])
33         REPLACE_ICONV_OPEN=1
34         AC_LIBOBJ([iconv_open])
35         ICONV_H='iconv.h'
36       fi
37     fi
38   fi
39 ])
40