XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
5.0 KiB

  1. // vim:ft=javascript
  2. ARG_ENABLE("xcache", "Include XCache support", "yes,shared");
  3. if (PHP_XCACHE != "no") {
  4. EXTENSION("xcache", "xcache.c", null, "/I " + configure_module_dirname);
  5. // {{{ check for xcache-constant
  6. ARG_ENABLE("xcache-constant", "XCache: Handle new constants made by php compiler (e.g.: for __halt_compiler)", "yes");
  7. if (PHP_XCACHE_CONSTANT != "no") {
  8. AC_DEFINE("HAVE_XCACHE_CONSTANT", 1, "Define to enable XCache handling of compile time constants");
  9. }
  10. // }}}
  11. ADD_SOURCES(configure_module_dirname + "/util", " \
  12. xc_stack.c \
  13. xc_trace.c \
  14. ", "xcache");
  15. ADD_SOURCES(configure_module_dirname + "/xcache", " \
  16. xc_allocator.c \
  17. xc_allocator_bestfit.c \
  18. xc_compatibility.c \
  19. xc_const_string.c \
  20. xc_extension.c \
  21. xc_ini.c \
  22. xc_mutex.c \
  23. xc_opcode_spec.c \
  24. xc_processor.c \
  25. xc_sandbox.c \
  26. xc_shm.c \
  27. xc_shm_mmap.c \
  28. xc_utils.c \
  29. ", "xcache");
  30. ADD_SOURCES(configure_module_dirname + "/mod_cacher", " \
  31. xc_cacher.c \
  32. ", "xcache");
  33. // {{{ add sources on enabled
  34. ARG_ENABLE("xcache-optimizer", "(N/A)", "no");
  35. ARG_ENABLE("xcache-coverager", "Enable code coverage dumper, useful for testing php scripts", "no");
  36. ARG_ENABLE("xcache-assembler", "(N/A)", "no");
  37. ARG_ENABLE("xcache-disassembler", "Enable opcode to php variable dumper, not for server usage", "no");
  38. ARG_ENABLE("xcache-encoder", "(N/A)", "no");
  39. ARG_ENABLE("xcache-decoder", "(N/A)", "no");
  40. var XCACHE_MODULES = "cacher";
  41. AC_DEFINE("HAVE_XCACHE_CACHER", 1, "Define for XCache: cacher")
  42. var options = ["optimizer",
  43. "coverager",
  44. "assembler", "disassembler",
  45. "encoder", "decoder"];
  46. for (var i in options) {
  47. var name = options[i];
  48. var uname = name.toUpperCase();
  49. var withval = eval("PHP_XCACHE_" + uname);
  50. if (withval != "no") {
  51. ADD_SOURCES(configure_module_dirname + "/mod_" + name, "xc_" + name + ".c", "xcache");
  52. XCACHE_MODULES += " " + name;
  53. STDOUT.WriteLine("Enabling XCache Module: " + name);
  54. AC_DEFINE("HAVE_XCACHE_" + uname, 1, "Define for XCache: " + name)
  55. }
  56. }
  57. AC_DEFINE("XCACHE_MODULES", XCACHE_MODULES);
  58. // }}}
  59. // {{{ check for programs needed
  60. var apps = ["m4", "grep", "sed"];
  61. for (var i in apps) {
  62. if (!PATH_PROG(apps[i])) {
  63. ERROR(apps[i] + " is currently required to build XCache");
  64. }
  65. }
  66. DEFINE("XCACHE_BACKTICK", "`")
  67. PATH_PROG("gawk", null, "XCACHE_AWK") || PATH_PROG("awk", null, "XCACHE_AWK");
  68. // the cygwin indent is known broken on our output
  69. var indent = false; // PATH_PROG("indent");
  70. if (indent) {
  71. indent += " -kr --use-tabs --tab-size 4 -sob -nce";
  72. }
  73. else {
  74. indent = PATH_PROG("cat");
  75. if (!indent) {
  76. indent = '';
  77. }
  78. }
  79. DEFINE("XCACHE_INDENT", indent);
  80. // }}}
  81. // {{{ check for xcache-test
  82. ARG_ENABLE("xcache-test", "XCache: Enable self test - FOR DEVELOPERS ONLY!!", "no");
  83. if (PHP_XCACHE_TEST != "no") {
  84. ADD_FLAG("XCACHE_ENABLE_TEST", "-DXCACHE_ENABLE_TEST");
  85. ADD_SOURCES(configure_module_dirname + "/xcache", "xc_malloc.c", "xcache");
  86. AC_DEFINE("HAVE_XCACHE_TEST", 1, "Define to enable XCache self test");
  87. }
  88. else {
  89. ADD_FLAG("XCACHE_ENABLE_TEST", "");
  90. }
  91. // }}}
  92. // {{{ check for xcache-test
  93. ARG_ENABLE("xcache-dprint", "XCache: Enable self debug print functions - FOR DEVELOPERS ONLY!!", "no");
  94. if (PHP_XCACHE_DPRINT != "no") {
  95. AC_DEFINE("HAVE_XCACHE_DPRINT", 1, "Define to enable XCache debug print functions");
  96. }
  97. // }}}
  98. // {{{ get ccrule
  99. var srcdir = configure_module_dirname;
  100. // it's a bit harder to get builddir
  101. var mfofile = "Makefile.objects";
  102. MFO.Close();
  103. var mfo = file_get_contents(mfofile);
  104. mfo.match(/(.*)\\xcache.obj:/);
  105. var builddir = RegExp.$1;
  106. mfo.match(/(.*\$\(CC\).* )\/c.*\\xcache.c.*/i);
  107. var ccrule = RegExp.$1;
  108. MFO = FSO.OpenTextFile(mfofile, 8);
  109. mfo = null;
  110. // }}}
  111. // {{{ add make fragments
  112. var makefileFrag = srcdir + "\\Makefile.frag";
  113. var makefileFragDeps = srcdir + "\\Makefile.frag.deps";
  114. STDOUT.WriteLine("Adding Makefile.frag: " + makefileFrag);
  115. STDOUT.WriteLine("Adding Makefile.frag.deps: " + makefileFragDeps);
  116. var frag = file_get_contents(makefileFrag) + "\r\n" + file_get_contents(makefileFragDeps);
  117. frag = frag.replace(/\$\(srcdir\)\//g, srcdir + '\\');
  118. frag = frag.replace(/\$\(srcdir\)/g, srcdir);
  119. frag = frag.replace(/\$\(builddir\)\//g, builddir + '\\');
  120. frag = frag.replace(/\$\(builddir\)/g, builddir);
  121. frag = frag.replace(/processor\//g, "processor\\");
  122. frag = frag.replace(/\.lo:/g, ".obj:");
  123. frag = frag.replace(/.*\$\(CC\).* -E (.*) -o (.*)/g, ccrule + " /E $1 > $2");
  124. frag = frag.replace(/ -o /g, " /Fo");
  125. frag = frag.replace(/cp /g, "copy ");
  126. frag = frag.replace(/mv /g, "move ");
  127. frag = frag.replace(/ \|\| /g, "\r\n\tif errorlevel 1 ");
  128. frag = frag.replace(/ && /g, "\r\n\tif not errorlevel 1 ");
  129. if (indent == '') {
  130. frag = frag.replace(/\| *\$\(XCACHE_INDENT\)/g, '');
  131. frag = frag.replace(/\$\(XCACHE_INDENT\) *< */g, 'type ');
  132. }
  133. MFO.WriteLine(frag);
  134. ADD_FLAG("CFLAGS_XCACHE", "/I " + builddir);
  135. /// }}}
  136. XCACHE_PROC_SOURCES=glob(srcdir + "\\processor\\*.m4").join(' ');
  137. ADD_FLAG("XCACHE_PROC_SOURCES", XCACHE_PROC_SOURCES);
  138. }