Compiling PECL extensions statically into PHP

It may be necessary to build a PECL extension statically into the PHP binary. To do this, the extension source will need to be placed under the /path/to/php/src/dir/ext/ directory, and the PHP build system will be required to regenerate its configure script.

$ cd /path/to/php/src/dir/ext
$ pecl download extname
$ gzip -d < extname.tgz | tar -xvf -
$ mv extname-x.x.x extname

This will result in the following directory:


From here, PHP needs to be forced to rebuild the configure script, and then it can be built as normal:

$ cd /path/to/php/src/dir
$ rm configure
$ ./buildconf --force
$ ./configure --help
$ ./configure --with-extname --enable-someotherext --with-foobar
$ make
$ make install

Note: To run the buildconf script, the autoconf 2.68 and automake 1.4+ will be needed. Newer versions of autoconf may work but are not supported.

Whether --enable-extname or --with-extname is used depends on the extension. Typically, an extension that does not require external libraries uses --enable. To be sure, run the following after buildconf:

$ ./configure --help | grep extname