blob: cd1548ea5b8de2c11502f6e7a2f0c074f3d668a0 [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;
Igor Zlatkovic3acadf42002-09-20 16:40:17 +000042var withZlib = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000043var withDebug = true;
44var withMemDebug = false;
Igor Zlatkovica6f2d902002-04-16 17:57:17 +000045var withSchemas = true;
Igor Zlatkovic8e040972002-09-20 13:39:53 +000046var withRegExps = true;
Igor Zlatkovic853514f2002-11-22 21:41:09 +000047var withPython = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000048/* Win32 build options. */
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000049var compiler = "msvc";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000050var buildDebug = 0;
51var buildStatic = 0;
52var buildPrefix = ".";
53var buildBinPrefix = "$(PREFIX)\\bin";
54var buildIncPrefix = "$(PREFIX)\\include";
55var buildLibPrefix = "$(PREFIX)\\lib";
56var buildSoPrefix = "$(PREFIX)\\lib";
57var buildInclude = ".";
58var buildLib = ".";
59/* Local stuff */
60var error = 0;
61
62/* Helper function, transforms the option variable into the 'Enabled'
63 or 'Disabled' string. */
64function boolToStr(opt)
65{
66 if (opt == false)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000067 return "no";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000068 else if (opt == true)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000069 return "yes";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000070 error = 1;
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000071 return "*** undefined ***";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000072}
73
74/* Helper function, transforms the argument string into a boolean
75 value. */
76function strToBool(opt)
77{
78 if (opt == 0 || opt == "no")
79 return false;
80 else if (opt == 1 || opt == "yes")
81 return true;
82 error = 1;
83 return false;
84}
85
86/* Displays the details about how to use this script. */
87function usage()
88{
89 var txt;
90 txt = "Usage:\n";
91 txt += " cscript " + WScript.ScriptName + " <options>\n";
92 txt += " cscript " + WScript.ScriptName + " help\n\n";
93 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000094 txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000095 txt += "\nXML processor options, default value given in parentheses:\n\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000096 txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000097 txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000098 txt += " ftp: Enable FTP client (" + (withFtp? "yes" : "no") + ")\n";
99 txt += " http: Enable HTTP client (" + (withHttp? "yes" : "no") + ")\n";
100 txt += " html: Enable HTML processor (" + (withHtml? "yes" : "no") + ")\n";
101 txt += " c14n: Enable C14N support (" + (withC14n? "yes" : "no") + ")\n";
102 txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n";
103 txt += " docb: Enable DocBook support (" + (withDocb? "yes" : "no") + ")\n";
104 txt += " xpath: Enable XPath support (" + (withXpath? "yes" : "no") + ")\n";
105 txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n";
106 txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000107 txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
108 txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000109 txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
110 txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000111 txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000112 txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000113 txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000114 txt += "\nWin32 build options, default value given in parentheses:\n\n";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000115 txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000116 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
117 txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
118 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
119 txt += " bindir: Directory where xmllint and friends should be installed\n";
120 txt += " (" + buildBinPrefix + ")\n";
121 txt += " incdir: Directory where headers should be installed\n";
122 txt += " (" + buildIncPrefix + ")\n";
123 txt += " libdir: Directory where static and import libraries should be\n";
124 txt += " installed (" + buildLibPrefix + ")\n";
125 txt += " sodir: Directory where shared libraries should be installed\n";
126 txt += " (" + buildSoPrefix + ")\n";
127 txt += " include: Additional search path for the compiler, particularily\n";
128 txt += " where iconv headers can be found (" + buildInclude + ")\n";
129 txt += " lib: Additional search path for the linker, particularily\n";
130 txt += " where iconv library can be found (" + buildLib + ")\n";
131 WScript.Echo(txt);
132}
133
134/* Discovers the version we are working with by reading the apropriate
135 configuration file. Despite its name, this also writes the configuration
136 file included by our makefile. */
137function discoverVersion()
138{
139 var fso, cf, vf, ln, s;
140 fso = new ActiveXObject("Scripting.FileSystemObject");
141 cf = fso.OpenTextFile(configFile, 1);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000142 if (compiler == "msvc")
143 versionFile = ".\\config.msvc";
144 else if (compiler == "mingw")
145 versionFile = ".\\config.mingw";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000146 else if (compiler == "bcb")
147 versionFile = ".\\config.bcb";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000148 vf = fso.CreateTextFile(versionFile, true);
149 vf.WriteLine("# " + versionFile);
150 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
151 vf.WriteBlankLines(1);
152 while (cf.AtEndOfStream != true) {
153 ln = cf.ReadLine();
154 s = new String(ln);
155 if (s.search(/^LIBXML_MAJOR_VERSION/) != -1) {
156 vf.WriteLine(s);
157 verMajor = s.substring(s.indexOf("=") + 1, s.length)
158 } else if(s.search(/^LIBXML_MINOR_VERSION/) != -1) {
159 vf.WriteLine(s);
160 verMinor = s.substring(s.indexOf("=") + 1, s.length)
161 } else if(s.search(/^LIBXML_MICRO_VERSION/) != -1) {
162 vf.WriteLine(s);
163 verMicro = s.substring(s.indexOf("=") + 1, s.length)
164 }
165 }
166 cf.Close();
167 vf.WriteLine("XML_SRCDIR=" + srcDirXml);
168 vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
169 vf.WriteLine("BINDIR=" + binDir);
170 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000171 vf.WriteLine("WITH_THREADS=" + withThreads);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000172 vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
173 vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
174 vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
175 vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
176 vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
177 vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
178 vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
179 vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
180 vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
181 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000182 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000183 vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
184 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000185 vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000186 vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000187 vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000188 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
189 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
190 vf.WriteLine("PREFIX=" + buildPrefix);
191 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
192 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
193 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
194 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000195 if (compiler == "msvc") {
196 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
197 vf.WriteLine("LIB=$(LIB);" + buildLib);
198 } else if (compiler == "mingw") {
199 vf.WriteLine("INCLUDE+=;" + buildInclude);
200 vf.WriteLine("LIB+=;" + buildLib);
201 }
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000202 } else if (compiler == "bcb") {
203 vf.WriteLine("INCLUDE=" + buildInclude);
204 vf.WriteLine("LIB=" + buildLib);
205 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000206 vf.Close();
207}
208
209/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
210 taking what the user passed on the command line into account. */
211function configureLibxml()
212{
213 var fso, ofi, of, ln, s;
214 fso = new ActiveXObject("Scripting.FileSystemObject");
215 ofi = fso.OpenTextFile(optsFileIn, 1);
216 of = fso.CreateTextFile(optsFile, true);
217 while (ofi.AtEndOfStream != true) {
218 ln = ofi.ReadLine();
219 s = new String(ln);
220 if (s.search(/\@VERSION\@/) != -1) {
221 of.WriteLine(s.replace(/\@VERSION\@/,
222 verMajor + "." + verMinor + "." + verMicro));
223 } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
224 of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
225 verMajor*10000 + verMinor*100 + verMicro*1));
226 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
227 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
228 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000229 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000230 } else if (s.search(/\@WITH_FTP\@/) != -1) {
231 of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
232 } else if (s.search(/\@WITH_HTTP\@/) != -1) {
233 of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
234 } else if (s.search(/\@WITH_HTML\@/) != -1) {
235 of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
236 } else if (s.search(/\@WITH_C14N\@/) != -1) {
237 of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
238 } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
239 of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
240 } else if (s.search(/\@WITH_DOCB\@/) != -1) {
241 of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
242 } else if (s.search(/\@WITH_XPATH\@/) != -1) {
243 of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
244 } else if (s.search(/\@WITH_XPTR\@/) != -1) {
245 of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
246 } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
247 of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
248 } else if (s.search(/\@WITH_ICONV\@/) != -1) {
249 of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000250 } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
251 of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000252 } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
253 of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
254 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
255 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000256 } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
257 of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000258 } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
259 of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000260 } else
261 of.WriteLine(ln);
262 }
263 ofi.Close();
264 of.Close();
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000265}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000266/* Configures Python bindings. Otherwise identical to the above */
267function configureLibxmlPy()
268{
269 var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
270 var pyOptsFile = srcDirXml + "\\python\\setup.py";
271 var fso, ofi, of, ln, s;
272 fso = new ActiveXObject("Scripting.FileSystemObject");
273 ofi = fso.OpenTextFile(pyOptsFileIn, 1);
274 of = fso.CreateTextFile(pyOptsFile, true);
275 while (ofi.AtEndOfStream != true) {
276 ln = ofi.ReadLine();
277 s = new String(ln);
278 if (s.search(/\@LIBXML_VERSION\@/) != -1) {
279 of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
280 verMajor + "." + verMinor + "." + verMicro));
281 } else if (s.search(/\@prefix\@/) != -1) {
282 of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
Daniel Veillard94bb2f12003-04-27 22:14:07 +0000283 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
284 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000285 } else
286 of.WriteLine(ln);
287 }
288 ofi.Close();
289 of.Close();
290}
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000291
292/* Creates the readme file for the binary distribution of 'bname', for the
293 version 'ver' in the file 'file'. This one is called from the Makefile when
294 generating a binary distribution. The parameters are passed by make. */
295function genReadme(bname, ver, file)
296{
297 var fso, f;
298 fso = new ActiveXObject("Scripting.FileSystemObject");
299 f = fso.CreateTextFile(file, true);
300 f.WriteLine(" " + bname + " " + ver);
301 f.WriteLine(" --------------");
302 f.WriteBlankLines(1);
303 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
304 f.WriteLine("platform.");
305 f.WriteBlankLines(1);
306 f.WriteLine(" The directory named 'include' contains the header files. Place its");
307 f.WriteLine("contents somewhere where it can be found by the compiler.");
308 f.WriteLine(" The directory which answers to the name 'lib' contains the static and");
309 f.WriteLine("dynamic libraries. Place them somewhere where they can be found by the");
310 f.WriteLine("linker. The files whose names end with '_a.lib' are aimed for static");
311 f.WriteLine("linking, the other files are lib/dll pairs.");
312 f.WriteLine(" The directory called 'util' contains various programs which count as a");
313 f.WriteLine("part of " + bname + ".");
314 f.WriteBlankLines(1);
Igor Zlatkovic0ceeb8e2002-09-10 19:07:02 +0000315 f.WriteLine(" If you plan to develop your own programme, in C, which uses " + bname + ", then");
316 f.WriteLine("you should know what to do with the files in the binary package. If you don't,");
317 f.WriteLine("know this, then please, please do some research on how to use a");
318 f.WriteLine("third-party library in a C programme. The topic belongs to the very basics");
319 f.WriteLine("and you will not be able to do much without that knowledge.");
320 f.WriteBlankLines(1);
321 f.WriteLine(" If you wish to use " + bname + " solely through the supplied utilities, such as");
322 f.WriteLine("xmllint or xsltproc, then all you need to do is place the");
323 f.WriteLine("contents of the 'lib' and 'util' directories from the binary package in a");
324 f.WriteLine("directory on your disc which is mentioned in your PATH environment");
325 f.WriteLine("variable. You can use an existing directory which is allready in the");
326 f.WriteLine("path, such as 'C:\WINDOWS', or 'C:\WINNT'. You can also create a new");
327 f.WriteLine("directory for " + bname + " and place the files there, but be sure to modify");
328 f.WriteLine("the PATH environment variable and add that new directory to its list.");
329 f.WriteBlankLines(1);
330 f.WriteLine(" If you use other software which needs " + bname + ", such as Apache");
331 f.WriteLine("Web Server in certain configurations, then please consult the");
332 f.WriteLine("documentation of that software and see if it mentions something about");
333 f.WriteLine("how it uses " + bname + " and how it expects it to be installed. If you find");
334 f.WriteLine("nothing, then the default installation, as described in the previous");
335 f.WriteLine("paragraph, should be suficient.");
336 f.WriteBlankLines(1);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000337 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
338 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
339 f.WriteLine("the address below.");
340 f.WriteBlankLines(1);
Daniel Veillardbeb70bd2002-12-18 14:53:54 +0000341 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000342 f.Close();
343}
344
345/*
346 * main(),
347 * Execution begins here.
348 */
349
350// Parse the command-line arguments.
351for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
352 var arg, opt;
353 arg = WScript.Arguments(i);
354 opt = arg.substring(0, arg.indexOf("="));
355 if (opt.length == 0)
356 opt = arg.substring(0, arg.indexOf(":"));
357 if (opt.length > 0) {
358 if (opt == "trio")
359 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
360 else if (opt == "threads")
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000361 withThreads = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000362 else if (opt == "ftp")
363 withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
364 else if (opt == "http")
365 withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
366 else if (opt == "html")
367 withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic9425ce22002-04-10 21:57:11 +0000368 else if (opt == "c14n")
369 withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000370 else if (opt == "catalog")
371 withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
372 else if (opt == "docb")
373 withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
374 else if (opt == "xpath")
375 withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
376 else if (opt == "xptr")
377 withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
378 else if (opt == "xinclude")
379 withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
380 else if (opt == "iconv")
381 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000382 else if (opt == "zlib")
383 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000384 else if (opt == "xml_debug")
385 withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
386 else if (opt == "mem_debug")
387 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000388 else if (opt == "schemas")
389 withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000390 else if (opt == "regexps")
391 withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000392 else if (opt == "python")
393 withPython = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000394 else if (opt == "compiler")
395 compiler = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000396 else if (opt == "debug")
397 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
398 else if (opt == "static")
399 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
400 else if (opt == "prefix")
401 buildPrefix = arg.substring(opt.length + 1, arg.length);
402 else if (opt == "incdir")
403 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
404 else if (opt == "bindir")
405 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
406 else if (opt == "libdir")
407 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
408 else if (opt == "sodir")
409 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
410 else if (opt == "incdir")
411 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
412 else if (opt == "include")
413 buildInclude = arg.substring(opt.length + 1, arg.length);
414 else if (opt == "lib")
415 buildLib = arg.substring(opt.length + 1, arg.length);
416 else
417 error = 1;
418 } else if (i == 0) {
419 if (arg == "genreadme") {
420 // This command comes from the Makefile and will not be checked
421 // for errors, because Makefile will always supply right the parameters.
422 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
423 WScript.Quit(0);
424 } else if (arg == "help") {
425 usage();
426 WScript.Quit(0);
427 }
428 } else
429 error = 1;
430}
431
432// If we fail here, it is because the user supplied an unrecognised argument.
433if (error != 0) {
434 usage();
435 WScript.Quit(error);
436}
437
438// Discover the version.
439discoverVersion();
440if (error != 0) {
441 WScript.Echo("Version discovery failed, aborting.");
442 WScript.Quit(error);
443}
444WScript.Echo(baseName + " version: " + verMajor + "." + verMinor + "." + verMicro);
445
446// Configure libxml.
447configureLibxml();
448if (error != 0) {
449 WScript.Echo("Configuration failed, aborting.");
450 WScript.Quit(error);
451}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000452if (withPython == true) {
453 configureLibxmlPy();
454 if (error != 0) {
455 WScript.Echo("Configuration failed, aborting.");
456 WScript.Quit(error);
457 }
458}
459
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000460
461// Create the makefile.
462var fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000463var makefile = ".\\Makefile.msvc";
464if (compiler == "mingw")
465 makefile = ".\\Makefile.mingw";
466fso.CopyFile(makefile, ".\\Makefile", true);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000467WScript.Echo("Created Makefile.");
468
469// Display the final configuration.
470var txtOut = "\nXML processor configuration\n";
471txtOut += "---------------------------\n";
472txtOut += " Trio: " + boolToStr(withTrio) + "\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000473txtOut += " Thread safety: " + withThreads + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000474txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
475txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
476txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
477txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
478txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
479txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
480txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
481txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
482txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000483txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
484txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000485txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
486txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000487txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000488txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000489txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000490txtOut += "\n";
491txtOut += "Win32 build configuration\n";
492txtOut += "-------------------------\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000493txtOut += " Compiler: " + compiler + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000494txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
495txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
496txtOut += " Install prefix: " + buildPrefix + "\n";
497txtOut += " Put tools in: " + buildBinPrefix + "\n";
498txtOut += " Put headers in: " + buildIncPrefix + "\n";
499txtOut += "Put static libs in: " + buildLibPrefix + "\n";
500txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
501txtOut += " Include path: " + buildInclude + "\n";
502txtOut += " Lib path: " + buildLib + "\n";
503WScript.Echo(txtOut);
504
505// Done.