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".
我正在尝试为PHP编写C扩展。 这是我的config.m4。 直接离开helloworld,几乎 p>
PHP_ARG_ENABLE(my_ext,是否启用my_ext支持,
[--enable-my-ext启用My Ext支持])
if 测试“$ PHP_MY_EXT”=“是”; 然后
AC_DEFINE(HAVE_MY_EXT,1,[你有我的分机])
PHP_NEW_EXTENSION(my_ext,my_ext.c,$ ext_shared)
fi
code> pre>
我运行phpize和./configure,它生成一个有效的Makefile。 到目前为止看起来不错。 strong> p>
现在,如果我将其他源文件添加到PHP_NEW_EXTENSION strong>,事情就会中断。 根据此处和这里,调用应如下所示: p>
PHP_NEW_EXTENSION(foo,foo.c bar.c baz.cpp,$ ext_shared)
code> pre>
完整语法: p>
PHP_NEW_EXTENSION(extname,sources [,shared [,sapi_class [,extra-cflags]]])
code> pre>
好的,所以 我将额外的源文件(logging.c)添加到该列表中: p>
PHP_NEW_EXTENSION(my_ext,my_ext.c,logging.c $ ext_shared)
code>
和phpize / configure 生成一个成功运行的Makefile,但实际上并没有构建任何东西。 strong>(是的,我做过distclean,phpize --clean, 等。 p>
我将成功的Makefile与破坏的文件进行了差异化,这里有不同之处: p>
$ diff Makefile Makefile。 破碎
14d13
&lt; shared_objects_my_ext = my_ext.lo
16c15
&lt; PHP_MODULES = $(phplibdir)/my_ext.la
---
&gt; PHP_MODULES =
170,175d168
&lt; $(phplibdir)/my_ext.la:./my_ext.la
< $(LIBTOOL)--mode = install cp ./my_ext.la $(phplibdir)
&lt;
&LT; ./my_ext.la:$(shared_objects_my_ext)$(MY_EXT_SHARED_DEPENDENCIES)
&lt; $(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)
&lt;
code> pre>
任何人都知道这里发生了什么? p>
BTW,如果我遗漏了额外的源文件,我会得到编译器 关于该文件中具有“内部链接但未定义”的函数的警告。 p>
div>
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.