]> granicus.if.org Git - php/commitdiff
Implement extension load-order deps.
authorWez Furlong <wez@php.net>
Sun, 18 Jul 2004 12:03:51 +0000 (12:03 +0000)
committerWez Furlong <wez@php.net>
Sun, 18 Jul 2004 12:03:51 +0000 (12:03 +0000)
acinclude.m4
build/genif.sh
build/order_by_dep.awk [new file with mode: 0644]
configure.in
ext/dom/config.m4
ext/simplexml/config.m4
ext/spl/config.m4
ext/xml/config.m4
ext/xsl/config.m4

index 084f70cc56dbbc434bb62bfb13e47f29a3053ab1..22fa4287284a57f0cd554abb85e8275340e8d6f2 100644 (file)
@@ -1920,3 +1920,14 @@ AC_DEFUN(PHP_TEST_BUILD, [
     LIBS=$old_LIBS
   ])
 ])
+
+dnl This macro is currently a placeholder in the config.m4 file
+dnl it is scanned by genif.sh when it builds the internal functions
+dnl list, so that modules can be init'd in the correct order
+dnl $1 = name of extension, $2 = extension upon which it depends
+dnl $3 = optional: if true, it's ok for $2 to have not been configured
+dnl default is false and should halt the build.
+dnl See ADD_EXTENSION_DEP in win32 build 
+AC_DEFUN(PHP_ADD_EXTENSION_DEP, [])
+
+
index cb5233b5ac8e3dba2453fca1bc668cfc72b27d9c..6fb8fc391fbc08192f03f0370ed83b675d9372ad 100644 (file)
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $Id: genif.sh,v 1.3 2002-03-22 10:22:41 sas Exp $
+# $Id: genif.sh,v 1.4 2004-07-18 12:03:51 wez Exp $
 # replacement for genif.pl
 
 infile=$1
@@ -17,13 +17,13 @@ if test -z "$infile" || test -z "$srcdir"; then
        exit 1
 fi
 
-module_ptrs=$extra_module_ptrs
 header_list=
 olddir=`pwd`
 cd $srcdir
 
+module_ptrs="$extra_module_ptrs`echo $@ | $awk -f ./build/order_by_dep.awk`"
+
 for ext in ${1+"$@"} ; do
-       module_ptrs="   phpext_${ext}_ptr,@NEWLINE@$module_ptrs"
        header_list="$header_list ext/$ext/*.h"
 done
 
diff --git a/build/order_by_dep.awk b/build/order_by_dep.awk
new file mode 100644 (file)
index 0000000..38128b2
--- /dev/null
@@ -0,0 +1,89 @@
+BEGIN {
+       orig_rs = RS;
+       orig_fs = FS;
+       RS=" ";
+       mod_count = 0;
+       SUBSEP=":";
+}
+
+function get_deps(module_name,       depline, cmd)
+{
+       # this could probably be made *much* better
+       RS=orig_rs;
+       FS="[(,) \t]+"
+       cmd = "grep PHP_ADD_EXTENSION_DEP ext/" module_name "/config*.m4"
+       while (cmd | getline) {
+#              printf("GOT: %s,%s,%s,%s,%s\n", $1, $2, $3, $4, $5);
+               if (!length($5)) {
+                       $5 = 0;
+               }
+               mod_deps[module_name, $4] = $5;
+       }
+       close(cmd)
+       RS=" ";
+       FS=orig_fs;
+}
+
+function get_module_index(name,  i)
+{
+       for (i in mods) {
+               if (mods[i] == name) {
+                       return i;
+               }
+       }
+       return -1;
+}
+
+function do_deps(mod_idx,        module_name, mod_name_len, dep, ext, val, depidx)
+{
+       module_name = mods[mod_idx];
+       mod_name_len = length(module_name);
+
+       for (ext in mod_deps) {
+               if (substr(ext, 0, mod_name_len+1) != module_name SUBSEP) {
+                       continue;
+               }
+               val = mod_deps[ext];
+               ext = substr(ext, mod_name_len+2, length(ext)-mod_name_len);
+
+               depidx = get_module_index(ext);
+               if (depidx >= 0) {
+                       do_deps(depidx);
+               }
+       }
+
+       #printf("       phpext_%s_ptr,\n", module_name);
+       printf("        phpext_%s_ptr,@NEWLINE@", module_name);
+       delete mods[mod_idx];
+}
+
+function count(arr,       n, i)
+{
+       n = 0;
+       for (i in arr)
+               n++;
+       return n;
+}
+
+/^[a-zA-Z0-9_-]+/ {
+       # mini hack for pedantic awk
+       gsub("[^a-zA-Z0-9_-]", "", $1)
+       # add each item to array
+       mods[mod_count++] = $1
+
+       # see if it has any module deps
+       get_deps($1);
+}
+END {
+       # order it correctly
+       out_count = 0;
+       
+       while (count(mods)) {
+               # count down, since we need to assemble it in reverse order
+               for (i = mod_count-1; i >= 0; --i) {
+                       if (i in mods) {
+                               do_deps(i);
+                       }
+               }
+       }
+}
index 3a417526635e720040deb0655cadea9d7e43e59a..bd56fc63ac01053bfc14fcd92fb62e701a738eca 100644 (file)
@@ -130,7 +130,31 @@ PHP_RUNPATH_SWITCH
 PHP_PROG_RE2C
 AC_PROG_RANLIB
 AC_PROG_LN_S
