« php-config
Composer 入門 »

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

警告

PECL は非推奨です。 PHP Installer for Extensions (PIE) は PECL を置き換えるものです。 拡張モジュールのインストールには PIE を使うことを推奨します。 詳しい情報は、 » https://github.com/php/pie を参照ください。

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 スクリプトを実行するためには、autoconf 2.68 と automake 1.4+ が必要です (新しいバージョンの autoconf でも動作するかも知れませんが、 サポートされていません)。

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

$ ./configure --help | grep extname
関連キーワード:
拡張   extname   configure   path   スクリプト   buildconf   enable   help   make   autoconf   config   Composer   入門   非推奨   Installer   Extensions   推奨   https   github   ソース   pecl   download   gzip   上記   再実行
関連する関数・ページ:
install.pecl.pear   install.pecl.downloads   install.pecl.phpize   install.pecl.intro   install.pecl   install.pecl.windows