2019-04-21 21:33:20 +08:00
|
|
|
# PHP build system V5 overview
|
|
|
|
|
|
|
|
* supports Makefile.ins during transition phase
|
|
|
|
* not-really-portable Makefile includes have been eliminated
|
|
|
|
* supports separate build directories without VPATH by using explicit rules only
|
|
|
|
* does not waste disk-space/CPU-time for building temporary libraries =>
|
|
|
|
especially noticeable on slower systems
|
|
|
|
* slow recursive make replaced with one global Makefile
|
|
|
|
* eases integration of proper dependencies
|
|
|
|
* adds PHP_DEFINE(what[, value]) which creates a single include-file per what.
|
|
|
|
This will allow more fine-grained dependencies.
|
|
|
|
* abandoning the "one library per directory" concept
|
|
|
|
* improved integration of the CLI
|
|
|
|
* several new targets:
|
|
|
|
* `build-modules`: builds and copies dynamic modules into `modules/`
|
|
|
|
* `install-cli`: installs the CLI only, so that the install-sapi target does
|
|
|
|
only what its name says
|
|
|
|
* finally abandoned automake
|
|
|
|
* changed some configure-time constructs to run at buildconf-time
|
|
|
|
* upgraded shtool to 1.5.4
|
|
|
|
* removed `$(moduledir)` (use `EXTENSION_DIR`)
|
|
|
|
|
|
|
|
## The reason for a new system
|
|
|
|
|
|
|
|
It became more and more apparent that there is a severe need for addressing the
|
|
|
|
portability concerns and improving the chance that your build is correct (how
|
|
|
|
often have you been told to `make clean`? When this is done, you won't need to
|
|
|
|
anymore).
|
|
|
|
|
|
|
|
## If you build PHP on a Unix system
|
|
|
|
|
|
|
|
You, as a user of PHP, will notice no changes. Of course, the build system will
|
|
|
|
be faster, look better and work smarter.
|
|
|
|
|
|
|
|
## If you are developing PHP
|
|
|
|
|
|
|
|
### Extension developers
|
|
|
|
|
|
|
|
Makefile.ins are abandoned. The files which are to be compiled are specified in
|
|
|
|
the `config.m4` now using the following macro:
|
|
|
|
|
|
|
|
```m4
|
2002-03-20 16:48:41 +08:00
|
|
|
PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)
|
2019-04-21 21:33:20 +08:00
|
|
|
```
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
E.g. this enables the extension foo which consists of three source-code modules,
|
|
|
|
two in C and one in C++. And, depending on the user's wishes, the extension will
|
|
|
|
even be built as a dynamic module.
|
2002-03-20 16:48:41 +08:00
|
|
|
|
|
|
|
The full syntax:
|
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
```m4
|
2002-03-20 16:48:41 +08:00
|
|
|
PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
|
2019-04-21 21:33:20 +08:00
|
|
|
```
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-03-13 07:25:07 +08:00
|
|
|
Please have a look at `build/php.m4` for the gory details and meanings of the
|
2019-04-21 21:33:20 +08:00
|
|
|
other parameters.
|
2002-03-20 16:48:41 +08:00
|
|
|
|
|
|
|
And that's basically it for the extension side.
|
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
If you previously built sub-libraries for this module, add the source-code files
|
|
|
|
here as well. If you need to specify separate include directories, do it this
|
|
|
|
way:
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
```m4
|
2002-03-20 16:48:41 +08:00
|
|
|
PHP_NEW_EXTENSION(foo, foo.c mylib/bar.c mylib/gregor.c,,,-I@ext_srcdir@/lib)
|
2019-04-21 21:33:20 +08:00
|
|
|
```
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
E.g. this builds the three files which are located relative to the extension
|
|
|
|
source directory and compiles all three files with the special include directive
|
|
|
|
(`@ext_srcdir@` is automatically replaced).
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
Now, you need to tell the build system that you want to build files in a
|
|
|
|
directory called `$ext_builddir/lib`:
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
```m4
|
2002-03-20 16:48:41 +08:00
|
|
|
PHP_ADD_BUILD_DIR($ext_builddir/lib)
|
2019-04-21 21:33:20 +08:00
|
|
|
```
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
Make sure to call this after `PHP_NEW_EXTENSION`, because `$ext_builddir` is
|
|
|
|
only set by the latter.
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
If you have a complex extension, you might to need add special Make rules. You
|
|
|
|
can do this by calling `PHP_ADD_MAKEFILE_FRAGMENT` in your `config.m4` after
|
|
|
|
`PHP_NEW_EXTENSION`.
|
2002-03-20 16:48:41 +08:00
|
|
|
|
|
|
|
This will read a file in the source-dir of your extension called
|
2019-04-21 21:33:20 +08:00
|
|
|
`Makefile.frag`. In this file, `$(builddir)` and `$(srcdir)` will be replaced by
|
|
|
|
the values which are correct for your extension and which are again determined
|
|
|
|
by the `PHP_NEW_EXTENSION` macro.
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
Make sure to prefix *all* relative paths correctly with either `$(builddir)` or
|
|
|
|
`$(srcdir)`. Because the build system does not change the working directory
|
|
|
|
anymore, we must use either absolute paths or relative ones to the top
|
|
|
|
build-directory. Correct prefixing ensures that.
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
### SAPI developers
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
Instead of using `PHP_SAPI=foo/PHP_BUILD_XYZ`, you will need to type
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
```m4
|
2002-03-20 16:48:41 +08:00
|
|
|
PHP_SELECT_SAPI(name, type, sources.c)
|
2019-04-21 21:33:20 +08:00
|
|
|
```
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
I.e. specify the source-code files as above and also pass the information
|
|
|
|
regarding how PHP is supposed to be built (shared module, program, etc).
|
2002-03-20 16:48:41 +08:00
|
|
|
|
|
|
|
For example for APXS:
|
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
```m4
|
2019-01-28 19:04:51 +08:00
|
|
|
PHP_SELECT_SAPI(apache, shared, sapi_apache.c mod_php.c php_apache.c)
|
2019-04-21 21:33:20 +08:00
|
|
|
```
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 10:53:02 +08:00
|
|
|
## General info
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
The foundation for the new system is the flexible handling of sources and their
|
|
|
|
contexts. With the help of macros you can define special flags for each
|
|
|
|
source-file, where it is located, in which target context it can work, etc.
|
2002-03-20 16:48:41 +08:00
|
|
|
|
2019-04-21 21:33:20 +08:00
|
|
|
Have a look at the well documented macros `PHP_ADD_SOURCES(_X)` in
|
2019-03-13 07:25:07 +08:00
|
|
|
`build/php.m4`.
|