简体   繁体   中英

phpize's config.m4 with more than one source file in PHP_NEW_EXTENSION produces a Makefile that does nothing

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM