The config.m4 file uses M4 macros to define how the extension is built and configured. For a self-contained extension, you typically use PHP_ARG_ENABLE or PHP_ARG_WITH to handle configuration flags, and PHP_NEW_EXTENSION to define the extension name and its source files.
To ensure the extension can be loaded as a shared module, pass $ext_shared as the third argument to PHP_NEW_EXTENSION.
PHP_ARG_ENABLE([foobar],
[whether to enable foobar],
[AS_HELP_STRING([--enable-foobar],
[Enable foobar])])
if test "$PHP_FOOBAR" != "no"; then
PHP_NEW_EXTENSION([foobar], [foo.c bar.c], [$ext_shared])
fi