1AC_DEFUN([PHP_MBSTRING_ADD_SOURCES], [
2  PHP_MBSTRING_SOURCES="$PHP_MBSTRING_SOURCES $1"
3])
4
5AC_DEFUN([PHP_MBSTRING_ADD_BASE_SOURCES], [
6  PHP_MBSTRING_BASE_SOURCES="$PHP_MBSTRING_BASE_SOURCES $1"
7])
8
9AC_DEFUN([PHP_MBSTRING_ADD_BUILD_DIR], [
10  PHP_MBSTRING_EXTRA_BUILD_DIRS="$PHP_MBSTRING_EXTRA_BUILD_DIRS $1"
11])
12
13AC_DEFUN([PHP_MBSTRING_ADD_INCLUDE], [
14  PHP_MBSTRING_EXTRA_INCLUDES="$PHP_MBSTRING_EXTRA_INCLUDES $1"
15])
16
17AC_DEFUN([PHP_MBSTRING_ADD_CFLAG], [
18  PHP_MBSTRING_CFLAGS="$PHP_MBSTRING_CFLAGS $1"
19])
20
21AC_DEFUN([PHP_MBSTRING_ADD_INSTALL_HEADERS], [
22  PHP_MBSTRING_INSTALL_HEADERS="$PHP_MBSTRING_INSTALL_HEADERS $1"
23])
24
25AC_DEFUN([PHP_MBSTRING_EXTENSION], [
26  PHP_NEW_EXTENSION(mbstring, $PHP_MBSTRING_BASE_SOURCES $PHP_MBSTRING_SOURCES, $ext_shared,, $PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
27  PHP_SUBST(MBSTRING_SHARED_LIBADD)
28
29  for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do
30    PHP_ADD_BUILD_DIR([$ext_builddir/$dir], 1)
31  done
32
33  for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do
34    PHP_ADD_INCLUDE([$ext_srcdir/$dir])
35    PHP_ADD_INCLUDE([$ext_builddir/$dir])
36  done
37
38  out="php_config.h"
39
40  dnl This is PECL build, check if bundled PCRE library is used
41  old_CPPFLAGS=$CPPFLAGS
42  CPPFLAGS=$INCLUDES
43  AC_EGREP_CPP(yes,[
44#include <main/php_config.h>
45#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
46yes
47#endif
48  ],[
49    PHP_PCRE_REGEX=yes
50  ],[
51    AC_EGREP_CPP(yes,[
52#include <main/php_config.h>
53#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
54yes
55#endif
56    ],[
57      PHP_PCRE_REGEX=pecl
58      PHP_ADD_INCLUDE($PHP_PCRE_DIR/include)
59    ],[
60      PHP_PCRE_REGEX=no
61    ])
62  ])
63
64
65  if test "$ext_shared" != "no" && test -f "$ext_builddir/config.h.in"; then
66    out="$abs_builddir/config.h"
67  fi
68
69  cat > $ext_builddir/libmbfl/config.h <<EOF
70#include "$out"
71EOF
72
73  PHP_MBSTRING_ADD_INSTALL_HEADERS([mbstring.h])
74  PHP_INSTALL_HEADERS([ext/mbstring], [$PHP_MBSTRING_INSTALL_HEADERS])
75])
76
77AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [
78  if test "$PHP_MBREGEX" = "yes"; then
79    PKG_CHECK_MODULES([ONIG], [oniguruma])
80    PHP_EVAL_LIBLINE($ONIG_LIBS, MBSTRING_SHARED_LIBADD)
81    PHP_EVAL_INCLINE($ONIG_CFLAGS)
82
83    save_old_LDFLAGS=$LDFLAGS
84    PHP_EVAL_LIBLINE([$MBSTRING_SHARED_LIBADD], LDFLAGS)
85    AC_MSG_CHECKING([if oniguruma has an invalid entry for KOI8 encoding])
86    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
87#include <oniguruma.h>
88    ]], [[
89return (int)(ONIG_ENCODING_KOI8 + 1);
90    ]])], [
91      AC_MSG_RESULT([no])
92    ], [
93      AC_MSG_RESULT([yes])
94      AC_DEFINE([PHP_ONIG_BAD_KOI8_ENTRY], [1], [define to 1 if oniguruma has an invalid entry for KOI8 encoding])
95    ])
96    LDFLAGS=$save_old_LDFLAGS
97
98    PHP_MBSTRING_ADD_CFLAG([-DONIG_ESCAPE_UCHAR_COLLISION=1])
99    PHP_MBSTRING_ADD_CFLAG([-DUChar=OnigUChar])
100
101    AC_DEFINE([HAVE_MBREGEX], 1, [whether to have multibyte regex support])
102
103    PHP_MBSTRING_ADD_BASE_SOURCES([php_mbregex.c])
104    PHP_MBSTRING_ADD_INSTALL_HEADERS([php_mbregex.h php_onig_compat.h])
105  fi
106])
107
108AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
109  dnl
110  dnl Bundled libmbfl is required and can not be disabled
111  dnl
112  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl])
113  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/mbfl])
114  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/filters])
115  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/nls])
116  PHP_MBSTRING_ADD_INCLUDE([libmbfl])
117  PHP_MBSTRING_ADD_INCLUDE([libmbfl/mbfl])
118
119  PHP_MBSTRING_ADD_SOURCES([
120    libmbfl/filters/html_entities.c
121    libmbfl/filters/mbfilter_7bit.c
122    libmbfl/filters/mbfilter_base64.c
123    libmbfl/filters/mbfilter_big5.c
124    libmbfl/filters/mbfilter_cp5022x.c
125    libmbfl/filters/mbfilter_cp51932.c
126    libmbfl/filters/mbfilter_cp932.c
127    libmbfl/filters/mbfilter_cp936.c
128    libmbfl/filters/mbfilter_gb18030.c
129    libmbfl/filters/mbfilter_euc_cn.c
130    libmbfl/filters/mbfilter_euc_jp.c
131    libmbfl/filters/mbfilter_euc_jp_2004.c
132    libmbfl/filters/mbfilter_euc_jp_win.c
133    libmbfl/filters/mbfilter_euc_kr.c
134    libmbfl/filters/mbfilter_euc_tw.c
135    libmbfl/filters/mbfilter_htmlent.c
136    libmbfl/filters/mbfilter_hz.c
137    libmbfl/filters/mbfilter_iso2022_jp_ms.c
138    libmbfl/filters/mbfilter_iso2022jp_2004.c
139    libmbfl/filters/mbfilter_iso2022jp_mobile.c
140    libmbfl/filters/mbfilter_iso2022_kr.c
141    libmbfl/filters/mbfilter_jis.c
142    libmbfl/filters/mbfilter_qprint.c
143    libmbfl/filters/mbfilter_singlebyte.c
144    libmbfl/filters/mbfilter_sjis.c
145    libmbfl/filters/mbfilter_sjis_mobile.c
146    libmbfl/filters/mbfilter_sjis_mac.c
147    libmbfl/filters/mbfilter_sjis_2004.c
148    libmbfl/filters/mbfilter_tl_jisx0201_jisx0208.c
149    libmbfl/filters/mbfilter_ucs2.c
150    libmbfl/filters/mbfilter_ucs4.c
151    libmbfl/filters/mbfilter_uhc.c
152    libmbfl/filters/mbfilter_utf16.c
153    libmbfl/filters/mbfilter_utf32.c
154    libmbfl/filters/mbfilter_utf7.c
155    libmbfl/filters/mbfilter_utf7imap.c
156    libmbfl/filters/mbfilter_utf8.c
157    libmbfl/filters/mbfilter_utf8_mobile.c
158    libmbfl/filters/mbfilter_uuencode.c
159    libmbfl/mbfl/mbfilter.c
160    libmbfl/mbfl/mbfilter_8bit.c
161    libmbfl/mbfl/mbfilter_pass.c
162    libmbfl/mbfl/mbfilter_wchar.c
163    libmbfl/mbfl/mbfl_convert.c
164    libmbfl/mbfl/mbfl_encoding.c
165    libmbfl/mbfl/mbfl_filter_output.c
166    libmbfl/mbfl/mbfl_language.c
167    libmbfl/mbfl/mbfl_memory_device.c
168    libmbfl/mbfl/mbfl_string.c
169    libmbfl/nls/nls_de.c
170    libmbfl/nls/nls_en.c
171    libmbfl/nls/nls_ja.c
172    libmbfl/nls/nls_kr.c
173    libmbfl/nls/nls_neutral.c
174    libmbfl/nls/nls_ru.c
175    libmbfl/nls/nls_uni.c
176    libmbfl/nls/nls_zh.c
177    libmbfl/nls/nls_hy.c
178    libmbfl/nls/nls_tr.c
179    libmbfl/nls/nls_ua.c
180  ])
181  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_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_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h])
182])
183
184dnl
185dnl Main config
186dnl
187
188PHP_ARG_ENABLE([mbstring],
189  [whether to enable multibyte string support],
190  [AS_HELP_STRING([--enable-mbstring],
191    [Enable multibyte string support])])
192
193PHP_ARG_ENABLE([mbregex],
194  [whether to enable multibyte regex support (requires oniguruma)],
195  [AS_HELP_STRING([--disable-mbregex],
196    [MBSTRING: Disable multibyte regex support])],
197  [yes],
198  [no])
199
200PHP_ARG_WITH(pcre-dir, pcre install prefix,
201[  --with-pcre-dir           MBSTRING: pcre install prefix], no, no)
202
203if test "$PHP_MBSTRING" != "no"; then
204  AC_DEFINE([HAVE_MBSTRING],1,[whether to have multibyte string support])
205
206  PHP_MBSTRING_ADD_BASE_SOURCES([mbstring.c php_unicode.c mb_gpc.c])
207
208  if test "$PHP_MBREGEX" != "no"; then
209    PHP_MBSTRING_SETUP_MBREGEX
210  fi
211
212  dnl libmbfl is required
213  PHP_MBSTRING_SETUP_LIBMBFL
214  PHP_MBSTRING_EXTENSION
215fi
216