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