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