Richard Quadling:
> Hi.
> 
> I'm new to compiling PHP on windows, so this may be a real newbie question.
> 
> My expectation of make-like tools is that they describe the how to
> create targets from sources (in a nutshell).
> 
> So, just for example, TSRM/readdir.h. I would expect that if I altered
> this file and then ran my make program (nmake for me on Windows with
> MS VC++ 2008 Express Edition), then TSRM would be built and all
> binaries re-linked that use this (again, in a nutshell).
> 
> What is happening is that the makefile has no knowledge of this header
> file, so it can't be used to make anything.
> 
> Is this expected behaviour? Please don't focus on just TSRM/readdir.h
> as this was one file I picked at random (as I had edited it recently).
> 
> Should editing ANY source level file (.h, .c type files) result in a make?
> 
> Or is it just .c files?

This is a bug in PHP Makefiles. You can use the depend.php script
that ships with my taint-for-PHP code. http://wiki.php.net/rfc/taint.

To apply (on *n*x systems):

$ cd $PHP_SOURCE
$ php depend.php >Makefile.fixed
$ make -f Makefile.fixed

It's a bit ugly, because it originally not written in PHP.

        Wietse

#!/some/where/php
<?php

# Usage: php depend.php
#
# The PHP 5.2.3 top-level Makefile provides very few include file
# dependencies. This results in an instantaneous "Build complete"
# message after changing a critical file such as Zend/zend.h.
#
# This script reads the PHP top-level Makefile, and emits on stdout
# a copy of that same Makefile, with source/include file dependencies
# appended at the end. Typically you'd redirect output to an alternate
# Makefile, and then build PHP by running "make -f altmakefile ..."
#
# On my 2GHz laptop the script runs for about 13 seconds; that is
# less than a tenth of the time needed for "make clean; make all",
# so it pays off relatively quickly.
#
# How this script works: it scans the PHP top-level Makefile for
# libtool commands (there's one for each .lo file). It then transforms
# those libtool commands into "$(CC) -M" commands that will produce
# the desired source/include file dependencies, and pipes those
# commands into a "make -f -" command. This script uses "make" because
# the "$(CC) -M" commands contain macros that are defined in the PHP
# top-level Makefile.
#
# The rest is a matter of fixing up the output. "$(CC) -M" assumes
# that we want source/include file dependencies for .o files in the
# current directory, but we need rules for .lo files in subdirectories
# instead.
#
# The script also massages the "$(CC) -M" output into portable form,
# by removing the system-dependent /usr/include dependencies and the
# site-dependent location of the build directory; this part is not
# strictly necessary and can easily be removed.
#
# Paranoia: we try to make sure that we miss no LIBTOOL command,
# otherwise we would miss dependencies for the corresponding .lo
# file,  and the build would use out-of-date .lo files.
#

# First copy the top-level Makefile to stdout, followed by a separator.
#
system("cat Makefile");
print "\n# BEGIN ADDITIONAL SOURCE/INCLUDE FILE DEPENDENCIES\n\n";

# Pipe Makefile-on-stdin rules into a "make" command.
#
$cwd = getcwd();
$make_portable = 
    "| sed -e 's;/usr/include/[^ ]* ;;g' -e '/^  *\\\\/d' -e 's;$cwd/;;g'";
($MAKE = popen("cat Makefile - | make -f - __depend__ $make_portable", "w")) || 
    die("Cannot execute \"make\"\n");

fprintf($MAKE, "\n__depend__:\n");

($MAKEFILE = fopen("Makefile", "r")) || die("Cannot open \"Makefile\"\n");
while (($line = fgets($MAKEFILE)) != FALSE) {
    if 
(preg_match("/^\s+\S\(LIBTOOL\)\s+--mode=compile\s+(\S\(CC\))\s+(.+)\s+-c\s+(.+)\s+-o\s+(\S+)/",
 $line, $s)) {
        fprintf($MAKE, "[EMAIL PROTECTED] -M $s[2] $s[3] | sed 's;^[^ ]*: 
;$s[4]: ;'\n");
        continue;
    }
    if (preg_match("/^\s+\S\(LIBTOOL\)\s+--mode=link/", $line)) {
        continue;
    }
    if (preg_match("/^\s+\S\(LIBTOOL\)/", $line)) {
        die("Unrecognized LIBTOOL command line in Makefile: $line\n");
    }
}
fclose($MAKEFILE);

# Wait until the "make" commands complete.
#
$status = pclose($MAKE);
print("Zend/zend_vm_execute.h: Zend/zend_vm_def.h\n");
print("\t(cd Zend; php zend_vm_gen.php --with-vm-kind=CALL)\n");
exit(($status & 0xff) | ($status >> 8));
?>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to