xref: /PHP-5.3/ext/ereg/config0.m4 (revision aa3eee1d)
1dnl $Id$
2dnl config.m4 for extension ereg
3
4dnl
5dnl Check for regex library type
6dnl
7PHP_ARG_WITH(regex,,
8[  --with-regex=TYPE       regex library type: system, php. [TYPE=php]
9                          WARNING: Do NOT use unless you know what you are doing!], php, no)
10
11case $PHP_REGEX in
12  system)
13    if test "$PHP_SAPI" = "apache" || test "$PHP_SAPI" = "apache2filter" || test "$PHP_SAPI" = "apache2handler"; then
14      REGEX_TYPE=php
15    else
16      REGEX_TYPE=system
17    fi
18    ;;
19  yes | php)
20    REGEX_TYPE=php
21    ;;
22  *)
23    REGEX_TYPE=php
24    AC_MSG_WARN([Invalid regex library type selected. Using default value: php])
25    ;;
26esac
27
28AC_MSG_CHECKING([which regex library to use])
29AC_MSG_RESULT([$REGEX_TYPE])
30
31if test "$REGEX_TYPE" = "php"; then
32  ereg_regex_sources="regex/regcomp.c regex/regexec.c regex/regerror.c regex/regfree.c"
33  ereg_regex_headers="regex/"
34  PHP_EREG_CFLAGS="-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp"
35fi
36
37PHP_NEW_EXTENSION(ereg, ereg.c $ereg_regex_sources, no,,$PHP_EREG_CFLAGS)
38PHP_INSTALL_HEADERS([ext/ereg], [php_ereg.h php_regex.h $ereg_regex_headers])
39
40if test "$REGEX_TYPE" = "php"; then
41  AC_DEFINE(HAVE_REGEX_T_RE_MAGIC, 1, [ ])
42  AC_DEFINE(HSREGEX,1,[ ])
43  AC_DEFINE(REGEX,1,[ ])
44  PHP_ADD_BUILD_DIR([$ext_builddir/regex], 1)
45  PHP_ADD_INCLUDE([$ext_srcdir/regex])
46elif test "$REGEX_TYPE" = "system"; then
47  AC_DEFINE(REGEX,0,[ ])
48  dnl Check if field re_magic exists in struct regex_t
49  AC_CACHE_CHECK([whether field re_magic exists in struct regex_t], ac_cv_regex_t_re_magic, [
50  AC_TRY_COMPILE([#include <sys/types.h>
51#include <regex.h>], [regex_t rt; rt.re_magic;],
52  [ac_cv_regex_t_re_magic=yes], [ac_cv_regex_t_re_magic=no])])
53  if test "$ac_cv_regex_t_re_magic" = "yes"; then
54    AC_DEFINE([HAVE_REGEX_T_RE_MAGIC], [ ], 1)
55  fi
56fi
57