Adding make directives for php extensions via config.m4
There are a set of autoconf directives that phpize provides aren’t documented (or don’t appear to be here).
One of these nice directives is PHP_ADD_MAKEFILE_FRAGMENT. When invoked with no parameters, PHP_ADD_MAKEFILE_FRAGMENT will look for Makefile.frag in the current working directory and include the contents into the generated Makefile. When invoked with a filepath, PHP_ADD_MAKEFILE_FRAGMENT will attempt to include the contents of the specified file at the filepath instead of just looking for Makefile.frag.
Specifying Makefile directives opens the door to adding compiler flags for specific build types, additional cleanup directives for testing artifacts, really whatever you want. I use it to specify debug builds.
debug: COMMON_FLAGS += -DDEBUG debug: all
In my code, I can now look for DEBUG in the preprocessor to enable or disable logging, for example. Neato.
















