~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/iconv/config.m4

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl
 
2
dnl $Id: config.m4,v 1.27.2.2 2005/01/10 21:37:59 tony2001 Exp $
 
3
dnl
 
4
 
 
5
PHP_ARG_WITH(iconv, for iconv support,
 
6
[  --without-iconv[=DIR]   Exclude iconv support], yes)
 
7
 
 
8
if test "$PHP_ICONV" != "no"; then
 
9
 
 
10
  PHP_SETUP_ICONV(ICONV_SHARED_LIBADD, [
 
11
    iconv_avail="yes";
 
12
  ],[
 
13
    iconv_avail="no";
 
14
  ])
 
15
 
 
16
  if test "$iconv_avail" != "no"; then
 
17
    iconv_cflags_save="$CFLAGS"
 
18
    iconv_ldflags_save="$LDFLAGS"
 
19
 
 
20
    if test -z "$ICONV_DIR"; then
 
21
      PHP_ICONV_PREFIX="/usr"
 
22
    else
 
23
      PHP_ICONV_PREFIX="$ICONV_DIR"
 
24
    fi
 
25
 
 
26
    CFLAGS="-I$PHP_ICONV_PREFIX/include $CFLAGS"
 
27
    LDFLAGS="-L$PHP_ICONV_PREFIX/lib $LDFLAGS"
 
28
 
 
29
    if test -r $PHP_ICONV_PREFIX/include/giconv.h; then
 
30
      PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/giconv.h"
 
31
    else
 
32
      PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/iconv.h"
 
33
    fi 
 
34
 
 
35
    if test -z "$iconv_lib_name"; then
 
36
      AC_MSG_CHECKING([if iconv is glibc's])
 
37
      AC_TRY_LINK([#include <gnu/libc-version.h>],[gnu_get_libc_version();],
 
38
      [
 
39
        AC_MSG_RESULT(yes)
 
40
        iconv_impl_name="glibc"
 
41
      ],[
 
42
        AC_MSG_RESULT(no)
 
43
      ])
 
44
    else
 
45
      case "$iconv_lib_name" in
 
46
        iconv [)]
 
47
          AC_MSG_CHECKING([if iconv is Konstantin Chuguev's])
 
48
          AC_TRY_LINK([#include <iconv.h>],[iconv_ccs_init(NULL, NULL);],
 
49
          [
 
50
            AC_MSG_RESULT(yes)
 
51
            iconv_impl_name="bsd"
 
52
          ],[
 
53
            AC_MSG_RESULT(no)
 
54
            iconv_impl_name="gnu_libiconv"
 
55
          ])
 
56
          ;;
 
57
 
 
58
        giconv [)]
 
59
          iconv_impl_name="gnu_libiconv"
 
60
          ;;
 
61
 
 
62
        biconv [)]
 
63
          iconv_impl_name="bsd"
 
64
          ;;
 
65
      esac
 
66
    fi 
 
67
 
 
68
    echo > ext/iconv/php_have_bsd_iconv.h
 
69
    echo > ext/iconv/php_have_glibc_iconv.h
 
70
 
 
71
    case "$iconv_impl_name" in
 
72
      gnu_libiconv [)]
 
73
        PHP_DEFINE([PHP_ICONV_IMPL],[\"libiconv\"],[ext/iconv])
 
74
        AC_DEFINE([PHP_ICONV_IMPL],["libiconv"],[Which iconv implementation to use])
 
75
        ;;
 
76
 
 
77
      bsd [)]
 
78
        PHP_DEFINE([HAVE_BSD_ICONV],1,[ext/iconv])
 
79
        AC_DEFINE([HAVE_BSD_ICONV],1,[Konstantin Chuguev's iconv implementation])
 
80
        PHP_DEFINE([PHP_ICONV_IMPL],[\"BSD iconv\"],[ext/iconv])
 
81
        AC_DEFINE([PHP_ICONV_IMPL],["BSD iconv"],[Which iconv implementation to use])
 
82
        ;;
 
83
 
 
84
      glibc [)]
 
85
        PHP_DEFINE([HAVE_GLIBC_ICONV],1,[ext/iconv])
 
86
        AC_DEFINE([HAVE_GLIBC_ICONV],1,[glibc's iconv implementation])
 
87
        PHP_DEFINE([PHP_ICONV_IMPL],[\"glibc\"],[ext/iconv])
 
88
        AC_DEFINE([PHP_ICONV_IMPL],["glibc"],[Which iconv implementation to use])
 
89
        ;;
 
90
    esac
 
91
 
 
92
    AC_MSG_CHECKING([if iconv supports errno])
 
93
    AC_TRY_RUN([
 
94
#include <$PHP_ICONV_H_PATH>
 
95
#include <errno.h>
 
96
 
 
97
int main() {
 
98
  iconv_t cd;
 
99
  cd = iconv_open( "*blahblah*", "*blahblah*" );
 
100
  if (cd == (iconv_t)(-1)) {
 
101
    if (errno == EINVAL) {
 
102
      return 0;
 
103
        } else {
 
104
      return 1;
 
105
    }
 
106
  }
 
107
  iconv_close( cd );
 
108
  return 2;
 
109
}
 
110
    ],[
 
111
      AC_MSG_RESULT(yes)
 
112
      PHP_DEFINE([ICONV_SUPPORTS_ERRNO],1,[ext/iconv])
 
113
      AC_DEFINE([ICONV_SUPPORTS_ERRNO],1,[Whether iconv supports error no or not])
 
114
    ],[
 
115
      AC_MSG_RESULT(no)
 
116
      PHP_DEFINE([ICONV_SUPPORTS_ERRNO],0,[ext/iconv])
 
117
      AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports error no or not])
 
118
    ])
 
119
 
 
120
    AC_MSG_CHECKING([if your cpp allows macro usage in include lines])
 
121
    AC_TRY_COMPILE([
 
122
#define FOO <$PHP_ICONV_H_PATH>
 
123
#include FOO
 
124
    ], [], [
 
125
      AC_MSG_RESULT([yes])
 
126
      PHP_DEFINE([PHP_ICONV_H_PATH], [<$PHP_ICONV_H_PATH>],[ext/iconv])
 
127
      AC_DEFINE_UNQUOTED([PHP_ICONV_H_PATH], [<$PHP_ICONV_H_PATH>], [Path to iconv.h])
 
128
    ], [
 
129
      AC_MSG_RESULT([no])
 
130
    ])
 
131
 
 
132
    CFLAGS="$iconv_cflags_save"
 
133
    LDFLAGS="$iconv_ldflags_save"
 
134
 
 
135
    PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-I\"$PHP_ICONV_PREFIX/include\"])
 
136
    PHP_SUBST(ICONV_SHARED_LIBADD)
 
137
  else
 
138
    AC_MSG_ERROR(Please reinstall the iconv library.)
 
139
  fi
 
140
fi