Search code examples
phpcbuildphp-extensionm4

Add sources to build php extension


I want to write a test php extension, which will provide a test class. I want to extract class declaration into a separate C-File and call class registration from module init function of myext.c file. I have the following files:

   testlib/
    test_class.c
   myext.c
   php_myext.h
   config.m4
   ...

Now config.m4 file is quite simple:

PHP_ARG_ENABLE(myext, [whether to enable myext support], [  --enable-myext           Enable myext support])

if test "$PHP_MYEXT" != "no"; then
  PHP_NEW_EXTENSION(myext, myext.c, $ext_shared)
fi

How to configure config.m4 to be able to add test_class.c to extension building?

UPDATE:

How to configure config.m4 to make it searching .c files in a specific folder and add to extension building automatically?


Solution

  • It's pretty straightforward:

    PHP_NEW_EXTENSION(myext, myext.c testlib/test_class.c, $ext_shared)