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
4.9 KiB

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