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.

144 lines
4.8 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 = "processor.c \
  11. xcache.c \
  12. mmap.c \
  13. mem.c \
  14. xc_malloc.c \
  15. xc_shm.c \
  16. const_string.c \
  17. opcode_spec.c \
  18. stack.c \
  19. utils.c \
  20. lock.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 += " " + 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. PATH_PROG("gawk", null, "AWK") || PATH_PROG("awk", null, "AWK");
  55. // the cygwin indent is known broken on our output
  56. var indent = false; // PATH_PROG("indent");
  57. if (indent) {
  58. indent += " -kr --use-tabs --tab-size 4 -sob -nce";
  59. }
  60. else {
  61. indent = PATH_PROG("cat");
  62. if (!indent) {
  63. indent = '';
  64. }
  65. }
  66. DEFINE("XCACHE_INDENT", indent);
  67. // }}}
  68. // {{{ create extension
  69. EXTENSION("xcache", xcache_sources);
  70. var srcdir = configure_module_dirname;
  71. // it's a bit harder to get builddir
  72. var mfofile = "Makefile.objects";
  73. MFO.Close();
  74. var mfo = file_get_contents(mfofile);
  75. mfo.match(/(.*\\xcache)\\xcache.obj/);
  76. var builddir = RegExp.$1;
  77. mfo.match(/(.*\$\(CC\).* )\/c.*\\xcache\\xcache.c.*/i);
  78. var ccrule = RegExp.$1;
  79. MFO = FSO.OpenTextFile(mfofile, 8);
  80. mfo = null;
  81. // }}}
  82. // {{{ add make fragments
  83. var file = srcdir + "\\Makefile.frag";
  84. STDOUT.WriteLine("Adding Makefile.frag: " + file);
  85. var frag = file_get_contents(file);
  86. frag = frag.replace(/\$\(srcdir\)\//g, srcdir + '\\');
  87. frag = frag.replace(/\$\(srcdir\)/g, srcdir);
  88. frag = frag.replace(/\$\(builddir\)\//g, builddir + '\\');
  89. frag = frag.replace(/\$\(builddir\)/g, builddir);
  90. frag = frag.replace(/processor\//g, "processor\\");
  91. frag = frag.replace(/\.lo:/g, ".obj:");
  92. frag = frag.replace(/.*\$\(CC\).* -E (.*) -o (.*)/, ccrule + " /E $1 > $2");
  93. frag = frag.replace(/ -o /g, " /Fo");
  94. frag = frag.replace(/mv -f /g, "move ");
  95. frag = frag.replace(/ \|\| /g, "\r\n\tif errorlevel 1 ");
  96. frag = frag.replace(/ && /g, "\r\n\tif not errorlevel 1 ");
  97. if (indent == '') {
  98. frag = frag.replace(/\| +\$\(XCACHE_INDENT\)/, '');
  99. frag = frag.replace(/\$\(XCACHE_INDENT\) < /, 'type ');
  100. }
  101. MFO.WriteLine(frag);
  102. ADD_FLAG("CFLAGS_XCACHE", "/I " + builddir);
  103. /// }}}
  104. // {{{ check for xcache-test
  105. ARG_ENABLE("xcache-test", "XCache: Enable self test - FOR DEVELOPERS ONLY!!", "no");
  106. if (PHP_XCACHE_TEST != "no") {
  107. ADD_FLAG("XCACHE_ENABLE_TEST", "-DXCACHE_ENABLE_TEST");
  108. AC_DEFINE("HAVE_XCACHE_TEST", 1, "Define to enable XCache self test");
  109. }
  110. else {
  111. ADD_FLAG("XCACHE_ENABLE_TEST", "");
  112. }
  113. XCACHE_PROC_SOURCES=glob(srcdir + "\\processor\\*.m4").join(' ');
  114. ADD_FLAG("XCACHE_PROC_SOURCES", XCACHE_PROC_SOURCES);
  115. // }}}
  116. // {{{ check for opcode_spec_def.h
  117. STDOUT.Write("Checking if you have opcode_spec_def.h for XCache ... ");
  118. var file = srcdir + "\\opcode_spec_def.h";
  119. if (FSO.FileExists(file)) {
  120. STDOUT.WriteLine("yes");
  121. AC_DEFINE("HAVE_XCACHE_OPCODE_SPEC_DEF", 1, "Define if you have opcode_spec_def.h for XCache");
  122. }
  123. else {
  124. STDOUT.WriteLine("no");
  125. // check for features depend on opcode_spec_def.h
  126. var xcache_require_opcode_spec_def = function(withval, name) {
  127. if (withval != "no") {
  128. ERROR(file + " is required to enable XCache " + name);
  129. }
  130. }
  131. xcache_require_opcode_spec_def(PHP_XCACHE_DISASSEMBLER, "disassembler");
  132. }
  133. // }}}
  134. }