PECL 拡張モジュールを PHP に静的に組み込む

PECL 拡張モジュールを PHP に静的に組み込みたいと思うこともあるでしょう。 そのためには、拡張モジュールのソースを /path/to/php/src/dir/ext/ ディレクトリに置き、PHP にその設定スクリプトを生成させる必要があります。

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

上記を行うと、以下のディレクトリが作成されます。


/path/to/php/src/dir/ext/extname

これ以降、PHP に configure スクリプトを再実行させ、通常通りに PHP をビルドします。


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

注意: buildconf スクリプトを実行するためには、autoconf2.68automake1.4+ が必要です (新しいバージョンの autoconf でも動作するかも知れませんが、 サポートされていません)。

拡張モジュールによって、--enable-extname もしくは --with-extname オプションを指定します。 外部ライブラリを使用しない拡張モジュールについては、 --enable が使われるのが一般的です。 buildconf の後で、以下を行うと確認できます。


$ ./configure --help | grep extname
To Top