xref: /PHP-8.4/ext/mbstring/config.m4 (revision 0f3b2e50)
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_SETUP_MBREGEX], [
22  PKG_CHECK_MODULES([ONIG], [oniguruma])
23  PHP_EVAL_LIBLINE([$ONIG_LIBS], [MBSTRING_SHARED_LIBADD])
24  PHP_EVAL_INCLINE([$ONIG_CFLAGS])
25
26  AC_CACHE_CHECK([if oniguruma has an invalid entry for KOI8 encoding],
27    [php_cv_lib_onig_invalid_koi8],
28    [save_old_LIBS=$LIBS
29      LIBS="$LIBS $MBSTRING_SHARED_LIBADD"
30      save_old_CFLAGS=$CFLAGS
31      CFLAGS="$CFLAGS $ONIG_CFLAGS"
32      AC_LINK_IFELSE([AC_LANG_PROGRAM([
33        #include <stdint.h>
34        #include <oniguruma.h>
35      ],
36      [return (intptr_t)(ONIG_ENCODING_KOI8 + 1);])],
37      [php_cv_lib_onig_invalid_koi8=no],
38      [php_cv_lib_onig_invalid_koi8=yes])
39      LIBS=$save_old_LIBS
40      CFLAGS=$save_old_CFLAGS])
41  AS_VAR_IF([php_cv_lib_onig_invalid_koi8], [yes],
42    [AC_DEFINE([PHP_ONIG_BAD_KOI8_ENTRY], [1],
43      [Define to 1 if oniguruma has an invalid entry for KOI8 encoding.])])
44
45  PHP_MBSTRING_ADD_CFLAG([-DONIG_ESCAPE_UCHAR_COLLISION=1])
46  PHP_MBSTRING_ADD_CFLAG([-DUChar=OnigUChar])
47
48  AC_DEFINE([HAVE_MBREGEX], [1],
49    [Define to 1 if mbstring has multibyte regex support enabled.])
50
51  PHP_MBSTRING_ADD_BASE_SOURCES([php_mbregex.c])
52  PHP_INSTALL_HEADERS([ext/mbstring], [php_mbregex.h php_onig_compat.h])
53])
54
55AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
56  dnl
57  dnl Bundled libmbfl is required and can not be disabled
58  dnl
59  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl])
60  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/mbfl])
61  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/filters])
62  PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/nls])
63  PHP_MBSTRING_ADD_INCLUDE([libmbfl])
64  PHP_MBSTRING_ADD_INCLUDE([libmbfl/mbfl])
65
66  PHP_MBSTRING_ADD_SOURCES([
67    libmbfl/filters/html_entities.c
68    libmbfl/filters/mbfilter_7bit.c
69    libmbfl/filters/mbfilter_base64.c
70    libmbfl/filters/mbfilter_cjk.c
71    libmbfl/filters/mbfilter_htmlent.c
72    libmbfl/filters/mbfilter_qprint.c
73    libmbfl/filters/mbfilter_singlebyte.c
74    libmbfl/filters/mbfilter_ucs2.c
75    libmbfl/filters/mbfilter_ucs4.c
76    libmbfl/filters/mbfilter_utf16.c
77    libmbfl/filters/mbfilter_utf32.c
78    libmbfl/filters/mbfilter_utf7.c
79    libmbfl/filters/mbfilter_utf7imap.c
80    libmbfl/filters/mbfilter_utf8.c
81    libmbfl/filters/mbfilter_uuencode.c
82    libmbfl/mbfl/mbfilter.c
83    libmbfl/mbfl/mbfilter_8bit.c
84    libmbfl/mbfl/mbfilter_pass.c
85    libmbfl/mbfl/mbfilter_wchar.c
86    libmbfl/mbfl/mbfl_convert.c
87    libmbfl/mbfl/mbfl_encoding.c
88    libmbfl/mbfl/mbfl_filter_output.c
89    libmbfl/mbfl/mbfl_language.c
90    libmbfl/mbfl/mbfl_memory_device.c
91    libmbfl/mbfl/mbfl_string.c
92    libmbfl/nls/nls_de.c
93    libmbfl/nls/nls_en.c
94    libmbfl/nls/nls_ja.c
95    libmbfl/nls/nls_kr.c
96    libmbfl/nls/nls_neutral.c
97    libmbfl/nls/nls_ru.c
98    libmbfl/nls/nls_uni.c
99    libmbfl/nls/nls_zh.c
100    libmbfl/nls/nls_hy.c
101    libmbfl/nls/nls_tr.c
102    libmbfl/nls/nls_ua.c
103  ])
104
105  PHP_INSTALL_HEADERS([ext/mbstring], m4_normalize([
106    libmbfl/config.h
107    libmbfl/mbfl/eaw_table.h
108    libmbfl/mbfl/mbfilter_8bit.h
109    libmbfl/mbfl/mbfilter_pass.h
110    libmbfl/mbfl/mbfilter_wchar.h
111    libmbfl/mbfl/mbfilter.h
112    libmbfl/mbfl/mbfl_consts.h
113    libmbfl/mbfl/mbfl_convert.h
114    libmbfl/mbfl/mbfl_defs.h
115    libmbfl/mbfl/mbfl_encoding.h
116    libmbfl/mbfl/mbfl_filter_output.h
117    libmbfl/mbfl/mbfl_language.h
118    libmbfl/mbfl/mbfl_memory_device.h
119    libmbfl/mbfl/mbfl_string.h
120  ]))
121])
122
123dnl
124dnl Main config
125dnl
126
127PHP_ARG_ENABLE([mbstring],
128  [whether to enable multibyte string support],
129  [AS_HELP_STRING([--enable-mbstring],
130    [Enable multibyte string support])])
131
132PHP_ARG_ENABLE([mbregex],
133  [whether to enable multibyte regex support (requires oniguruma)],
134  [AS_HELP_STRING([--disable-mbregex],
135    [MBSTRING: Disable multibyte regex support])],
136  [yes],
137  [no])
138
139if test "$PHP_MBSTRING" != "no"; then
140  AC_DEFINE([HAVE_MBSTRING], [1],
141    [Define to 1 if the PHP extension 'mbstring' is available.])
142
143  PHP_MBSTRING_ADD_BASE_SOURCES([mbstring.c php_unicode.c mb_gpc.c])
144
145  AS_VAR_IF([PHP_MBREGEX], [yes], [PHP_MBSTRING_SETUP_MBREGEX])
146
147  dnl libmbfl is required
148  PHP_MBSTRING_SETUP_LIBMBFL
149
150  PHP_NEW_EXTENSION([mbstring],
151    [$PHP_MBSTRING_BASE_SOURCES $PHP_MBSTRING_SOURCES],
152    [$ext_shared],,
153    [$PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
154
155  PHP_SUBST([MBSTRING_SHARED_LIBADD])
156
157  for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do
158    PHP_ADD_BUILD_DIR([$ext_builddir/$dir], [1])
159  done
160
161  for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do
162    PHP_ADD_INCLUDE([$ext_srcdir/$dir])
163    PHP_ADD_INCLUDE([$ext_builddir/$dir])
164  done
165
166  out="php_config.h"
167
168  if test "$ext_shared" != "no" && test -f "$ext_builddir/config.h.in"; then
169    out="$abs_builddir/config.h"
170  fi
171
172  cat > $ext_builddir/libmbfl/config.h <<EOF
173#include "$out"
174EOF
175
176  PHP_INSTALL_HEADERS([ext/mbstring], [mbstring.h])
177
178  PHP_ADD_EXTENSION_DEP(mbstring, pcre)
179fi
180