README.UNIX-BUILD-SYSTEM 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. PHP Build System V5 Overview
  2. - supports Makefile.ins during transition phase
  3. - not-really-portable Makefile includes have been eliminated
  4. - supports separate build directories without VPATH by using
  5. explicit rules only
  6. - does not waste disk-space/CPU-time for building temporary libraries
  7. => especially noticeable on slower systems
  8. - slow recursive make replaced with one global Makefile
  9. - eases integration of proper dependencies
  10. - adds PHP_DEFINE(what[, value]) which creates a single include-file
  11. per what. This will allow more fine-grained dependencies.
  12. - abandoning the "one library per directory" concept
  13. - improved integration of the CLI
  14. - several new targets
  15. build-modules: builds and copies dynamic modules into modules/
  16. install-cli: installs the CLI only, so that the install-sapi
  17. target does only what its name says
  18. - finally abandoned automake (still requires aclocal at this time)
  19. - changed some configure-time constructs to run at buildconf-time
  20. - upgraded shtool to 1.5.4
  21. - removed $(moduledir) (use EXTENSION_DIR)
  22. The Reason For a New System
  23. It became more and more apparent that there is a severe need
  24. for addressing the portability concerns and improving the chance
  25. that your build is correct (how often have you been told to
  26. "make clean"? When this is done, you won't need to anymore).
  27. If You Build PHP on a Unix System
  28. You, as a user of PHP, will notice no changes. Of course, the build
  29. system will be faster, look better and work smarter.
  30. If You Are Developing PHP
  31. Extension developers:
  32. Makefile.ins are abandoned. The files which are to be compiled
  33. are specified in the config.m4 now using the following macro:
  34. PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)
  35. E.g. this enables the extension foo which consists of three source-code
  36. modules, two in C and one in C++. And, depending on the user's wishes,
  37. the extension will even be built as a dynamic module.
  38. The full syntax:
  39. PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
  40. Please have a look at acinclude.m4 for the gory details and meanings
  41. of the other parameters.
  42. And that's basically it for the extension side.
  43. If you previously built sub-libraries for this module, add
  44. the source-code files here as well. If you need to specify
  45. separate include directories, do it this way:
  46. PHP_NEW_EXTENSION(foo, foo.c mylib/bar.c mylib/gregor.c,,,-I@ext_srcdir@/lib)
  47. E.g. this builds the three files which are located relative to the
  48. extension source directory and compiles all three files with the
  49. special include directive (@ext_srcdir@ is automatically replaced).
  50. Now, you need to tell the build system that you want to build files
  51. in a directory called $ext_builddir/lib:
  52. PHP_ADD_BUILD_DIR($ext_builddir/lib)
  53. Make sure to call this after PHP_NEW_EXTENSION, because $ext_builddir
  54. is only set by the latter.
  55. If you have a complex extension, you might to need add special
  56. Make rules. You can do this by calling PHP_ADD_MAKEFILE_FRAGMENT
  57. in your config.m4 after PHP_NEW_EXTENSION.
  58. This will read a file in the source-dir of your extension called
  59. Makefile.frag. In this file, $(builddir) and $(srcdir) will be
  60. replaced by the values which are correct for your extension
  61. and which are again determined by the PHP_NEW_EXTENSION macro.
  62. Make sure to prefix *all* relative paths correctly with either
  63. $(builddir) or $(srcdir). Because the build system does not
  64. change the working directory anymore, we must use either
  65. absolute paths or relative ones to the top build-directory.
  66. Correct prefixing ensures that.
  67. SAPI developers:
  68. Instead of using PHP_SAPI=foo/PHP_BUILD_XYZ, you will need to type
  69. PHP_SELECT_SAPI(name, type, sources.c)
  70. I.e. specify the source-code files as above and also pass the
  71. information regarding how PHP is supposed to be built (shared
  72. module, program, etc).
  73. For example for APXS:
  74. PHP_SELECT_SAPI(apache, shared, sapi_apache.c mod_php5.c php_apache.c)
  75. General info
  76. The foundation for the new system is the flexible handling of
  77. sources and their contexts. With the help of macros you
  78. can define special flags for each source-file, where it is
  79. located, in which target context it can work, etc.
  80. Have a look at the well documented macros
  81. PHP_ADD_SOURCES(_X) in acinclude.m4.