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.

135 lines
4.4 KiB

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