1PHP_ARG_WITH([iconv], 2 [for iconv support], 3 [AS_HELP_STRING([[--without-iconv[=DIR]]], 4 [Exclude iconv support])], 5 [yes]) 6 7if test "$PHP_ICONV" != "no"; then 8 9 PHP_SETUP_ICONV(ICONV_SHARED_LIBADD, [ 10 iconv_avail="yes"; 11 ],[ 12 iconv_avail="no"; 13 ]) 14 15 if test "$iconv_avail" != "no"; then 16 save_LDFLAGS="$LDFLAGS" 17 save_CFLAGS="$CFLAGS" 18 LDFLAGS="$ICONV_SHARED_LIBADD $LDFLAGS" 19 CFLAGS="$INCLUDES $CFLAGS" 20 21 AC_MSG_CHECKING([if iconv is glibc's]) 22 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnu/libc-version.h>]], [[gnu_get_libc_version();]])],[ 23 AC_MSG_RESULT(yes) 24 iconv_impl_name="glibc" 25 ],[ 26 AC_MSG_RESULT(no) 27 ]) 28 29 if test -z "$iconv_impl_name"; then 30 AC_MSG_CHECKING([if using GNU libiconv]) 31 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 32#include <iconv.h> 33#include <stdio.h> 34int main(void) { 35 printf("%d", _libiconv_version); 36 return 0; 37} 38 ]])],[ 39 AC_MSG_RESULT(yes) 40 iconv_impl_name="gnu_libiconv" 41 ],[ 42 AC_MSG_RESULT(no) 43 ],[ 44 AC_MSG_RESULT([no, cross-compiling]) 45 ]) 46 fi 47 48 if test -z "$iconv_impl_name"; then 49 AC_MSG_CHECKING([if iconv is Konstantin Chuguev's]) 50 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], [[iconv_ccs_init(NULL, NULL);]])],[ 51 AC_MSG_RESULT(yes) 52 iconv_impl_name="bsd" 53 ],[ 54 AC_MSG_RESULT(no) 55 ]) 56 fi 57 58 if test -z "$iconv_impl_name"; then 59 AC_MSG_CHECKING([if using IBM iconv]) 60 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], [[cstoccsid("");]])],[ 61 AC_MSG_RESULT(yes) 62 iconv_impl_name="ibm" 63 ],[ 64 AC_MSG_RESULT(no) 65 ]) 66 fi 67 68 case "$iconv_impl_name" in 69 gnu_libiconv [)] 70 AC_DEFINE([PHP_ICONV_IMPL],["libiconv"],[Which iconv implementation to use]) 71 AC_DEFINE([HAVE_LIBICONV],1,[Whether libiconv is used]) 72 ;; 73 74 bsd [)] 75 AC_DEFINE([HAVE_BSD_ICONV],1,[Konstantin Chuguev's iconv implementation]) 76 AC_DEFINE([PHP_ICONV_IMPL],["BSD iconv"],[Which iconv implementation to use]) 77 ;; 78 79 glibc [)] 80 AC_DEFINE([HAVE_GLIBC_ICONV],1,[glibc's iconv implementation]) 81 AC_DEFINE([PHP_ICONV_IMPL],["glibc"],[Which iconv implementation to use]) 82 ;; 83 ibm [)] 84 AC_DEFINE([HAVE_IBM_ICONV],1,[IBM iconv implementation]) 85 AC_DEFINE([PHP_ICONV_IMPL],["IBM iconv"],[Which iconv implementation to use]) 86 ;; 87 esac 88 89 AC_MSG_CHECKING([if iconv supports errno]) 90 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 91#include <iconv.h> 92#include <errno.h> 93 94int main(void) { 95 iconv_t cd; 96 cd = iconv_open( "*blahblah*", "*blahblahblah*" ); 97 if (cd == (iconv_t)(-1)) { 98 if (errno == EINVAL) { 99 return 0; 100 } else { 101 return 1; 102 } 103 } 104 iconv_close( cd ); 105 return 2; 106} 107 ]])],[ 108 AC_MSG_RESULT(yes) 109 ],[ 110 AC_MSG_RESULT(no) 111 AC_MSG_ERROR(iconv does not support errno) 112 ],[ 113 AC_MSG_RESULT(yes, cross-compiling) 114 ]) 115 116 AC_MSG_CHECKING([if iconv supports //IGNORE]) 117 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 118#include <iconv.h> 119#include <stdlib.h> 120 121int main(void) { 122 iconv_t cd = iconv_open( "UTF-8//IGNORE", "UTF-8" ); 123 if(cd == (iconv_t)-1) { 124 return 1; 125 } 126 char *in_p = "\xC3\xC3\xC3\xB8"; 127 size_t in_left = 4, out_left = 4096; 128 char *out = malloc(out_left); 129 char *out_p = out; 130 size_t result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left); 131 if(result == (size_t)-1) { 132 return 1; 133 } 134 return 0; 135} 136 ]])],[ 137 AC_MSG_RESULT(yes) 138 AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE]) 139 ],[ 140 AC_MSG_RESULT(no) 141 AC_DEFINE([ICONV_BROKEN_IGNORE],1,[Whether iconv supports IGNORE]) 142 ],[ 143 AC_MSG_RESULT(no, cross-compiling) 144 AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE]) 145 ]) 146 147 LDFLAGS="$save_LDFLAGS" 148 CFLAGS="$save_CFLAGS" 149 150 PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) 151 PHP_SUBST(ICONV_SHARED_LIBADD) 152 PHP_INSTALL_HEADERS([ext/iconv/]) 153 else 154 AC_MSG_ERROR(Please reinstall the iconv library.) 155 fi 156fi 157