CPP builtins
[m6w6/ext-psi] / config.m4
index 991550584e99eef07506cf760d61c1c102323964..75ea3f73052a5f4b9f32695e04179762693530d2 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -1,44 +1,64 @@
-PHP_ARG_ENABLE(psi, whether to enable psi support,
-[  --with-psi[[=path to libjit]]
-                          Enable PHP System Interface support])
-
-if test "$PHP_PSI" != "no"; then
-       AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
-       AC_PATH_PROG(LEMON, lemon, ./lemon)
-       PHP_SUBST(LEMON)
-
-       AC_CACHE_CHECK(for libjit install root, PSI_cv_LIBJIT_DIR, [
-       for PSI_cv_LIBJIT_DIR in {/usr{,/local},/opt}{,libjit}
-       do
-               if test -e $PSI_cv_LIBJIT_DIR/include/jit/jit.h
-               then
-                       break
-               fi
-               PSI_cv_LIBJIT_DIR=
-       done])
-       if test -z "$PSI_cv_LIBJIT_DIR"
-       then
-               AC_MSG_ERROR([Could not find libjit, please provide the base install path])
-       fi
-
-       PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi)
-       PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi)
-
-       PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src)
-       PHP_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src)
-
-       PHP_PSI_HEADERS=`(cd $PHP_PSI_SRCDIR/src && echo *.h)`
-       PHP_PSI_SOURCES=`(cd $PHP_PSI_SRCDIR && echo src/*.c)`
-       PHP_PSI_SOURCES="src/parser.c src/parser_proc.c"
+m4_foreach(incfile, [
+       [ax/ax_check_compile_flag.m4],
+       [ax/ax_check_sign.m4],
+       [ax/ax_pthread.m4],
+       [psi/psi.m4],
+       [psi/psi_type.m4]], [
+       dnl pecl build
+       sinclude([m4/]incfile)
+       dnl php-src build
+       sinclude([ext/psi/m4/]incfile)
+])
 
-       PHP_NEW_EXTENSION(psi, $PHP_PSI_SOURCES, $ext_shared)
-       PHP_INSTALL_HEADERS(ext/psi, php_psi.h $PHP_PSI_HEADERS)
+PHP_ARG_ENABLE(psi, whether to enable PHP System Interface support,
+[  --enable-psi            Enable PSI (PHP System Interface) support])
+
+if test "$PHP_PSI" != no; then
+
+       PHP_ARG_ENABLE(psi-maintainer-mode, whether to enable maintainer mode,
+       [  --enable-psi-maintainer-mode
+                          PSI: enable maintainer mode
+                           . make dependencies], [no], [no])
+    PHP_ARG_ENABLE(psi-threaded-parser, whether to enable threaded parser,
+    [  --enable-psi-threaded-parser
+                          PSI: enable threads for startup parsing], [yes], [no])
+
+       PHP_ARG_WITH(psi-libjit, where to find libjit,
+       [  --with-psi-libjit=DIR   PSI: path to libjit], [ ], [ ])
+
+       PHP_ARG_WITH(psi-libffi, where to find libffi,
+       [  --with-psi-libffi=DIR   PSI: path to libffi], [ ], [ ])
+
+       AC_HEADER_ASSERT dnl # adds --disable-assert to define NDEBUG
 
-       PHP_SUBST(PHP_PSI_HEADERS)
-       PHP_SUBST(PHP_PSI_SOURCES)
+       PSI_CONFIG_INIT
+       
+       PSI_CHECK_MAINTAINER_MODE
+       PSI_CHECK_THREADED_PARSER
 
-       PHP_SUBST(PHP_PSI_SRCDIR)
-       PHP_SUBST(PHP_PSI_BUILDDIR)
+       dnl we cannot use AC_USE_SYSTEM_EXTENSIONS here, because we're way too late
+       dnl in the game, and we're currently only targeting _GNU_SOURCE for now
+       PSI_CHECK_GNU_SOURCE
+       PSI_CHECK_CPP
+       PSI_CHECK_STD_TYPES
+       
+       AC_HEADER_DIRENT
+       AC_FUNC_FNMATCH
+       AC_FUNC_MMAP
+       AC_CHECK_FUNCS([mknodat eaccess])
+
+       PSI_CHECK_PTHREAD
+       PSI_CHECK_LIBJIT
+       PSI_CHECK_LIBFFI
+
+       PSI_CONFIG_DONE
+
+       AC_DEFINE_UNQUOTED(PHP_PSI_SHLIB_SUFFIX, ["$SHLIB_SUFFIX_NAME"], DL suffix)
+
+       PHP_SUBST(PSI_SHARED_LIBADD)
+       PHP_NEW_EXTENSION(psi, $PHP_PSI_SOURCES, $ext_shared)
+       PHP_INSTALL_HEADERS(ext/psi, php_psi.h $PHP_PSI_HEADERS)
 
        PHP_ADD_MAKEFILE_FRAGMENT
+       AC_MSG_RESULT()
 fi