- cat >$PHP_PSI_BUILDDIR/php_psi.dep <<EOF
-\$(PHP_PSI_SRCDIR)/php_psi.h:
-php_psi.h:
-\$(PHP_PSI_SRCDIR)/php_psi_stdinc.h:
-php_psi_stdinc.h:
-EOF
- for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_MACROS $PSI_DECLS $PSI_VA_DECLS $PSI_FN_DECLS; do
- cat >>$PHP_PSI_BUILDDIR/php_psi.dep <<EOF
-$i:
-$(basename $i):
-EOF
- cat >$i <<EOF
-/* generated by configure */
-#include "php_psi_stdinc.h"
-EOF
- done
- cat >>$PSI_STDTYPES <<EOF
-static struct psi_std_type {
- token_t type_tag;
- const char *type_name;
- const char *alias;
-} psi_std_types@<:@@:>@ = {
- {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
-static struct psi_predef_type {
- token_t type_tag;
- const char *type_name;
- const char *alias;
-} psi_predef_types@<:@@:>@ = {
-EOF
- cat >>$PSI_STRUCTS <<EOF
-static struct psi_predef_struct {
- token_t type_tag;
- const char *type_name;
- const char *var_name;
- size_t offset;
- size_t size;
- size_t pointer_level;
- size_t array_size;
-} psi_predef_structs@<:@@:>@ = {
-EOF
- cat >>$PSI_UNIONS <<EOF
-static struct psi_predef_union {
- token_t type_tag;
- const char *type_name;
- const char *var_name;
- size_t offset;
- size_t size;
- size_t pointer_level;
- size_t array_size;
-} psi_predef_unions@<:@@:>@ = {
-EOF
- cat >>$PSI_CONSTS <<EOF
-static struct psi_predef_const {
- token_t type_tag;
- const char *type_name;
- const char *var_name;
- const char *val_text;
- token_t val_type_tag;
-} psi_predef_consts@<:@@:>@ = {
-EOF
- cat >>$PSI_REDIRS <<EOF
-typedef void (*psi_func_ptr)();
-static struct psi_func_redir {
- const char *name;
- psi_func_ptr func;
-} psi_func_redirs@<:@@:>@ = {
-EOF
- cat >>$PSI_MACROS <<EOF
-EOF
- cat >>$PSI_DECLS <<EOF
-static struct psi_predef_decl {
- token_t type_tag;
- const char *type_name;
- const char *var_name;
- size_t pointer_level;
- size_t array_size;
-} psi_predef_decls@<:@@:>@ = {
-EOF
- cat >>$PSI_VA_DECLS <<EOF
-static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
-EOF
- cat >>$PSI_FN_DECLS <<EOF
-static struct psi_predef_decl psi_predef_functor_decls@<:@@:>@ = {
-EOF
+ psi_save_LIBS=$LIBS
+ LIBS=
+
+ ac_includes_default="AC_INCLUDES_DEFAULT"
+
+ AC_PROG_AWK
+ AC_PATH_PROG(NM, nm)
+ AC_CACHE_CHECK(for libc start main symbol, psi_cv_libc_main, [
+ psi_libc_main=
+ AC_TRY_LINK(PSI_INCLUDES, [(void)0;], [
+ psi_libc_main=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
+ ])
+ psi_cv_libc_main=$psi_libc_main
+ ])
+
+ AC_MSG_CHECKING(for preprocessor defaults)
+ psi_cpp_predef=`$CPP -Wp,-dM $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 - </dev/null`
+ psi_cpp_search=`$CPP -Wp,-v $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 - </dev/null 2>&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
+
+ PSI_STDTYPES=
+ PSI_TYPES=
+ PSI_COMPOSITES=
+ PSI_CONSTS=
+ PSI_REDIRS=
+ PSI_MACROS=
+ PSI_DECLS=
+
+ 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_WAIT()
+dnl Internal: waits for sub configures in maintainer mode
+AC_DEFUN(PSI_CONFIG_WAIT, [
+ wait
+ if test $? -gt 0; then
+ cat $PSI_CONFIG_TMP/*/stderr.log >&2
+ exit 1
+ fi