mirror of
https://github.com/php/php-src.git
synced 2026-04-05 07:02:33 +02:00
The next generation of C compilers is going to enforce the C standard more strictly: https://wiki.gentoo.org/wiki/Modern_C_porting One warning that will eventually become an error is -Wimplicit-function-declaration. This is relatively easy to catch in most code (it will fail to compile), but inside of autoconf tests it can go unnoticed because many feature-test compilations fail by design. For example, AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], [[iconv_ccs_init(NULL, NULL);]])]... is designed to fail if iconv_ccs_init() is not in iconv.h. On the other hand, AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <iconv.h> int main() { printf("%d", _libiconv_version); return 0; } should pass if _libiconv_version is defined. If the user has -Werror=implicit-function-declaration in his CFLAGS, however, it will not: $ export CFLAGS="$CFLAGS -Werror=implicit-function-declaration" $ ./configure ... checking if using GNU libiconv... no This is because the stdio.h header that defines printf() is missing: conftest.c:240:3: error: implicit declaration of function 'printf' [-Werror=implicit-function-declaration] 240 | printf("%d", _libiconv_version); | ^~~~~~ conftest.c:239:1: note: include '<stdio.h>' or provide a declaration of 'printf' This commit adds the include, correcting the test with any compiler that balks at implicit function definitions. Closes GH-10751
157 lines
4.0 KiB
Plaintext
157 lines
4.0 KiB
Plaintext
PHP_ARG_WITH([iconv],
|
|
[for iconv support],
|
|
[AS_HELP_STRING([[--without-iconv[=DIR]]],
|
|
[Exclude iconv support])],
|
|
[yes])
|
|
|
|
if test "$PHP_ICONV" != "no"; then
|
|
|
|
PHP_SETUP_ICONV(ICONV_SHARED_LIBADD, [
|
|
iconv_avail="yes";
|
|
],[
|
|
iconv_avail="no";
|
|
])
|
|
|
|
if test "$iconv_avail" != "no"; then
|
|
save_LDFLAGS="$LDFLAGS"
|
|
save_CFLAGS="$CFLAGS"
|
|
LDFLAGS="$ICONV_SHARED_LIBADD $LDFLAGS"
|
|
CFLAGS="$INCLUDES $CFLAGS"
|
|
|
|
AC_MSG_CHECKING([if iconv is glibc's])
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gnu/libc-version.h>]], [[gnu_get_libc_version();]])],[
|
|
AC_MSG_RESULT(yes)
|
|
iconv_impl_name="glibc"
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
])
|
|
|
|
if test -z "$iconv_impl_name"; then
|
|
AC_MSG_CHECKING([if using GNU libiconv])
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
|
#include <iconv.h>
|
|
#include <stdio.h>
|
|
int main(void) {
|
|
printf("%d", _libiconv_version);
|
|
return 0;
|
|
}
|
|
]])],[
|
|
AC_MSG_RESULT(yes)
|
|
iconv_impl_name="gnu_libiconv"
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
],[
|
|
AC_MSG_RESULT([no, cross-compiling])
|
|
])
|
|
fi
|
|
|
|
if test -z "$iconv_impl_name"; then
|
|
AC_MSG_CHECKING([if iconv is Konstantin Chuguev's])
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], [[iconv_ccs_init(NULL, NULL);]])],[
|
|
AC_MSG_RESULT(yes)
|
|
iconv_impl_name="bsd"
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
])
|
|
fi
|
|
|
|
if test -z "$iconv_impl_name"; then
|
|
AC_MSG_CHECKING([if using IBM iconv])
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], [[cstoccsid("");]])],[
|
|
AC_MSG_RESULT(yes)
|
|
iconv_impl_name="ibm"
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
])
|
|
fi
|
|
|
|
case "$iconv_impl_name" in
|
|
gnu_libiconv [)]
|
|
AC_DEFINE([PHP_ICONV_IMPL],["libiconv"],[Which iconv implementation to use])
|
|
AC_DEFINE([HAVE_LIBICONV],1,[Whether libiconv is used])
|
|
;;
|
|
|
|
bsd [)]
|
|
AC_DEFINE([HAVE_BSD_ICONV],1,[Konstantin Chuguev's iconv implementation])
|
|
AC_DEFINE([PHP_ICONV_IMPL],["BSD iconv"],[Which iconv implementation to use])
|
|
;;
|
|
|
|
glibc [)]
|
|
AC_DEFINE([HAVE_GLIBC_ICONV],1,[glibc's iconv implementation])
|
|
AC_DEFINE([PHP_ICONV_IMPL],["glibc"],[Which iconv implementation to use])
|
|
;;
|
|
ibm [)]
|
|
AC_DEFINE([HAVE_IBM_ICONV],1,[IBM iconv implementation])
|
|
AC_DEFINE([PHP_ICONV_IMPL],["IBM iconv"],[Which iconv implementation to use])
|
|
;;
|
|
esac
|
|
|
|
AC_MSG_CHECKING([if iconv supports errno])
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
|
#include <iconv.h>
|
|
#include <errno.h>
|
|
|
|
int main(void) {
|
|
iconv_t cd;
|
|
cd = iconv_open( "*blahblah*", "*blahblahblah*" );
|
|
if (cd == (iconv_t)(-1)) {
|
|
if (errno == EINVAL) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
iconv_close( cd );
|
|
return 2;
|
|
}
|
|
]])],[
|
|
AC_MSG_RESULT(yes)
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
AC_MSG_ERROR(iconv does not support errno)
|
|
],[
|
|
AC_MSG_RESULT(yes, cross-compiling)
|
|
])
|
|
|
|
AC_MSG_CHECKING([if iconv supports //IGNORE])
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
|
#include <iconv.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(void) {
|
|
iconv_t cd = iconv_open( "UTF-8//IGNORE", "UTF-8" );
|
|
if(cd == (iconv_t)-1) {
|
|
return 1;
|
|
}
|
|
char *in_p = "\xC3\xC3\xC3\xB8";
|
|
size_t in_left = 4, out_left = 4096;
|
|
char *out = malloc(out_left);
|
|
char *out_p = out;
|
|
size_t result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left);
|
|
if(result == (size_t)-1) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
]])],[
|
|
AC_MSG_RESULT(yes)
|
|
AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE])
|
|
],[
|
|
AC_MSG_RESULT(no)
|
|
AC_DEFINE([ICONV_BROKEN_IGNORE],1,[Whether iconv supports IGNORE])
|
|
],[
|
|
AC_MSG_RESULT(no, cross-compiling)
|
|
AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE])
|
|
])
|
|
|
|
LDFLAGS="$save_LDFLAGS"
|
|
CFLAGS="$save_CFLAGS"
|
|
|
|
PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
|
|
PHP_SUBST(ICONV_SHARED_LIBADD)
|
|
PHP_INSTALL_HEADERS([ext/iconv/])
|
|
else
|
|
AC_MSG_ERROR(Please reinstall the iconv library.)
|
|
fi
|
|
fi
|