X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=config.m4;h=828c93740753d64d8f798be06c6f6ad2f1ec5d58;hp=807670c4c4f955de2c8cbe9f307a25215e24a773;hb=52ed5940ed0ab3cafd36fbded2e83c92563e7b2b;hpb=7eb47ef2fc5655e7196e4e0fbf5104eed8274601 diff --git a/config.m4 b/config.m4 index 807670c..828c937 100644 --- a/config.m4 +++ b/config.m4 @@ -1,96 +1,184 @@ -PHP_ARG_ENABLE(psi, whether to enable psi support, -[ --enable-psi Enable PHP System Interface support]) -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 libjit, -[ --with-psi-libffi=DIR PSI: path to libffi]) - -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) - - if test -z "$PKG_CONFIG" - then - AC_PATH_PROG(PKG_CONFIG, pkg-config, false) - fi +PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi) - export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH" - - AC_CACHE_CHECK(for libffi through pkg-config, PSI_cv_LIBFFI, [ - if $PKG_CONFIG --exists libffi - then - PSI_cv_LIBFFI=true - else - PSI_cv_LIBFFI=false - fi]) - if $PSI_cv_LIBFFI - then - PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`) - PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD) - else - AC_CACHE_CHECK(for libffi, PSI_cv_LIBFFI_DIR, [ - for PSI_cv_LIBFFI_DIR in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi} - do - if test -e $PSI_cv_LIBFFI_DIR/include/ffi/ffi.h - then - break - fi - PSI_cv_LIBFFI_DIR= - done]) - if test -n "$PSI_cv_LIBFFI_DIR" - then - PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [ - AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ]) - ], [ - ], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR) - PHP_CHECK_LIBRARY(ffi, ffi_closure_free, [ - AC_DEFINE(PSI_HAVE_FFI_CLOSURE_FREE, 1, [ ]) - ], [ - ], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR) - PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [ - AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ]) - ], [ - ], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR) - PHP_ADD_INCLUDE($PSI_cv_LIBFFI_DIR/include/ffi) - PHP_ADD_LIBRARY_WITH_PATH(ffi, $PSI_cv_LIBFFI_DIR/$PHP_LIBDIR, PSI_SHARED_LIBADD) - else - AC_MSG_WARN([Could not find libffi, please provide the base install path]) - fi - fi +case "PHP_EXT_BUILDDIR(psi)" in +""|.) PHP_PSI_BUILDDIR=$PHP_PSI_SRCDIR + ;; +*) PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi) + ;; +esac + +m4_foreach(incfile, [ + [ax/ax_check_sign.m4], + [ax/ax_pthread.m4], + [psi/psi.m4], + [psi/psi_type.m4], + [psi/psi_const.m4], + [psi/psi_decl.m4], + [psi/psi_macro.m4], + [psi/psi_composite.m4], + [posix/arpa_inet.m4], + [posix/errno.m4], + [posix/fcntl.m4], + [posix/glob.m4], + [posix/locale.m4], + [posix/stddef.m4], + [posix/stdio.m4], + [posix/stdint.m4], + [posix/stdlib.m4], + [posix/sys_select.m4], + [posix/sys_socket.m4], + [posix/sys_stat.m4], + [posix/sys_time.m4], + [posix/sys_times.m4], + [posix/sys_types.m4], + [posix/sys_uio.m4], + [posix/sys_utsname.m4], + [posix/ndbm.m4], + [posix/netdb.m4], + [posix/netinet_in.m4], + [posix/netinet_tcp.m4], + [posix/poll.m4], + [posix/signal.m4], + [posix/syslog.m4], + [posix/time.m4], + [posix/unistd.m4], + [posix/wchar.m4], + [posix/wctype.m4]], [ + dnl pecl build + sinclude([m4/]incfile) + dnl php-src build + sinclude([ext/psi/m4/]incfile) +]) + +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-posix, whether to pre-define POSIX decls, + [ --enable-psi-posix=... PSI: pre-define POSIX decls], [all], [no]) + + PHP_ARG_ENABLE(psi-maintainer-mode, whether to enable maintainer mode, + [ --enable-psi-maintainer-mode + PSI: enable maintainer mode + . parallel configure + . make dependencies + . extra debug wrappers], [no], [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 + + 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 + AC_MSG_CHECKING([for _GNU_SOURCE]) + AC_EGREP_CPP([gnu_source_not_defined], [ + #ifndef _GNU_SOURCE + gnu_source_not_defined + #endif + ], [ + AC_MSG_RESULT([needs define]) + AC_DEFINE([_GNU_SOURCE], [1], [ ]) + ], [ + AC_MSG_RESULT([already defined]) + ]) + + PSI_LEMON + PSI_CHECK_LIBJIT + PSI_CHECK_LIBFFI + + AC_PATH_PROG(NM, nm) + AC_FUNC_FNMATCH + AC_FUNC_MMAP + + PSI_CONFIG_INIT - AC_CACHE_CHECK(for libjit, PSI_cv_LIBJIT_DIR, [ - for PSI_cv_LIBJIT_DIR in $PHP_PSI_LIBJIT {/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 -n "$PSI_cv_LIBJIT_DIR" - then - PHP_ADD_INCLUDE($PSI_cv_LIBJIT_DIR/include) - PHP_ADD_LIBRARY_WITH_PATH(jit, $PSI_cv_LIBJIT_DIR/$PHP_LIBDIR, PSI_SHARED_LIBADD) - else - AC_MSG_WARN([Could not find libjit, please provide the base install path]) + dnl basics, one-by-one + PSI_CHECK_STD_TYPES + PSI_CHECK_STDINT + PSI_CHECK_SYS_TYPES + PSI_CHECK_STDDEF + + dnl parallel + AC_MSG_CHECKING([for POSIX modules]) + if ! $PSI_FAST_CONFIG; then + AC_MSG_RESULT([$PHP_PSI_POSIX]) fi + + PSI_CONFIG_POSIX(signal, signal.h, [ + PSI_CONFIG_POSIX(time, time.h, [ + PSI_CONFIG_POSIX(sys/stat, sys/stat.h) + PSI_CONFIG_POSIX(wchar, wchar.h, [ + PSI_CONFIG_POSIX(wctype, wctype.h) + ]) + ]) + PSI_CONFIG_POSIX(sys/select, sys/select.h) + ]) + PSI_CONFIG_POSIX(poll, poll.h) + PSI_CONFIG_POSIX(syslog, syslog.h) + PSI_CONFIG_POSIX(errno, errno.h) + PSI_CONFIG_POSIX(fcntl, fcntl.h) + PSI_CONFIG_POSIX(glob, glob.h) + PSI_CONFIG_POSIX(locale, locale.h xlocale.h) + PSI_CONFIG_POSIX(stdio, stdio.h) + PSI_CONFIG_POSIX(stdlib, stdlib.h) + PSI_CONFIG_POSIX(unistd, unistd.h) + PSI_CONFIG_POSIX(sys/socket, sys/socket.h, [ + PSI_CONFIG_POSIX(netinet/in, netinet/in.h, [ + PSI_CONFIG_POSIX(arpa/inet, arpa/inet.h) + ]) + PSI_CONFIG_POSIX(netdb, netdb.h) + ]) + PSI_CONFIG_POSIX(netinet/tcp, netinet/tcp.h) + PSI_CONFIG_POSIX(sys/time, sys/time.h) + PSI_CONFIG_POSIX(sys/times, sys/times.h) + PSI_CONFIG_POSIX(sys/uio, sys/uio.h) + PSI_CONFIG_POSIX(sys/utsname, sys/utsname.h) + PSI_CONFIG_POSIX(ndbm, dnl + ndbm.h dnl posix + relic.h dnl qdbm + gdbm-ndbm.h dnl gdbm + ) + + PSI_CONFIG_DONE PHP_SUBST(PSI_SHARED_LIBADD) - PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi) - PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi) + AC_DEFINE_UNQUOTED(PHP_PSI_SHLIB_SUFFIX, ["$SHLIB_SUFFIX_NAME"], DL suffix) + PHP_ADD_INCLUDE($PHP_PSI_SRCDIR) PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src) + PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src/calc) + PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src/types) + PHP_ADD_INCLUDE($PHP_PSI_BUILDDIR) PHP_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src) + PHP_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src/types) - PHP_PSI_HEADERS=`(cd $PHP_PSI_SRCDIR/src && echo *.h)` - PHP_PSI_SOURCES="src/parser_proc.c src/parser.c src/validator.c src/module.c src/context.c" - PHP_PSI_SOURCES="$PHP_PSI_SOURCES src/libjit.c src/libffi.c" + PHP_PSI_HEADERS=" \ + src/calc/basic.h src/calc/bin.h src/calc/bool.h src/calc/cast.h \ + src/calc/cmp.h src/calc/oper.h \ + `(cd $PHP_PSI_SRCDIR/src && ls *.h types/*.h)` \ + " + # parser* should come first + PHP_PSI_SOURCES=" \ + src/parser_proc.c src/parser.c \ + `(cd $PHP_PSI_SRCDIR && ls src/*.c src/types/*.c \ + | $EGREP -v '^src/parser' \ + )` \ + " + PHP_PSI_GENERATED=" \ + src/parser_proc.y src/parser_proc.c src/parser.c \ + src/calc/basic.h src/calc/bin.h src/calc/bool.h src/calc/cast.h \ + src/calc/cmp.h src/calc/oper.h \ + " PHP_NEW_EXTENSION(psi, $PHP_PSI_SOURCES, $ext_shared) PHP_INSTALL_HEADERS(ext/psi, php_psi.h $PHP_PSI_HEADERS) + PHP_SUBST(PHP_PSI_GENERATED) PHP_SUBST(PHP_PSI_HEADERS) PHP_SUBST(PHP_PSI_SOURCES) @@ -98,4 +186,5 @@ if test "$PHP_PSI" != "no"; then PHP_SUBST(PHP_PSI_BUILDDIR) PHP_ADD_MAKEFILE_FRAGMENT + AC_MSG_RESULT() fi