注意需要重新执行phpize,config.m4的修改才会生效;
在执行./configure时,所有的输出将记录到config.log里,通过查看此文件可以调试config.m4。
如何从零开始创建一个php扩展可以参见文章php扩展-扩展的生成和编译,
config.m4文件常用的语句和宏
以下将以”myext”作为正在开发的扩展名称进行举例:
1. 由用户输入配置选项
比如–enable-myext, –with-myext-includedir=dir
php_arg_enable(myext, whether to enable myext support,
[ --enable-ext enable ext support])
在configure –help时将输出:–enable-ext enable ext support
php_arg_with(myext-includedir, for myext header,
[ --with-myext-includedir=dir myext header files], no, no)
在configure –help时将输出:–with-myext-includedir=dir myext header files
2. 输出信息
ac_msg_checking(message), 在执行configure命令时输出”checking “;
ac_msg_result(value), 输出check的结果;
ac_msg_error(message), 输出一条消息并退出configure的执行;
3. 添加包含路径
php_add_include(path), 添加编译时的包含路径;
4. 链接第三方库
php_add_library_with_path(),添加编译时的链接库路径
php_add_library(), 添加链接库;
5. 其他
ac_define(name,value,description), 向php_config.h添加一个define:#define name value // description;
ac_try_compile (includes, function-body, [action-if-found [, action-if-not-found]])
示例如下:
... ac_msg_checking(php version) ... ac_msg_result([$php_version]) ... php_major_version=`echo $php_version | sed -e 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/ \1/g' 2>/dev/null`if test $php_major_version -lt 5; thenac_msg_error([need at least php 5 or newer])fi... php_add_include([$ext_srcdir/snappy]) ... php_add_library_with_path(snappy, $libsnappy_libdir, snappy_shared_libadd) ... libname=stdc++php_add_library($libname, , snappy_shared_libadd)
