X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=config.m4;h=828c93740753d64d8f798be06c6f6ad2f1ec5d58;hp=d2cf0733ac9e395a89300424b5c0789442b6c205;hb=52ed5940ed0ab3cafd36fbded2e83c92563e7b2b;hpb=eea1703836c35020dd45e465f5cb1450eadfaa1c diff --git a/config.m4 b/config.m4 index d2cf073..828c937 100644 --- a/config.m4 +++ b/config.m4 @@ -1,238 +1,184 @@ +PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi) + +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 PHP System Interface support]) -PHP_ARG_WITH(psi-libjit, where to find libjit, -[ --with-psi-libjit=DIR PSI: path to libjit], [], no) -PHP_ARG_WITH(psi-libffi, where to find libjit, -[ --with-psi-libffi=DIR PSI: path to libffi], [], no) - -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 +[ --enable-psi Enable PSI (PHP System Interface) support]) - 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 - AC_MSG_CHECKING(for libffi) - PSI_cv_LIBFFI_DIR=`$PKG_CONFIG --variable=prefix libffi` - AC_MSG_RESULT($PSI_cv_LIBFFI_DIR) - 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_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 - PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [ - PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [ - AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ]) - ], [], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR) - AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ]) +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 ], [ - PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [ - AC_CHECK_HEADERS(sys/mman.h) - PHP_CHECK_FUNC(mmap) - AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ]) - ], [ - ], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR) - ], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR) - - 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]) - fi + AC_MSG_RESULT([needs define]) + AC_DEFINE([_GNU_SOURCE], [1], [ ]) + ], [ + AC_MSG_RESULT([already defined]) + ]) - PHP_SUBST(PSI_SHARED_LIBADD) + PSI_LEMON + PSI_CHECK_LIBJIT + PSI_CHECK_LIBFFI - PSI_TYPES="" - dnl PSI_TYPE(type name, basic type, whether to check alignmnet) - AC_DEFUN(PSI_TYPE, [ - AC_CHECK_SIZEOF($1) - if test "$3" && test "$3" != "no" - then - AC_CHECK_ALIGNOF($1) - fi - if test "$2" && test "$ac_cv_sizeof_[]$1" -gt 0; then - psi_type_bits=`expr ${AS_TR_SH(ac_cv_sizeof_[]$1)} \* 8` - PSI_TYPES="{PSI_T_[]translit($2,a-z,A-Z)[]${psi_type_bits}, \""$2[]${psi_type_bits}[]_t"\", \""$1"\"}, $PSI_TYPES" - fi - ]) - + AC_PATH_PROG(NM, nm) + AC_FUNC_FNMATCH + AC_FUNC_MMAP - PSI_CONSTS="" - dnl PSI_COMPUTE_STR(variable, string or expression, includes) - AC_DEFUN(PSI_COMPUTE_STR, [ - AC_TRY_RUN([ - $3 - int main() { - return EOF == fputs($2, fopen("conftest.out", "w")); - } - ], [ - eval $1=\\\"`cat conftest.out`\\\" - ]) - ]) + PSI_CONFIG_INIT + + 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 - dnl PSI_CONST(const name, type, headers to include) - AC_DEFUN(PSI_CONST, [ - AC_MSG_CHECKING(value of $1) - PSI_INCLUDES= - if test "$3" - then - for i in $3 - do - PSI_INCLUDES="$PSI_INCLUDES -#include <$i>" - done - fi - case $2 in - str*|quoted_str*) - PSI_COMPUTE_STR(psi_const_val, $1, AC_INCLUDES_DEFAULT()$PSI_INCLUDES) - if test "$psi_const_val"; then - PSI_CONSTS="{PSI_T_STRING, \"string\", \"$1\", $psi_const_val, PSI_T_QUOTED_STRING}, $PSI_CONSTS" - fi - ;; - *) - AC_COMPUTE_INT(psi_const_val, $1, AC_INCLUDES_DEFAULT()$PSI_INCLUDES) - if test "$psi_const_val"; then - PSI_CONSTS="{PSI_T_INT, \"int\", \"$1\", \"$psi_const_val\", PSI_T_NUMBER}, $PSI_CONSTS" - fi - ;; - esac - - AC_MSG_RESULT($psi_const_val) + 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) ]) - - AC_DEFUN([AX_CHECK_SIGN], [ - typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"` - AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [ - AC_TRY_COMPILE([$4], - [ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ], - [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ], - [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])]) - symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "a-z" "A-Z"` - if eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"yes\""; then - $2 - elif eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"no\""; then - $3 - fi + 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 - PSI_TYPE(char, int) - PSI_TYPE(short, int) - PSI_TYPE(int, int) - PSI_TYPE(long, int) - PSI_TYPE(float) - PSI_TYPE(double) - PSI_TYPE(void *) - - dnl stddef.h - PSI_TYPE(ptrdiff_t, int) - PSI_TYPE(size_t, uint) - AC_CHECK_TYPE(wchar_t, [ - AX_CHECK_SIGN(wchar_t, psi_wchar_t=int, psi_wchar_t=uint) - PSI_TYPE(wchar_t, $psi_wchar_t) - ]) + PHP_SUBST(PSI_SHARED_LIBADD) - dnl stdio.h - PSI_CONST(BUFSIZ, int) - PSI_CONST(_IOFBF, int) - PSI_CONST(_IOLBF, int) - PSI_CONST(_IONBF, int) - PSI_CONST(SEEK_CUR, int) - PSI_CONST(SEEK_END, int) - PSI_CONST(SEEK_SET, int) - PSI_CONST(FILENAME_MAX, int) - PSI_CONST(FOPEN_MAX, int) - PSI_CONST(TMP_MAX, int) - PSI_CONST(EOF, int) - PSI_CONST(P_tmpdir, string) - PSI_CONST(L_ctermid, int) - PSI_CONST(L_tmpnam, int) - dnl stdlib.h - PSI_CONST(EXIT_FAILURE, int) - PSI_CONST(EXIT_SUCCESS, int) - PSI_CONST(RAND_MAX, int) - PSI_CONST(MB_CUR_MAX, int) - dnl sys/time.h - PSI_CONST(ITIMER_REAL, int, sys/time.h) - PSI_CONST(ITIMER_VIRTUAL, int, sys/time.h) - PSI_CONST(ITIMER_PROF, int, sys/time.h) - dnl sys/types.h - PSI_TYPE(blkcnt_t, int) - PSI_TYPE(blksize_t, int) - PSI_TYPE(clock_t, int) - PSI_TYPE(clockid_t, int) - PSI_TYPE(dev_t, int) - PSI_TYPE(fsblkcnt_t, uint) - PSI_TYPE(fsfilcnt_t, uint) - PSI_TYPE(gid_t, int) - PSI_TYPE(id_t, int) - PSI_TYPE(ino_t, uint) - PSI_TYPE(key_t, int) - PSI_TYPE(mode_t, int) - PSI_TYPE(nlink_t, int) - PSI_TYPE(off_t, int) - PSI_TYPE(pid_t, int) - PSI_TYPE(ssize_t, int) - PSI_TYPE(suseconds_t, int) - PSI_TYPE(time_t, int) - PSI_TYPE(timer_t, int) - PSI_TYPE(uid_t) - - AC_DEFINE_UNQUOTED(PHP_PSI_TYPES, $PSI_TYPES, Predefined types) - AC_DEFINE_UNQUOTED(PHP_PSI_CONSTS, $PSI_CONSTS, Predefined constants) - - 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_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_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src/types) + + 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) @@ -240,4 +186,5 @@ if test "$PHP_PSI" != "no"; then PHP_SUBST(PHP_PSI_BUILDDIR) PHP_ADD_MAKEFILE_FRAGMENT + AC_MSG_RESULT() fi