tags:

views:

66

answers:

2

The standard way of writing PHP extensions is to use autoconf/automake alongside a script called phpize, which seems to generate your autoconf configuration based on a template that's specific to your PHP environment. This let's it build the PHP extension for the right version of PHP, etc.

autoconf and the m4 language that is used to configure it is arcane, and people have written alternatives, such as scons. I want to be able to use one of these when building a PHP extension.

In principle, you should be able to use scons or similar tools to build PHP extensions. However, I can't see how you would replace the phpize step.

Has anyone had any success in building PHP extensions with scons, or another more modern build tool?

A: 

phpize(1) is just a shell script, so i guess you could modify it to work with scons...

echo
Phpize copies a template chunk of m4 code from the user's environment. The problem is, I don't know the environment-specific ways in which this fragment can differ, so I don't know which parameters I would need to extract from it.
Sam Minnée
Hmm yeh i dont know. i was just throwing it out there because i happened to remember it being a shell script.
echo
A: 

The path of least resistance would be to have SCons run autoconf, phpize and whatever else is needed for your PHP extension. You may be able to extract the compiler configuration out of there and let SCons do the actual building, or you can simply have SCons run "make".

Declaring shell command targets from SCons is easy, but getting dependencies right is always tricky.

Basically you will have to let SCons know of any intermediate file produced by these external tools. This way it can not only properly clean them, but it can also cache the whole series of steps based on the content signature of each intermediate result (MD5 checksum).

Proper caching will significantly reduce the number of times these external tools will actually need to be invoked as the code base changes.

While I don't think somebody has written a specific solution for PHP, there are lots of custom builders on the SCons wiki that do similar things.

BennyG