X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=m4%2Fpsi%2Fpsi.m4;h=f292c3e40d0c331cb4423d5905522fa3b6768752;hb=b0fdc1f1b8ae5ec4d3f47741b523fa6a60ae32bb;hp=b979719862a2db08fff771411158c4c7def3fe7d;hpb=3ef8c66ab1300801bcdb15b43f9f28e77b6487b6;p=m6w6%2Fext-psi diff --git a/m4/psi/psi.m4 b/m4/psi/psi.m4 index b979719..f292c3e 100644 --- a/m4/psi/psi.m4 +++ b/m4/psi/psi.m4 @@ -1,15 +1,3 @@ -dnl Generated headers with pre-defined types, structs, consts and decls. -PSI_STDINC=$PHP_PSI_SRCDIR/php_psi_stdinc.h -PSI_STDTYPES=$PHP_PSI_SRCDIR/php_psi_stdtypes.h -PSI_TYPES=$PHP_PSI_SRCDIR/php_psi_types.h -PSI_STRUCTS=$PHP_PSI_SRCDIR/php_psi_structs.h -PSI_UNIONS=$PHP_PSI_SRCDIR/php_psi_unions.h -PSI_CONSTS=$PHP_PSI_SRCDIR/php_psi_consts.h -PSI_REDIRS=$PHP_PSI_SRCDIR/php_psi_redirs.h -PSI_MACROS=$PHP_PSI_SRCDIR/php_psi_macros.h -PSI_DECLS=$PHP_PSI_SRCDIR/php_psi_decls.h -PSI_VA_DECLS=$PHP_PSI_SRCDIR/php_psi_va_decls.h -PSI_FN_DECLS=$PHP_PSI_SRCDIR/php_psi_fn_decls.h dnl PSI_CONFIG_INIT() dnl Creates stubs of the headers with pre-defined types etc. @@ -19,238 +7,77 @@ AC_DEFUN(PSI_CONFIG_INIT, [ psi_save_LIBS=$LIBS LIBS= + ac_includes_default="AC_INCLUDES_DEFAULT" + + AC_PROG_AWK + + AC_MSG_CHECKING(for preprocessor defaults) + psi_cpp_predef=`$CPP -Wp,-dM $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 - &1 >/dev/null \ + | $AWK ' + /include.*search.*start/ { + capture = 1 + next + } + /@<:@Ee@:>@nd.*search/ { + capture = 0 + } + { + if (capture) + print $1 + } + ' \ + ` + psi_cpp_predef_count=`printf %s "$psi_cpp_predef" | wc -l` + psi_cpp_search_count=`printf %s "$psi_cpp_search" | wc -l` + AC_MSG_RESULT([$psi_cpp_predef_count predefined macros, and $psi_cpp_search_count search paths]) + PSI_CPP_PREDEF=`printf "%s\n" "$psi_cpp_predef" | \ + $AWK '{ + gsub(/"/, "\\\\\""); + printf "\"%s\\\n\"\n", $[]0 + }' \ + ` + PSI_CPP_SEARCH=`printf %s "$psi_cpp_search" | \ + $AWK '{ + if (i) printf ":"; + gsub(/^@<:@@<:@:space:@:>@@:>@+/,""); + gsub(/@<:@@<:@:space:@:>@@:>@+$/,""); + printf "%s", $[]0; + ++i + }' \ + ` + if test "$PHP_PSI_MAINTAINER_MODE" = "yes"; then - PSI_FAST_CONFIG=true PSI_DEPS=true - PSI_EXTRA_REDIRS=true - PHP_SUBST(PSI_DEPS) - - PSI_CONFIG_TMP=$(mktemp -d) else - PSI_FAST_CONFIG=false PSI_DEPS=false - if test "$PHP_DEBUG" = "1"; then - PSI_EXTRA_REDIRS=true - else - PSI_EXTRA_REDIRS=false - fi fi - cat >$PHP_PSI_BUILDDIR/php_psi.dep <>$PHP_PSI_BUILDDIR/php_psi.dep <$i <>$PSI_STDTYPES <@ = { - {PSI_T_INT8, "int8_t", NULL}, - {PSI_T_INT16, "int16_t", NULL}, - {PSI_T_INT32, "int32_t", NULL}, - {PSI_T_INT64, "int64_t", NULL}, - {PSI_T_UINT8, "uint8_t", NULL}, - {PSI_T_UINT16, "uint16_t", NULL}, - {PSI_T_UINT32, "uint32_t", NULL}, - {PSI_T_UINT64, "uint64_t", NULL}, -EOF - cat >>$PSI_TYPES <@ = { -EOF - cat >>$PSI_STRUCTS <@ = { -EOF - cat >>$PSI_UNIONS <@ = { -EOF - cat >>$PSI_CONSTS <@ = { -EOF - cat >>$PSI_REDIRS <@ = { -EOF - cat >>$PSI_MACROS <>$PSI_DECLS <@ = { -EOF - cat >>$PSI_VA_DECLS <@ = { -EOF - cat >>$PSI_FN_DECLS <@ = { -EOF + PSI_STDTYPES= + PSI_CONSTS= + + AC_CONFIG_FILES( + [$PHP_PSI_BUILDDIR/php_psi_stdinc.h:$PHP_PSI_SRCDIR/php_psi_stdinc.h.in] + [$PHP_PSI_BUILDDIR/php_psi_posix.h:$PHP_PSI_SRCDIR/php_psi_posix.h.in] + [$PHP_PSI_BUILDDIR/php_psi_cpp.h:$PHP_PSI_SRCDIR/php_psi_cpp.h.in] + ) + ]) dnl PSI_CONFIG_DONE() dnl Finish the headers with the pre-defined types etc. AC_DEFUN(PSI_CONFIG_DONE, [ - - wait - - if $PSI_FAST_CONFIG; then - for conf_env in $PSI_CONFIG_TMP/*/conf.env; do - source $conf_env - done - fi - psi_eval_LIBS=$LIBS LIBS=$psi_save_LIBS PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD) - cat >$PSI_STDINC <>$i < -AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)]) - -dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not) -dnl Internal. Used to check if --enable-psi-posix=section was given. -AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [ - AS_TR_SH([psi_config_posix_]$1)=false - case "$PHP_PSI_POSIX" in - yes|all) - AS_TR_SH([psi_config_posix_]$1)=true - ;; - *) - if expr "$PHP_PSI_POSIX" : '\b$1\b' >/dev/null; then - AS_TR_SH([psi_config_posix_]$1)=true - fi - ;; - esac - if $AS_TR_SH([psi_config_posix_]$1); then - ifelse([$2],,:,[$2]) - else - ifelse([$3],,:,[$3]) - fi -]) - -dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not) -dnl Shell-if test if PSI POSIX section was configured. -AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [ - if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then - ifelse([$2],,:,[$2]) - else - ifelse([$3],,:,[$3]) - fi -]) - -dnl PSI_CONFIG_POSIX(section, headers) -AC_DEFUN(PSI_CONFIG_POSIX, [ - PSI_CONFIG_POSIX_ENABLED($1, [ - if $PSI_FAST_CONFIG; then - PSI_CONFIG_POSIX_PARALLEL($1, $2) - else - ifelse([$2],,:,[AC_CHECK_HEADERS($2)]) - AS_TR_CPP([PSI_CHECK_$1]) - fi - ]) -]) - -AC_DEFUN([PSI_CONFIG_POSIX_PARALLEL], [ - ( - dnl setup - mkdir $PSI_CONFIG_TMP/AS_TR_SH([$1]) - ln -s $(pwd)/confdefs.h $PSI_CONFIG_TMP/AS_TR_SH([$1])/confdefs.h - - dnl restore stdio - exec 66>&AS_MESSAGE_FD - exec AS_MESSAGE_FD>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stdout.log - exec 2>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stderr.log - - dnl check for headers? - ifelse([$2],,:,[AC_CHECK_HEADERS($2)]) - - dnl chaway - cd $PSI_CONFIG_TMP/AS_TR_SH([$1]) - - dnl run checks - AS_TR_CPP([PSI_CHECK_$1]) - - dnl save libs - cat >$PSI_CONFIG_TMP/AS_TR_SH([$1])/conf.env <&66 - ) & + [PSI_INCLUDES]="PSI_INCLUDES" + AC_SUBST([PSI_INCLUDES]) + AC_SUBST([PSI_STDTYPES]) + AC_SUBST([PSI_CONSTS]) + AC_SUBST([PSI_CPP_SEARCH]) + AC_SUBST([PSI_CPP_PREDEF]) ]) AC_DEFUN(PSI_PTHREAD_ONCE, [ @@ -265,16 +92,15 @@ AC_DEFUN(PSI_PTHREAD, [ dnl PSI_INCLUDES() dnl Expands to a complete list of include statements including -dnl AC_INCLUDES_DEFAULT(). -AC_DEFUN(PSI_INCLUDES, [dnl -#define PSI_INCLUDES +dnl autoconf's defaults. +AC_DEFUN(PSI_INCLUDES, [ #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif #ifndef _REENTRANT # define _REENTRANT #endif -AC_INCLUDES_DEFAULT() +$ac_includes_default #ifdef HAVE_STDBOOL_H # include #else @@ -311,6 +137,9 @@ typedef bool _Bool; #ifdef HAVE_ARPA_NAMESER_H # include #endif +#ifdef HAVE_ARPA_INET_H +# include +#endif #ifdef HAVE_FCNTL_H # include #endif @@ -371,8 +200,14 @@ AC_DEFUN(PSI_LEMON, [ AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project) if test -z "$LEMON" then - AC_PATH_PROG(LEMON, lemon, ./lemon) + AC_PATH_PROG(LEMON, lemon, $PHP_PSI_BUILDDIR/lemon) + if expr + "$LEMON" : "/" >/dev/null; then + LEMON_PATH= + else + LEMON_PATH=$abs_builddir/ + fi fi + PHP_SUBST(LEMON_PATH) PHP_SUBST(LEMON) ]) @@ -410,7 +245,7 @@ AC_DEFUN([PSI_SH_TEST_ALIGNOF], [test -n "$AS_TR_SH([ac_cv_alignof_]$1)" && test dnl PSI_CHECK_SIZEOF(type, special-includes) dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES -dnl Defines psi\\SIZEOF_ pre-defined constant in $PSI_CONSTS. +dnl Defines psi\\SIZEOF_ pre-defined constant in $PSI_CONSTS_H. AC_DEFUN(PSI_CHECK_SIZEOF, [ AC_CHECK_SIZEOF($1, [], PSI_INCLUDES $2) @@ -421,7 +256,7 @@ AC_DEFUN(PSI_CHECK_SIZEOF, [ dnl PSI_CHECK_ALIGNOF(type, special-includes) dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES -dnl Defines psi\\ALIGNOF_ pre-defined constant in $PSI_CONSTS. +dnl Defines psi\\ALIGNOF_ pre-defined constant in $PSI_CONSTS_H. AC_DEFUN(PSI_CHECK_ALIGNOF, [ AC_CHECK_ALIGNOF($1, PSI_INCLUDES $2) @@ -439,7 +274,7 @@ AC_DEFUN(PSI_CHECK_OFFSETOF, [ [offset of $2 in $1], [AS_TR_SH([ac_cv_offsetof_$1_$2])], [(long int) (offsetof ($1, $2))], - [PSI_INCLUDES], + PSI_INCLUDES, [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])] ) AC_DEFINE_UNQUOTED( @@ -535,6 +370,13 @@ AC_DEFUN(PSI_CHECK_LIBFFI, [ AC_MSG_WARN([Could not find libffi, please provide the base install path]) fi fi + + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $INCLUDES" + AC_CHECK_DECL(FFI_STDCALL,[AC_DEFINE([HAVE_FFI_STDCALL],[1],[ ])],,[#include "ffi.h"]) + AC_CHECK_DECL(FFI_FASTCALL,[AC_DEFINE([HAVE_FFI_FASTCALL],[1],[ ])],,[#include "ffi.h"]) + CFLAGS=$save_CFLAGS + PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [ PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [ AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])