The Config.m4 file is used to specify the options that are supported when the extension being developed is built under Unix-like systems, which libraries are required for this extension, and which source files are written using the GNU autoconf syntax.
Note the need to re-execute PHPIZE,CONFIG.M4 changes will not take effect;
When the./configure is executed, all output is recorded in the Config.log and can be debugged by viewing this file CONFIG.M4.
How to create a php extension from scratch can be found in the article php extension-extension generation and compilation,
Statements and macros commonly used in CONFIG.M4 files
The following is an example of "Myext" as the extension name being developed:
1. Input configuration options by user
Like –enable-myext,–with-myext-includedir=dir.
Php_arg_enable (Myext, whether to ENABLE Myext support,
[--enable-ext enable ext support])
Output at Configure–help: –enable-ext Enable ext support
Php_arg_with (Myext-includedir, for myext header,
[--with-myext-includedir=dir myext header Files], no, NO)
Output at Configure–help: –with-myext-includedir=dir myext header files
2. Output information
Ac_msg_checking (message), output "CHECKING" When executing the Configure command;
Ac_msg_result (value), outputs the result of the check;
Ac_msg_error (message), outputs a message and exits execution of configure;
3. Add the Include path
Php_add_include (path), adding a compile-time include path;
4. Linking third-party libraries
Php_add_library_with_path (), adding a link library path at compile time
Php_add_library (), add link library;
5. Other
Ac_define (name,value,description), add a DEFINE to Php_config.h: #define NAME value//description;
Ac_try_compile (includes, function-body, [Action-if-found [, Action-if-not-found]])
Examples are as follows:
... Ac_msg_checking (PHP version) ... Ac_msg_result ([$PHP _version]) ... Php_major_version= ' echo $PHP _version | Sed-e ' s/\ ([[0-9]]*\] \.\ ([[0-9]]*\] \.\ ([[0-9]]*\]. */\1/g ' 2>/dev/null ' if test $PHP _major_version-lt 5; Thenac_msg_error ([Need at least PHP 5 or newer]) fi ... Php_add_include ([$ext _srcdir/snappy]) ... Php_add_library_with_path (Snappy, $LIBSNAPPY _libdir, Snappy_shared_libadd) ... Libname=stdc++php_add_library ($LIBNAME,, Snappy_shared_libadd)