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