xref: /PHP-8.3/ext/mbstring/config.m4 (revision c717c79a)
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  if test "$ext_shared" != "no" && test -f "$ext_builddir/config.h.in"; then
41    out="$abs_builddir/config.h"
42  fi
43
44  cat > $ext_builddir/libmbfl/config.h <<EOF
45#include "$out"
46EOF
47
48  PHP_MBSTRING_ADD_INSTALL_HEADERS([mbstring.h])
49  PHP_INSTALL_HEADERS([ext/mbstring], [$PHP_MBSTRING_INSTALL_HEADERS])
50])
51
52AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [
53  if test "$PHP_MBREGEX" = "yes"; then
54    PKG_CHECK_MODULES([ONIG], [oniguruma])
55    PHP_EVAL_LIBLINE($ONIG_LIBS, MBSTRING_SHARED_LIBADD)
56    PHP_EVAL_INCLINE($ONIG_CFLAGS)
57
58    save_old_LDFLAGS=$LDFLAGS
59    PHP_EVAL_LIBLINE([$MBSTRING_SHARED_LIBADD], LDFLAGS)
60    AC_MSG_CHECKING([if oniguruma has an invalid entry for KOI8 encoding])
61    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
62#include <oniguruma.h>
63    ]], [[
64return (int)(ONIG_ENCODING_KOI8 + 1);
65    ]])], [
66      AC_MSG_RESULT([no])
67    ], [
68      AC_MSG_RESULT([yes])
69      AC_DEFINE([PHP_ONIG_BAD_KOI8_ENTRY], [1], [define to 1 if oniguruma has an invalid entry for KOI8 encoding])
70    ])
71    LDFLAGS=$save_old_LDFLAGS
72
73    PHP_MBSTRING_ADD_CFLAG([-DONIG_ESCAPE_UCHAR_COLLISION=1])
74    PHP_MBSTRING_ADD_CFLAG([-DUChar=OnigUChar])
75
76    AC_DEFINE([HAVE_MBREGEX], 1, [whether to have multibyte regex support])
77
78    PHP_MBSTRING_ADD_BASE_SOURCES([php_mbregex.c])
79    PHP_MBSTRING_ADD_INSTALL_HEADERS([php_mbregex.h php_onig_compat.h])
80  fi
81])
82
83AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
84  dnl
85  dnl Bundled libmbfl is required and can not be disabled
86  dnl
87  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl])
88  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/mbfl])
89  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/filters])
90  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/nls])
91  PHP_MBSTRING_ADD_INCLUDE([libmbfl])
92  PHP_MBSTRING_ADD_INCLUDE([libmbfl/mbfl])
93
94  PHP_MBSTRING_ADD_SOURCES([
95    libmbfl/filters/html_entities.c
96    libmbfl/filters/mbfilter_7bit.c
97    libmbfl/filters/mbfilter_base64.c
98    libmbfl/filters/mbfilter_cjk.c
99    libmbfl/filters/mbfilter_htmlent.c
100    libmbfl/filters/mbfilter_qprint.c
101    libmbfl/filters/mbfilter_singlebyte.c
102    libmbfl/filters/mbfilter_ucs2.c
103    libmbfl/filters/mbfilter_ucs4.c
104    libmbfl/filters/mbfilter_utf16.c
105    libmbfl/filters/mbfilter_utf32.c
106    libmbfl/filters/mbfilter_utf7.c
107    libmbfl/filters/mbfilter_utf7imap.c
108    libmbfl/filters/mbfilter_utf8.c
109    libmbfl/filters/mbfilter_utf8_mobile.c
110    libmbfl/filters/mbfilter_uuencode.c
111    libmbfl/mbfl/mbfilter.c
112    libmbfl/mbfl/mbfilter_8bit.c
113    libmbfl/mbfl/mbfilter_pass.c
114    libmbfl/mbfl/mbfilter_wchar.c
115    libmbfl/mbfl/mbfl_convert.c
116    libmbfl/mbfl/mbfl_encoding.c
117    libmbfl/mbfl/mbfl_filter_output.c
118    libmbfl/mbfl/mbfl_language.c
119    libmbfl/mbfl/mbfl_memory_device.c
120    libmbfl/mbfl/mbfl_string.c
121    libmbfl/nls/nls_de.c
122    libmbfl/nls/nls_en.c
123    libmbfl/nls/nls_ja.c
124    libmbfl/nls/nls_kr.c
125    libmbfl/nls/nls_neutral.c
126    libmbfl/nls/nls_ru.c
127    libmbfl/nls/nls_uni.c
128    libmbfl/nls/nls_zh.c
129    libmbfl/nls/nls_hy.c
130    libmbfl/nls/nls_tr.c
131    libmbfl/nls/nls_ua.c
132  ])
133  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])
134])
135
136dnl
137dnl Main config
138dnl
139
140PHP_ARG_ENABLE([mbstring],
141  [whether to enable multibyte string support],
142  [AS_HELP_STRING([--enable-mbstring],
143    [Enable multibyte string support])])
144
145PHP_ARG_ENABLE([mbregex],
146  [whether to enable multibyte regex support (requires oniguruma)],
147  [AS_HELP_STRING([--disable-mbregex],
148    [MBSTRING: Disable multibyte regex support])],
149  [yes],
150  [no])
151
152if test "$PHP_MBSTRING" != "no"; then
153  AC_DEFINE([HAVE_MBSTRING],1,[whether to have multibyte string support])
154
155  PHP_MBSTRING_ADD_BASE_SOURCES([mbstring.c php_unicode.c mb_gpc.c])
156
157  if test "$PHP_MBREGEX" != "no"; then
158    PHP_MBSTRING_SETUP_MBREGEX
159  fi
160
161  dnl libmbfl is required
162  PHP_MBSTRING_SETUP_LIBMBFL
163  PHP_MBSTRING_EXTENSION
164fi
165