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