dsz1966 2014-05-29 16:22
浏览 173
已采纳

phpize的config.m4在PHP_NEW_EXTENSION中有多个源文件会产生一个什么也不做的Makefile

I am trying to write a C extension to PHP. This is my config.m4. Straight out of helloworld, almost

PHP_ARG_ENABLE(my_ext, whether to enable my_ext support,
[ --enable-my-ext   Enable My Ext support])

if test "$PHP_MY_EXT" = "yes"; then
  AC_DEFINE(HAVE_MY_EXT, 1, [Whether you have my ext])
  PHP_NEW_EXTENSION(my_ext, my_ext.c,  $ext_shared)
fi

When I run phpize and ./configure, it generates a Makefile that works. Looking good so far.

Now, if I add an additional source file to PHP_NEW_EXTENSION, things break down. As per here and here, the call should look like:

PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)

The full syntax:

PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])

Ok, so I add my extra source file (logging.c) to that list:

PHP_NEW_EXTENSION(my_ext, my_ext.c, logging.c  $ext_shared)

and phpize/configure produce a Makefile that runs successfully, but does not actually build anything. (yes, I've done make distclean, phpize --clean, etc.)

I diffed the successful Makefile vs. the broken one, and here are the differences:

$ diff Makefile Makefile.broken 
14d13
< shared_objects_my_ext = my_ext.lo
16c15
< PHP_MODULES = $(phplibdir)/my_ext.la
---
> PHP_MODULES =
170,175d168
< $(phplibdir)/my_ext.la: ./my_ext.la
<   $(LIBTOOL) --mode=install cp ./my_ext.la $(phplibdir)
< 
< ./my_ext.la: $(shared_objects_my_ext) $(MY_EXT_SHARED_DEPENDENCIES)
<   $(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_my_ext) $(MY_EXT_SHARED_LIBADD)
< 

Anyone know what is going on here?

BTW, if I leave out the extra source file, I get compiler warnings about functions in that file having "internal linkage but is not defined".

展开全部

  • 写回答

1条回答 默认 最新

  • duanliao5995 2014-06-04 15:16
    关注

    Try moving the 2nd comma

    PHP_NEW_EXTENSION(my_ext, my_ext.c, logging.c $ext_shared)

    To

    PHP_NEW_EXTENSION(my_ext, my_ext.c logging.c, $ext_shared)

    If I understand the documentation correctly, the 2nd argument should be a space separated list of your sources.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部