configure: add --enable-psi-maintainer-mode
[m6w6/ext-psi] / m4 / psi / psi.m4
index c8eec1850d9f546efeef16b550e39bbf1be9c38a..b979719862a2db08fff771411158c4c7def3fe7d 100644 (file)
@@ -16,6 +16,27 @@ dnl Creates stubs of the headers with pre-defined types etc.
 dnl These headers are included by src/context.c.
 dnl This macro must be called prior any checks for a type, struct, decl etc.
 AC_DEFUN(PSI_CONFIG_INIT, [
+       psi_save_LIBS=$LIBS
+       LIBS=
+
+       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 <<EOF
 \$(PHP_PSI_SRCDIR)/php_psi.h:
 php_psi.h:
@@ -114,6 +135,19 @@ EOF
 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 <<EOF
 /* generated by configure */
 #ifndef PSI_STDINC_H
@@ -181,13 +215,44 @@ AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
 dnl PSI_CONFIG_POSIX(section, headers)
 AC_DEFUN(PSI_CONFIG_POSIX, [
        PSI_CONFIG_POSIX_ENABLED($1, [
-               PHP_CONFIGURE_PART(Configuring PSI POSIX: $1)
-               ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
-       ], [
-               return 0
+               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 <<EOF
+LIBS="$LIBS \$LIBS"
+EOF
+               dnl done
+               printf "%s " "$1" >&66
+       ) &
+])
+
 AC_DEFUN(PSI_PTHREAD_ONCE, [
        AX_PTHREAD([
                LIBS="$PTHREAD_LIBS $LIBS"