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.
 
 
 
 
 
 

134 lines
4.6 KiB

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