blob: 3735aa02e53e80b52ec6db6aaadbe19fa480d67a [file] [log] [blame]
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +00001/* Configure script for libxml, specific for Windows with Scripting Host.
2 *
3 * This script will configure the libxml build process and create necessary files.
4 * Run it with an 'help', or an invalid option and it will tell you what options
5 * it accepts.
6 *
Daniel Veillardbeb70bd2002-12-18 14:53:54 +00007 * March 2002, Igor Zlatkovic <igor@zlatkovic.com>
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +00008 */
9
10/* The source directory, relative to the one where this file resides. */
11var srcDirXml = "..";
12var srcDirUtils = "..";
13/* The directory where we put the binaries after compilation. */
14var binDir = "binaries";
15/* Base name of what we are building. */
16var baseName = "libxml2";
17/* Configure file which contains the version and the output file where
18 we can store our build configuration. */
19var configFile = srcDirXml + "\\configure.in";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000020var versionFile = ".\\config.msvc";
Igor Zlatkovic853514f2002-11-22 21:41:09 +000021/* Input and output files regarding the libxml features. */
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000022var optsFileIn = srcDirXml + "\\include\\libxml\\xmlversion.h.in";
23var optsFile = srcDirXml + "\\include\\libxml\\xmlversion.h";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000024/* Version strings for the binary distribution. Will be filled later
25 in the code. */
26var verMajor;
27var verMinor;
28var verMicro;
29/* Libxml features. */
30var withTrio = false;
Igor Zlatkovice38ab532003-05-17 11:30:54 +000031var withThreads = "native";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000032var withFtp = true;
33var withHttp = true;
34var withHtml = true;
35var withC14n = true;
36var withCatalog = true;
37var withDocb = true;
38var withXpath = true;
39var withXptr = true;
40var withXinclude = true;
41var withIconv = true;
William M. Brack6d13f332003-08-08 16:40:36 +000042var withIso8859x = false;
Igor Zlatkovic3acadf42002-09-20 16:40:17 +000043var withZlib = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000044var withDebug = true;
45var withMemDebug = false;
Igor Zlatkovica6f2d902002-04-16 17:57:17 +000046var withSchemas = true;
Igor Zlatkovic8e040972002-09-20 13:39:53 +000047var withRegExps = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000048var withTree = true;
49var withReader = true;
50var withWalker = true;
51var withPush = true;
52var withValid = true;
53var withSax1 = true;
54var withLegacy = true;
55var withOutput = true;
Igor Zlatkovic853514f2002-11-22 21:41:09 +000056var withPython = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000057/* Win32 build options. */
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000058var dirSep = "\\";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000059var compiler = "msvc";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000060var buildDebug = 0;
61var buildStatic = 0;
62var buildPrefix = ".";
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000063var buildBinPrefix = "";
64var buildIncPrefix = "";
65var buildLibPrefix = "";
66var buildSoPrefix = "";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000067var buildInclude = ".";
68var buildLib = ".";
69/* Local stuff */
70var error = 0;
71
72/* Helper function, transforms the option variable into the 'Enabled'
73 or 'Disabled' string. */
74function boolToStr(opt)
75{
76 if (opt == false)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000077 return "no";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000078 else if (opt == true)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000079 return "yes";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000080 error = 1;
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000081 return "*** undefined ***";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000082}
83
84/* Helper function, transforms the argument string into a boolean
85 value. */
86function strToBool(opt)
87{
88 if (opt == 0 || opt == "no")
89 return false;
90 else if (opt == 1 || opt == "yes")
91 return true;
92 error = 1;
93 return false;
94}
95
96/* Displays the details about how to use this script. */
97function usage()
98{
99 var txt;
100 txt = "Usage:\n";
101 txt += " cscript " + WScript.ScriptName + " <options>\n";
102 txt += " cscript " + WScript.ScriptName + " help\n\n";
103 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000104 txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000105 txt += "\nXML processor options, default value given in parentheses:\n\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000106 txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000107 txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000108 txt += " ftp: Enable FTP client (" + (withFtp? "yes" : "no") + ")\n";
109 txt += " http: Enable HTTP client (" + (withHttp? "yes" : "no") + ")\n";
110 txt += " html: Enable HTML processor (" + (withHtml? "yes" : "no") + ")\n";
111 txt += " c14n: Enable C14N support (" + (withC14n? "yes" : "no") + ")\n";
112 txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n";
113 txt += " docb: Enable DocBook support (" + (withDocb? "yes" : "no") + ")\n";
114 txt += " xpath: Enable XPath support (" + (withXpath? "yes" : "no") + ")\n";
115 txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n";
116 txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000117 txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000118 txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000119 txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000120 txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
121 txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000122 txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000123 txt += " tree: Enable tree api (" + (withTree? "yes" : "no") + ")\n";
124 txt += " reader: Enable xmlReader api (" + (withReader? "yes" : "no") + ")\n";
125 txt += " walker: Enable xmlDocWalker api (" + (withWalker? "yes" : "no") + ")\n";
126 txt += " push: Enable push api (" + (withPush? "yes" : "no") + ")\n";
127 txt += " valid: Enable DTD validation support (" + (withValid? "yes" : "no") + ")\n";
128 txt += " sax1: Enable SAX1 api (" + (withSax1? "yes" : "no") + ")\n";
129 txt += " legacy: Enable Deprecated api's (" + (withLegacy? "yes" : "no") + ")\n";
130 txt += " output: Enable serialization support (" + (withOutput? "yes" : "no") + ")\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000131 txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000132 txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000133 txt += "\nWin32 build options, default value given in parentheses:\n\n";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000134 txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000135 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
136 txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
137 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
138 txt += " bindir: Directory where xmllint and friends should be installed\n";
139 txt += " (" + buildBinPrefix + ")\n";
140 txt += " incdir: Directory where headers should be installed\n";
141 txt += " (" + buildIncPrefix + ")\n";
142 txt += " libdir: Directory where static and import libraries should be\n";
143 txt += " installed (" + buildLibPrefix + ")\n";
144 txt += " sodir: Directory where shared libraries should be installed\n";
145 txt += " (" + buildSoPrefix + ")\n";
146 txt += " include: Additional search path for the compiler, particularily\n";
147 txt += " where iconv headers can be found (" + buildInclude + ")\n";
148 txt += " lib: Additional search path for the linker, particularily\n";
149 txt += " where iconv library can be found (" + buildLib + ")\n";
150 WScript.Echo(txt);
151}
152
153/* Discovers the version we are working with by reading the apropriate
154 configuration file. Despite its name, this also writes the configuration
155 file included by our makefile. */
156function discoverVersion()
157{
158 var fso, cf, vf, ln, s;
159 fso = new ActiveXObject("Scripting.FileSystemObject");
160 cf = fso.OpenTextFile(configFile, 1);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000161 if (compiler == "msvc")
162 versionFile = ".\\config.msvc";
163 else if (compiler == "mingw")
164 versionFile = ".\\config.mingw";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000165 else if (compiler == "bcb")
166 versionFile = ".\\config.bcb";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000167 vf = fso.CreateTextFile(versionFile, true);
168 vf.WriteLine("# " + versionFile);
169 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
170 vf.WriteBlankLines(1);
171 while (cf.AtEndOfStream != true) {
172 ln = cf.ReadLine();
173 s = new String(ln);
Daniel Veillard70b18562003-09-24 21:45:21 +0000174 if (s.search(/^LIBXML_MAJOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000175 vf.WriteLine(s);
176 verMajor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000177 } else if(s.search(/^LIBXML_MINOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000178 vf.WriteLine(s);
179 verMinor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000180 } else if(s.search(/^LIBXML_MICRO_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000181 vf.WriteLine(s);
182 verMicro = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000183 } else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
184 vf.WriteLine(s);
185 verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length)
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000186 }
187 }
188 cf.Close();
189 vf.WriteLine("XML_SRCDIR=" + srcDirXml);
190 vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
191 vf.WriteLine("BINDIR=" + binDir);
192 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000193 vf.WriteLine("WITH_THREADS=" + withThreads);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000194 vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
195 vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
196 vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
197 vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
198 vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
199 vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
200 vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
201 vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
202 vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
203 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000204 vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000205 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000206 vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
207 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000208 vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000209 vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000210 vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
211 vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
212 vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
213 vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
214 vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
215 vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
216 vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
217 vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000218 vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000219 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
220 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
221 vf.WriteLine("PREFIX=" + buildPrefix);
222 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
223 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
224 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
225 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000226 if (compiler == "msvc") {
227 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
228 vf.WriteLine("LIB=$(LIB);" + buildLib);
229 } else if (compiler == "mingw") {
230 vf.WriteLine("INCLUDE+=;" + buildInclude);
231 vf.WriteLine("LIB+=;" + buildLib);
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000232 } else if (compiler == "bcb") {
233 vf.WriteLine("INCLUDE=" + buildInclude);
234 vf.WriteLine("LIB=" + buildLib);
235 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000236 vf.Close();
237}
238
239/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
240 taking what the user passed on the command line into account. */
241function configureLibxml()
242{
243 var fso, ofi, of, ln, s;
244 fso = new ActiveXObject("Scripting.FileSystemObject");
245 ofi = fso.OpenTextFile(optsFileIn, 1);
246 of = fso.CreateTextFile(optsFile, true);
247 while (ofi.AtEndOfStream != true) {
248 ln = ofi.ReadLine();
249 s = new String(ln);
250 if (s.search(/\@VERSION\@/) != -1) {
251 of.WriteLine(s.replace(/\@VERSION\@/,
Daniel Veillard70b18562003-09-24 21:45:21 +0000252 verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000253 } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
254 of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
255 verMajor*10000 + verMinor*100 + verMicro*1));
256 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
257 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
258 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000259 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000260 } else if (s.search(/\@WITH_FTP\@/) != -1) {
261 of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
262 } else if (s.search(/\@WITH_HTTP\@/) != -1) {
263 of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
264 } else if (s.search(/\@WITH_HTML\@/) != -1) {
265 of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
266 } else if (s.search(/\@WITH_C14N\@/) != -1) {
267 of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
268 } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
269 of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
270 } else if (s.search(/\@WITH_DOCB\@/) != -1) {
271 of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
272 } else if (s.search(/\@WITH_XPATH\@/) != -1) {
273 of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
274 } else if (s.search(/\@WITH_XPTR\@/) != -1) {
275 of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
276 } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
277 of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
278 } else if (s.search(/\@WITH_ICONV\@/) != -1) {
279 of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000280 } else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
281 of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000282 } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
283 of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000284 } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
285 of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
286 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
287 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000288 } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
289 of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000290 } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
291 of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000292 } else if (s.search(/\@WITH_TREE\@/) != -1) {
293 of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
294 } else if (s.search(/\@WITH_READER\@/) != -1) {
295 of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
296 } else if (s.search(/\@WITH_WALKER\@/) != -1) {
297 of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
298 } else if (s.search(/\@WITH_PUSH\@/) != -1) {
299 of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
300 } else if (s.search(/\@WITH_VALID\@/) != -1) {
301 of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
302 } else if (s.search(/\@WITH_SAX1\@/) != -1) {
303 of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
304 } else if (s.search(/\@WITH_LEGACY\@/) != -1) {
305 of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
306 } else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
307 of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000308 } else
309 of.WriteLine(ln);
310 }
311 ofi.Close();
312 of.Close();
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000313}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000314/* Configures Python bindings. Otherwise identical to the above */
315function configureLibxmlPy()
316{
317 var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
318 var pyOptsFile = srcDirXml + "\\python\\setup.py";
319 var fso, ofi, of, ln, s;
320 fso = new ActiveXObject("Scripting.FileSystemObject");
321 ofi = fso.OpenTextFile(pyOptsFileIn, 1);
322 of = fso.CreateTextFile(pyOptsFile, true);
323 while (ofi.AtEndOfStream != true) {
324 ln = ofi.ReadLine();
325 s = new String(ln);
326 if (s.search(/\@LIBXML_VERSION\@/) != -1) {
327 of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
328 verMajor + "." + verMinor + "." + verMicro));
329 } else if (s.search(/\@prefix\@/) != -1) {
330 of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
Daniel Veillard94bb2f12003-04-27 22:14:07 +0000331 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
332 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000333 } else
334 of.WriteLine(ln);
335 }
336 ofi.Close();
337 of.Close();
338}
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000339
340/* Creates the readme file for the binary distribution of 'bname', for the
341 version 'ver' in the file 'file'. This one is called from the Makefile when
342 generating a binary distribution. The parameters are passed by make. */
343function genReadme(bname, ver, file)
344{
345 var fso, f;
346 fso = new ActiveXObject("Scripting.FileSystemObject");
347 f = fso.CreateTextFile(file, true);
348 f.WriteLine(" " + bname + " " + ver);
349 f.WriteLine(" --------------");
350 f.WriteBlankLines(1);
351 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
352 f.WriteLine("platform.");
353 f.WriteBlankLines(1);
354 f.WriteLine(" The directory named 'include' contains the header files. Place its");
355 f.WriteLine("contents somewhere where it can be found by the compiler.");
356 f.WriteLine(" The directory which answers to the name 'lib' contains the static and");
357 f.WriteLine("dynamic libraries. Place them somewhere where they can be found by the");
358 f.WriteLine("linker. The files whose names end with '_a.lib' are aimed for static");
359 f.WriteLine("linking, the other files are lib/dll pairs.");
360 f.WriteLine(" The directory called 'util' contains various programs which count as a");
361 f.WriteLine("part of " + bname + ".");
362 f.WriteBlankLines(1);
Igor Zlatkovic0ceeb8e2002-09-10 19:07:02 +0000363 f.WriteLine(" If you plan to develop your own programme, in C, which uses " + bname + ", then");
364 f.WriteLine("you should know what to do with the files in the binary package. If you don't,");
365 f.WriteLine("know this, then please, please do some research on how to use a");
366 f.WriteLine("third-party library in a C programme. The topic belongs to the very basics");
367 f.WriteLine("and you will not be able to do much without that knowledge.");
368 f.WriteBlankLines(1);
369 f.WriteLine(" If you wish to use " + bname + " solely through the supplied utilities, such as");
370 f.WriteLine("xmllint or xsltproc, then all you need to do is place the");
371 f.WriteLine("contents of the 'lib' and 'util' directories from the binary package in a");
372 f.WriteLine("directory on your disc which is mentioned in your PATH environment");
373 f.WriteLine("variable. You can use an existing directory which is allready in the");
374 f.WriteLine("path, such as 'C:\WINDOWS', or 'C:\WINNT'. You can also create a new");
375 f.WriteLine("directory for " + bname + " and place the files there, but be sure to modify");
376 f.WriteLine("the PATH environment variable and add that new directory to its list.");
377 f.WriteBlankLines(1);
378 f.WriteLine(" If you use other software which needs " + bname + ", such as Apache");
379 f.WriteLine("Web Server in certain configurations, then please consult the");
380 f.WriteLine("documentation of that software and see if it mentions something about");
381 f.WriteLine("how it uses " + bname + " and how it expects it to be installed. If you find");
382 f.WriteLine("nothing, then the default installation, as described in the previous");
383 f.WriteLine("paragraph, should be suficient.");
384 f.WriteBlankLines(1);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000385 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
386 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
387 f.WriteLine("the address below.");
388 f.WriteBlankLines(1);
Daniel Veillardbeb70bd2002-12-18 14:53:54 +0000389 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000390 f.Close();
391}
392
William M. Brack6d13f332003-08-08 16:40:36 +0000393
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000394/*
395 * main(),
396 * Execution begins here.
397 */
398
399// Parse the command-line arguments.
400for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
401 var arg, opt;
402 arg = WScript.Arguments(i);
403 opt = arg.substring(0, arg.indexOf("="));
404 if (opt.length == 0)
405 opt = arg.substring(0, arg.indexOf(":"));
406 if (opt.length > 0) {
407 if (opt == "trio")
408 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
409 else if (opt == "threads")
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000410 withThreads = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000411 else if (opt == "ftp")
412 withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
413 else if (opt == "http")
414 withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
415 else if (opt == "html")
416 withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic9425ce22002-04-10 21:57:11 +0000417 else if (opt == "c14n")
418 withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000419 else if (opt == "catalog")
420 withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
421 else if (opt == "docb")
422 withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
423 else if (opt == "xpath")
424 withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
425 else if (opt == "xptr")
426 withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
427 else if (opt == "xinclude")
428 withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
429 else if (opt == "iconv")
430 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
William M. Brack6d13f332003-08-08 16:40:36 +0000431 else if (opt == "iso8859x")
432 withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000433 else if (opt == "zlib")
434 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000435 else if (opt == "xml_debug")
436 withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
437 else if (opt == "mem_debug")
438 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000439 else if (opt == "schemas")
440 withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000441 else if (opt == "regexps")
442 withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000443 else if (opt == "tree")
444 withTree = strToBool(arg.substring(opt.length + 1, arg.length));
445 else if (opt == "reader")
446 withReader = strToBool(arg.substring(opt.length + 1, arg.length));
447 else if (opt == "walker")
448 withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
449 else if (opt == "push")
450 withPush = strToBool(arg.substring(opt.length + 1, arg.length));
451 else if (opt == "valid")
452 withValid = strToBool(arg.substring(opt.length + 1, arg.length));
453 else if (opt == "sax1")
454 withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
455 else if (opt == "legacy")
456 withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
457 else if (opt == "output")
458 withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000459 else if (opt == "python")
460 withPython = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000461 else if (opt == "compiler")
462 compiler = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000463 else if (opt == "debug")
464 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
465 else if (opt == "static")
466 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
467 else if (opt == "prefix")
468 buildPrefix = arg.substring(opt.length + 1, arg.length);
469 else if (opt == "incdir")
470 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
471 else if (opt == "bindir")
472 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
473 else if (opt == "libdir")
474 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
475 else if (opt == "sodir")
476 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
477 else if (opt == "incdir")
478 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
479 else if (opt == "include")
480 buildInclude = arg.substring(opt.length + 1, arg.length);
481 else if (opt == "lib")
482 buildLib = arg.substring(opt.length + 1, arg.length);
483 else
484 error = 1;
485 } else if (i == 0) {
486 if (arg == "genreadme") {
487 // This command comes from the Makefile and will not be checked
488 // for errors, because Makefile will always supply right the parameters.
489 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
490 WScript.Quit(0);
491 } else if (arg == "help") {
492 usage();
493 WScript.Quit(0);
494 }
William M. Brack6d13f332003-08-08 16:40:36 +0000495
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000496 } else {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000497 error = 1;
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000498 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000499}
500
William M. Brack6d13f332003-08-08 16:40:36 +0000501
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000502// If we fail here, it is because the user supplied an unrecognised argument.
503if (error != 0) {
504 usage();
505 WScript.Quit(error);
506}
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000507dirSep = "\\";
508if (compiler == "mingw")
509 dirSep = "/";
510if (buildBinPrefix == "")
511 buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
512if (buildIncPrefix == "")
513 buildIncPrefix = "$(PREFIX)" + dirSep + "include";
514if (buildLibPrefix == "")
515 buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
516if (buildSoPrefix == "")
517 buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
William M. Brack6d13f332003-08-08 16:40:36 +0000518
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000519// Discover the version.
520discoverVersion();
521if (error != 0) {
522 WScript.Echo("Version discovery failed, aborting.");
523 WScript.Quit(error);
524}
William M. Brack6d13f332003-08-08 16:40:36 +0000525
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000526WScript.Echo(baseName + " version: " + verMajor + "." + verMinor + "." + verMicro);
527
528// Configure libxml.
529configureLibxml();
530if (error != 0) {
531 WScript.Echo("Configuration failed, aborting.");
532 WScript.Quit(error);
533}
William M. Brack6d13f332003-08-08 16:40:36 +0000534
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000535if (withPython == true) {
536 configureLibxmlPy();
537 if (error != 0) {
538 WScript.Echo("Configuration failed, aborting.");
539 WScript.Quit(error);
540 }
William M. Brack6d13f332003-08-08 16:40:36 +0000541
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000542}
543
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000544// Create the makefile.
545var fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000546var makefile = ".\\Makefile.msvc";
547if (compiler == "mingw")
548 makefile = ".\\Makefile.mingw";
Igor Zlatkovice8b5b0f2003-06-16 07:12:50 +0000549else if (compiler == "bcb")
550 makefile = ".\\Makefile.bcb";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000551fso.CopyFile(makefile, ".\\Makefile", true);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000552WScript.Echo("Created Makefile.");
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000553// Create the config.h.
554var confighsrc = "..\\include\\win32config.h";
555var configh = "..\\config.h";
556fso.CopyFile(confighsrc, configh, true);
557WScript.Echo("Created config.h.");
558
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000559
560// Display the final configuration.
561var txtOut = "\nXML processor configuration\n";
562txtOut += "---------------------------\n";
563txtOut += " Trio: " + boolToStr(withTrio) + "\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000564txtOut += " Thread safety: " + withThreads + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000565txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
566txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
567txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
568txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
569txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
570txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
571txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
572txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
573txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000574txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000575txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000576txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000577txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
578txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000579txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000580txtOut += " Tree support: " + boolToStr(withTree) + "\n";
581txtOut += " Reader support: " + boolToStr(withReader) + "\n";
582txtOut += " Walker support: " + boolToStr(withWalker) + "\n";
583txtOut += " Push support: " + boolToStr(withPush) + "\n";
584txtOut += "Validation support: " + boolToStr(withValid) + "\n";
585txtOut += " SAX1 support: " + boolToStr(withSax1) + "\n";
586txtOut += " Legacy support: " + boolToStr(withLegacy) + "\n";
587txtOut += " Output support: " + boolToStr(withOutput) + "\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000588txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000589txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000590txtOut += "\n";
591txtOut += "Win32 build configuration\n";
592txtOut += "-------------------------\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000593txtOut += " Compiler: " + compiler + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000594txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
595txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
596txtOut += " Install prefix: " + buildPrefix + "\n";
597txtOut += " Put tools in: " + buildBinPrefix + "\n";
598txtOut += " Put headers in: " + buildIncPrefix + "\n";
599txtOut += "Put static libs in: " + buildLibPrefix + "\n";
600txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
601txtOut += " Include path: " + buildInclude + "\n";
602txtOut += " Lib path: " + buildLib + "\n";
603WScript.Echo(txtOut);
604
William M. Brack6d13f332003-08-08 16:40:36 +0000605//
606