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".