1dnl 2dnl $Id$ 3dnl 4 5AC_DEFUN([PHP_MBSTRING_ADD_SOURCES], [ 6 PHP_MBSTRING_SOURCES="$PHP_MBSTRING_SOURCES $1" 7]) 8 9AC_DEFUN([PHP_MBSTRING_ADD_BASE_SOURCES], [ 10 PHP_MBSTRING_BASE_SOURCES="$PHP_MBSTRING_BASE_SOURCES $1" 11]) 12 13AC_DEFUN([PHP_MBSTRING_ADD_BUILD_DIR], [ 14 PHP_MBSTRING_EXTRA_BUILD_DIRS="$PHP_MBSTRING_EXTRA_BUILD_DIRS $1" 15]) 16 17AC_DEFUN([PHP_MBSTRING_ADD_INCLUDE], [ 18 PHP_MBSTRING_EXTRA_INCLUDES="$PHP_MBSTRING_EXTRA_INCLUDES $1" 19]) 20 21AC_DEFUN([PHP_MBSTRING_ADD_CONFIG_HEADER], [ 22 PHP_MBSTRING_EXTRA_CONFIG_HEADERS="$PHP_MBSTRING_EXTRA_CONFIG_HEADERS $1" 23]) 24 25AC_DEFUN([PHP_MBSTRING_ADD_CFLAG], [ 26 PHP_MBSTRING_CFLAGS="$PHP_MBSTRING_CFLAGS $1" 27]) 28 29AC_DEFUN([PHP_MBSTRING_ADD_INSTALL_HEADERS], [ 30 PHP_MBSTRING_INSTALL_HEADERS="$PHP_MBSTRING_INSTALL_HEADERS $1" 31]) 32 33AC_DEFUN([PHP_MBSTRING_EXTENSION], [ 34 PHP_NEW_EXTENSION(mbstring, $PHP_MBSTRING_SOURCES, $ext_shared,, $PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) 35 PHP_SUBST(MBSTRING_SHARED_LIBADD) 36 37 for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do 38 PHP_ADD_BUILD_DIR([$ext_builddir/$dir], 1) 39 done 40 41 for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do 42 PHP_ADD_INCLUDE([$ext_srcdir/$dir]) 43 PHP_ADD_INCLUDE([$ext_builddir/$dir]) 44 done 45 46 if test "$ext_shared" = "no"; then 47 PHP_ADD_SOURCES(PHP_EXT_DIR(mbstring), $PHP_MBSTRING_BASE_SOURCES) 48 out="php_config.h" 49 else 50 PHP_ADD_SOURCES_X(PHP_EXT_DIR(mbstring),$PHP_MBSTRING_BASE_SOURCES,,shared_objects_mbstring,yes) 51 if test -f "$ext_builddir/config.h.in"; then 52 out="$abs_builddir/config.h" 53 else 54 out="php_config.h" 55 fi 56 fi 57 58 if test "$PHP_MBSTRING_BUNDLED_ONIG" = "1"; then 59 cp $ext_srcdir/oniguruma/src/oniguruma.h $ext_srcdir/oniguruma/oniguruma.h 60 fi 61 62 for cfg in $PHP_MBSTRING_EXTRA_CONFIG_HEADERS; do 63 cat > $ext_builddir/$cfg <<EOF 64#include "$out" 65EOF 66 done 67 PHP_MBSTRING_ADD_INSTALL_HEADERS([mbstring.h]) 68 PHP_INSTALL_HEADERS([ext/mbstring], [$PHP_MBSTRING_INSTALL_HEADERS]) 69]) 70 71AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [ 72 if test "$PHP_MBREGEX" = "yes"; then 73 if test "$PHP_ONIG" = "yes" || test "$PHP_ONIG" = "no"; then 74 dnl 75 dnl Bundled oniguruma 76 dnl 77 PHP_MBSTRING_BUNDLED_ONIG=1 78 if test "$PHP_MBREGEX_BACKTRACK" != "no"; then 79 AC_DEFINE([USE_COMBINATION_EXPLOSION_CHECK],1,[whether to check multibyte regex backtrack]) 80 fi 81 82 AC_CACHE_CHECK(for variable length prototypes and stdarg.h, php_cv_mbstring_stdarg, [ 83 AC_TRY_RUN([ 84#include <stdarg.h> 85int foo(int x, ...) { 86 va_list va; 87 va_start(va, x); 88 va_arg(va, int); 89 va_arg(va, char *); 90 va_arg(va, double); 91 return 0; 92} 93int main() { return foo(10, "", 3.14); } 94 ], [php_cv_mbstring_stdarg=yes], [php_cv_mbstring_stdarg=no], [ 95 php_cv_mbstring_stdarg=no 96 ]) 97 ]) 98 99 AC_CHECK_HEADERS([stdlib.h string.h strings.h unistd.h sys/time.h sys/times.h stdarg.h]) 100 AC_CHECK_SIZEOF(int, 4) 101 AC_CHECK_SIZEOF(short, 2) 102 AC_CHECK_SIZEOF(long, 4) 103 AC_C_CONST 104 AC_HEADER_TIME 105 AC_FUNC_ALLOCA 106 AC_FUNC_MEMCMP 107 AC_CHECK_HEADER([stdarg.h], [ 108 AC_DEFINE([HAVE_STDARG_PROTOTYPES], [1], [Define to 1 if you have the <stdarg.h> header file.]) 109 ], []) 110 AC_DEFINE([PHP_ONIG_BUNDLED], [1], [Define to 1 if the bundled oniguruma is used]) 111 AC_DEFINE([HAVE_ONIG], [1], [Define to 1 if the oniguruma library is available]) 112 PHP_MBSTRING_ADD_CFLAG([-DNOT_RUBY]) 113 PHP_MBSTRING_ADD_BUILD_DIR([oniguruma]) 114 PHP_MBSTRING_ADD_BUILD_DIR([oniguruma/src]) 115 PHP_MBSTRING_ADD_INCLUDE([oniguruma]) 116 PHP_MBSTRING_ADD_CONFIG_HEADER([oniguruma/src/config.h]) 117 PHP_MBSTRING_ADD_SOURCES([ 118 oniguruma/src/ascii.c 119 oniguruma/src/big5.c 120 oniguruma/src/cp1251.c 121 oniguruma/src/euc_jp.c 122 oniguruma/src/euc_jp_prop.c 123 oniguruma/src/euc_kr.c 124 oniguruma/src/euc_tw.c 125 oniguruma/src/gb18030.c 126 oniguruma/src/iso8859_1.c 127 oniguruma/src/iso8859_10.c 128 oniguruma/src/iso8859_11.c 129 oniguruma/src/iso8859_13.c 130 oniguruma/src/iso8859_14.c 131 oniguruma/src/iso8859_15.c 132 oniguruma/src/iso8859_16.c 133 oniguruma/src/iso8859_2.c 134 oniguruma/src/iso8859_3.c 135 oniguruma/src/iso8859_4.c 136 oniguruma/src/iso8859_5.c 137 oniguruma/src/iso8859_6.c 138 oniguruma/src/iso8859_7.c 139 oniguruma/src/iso8859_8.c 140 oniguruma/src/iso8859_9.c 141 oniguruma/src/koi8.c 142 oniguruma/src/koi8_r.c 143 oniguruma/src/onig_init.c 144 oniguruma/src/regcomp.c 145 oniguruma/src/regenc.c 146 oniguruma/src/regerror.c 147 oniguruma/src/regexec.c 148 oniguruma/src/regext.c 149 oniguruma/src/reggnu.c 150 oniguruma/src/regparse.c 151 oniguruma/src/regposerr.c 152 oniguruma/src/regposix.c 153 oniguruma/src/regsyntax.c 154 oniguruma/src/regtrav.c 155 oniguruma/src/regversion.c 156 oniguruma/src/sjis.c 157 oniguruma/src/sjis_prop.c 158 oniguruma/src/st.c 159 oniguruma/src/unicode.c 160 oniguruma/src/unicode_fold1_key.c 161 oniguruma/src/unicode_fold2_key.c 162 oniguruma/src/unicode_fold3_key.c 163 oniguruma/src/unicode_unfold_key.c 164 oniguruma/src/utf16_be.c 165 oniguruma/src/utf16_le.c 166 oniguruma/src/utf32_be.c 167 oniguruma/src/utf32_le.c 168 oniguruma/src/utf8.c 169 ]) 170 PHP_MBSTRING_ADD_INSTALL_HEADERS([oniguruma/oniguruma.h]) 171 else 172 dnl 173 dnl External oniguruma 174 dnl 175 PHP_MBSTRING_BUNDLED_ONIG=0 176 if test ! -f "$PHP_ONIG/include/oniguruma.h"; then 177 AC_MSG_ERROR([oniguruma.h not found in $PHP_ONIG/include]) 178 fi 179 PHP_ADD_INCLUDE([$PHP_ONIG/include]) 180 181 PHP_CHECK_LIBRARY(onig, onig_init, [ 182 PHP_ADD_LIBRARY_WITH_PATH(onig, $PHP_ONIG/$PHP_LIBDIR, MBSTRING_SHARED_LIBADD) 183 AC_DEFINE([HAVE_ONIG], [1], [Define to 1 if the oniguruma library is available]) 184 ],[ 185 AC_MSG_ERROR([Problem with oniguruma. Please check config.log for more information.]) 186 ], [ 187 -L$PHP_ONIG/$PHP_LIBDIR 188 ]) 189 190 save_old_LDFLAGS=$LDFLAGS 191 PHP_EVAL_LIBLINE([$MBSTRING_SHARED_LIBADD], LDFLAGS) 192 AC_MSG_CHECKING([if oniguruma has an invalid entry for KOI8 encoding]) 193 AC_TRY_LINK([ 194#include <oniguruma.h> 195 ], [ 196return (int)(ONIG_ENCODING_KOI8 + 1); 197 ], [ 198 AC_MSG_RESULT([no]) 199 ], [ 200 AC_MSG_RESULT([yes]) 201 AC_DEFINE([PHP_ONIG_BAD_KOI8_ENTRY], [1], [define to 1 if oniguruma has an invalid entry for KOI8 encoding]) 202 ]) 203 LDFLAGS=$save_old_LDFLAGS 204 fi 205 206 PHP_MBSTRING_ADD_CFLAG([-DONIG_ESCAPE_UCHAR_COLLISION=1]) 207 PHP_MBSTRING_ADD_CFLAG([-DUChar=OnigUChar]) 208 209 AC_DEFINE([HAVE_MBREGEX], 1, [whether to have multibyte regex support]) 210 211 PHP_MBSTRING_ADD_BASE_SOURCES([php_mbregex.c]) 212 PHP_MBSTRING_ADD_INSTALL_HEADERS([php_mbregex.h php_onig_compat.h]) 213 fi 214]) 215 216AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [ 217 dnl libmbfl is required and can not be disabled 218 if test "$PHP_LIBMBFL" = "yes" || test "$PHP_LIBMBFL" = "no"; then 219 dnl 220 dnl Bundled libmbfl 221 dnl 222 PHP_MBSTRING_ADD_BUILD_DIR([libmbfl]) 223 PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/mbfl]) 224 PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/filters]) 225 PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/nls]) 226 PHP_MBSTRING_ADD_INCLUDE([libmbfl]) 227 PHP_MBSTRING_ADD_INCLUDE([libmbfl/mbfl]) 228 PHP_MBSTRING_ADD_CONFIG_HEADER([libmbfl/config.h]) 229 230 PHP_MBSTRING_ADD_SOURCES([ 231 libmbfl/filters/html_entities.c 232 libmbfl/filters/mbfilter_7bit.c 233 libmbfl/filters/mbfilter_ascii.c 234 libmbfl/filters/mbfilter_base64.c 235 libmbfl/filters/mbfilter_big5.c 236 libmbfl/filters/mbfilter_byte2.c 237 libmbfl/filters/mbfilter_byte4.c 238 libmbfl/filters/mbfilter_cp1251.c 239 libmbfl/filters/mbfilter_cp1252.c 240 libmbfl/filters/mbfilter_cp1254.c 241 libmbfl/filters/mbfilter_cp5022x.c 242 libmbfl/filters/mbfilter_cp51932.c 243 libmbfl/filters/mbfilter_cp850.c 244 libmbfl/filters/mbfilter_cp866.c 245 libmbfl/filters/mbfilter_cp932.c 246 libmbfl/filters/mbfilter_cp936.c 247 libmbfl/filters/mbfilter_gb18030.c 248 libmbfl/filters/mbfilter_euc_cn.c 249 libmbfl/filters/mbfilter_euc_jp.c 250 libmbfl/filters/mbfilter_euc_jp_2004.c 251 libmbfl/filters/mbfilter_euc_jp_win.c 252 libmbfl/filters/mbfilter_euc_kr.c 253 libmbfl/filters/mbfilter_euc_tw.c 254 libmbfl/filters/mbfilter_htmlent.c 255 libmbfl/filters/mbfilter_hz.c 256 libmbfl/filters/mbfilter_iso2022_jp_ms.c 257 libmbfl/filters/mbfilter_iso2022jp_2004.c 258 libmbfl/filters/mbfilter_iso2022jp_mobile.c 259 libmbfl/filters/mbfilter_iso2022_kr.c 260 libmbfl/filters/mbfilter_iso8859_1.c 261 libmbfl/filters/mbfilter_iso8859_10.c 262 libmbfl/filters/mbfilter_iso8859_13.c 263 libmbfl/filters/mbfilter_iso8859_14.c 264 libmbfl/filters/mbfilter_iso8859_15.c 265 libmbfl/filters/mbfilter_iso8859_16.c 266 libmbfl/filters/mbfilter_iso8859_2.c 267 libmbfl/filters/mbfilter_iso8859_3.c 268 libmbfl/filters/mbfilter_iso8859_4.c 269 libmbfl/filters/mbfilter_iso8859_5.c 270 libmbfl/filters/mbfilter_iso8859_6.c 271 libmbfl/filters/mbfilter_iso8859_7.c 272 libmbfl/filters/mbfilter_iso8859_8.c 273 libmbfl/filters/mbfilter_iso8859_9.c 274 libmbfl/filters/mbfilter_jis.c 275 libmbfl/filters/mbfilter_koi8r.c 276 libmbfl/filters/mbfilter_armscii8.c 277 libmbfl/filters/mbfilter_qprint.c 278 libmbfl/filters/mbfilter_sjis.c 279 libmbfl/filters/mbfilter_sjis_open.c 280 libmbfl/filters/mbfilter_sjis_mobile.c 281 libmbfl/filters/mbfilter_sjis_mac.c 282 libmbfl/filters/mbfilter_sjis_2004.c 283 libmbfl/filters/mbfilter_tl_jisx0201_jisx0208.c 284 libmbfl/filters/mbfilter_ucs2.c 285 libmbfl/filters/mbfilter_ucs4.c 286 libmbfl/filters/mbfilter_uhc.c 287 libmbfl/filters/mbfilter_utf16.c 288 libmbfl/filters/mbfilter_utf32.c 289 libmbfl/filters/mbfilter_utf7.c 290 libmbfl/filters/mbfilter_utf7imap.c 291 libmbfl/filters/mbfilter_utf8.c 292 libmbfl/filters/mbfilter_utf8_mobile.c 293 libmbfl/filters/mbfilter_uuencode.c 294 libmbfl/filters/mbfilter_koi8u.c 295 libmbfl/mbfl/mbfilter.c 296 libmbfl/mbfl/mbfilter_8bit.c 297 libmbfl/mbfl/mbfilter_pass.c 298 libmbfl/mbfl/mbfilter_wchar.c 299 libmbfl/mbfl/mbfl_convert.c 300 libmbfl/mbfl/mbfl_encoding.c 301 libmbfl/mbfl/mbfl_filter_output.c 302 libmbfl/mbfl/mbfl_ident.c 303 libmbfl/mbfl/mbfl_language.c 304 libmbfl/mbfl/mbfl_memory_device.c 305 libmbfl/mbfl/mbfl_string.c 306 libmbfl/mbfl/mbfl_allocators.c 307 libmbfl/nls/nls_de.c 308 libmbfl/nls/nls_en.c 309 libmbfl/nls/nls_ja.c 310 libmbfl/nls/nls_kr.c 311 libmbfl/nls/nls_neutral.c 312 libmbfl/nls/nls_ru.c 313 libmbfl/nls/nls_uni.c 314 libmbfl/nls/nls_zh.c 315 libmbfl/nls/nls_hy.c 316 libmbfl/nls/nls_tr.c 317 libmbfl/nls/nls_ua.c 318 ]) 319 PHP_MBSTRING_ADD_CFLAG([-DHAVE_CONFIG_H]) 320 PHP_MBSTRING_ADD_INSTALL_HEADERS([libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_allocators.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_ident.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h]) 321 else 322 dnl 323 dnl External libmfl 324 dnl 325 for inc in include include/mbfl-1.0 include/mbfl; do 326 if test -f "$PHP_LIBMBFL/$inc/mbfilter.h"; then 327 PHP_LIBMBFL_INCLUDE="$inc" 328 break 329 fi 330 done 331 332 if test -z "$PHP_LIBMBFL_INCLUDE"; then 333 AC_MSG_ERROR([mbfilter.h not found. Please reinstall libmbfl library.]) 334 else 335 PHP_ADD_INCLUDE([$PHP_LIBMBFL_INCLUDE]) 336 fi 337 338 PHP_CHECK_LIBRARY(mbfl, mbfl_buffer_converter_new, [ 339 PHP_ADD_LIBRARY_WITH_PATH(mbfl, $PHP_LIBMBFL/$PHP_LIBDIR, MBSTRING_SHARED_LIBADD) 340 ],[ 341 AC_MSG_ERROR([Problem with libmbfl. Please check config.log for more information.]) 342 ], [ 343 -L$PHP_LIBMBFL/$PHP_LIBDIR 344 ]) 345 fi 346]) 347 348dnl 349dnl Main config 350dnl 351 352PHP_ARG_ENABLE(mbstring, whether to enable multibyte string support, 353[ --enable-mbstring Enable multibyte string support]) 354 355PHP_ARG_ENABLE([mbregex], [whether to enable multibyte regex support], 356[ --disable-mbregex MBSTRING: Disable multibyte regex support], yes, no) 357 358PHP_ARG_ENABLE([mbregex_backtrack], [whether to check multibyte regex backtrack], 359[ --disable-mbregex-backtrack 360 MBSTRING: Disable multibyte regex backtrack check], yes, no) 361 362PHP_ARG_WITH(libmbfl, [for external libmbfl], 363[ --with-libmbfl[=DIR] MBSTRING: Use external libmbfl. DIR is the libmbfl base 364 install directory [BUNDLED]], no, no) 365 366PHP_ARG_WITH(onig, [for external oniguruma], 367[ --with-onig[=DIR] MBSTRING: Use external oniguruma. DIR is the oniguruma install prefix. 368 If DIR is not set, the bundled oniguruma will be used], no, no) 369 370if test "$PHP_MBSTRING" != "no"; then 371 AC_DEFINE([HAVE_MBSTRING],1,[whether to have multibyte string support]) 372 373 PHP_MBSTRING_ADD_BASE_SOURCES([mbstring.c php_unicode.c mb_gpc.c]) 374 375 if test "$PHP_MBREGEX" != "no"; then 376 PHP_MBSTRING_SETUP_MBREGEX 377 fi 378 379 dnl libmbfl is required 380 PHP_MBSTRING_SETUP_LIBMBFL 381 PHP_MBSTRING_EXTENSION 382fi 383 384# vim600: sts=2 sw=2 et 385