-AC_PROG_AWK
+
+dnl Some vendors force mawk before gawk; mawk is broken so we don't like that,
+dnl and check manually
+dnl AC_PROG_AWK
+AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
+case "$AWK" in
+       *mawk)
+               AC_MSG_WARN([mawk is known to have problems on some systems.  You should install GNU awk])
+               ;;
+       *gawk)
+               ;;
+       bork)
+               AC_MSG_ERROR([Could not find awk; Install GNU awk])
+               ;;
+       *)
+               AC_MSG_CHECKING([if $AWK is broken])
+               if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
+                       AC_MSG_RESULT([yes])
+                       AC_MSG_ERROR([You should install GNU awk])
+               else
+                       AC_MSG_RESULT([no - good!])
+               fi
+               ;;
+esac
+
 AC_PROG_YACC
 if test "$YACC" != "bison -y"; then
     AC_MSG_WARN([You will need bison if you want to regenerate the PHP parsers.])
index 82c97e6bd34ce4fb54f2c1142ccdd617b71e9937..d4eea28109536f4d9b79799dcecf09a25416c703 100644 (file)
@@ -26,6 +26,7 @@ if test "$PHP_DOM" != "no" && test "$PHP_LIBXML" != "no"; then
                             typeinfo.c domerror.c domlocator.c namednodemap.c userdatahandler.c], 
                             $ext_shared)
     PHP_SUBST(DOM_SHARED_LIBADD)
+       PHP_ADD_EXTENSION_DEP(dom, libxml)
   ], [
     AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
   ])
index 9fa9c455edc2a6d81cc379283432e1fea3434b78..1869c2056155d5415d9dc89f3446c23f4641c086 100644 (file)
@@ -18,4 +18,5 @@ if test "$PHP_SIMPLEXML" != "no" && test "$PHP_LIBXML" != "no"; then
   ], [
     AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
   ])
+  PHP_ADD_EXTENSION_DEP(simplexml, libxml)
 fi
index 0f5e43181d2546f81cec068964d2d2e05855d726..f5b5639ddf17f7cbece7a8e1712d6f16ff5ca297 100755 (executable)
@@ -10,4 +10,5 @@ if test "$PHP_SPL" != "no"; then
   fi
   AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support]) 
   PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c, $ext_shared)
+  PHP_ADD_EXTENSION_DEP(spl, simplexml)
 fi
index 72c98ed8145fca5a8214ab19a0241bdc6613b2e0..a7c87e3673334cd7aa5b3c508c088cb93cf805dd 100644 (file)
@@ -47,5 +47,6 @@ if test "$PHP_XML" != "no" && test "$PHP_LIBXML" != "no" -o "$PHP_LIBEXPAT_DIR"
 
   PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared)
   PHP_SUBST(XML_SHARED_LIBADD)
+  PHP_ADD_EXTENSION_DEP(xml, libxml)
   AC_DEFINE(HAVE_XML, 1, [ ])
 fi
index 13290409ac293787725f79420fc408fdb50fe916..552ed94f2de2add4d99abc1616c5433296f9a943 100644 (file)
@@ -59,4 +59,5 @@ if test "$PHP_XSL" != "no"; then
   AC_DEFINE(HAVE_XSL,1,[ ])
   PHP_NEW_EXTENSION(xsl, php_xsl.c xsltprocessor.c, $ext_shared)
   PHP_SUBST(XSL_SHARED_LIBADD)
+  PHP_ADD_EXTENSION_DEP(xsl, libxml)
 fi