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?
Regards
Richard Quadling.
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
Hi Richard,
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).
Yes that's expected behaviour. If you change a header file you need to
rebuild from scratch (make clean - no idea if that works, never tried it
under doze - deleting Release_TS or Debug_TS and running config.nice should
be enough. If you add a file you need to remember to add it in config.w32
(and config.m4), delete the build dirs and run buildconf. If you change
something in .c source you can just run make and the existing build will be
updated, but it's still best to do a clean build prior to committing those
changes.
- Steph
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 nx 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, "\t@$s[1] -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));
?
Hi!
Should editing ANY source level file (.h, .c type files) result in a make?
Theoretically, it should. But it's as good as makefile dependencies, of
course. I'm not sure PHP configure script generates dependencies for all
files...
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Hi Stas,
Should editing ANY source level file (.h, .c type files) result in a
make?Theoretically, it should. But it's as good as makefile dependencies, of
course. I'm not sure PHP configure script generates dependencies for all
files...
I spent some time looking into this yesterday (Richard and I had one of
those off-list exchanges). Not sure if *nix compilers work in the same way,
but under Windows nmake treats any headers included in source files as
"implicit prerequisites". Only explicit header declarations are compiled in
their own right.
I'd assume that this is what knocked almost 15 minutes off the build time
when moving from our .dsp files (which had explicit header declarations) to
the config.w32 setup.
Keeping in mind that headers are far less likely to be altered than C files
once an API is stable, there doesn't seem much point in making the build
slower or the task of writing config.w32 files more complex just so's those
undertaking active development won't need to make clean and re-run configure
now and again.
- Steph
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com