xref: /aosp_15_r20/external/libxml2/win32/configure.js (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1/* 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 *
7 * March 2002, Igor Zlatkovic <[email protected]>
8 */
9
10/* The source directory, relative to the one where this file resides. */
11var srcDirXml = "..";
12var srcDirUtils = "..";
13/* Base name of what we are building. */
14var baseName = "libxml2";
15/* Configure file which contains the version and the output file where
16   we can store our build configuration. */
17var configFile = srcDirXml + "\\configure.ac";
18var versionFile = ".\\config.msvc";
19/* Input and output files regarding the libxml features. */
20var optsFileIn = srcDirXml + "\\include\\libxml\\xmlversion.h.in";
21var optsFile = srcDirXml + "\\include\\libxml\\xmlversion.h";
22/* Version strings for the binary distribution. Will be filled later
23   in the code. */
24var verMajor;
25var verMinor;
26var verMicro;
27var verMicroSuffix;
28var verCvs;
29var useCvsVer = true;
30/* Libxml features. */
31var withThreads = "native";
32var withHttp = true;
33var withHtml = true;
34var withC14n = true;
35var withCatalog = true;
36var withXpath = true;
37var withXptr = true;
38var withXinclude = true;
39var withIconv = true;
40var withIcu = false;
41var withIso8859x = false;
42var withZlib = false;
43var withLzma = false;
44var withDebug = true;
45var withSchemas = true;
46var withSchematron = true;
47var withRegExps = true;
48var withModules = true;
49var withTree = true;
50var withReader = true;
51var withWriter = true;
52var withWalker = true;
53var withPattern = true;
54var withPush = true;
55var withValid = true;
56var withSax1 = true;
57var withLegacy = true;
58var withOutput = true;
59var withPython = false;
60/* Win32 build options. */
61var dirSep = "\\";
62var compiler = "msvc";
63var cruntime = "/MD";
64var dynruntime = true;
65var vcmanifest = false;
66var buildDebug = 0;
67var buildStatic = 0;
68var buildPrefix = ".";
69var buildBinPrefix = "";
70var buildIncPrefix = "";
71var buildLibPrefix = "";
72var buildSoPrefix = "";
73var buildInclude = ".";
74var buildLib = ".";
75/* Local stuff */
76var error = 0;
77
78/* Helper function, transforms the option variable into the 'Enabled'
79   or 'Disabled' string. */
80function boolToStr(opt)
81{
82	if (opt == false)
83		return "no";
84	else if (opt == true)
85		return "yes";
86	error = 1;
87	return "*** undefined ***";
88}
89
90/* Helper function, transforms the argument string into a boolean
91   value. */
92function strToBool(opt)
93{
94	if (opt == 0 || opt == "no")
95		return false;
96	else if (opt == 1 || opt == "yes")
97		return true;
98	error = 1;
99	return false;
100}
101
102/* Displays the details about how to use this script. */
103function usage()
104{
105	var txt;
106	txt = "Usage:\n";
107	txt += "  cscript " + WScript.ScriptName + " <options>\n";
108	txt += "  cscript " + WScript.ScriptName + " help\n\n";
109	txt += "Options can be specified in the form <option>=<value>, where the value is\n";
110	txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
111	txt += "\nXML processor options, default value given in parentheses:\n\n";
112	txt += "  threads:    Enable thread safety [no|ctls|native|posix] (" + (withThreads)  + ") \n";
113	txt += "  http:       Enable HTTP client (" + (withHttp? "yes" : "no")  + ")\n";
114	txt += "  html:       Enable HTML processor (" + (withHtml? "yes" : "no")  + ")\n";
115	txt += "  c14n:       Enable C14N support (" + (withC14n? "yes" : "no")  + ")\n";
116	txt += "  catalog:    Enable catalog support (" + (withCatalog? "yes" : "no")  + ")\n";
117	txt += "  xpath:      Enable XPath support (" + (withXpath? "yes" : "no")  + ")\n";
118	txt += "  xptr:       Enable XPointer support (" + (withXptr? "yes" : "no")  + ")\n";
119	txt += "  xinclude:   Enable XInclude support (" + (withXinclude? "yes" : "no")  + ")\n";
120	txt += "  iconv:      Enable iconv support (" + (withIconv? "yes" : "no")  + ")\n";
121	txt += "  icu:        Enable icu support (" + (withIcu? "yes" : "no")  + ")\n";
122	txt += "  iso8859x:   Enable ISO8859X support (" + (withIso8859x? "yes" : "no")  + ")\n";
123	txt += "  zlib:       Enable zlib support (" + (withZlib? "yes" : "no")  + ")\n";
124	txt += "  lzma:       Enable lzma support (" + (withLzma? "yes" : "no")  + ")\n";
125	txt += "  xml_debug:  Enable XML debbugging module (" + (withDebug? "yes" : "no")  + ")\n";
126	txt += "  regexps:    Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
127	txt += "  modules:    Enable module support (" + (withModules? "yes" : "no") + ")\n";
128	txt += "  tree:       Enable tree api (" + (withTree? "yes" : "no") + ")\n";
129	txt += "  reader:     Enable xmlReader api (" + (withReader? "yes" : "no") + ")\n";
130	txt += "  writer:     Enable xmlWriter api (" + (withWriter? "yes" : "no") + ")\n";
131	txt += "  walker:     Enable xmlDocWalker api (" + (withWalker? "yes" : "no") + ")\n";
132	txt += "  pattern:    Enable xmlPattern api (" + (withPattern? "yes" : "no")  + ")\n";
133	txt += "  push:       Enable push api (" + (withPush? "yes" : "no") + ")\n";
134	txt += "  valid:      Enable DTD validation support (" + (withValid? "yes" : "no") + ")\n";
135	txt += "  sax1:       Enable SAX1 api (" + (withSax1? "yes" : "no") + ")\n";
136	txt += "  legacy:     Enable Deprecated api's (" + (withLegacy? "yes" : "no") + ")\n";
137	txt += "  output:     Enable serialization support (" + (withOutput? "yes" : "no") + ")\n";
138	txt += "  schemas:    Enable XML Schema support (" + (withSchemas? "yes" : "no")  + ")\n";
139	txt += "  schematron: Enable Schematron support (" + (withSchematron? "yes" : "no")  + ")\n";
140	txt += "  python:     Build Python bindings (" + (withPython? "yes" : "no")  + ")\n";
141	txt += "\nWin32 build options, default value given in parentheses:\n\n";
142	txt += "  compiler:   Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
143	txt += "  cruntime:   C-runtime compiler option (only msvc) (" + cruntime + ")\n";
144	txt += "  dynruntime: Use the dynamic RTL (only bcb) (" + dynruntime + ")\n";
145	txt += "  vcmanifest: Embed VC manifest (only msvc) (" + (vcmanifest? "yes" : "no") + ")\n";
146	txt += "  debug:      Build unoptimised debug executables (" + (buildDebug? "yes" : "no")  + ")\n";
147	txt += "  static:     Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no")  + ")\n";
148	txt += "              Note: automatically enabled if cruntime is not /MD or /MDd\n";
149	txt += "  prefix:     Base directory for the installation (" + buildPrefix + ")\n";
150	txt += "  bindir:     Directory where xmllint and friends should be installed\n";
151	txt += "              (" + buildBinPrefix + ")\n";
152	txt += "  incdir:     Directory where headers should be installed\n";
153	txt += "              (" + buildIncPrefix + ")\n";
154	txt += "  libdir:     Directory where static and import libraries should be\n";
155	txt += "              installed (" + buildLibPrefix + ")\n";
156	txt += "  sodir:      Directory where shared libraries should be installed\n";
157	txt += "              (" + buildSoPrefix + ")\n";
158	txt += "  include:    Additional search path for the compiler, particularly\n";
159	txt += "              where iconv headers can be found (" + buildInclude + ")\n";
160	txt += "  lib:        Additional search path for the linker, particularly\n";
161	txt += "              where iconv library can be found (" + buildLib + ")\n";
162	WScript.Echo(txt);
163}
164
165/* Discovers the version we are working with by reading the appropriate
166   configuration file. Despite its name, this also writes the configuration
167   file included by our makefile. */
168function discoverVersion()
169{
170	var fso, cf, vf, ln, s, iDot, iSlash;
171	fso = new ActiveXObject("Scripting.FileSystemObject");
172	verCvs = "";
173	cf = fso.OpenTextFile(configFile, 1);
174	if (compiler == "msvc")
175		versionFile = ".\\config.msvc";
176	else if (compiler == "mingw")
177		versionFile = ".\\config.mingw";
178	else if (compiler == "bcb")
179		versionFile = ".\\config.bcb";
180	vf = fso.CreateTextFile(versionFile, true);
181	vf.WriteLine("# " + versionFile);
182	vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
183	vf.WriteBlankLines(1);
184	while (cf.AtEndOfStream != true) {
185		ln = cf.ReadLine();
186		s = new String(ln);
187		if (m = s.match(/^m4_define\(\[MAJOR_VERSION\], (\w+)\)/)) {
188			vf.WriteLine("LIBXML_MAJOR_VERSION=" + m[1]);
189			verMajor = m[1];
190		} else if(m = s.match(/^m4_define\(\[MINOR_VERSION\], (\w+)\)/)) {
191			vf.WriteLine("LIBXML_MINOR_VERSION=" + m[1]);
192			verMinor = m[1];
193		} else if(m = s.match(/^m4_define\(\[MICRO_VERSION\], (\w+)\)/)) {
194			vf.WriteLine("LIBXML_MICRO_VERSION=" + m[1]);
195			verMicro = m[1];
196		} else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
197			vf.WriteLine(s);
198			verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length);
199		}
200	}
201	cf.Close();
202	vf.WriteLine("XML_SRCDIR=" + srcDirXml);
203	vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
204	vf.WriteLine("WITH_THREADS=" + withThreads);
205	vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
206	vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
207	vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
208	vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
209	vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
210	vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
211	vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
212	vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
213	vf.WriteLine("WITH_ICU=" + (withIcu? "1" : "0"));
214	vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
215	vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
216	vf.WriteLine("WITH_LZMA=" + (withLzma? "1" : "0"));
217	vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
218	vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
219	vf.WriteLine("WITH_SCHEMATRON=" + (withSchematron? "1" : "0"));
220	vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
221	vf.WriteLine("WITH_MODULES=" + (withModules? "1" : "0"));
222	vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
223	vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
224	vf.WriteLine("WITH_WRITER=" + (withWriter? "1" : "0"));
225	vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
226	vf.WriteLine("WITH_PATTERN=" + (withPattern? "1" : "0"));
227	vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
228	vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
229	vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
230	vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
231	vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
232	vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
233	vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
234	vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
235	vf.WriteLine("PREFIX=" + buildPrefix);
236	vf.WriteLine("BINPREFIX=" + buildBinPrefix);
237	vf.WriteLine("INCPREFIX=" + buildIncPrefix);
238	vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
239	vf.WriteLine("SOPREFIX=" + buildSoPrefix);
240	if (compiler == "msvc") {
241		vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
242		vf.WriteLine("LIB=$(LIB);" + buildLib);
243		vf.WriteLine("CRUNTIME=" + cruntime);
244		vf.WriteLine("VCMANIFEST=" + (vcmanifest? "1" : "0"));
245	} else if (compiler == "mingw") {
246		vf.WriteLine("INCLUDE+= -I" + buildInclude);
247		vf.WriteLine("LIB+= -L" + buildLib);
248	} else if (compiler == "bcb") {
249		vf.WriteLine("INCLUDE=" + buildInclude);
250		vf.WriteLine("LIB=" + buildLib);
251		vf.WriteLine("DYNRUNTIME=" + (dynruntime? "1" : "0"));
252	}
253	vf.Close();
254	versionFile = "rcVersion.h";
255	vf = fso.CreateTextFile(versionFile, true);
256	vf.WriteLine("/*");
257	vf.WriteLine("  " + versionFile);
258	vf.WriteLine("  This file is generated automatically by " + WScript.ScriptName + ".");
259	vf.WriteLine("*/");
260	vf.WriteBlankLines(1);
261	vf.WriteLine("#define LIBXML_MAJOR_VERSION " + verMajor);
262	vf.WriteLine("#define LIBXML_MINOR_VERSION " + verMinor);
263	vf.WriteLine("#define LIBXML_MICRO_VERSION " + verMicro);
264	vf.WriteLine("#define LIBXML_DOTTED_VERSION " + "\"" + verMajor + "." + verMinor + "." + verMicro + "\"");
265	vf.Close();
266}
267
268/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
269   taking what the user passed on the command line into account. */
270function configureLibxml()
271{
272	var fso, ofi, of, ln, s;
273	fso = new ActiveXObject("Scripting.FileSystemObject");
274	ofi = fso.OpenTextFile(optsFileIn, 1);
275	of = fso.CreateTextFile(optsFile, true);
276	while (ofi.AtEndOfStream != true) {
277		ln = ofi.ReadLine();
278		s = new String(ln);
279		if (s.search(/\@VERSION\@/) != -1) {
280			of.WriteLine(s.replace(/\@VERSION\@/,
281				verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
282		} else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
283			of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
284				verMajor*10000 + verMinor*100 + verMicro*1));
285		} else if (s.search(/\@LIBXML_VERSION_EXTRA\@/) != -1) {
286			of.WriteLine(s.replace(/\@LIBXML_VERSION_EXTRA\@/, verCvs));
287		} else if (s.search(/\@WITH_THREADS\@/) != -1) {
288			of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
289		} else if (s.search(/\@WITH_THREAD_ALLOC\@/) != -1) {
290			of.WriteLine(s.replace(/\@WITH_THREAD_ALLOC\@/, "0"));
291		} else if (s.search(/\@WITH_HTTP\@/) != -1) {
292			of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
293		} else if (s.search(/\@WITH_HTML\@/) != -1) {
294			of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
295		} else if (s.search(/\@WITH_C14N\@/) != -1) {
296			of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
297		} else if (s.search(/\@WITH_CATALOG\@/) != -1) {
298			of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
299		} else if (s.search(/\@WITH_XPATH\@/) != -1) {
300			of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
301		} else if (s.search(/\@WITH_XPTR\@/) != -1) {
302			of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
303		} else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
304			of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
305		} else if (s.search(/\@WITH_ICONV\@/) != -1) {
306			of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
307		} else if (s.search(/\@WITH_ICU\@/) != -1) {
308			of.WriteLine(s.replace(/\@WITH_ICU\@/, withIcu? "1" : "0"));
309		} else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
310			of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
311		} else if (s.search(/\@WITH_ZLIB\@/) != -1) {
312			of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
313		} else if (s.search(/\@WITH_LZMA\@/) != -1) {
314			of.WriteLine(s.replace(/\@WITH_LZMA\@/, withLzma? "1" : "0"));
315		} else if (s.search(/\@WITH_DEBUG\@/) != -1) {
316			of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
317		} else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
318			of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
319		} else if (s.search(/\@WITH_SCHEMATRON\@/) != -1) {
320			of.WriteLine(s.replace(/\@WITH_SCHEMATRON\@/, withSchematron? "1" : "0"));
321		} else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
322			of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
323		} else if (s.search(/\@WITH_MODULES\@/) != -1) {
324			of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0"));
325		} else if (s.search(/\@MODULE_EXTENSION\@/) != -1) {
326			of.WriteLine(s.replace(/\@MODULE_EXTENSION\@/, ".dll"));
327		} else if (s.search(/\@WITH_TREE\@/) != -1) {
328			of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
329		} else if (s.search(/\@WITH_READER\@/) != -1) {
330			of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
331		} else if (s.search(/\@WITH_WRITER\@/) != -1) {
332			of.WriteLine(s.replace(/\@WITH_WRITER\@/, withWriter? "1" : "0"));
333		} else if (s.search(/\@WITH_WALKER\@/) != -1) {
334			of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
335		} else if (s.search(/\@WITH_PATTERN\@/) != -1) {
336			of.WriteLine(s.replace(/\@WITH_PATTERN\@/, withPattern? "1" : "0"));
337		} else if (s.search(/\@WITH_PUSH\@/) != -1) {
338			of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
339		} else if (s.search(/\@WITH_VALID\@/) != -1) {
340			of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
341		} else if (s.search(/\@WITH_SAX1\@/) != -1) {
342			of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
343		} else if (s.search(/\@WITH_LEGACY\@/) != -1) {
344			of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
345		} else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
346			of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
347		} else
348			of.WriteLine(ln);
349	}
350	ofi.Close();
351	of.Close();
352}
353/* Configures Python bindings. Otherwise identical to the above */
354function configureLibxmlPy()
355{
356	var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
357	var pyOptsFile = srcDirXml + "\\python\\setup.py";
358	var fso, ofi, of, ln, s;
359	fso = new ActiveXObject("Scripting.FileSystemObject");
360	ofi = fso.OpenTextFile(pyOptsFileIn, 1);
361	of = fso.CreateTextFile(pyOptsFile, true);
362	while (ofi.AtEndOfStream != true) {
363		ln = ofi.ReadLine();
364		s = new String(ln);
365		if (s.search(/\@LIBXML_VERSION\@/) != -1) {
366			of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
367				verMajor + "." + verMinor + "." + verMicro));
368		} else if (s.search(/\@prefix\@/) != -1) {
369			of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
370		} else if (s.search(/\@WITH_THREADS\@/) != -1) {
371			of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
372		} else if (s.search(/\@WITH_ZLIB\@/) != -1) {
373			of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
374		} else if (s.search(/\@WITH_LZMA\@/) != -1) {
375			of.WriteLine(s.replace(/\@WITH_LZMA\@/, withLzma? "1" : "0"));
376		} else if (s.search(/\@WITH_ICONV\@/) != -1) {
377            of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
378		} else if (s.search(/\@WITH_ICU\@/) != -1) {
379			of.WriteLine(s.replace(/\@WITH_ICU\@/, withIcu? "1" : "0"));
380		} else
381			of.WriteLine(ln);
382	}
383	ofi.Close();
384	of.Close();
385}
386
387/* Creates the readme file for the binary distribution of 'bname', for the
388   version 'ver' in the file 'file'. This one is called from the Makefile when
389   generating a binary distribution. The parameters are passed by make. */
390function genReadme(bname, ver, file)
391{
392	var fso, f;
393	fso = new ActiveXObject("Scripting.FileSystemObject");
394	f = fso.CreateTextFile(file, true);
395	f.WriteLine("  " + bname + " " + ver);
396	f.WriteLine("  --------------");
397	f.WriteBlankLines(1);
398	f.WriteLine("  This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
399	f.WriteLine("platform.");
400	f.WriteBlankLines(1);
401	f.WriteLine("  The files in this package do not require any special installation");
402	f.WriteLine("steps. Extract the contents of the archive wherever you wish and");
403	f.WriteLine("make sure that your tools which use " + bname + " can find it.");
404	f.WriteBlankLines(1);
405	f.WriteLine("  For example, if you want to run the supplied utilities from the command");
406	f.WriteLine("line, you can, if you wish, add the 'bin' subdirectory to the PATH");
407	f.WriteLine("environment variable.");
408	f.WriteLine("  If you want to make programmes in C which use " + bname + ", you'll");
409	f.WriteLine("likely know how to use the contents of this package. If you don't, please");
410	f.WriteLine("refer to your compiler's documentation.");
411	f.WriteBlankLines(1);
412	f.WriteLine("  If there is something you cannot keep for yourself, such as a problem,");
413	f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
414	f.WriteLine("the address below.");
415	f.WriteBlankLines(1);
416	f.WriteLine("                              Igor Zlatkovic ([email protected])");
417	f.Close();
418}
419
420
421/*
422 * main(),
423 * Execution begins here.
424 */
425
426// Parse the command-line arguments.
427for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
428	var arg, opt;
429	arg = WScript.Arguments(i);
430	opt = arg.substring(0, arg.indexOf("="));
431	if (opt.length == 0)
432		opt = arg.substring(0, arg.indexOf(":"));
433	if (opt.length > 0) {
434		if (opt == "threads")
435			withThreads = arg.substring(opt.length + 1, arg.length);
436		else if (opt == "http")
437			withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
438		else if (opt == "html")
439			withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
440		else if (opt == "c14n")
441			withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
442		else if (opt == "catalog")
443			withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
444		else if (opt == "xpath")
445			withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
446		else if (opt == "xptr")
447			withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
448		else if (opt == "xinclude")
449			withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
450		else if (opt == "iconv")
451			withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
452		else if (opt == "icu")
453			withIcu = strToBool(arg.substring(opt.length + 1, arg.length));
454		else if (opt == "iso8859x")
455			withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
456		else if (opt == "zlib")
457			withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
458		else if (opt == "lzma")
459			withLzma = strToBool(arg.substring(opt.length + 1, arg.length));
460		else if (opt == "xml_debug")
461			withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
462		else if (opt == "schemas")
463			withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
464		else if (opt == "schematron")
465			withSchematron = strToBool(arg.substring(opt.length + 1, arg.length));
466		else if (opt == "regexps")
467			withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
468		else if (opt == "modules")
469			withModules = strToBool(arg.substring(opt.length + 1, arg.length));
470		else if (opt == "tree")
471			withTree = strToBool(arg.substring(opt.length + 1, arg.length));
472		else if (opt == "reader")
473			withReader = strToBool(arg.substring(opt.length + 1, arg.length));
474		else if (opt == "writer")
475			withWriter = strToBool(arg.substring(opt.length + 1, arg.length));
476		else if (opt == "walker")
477			withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
478		else if (opt == "pattern")
479			withPattern = strToBool(arg.substring(opt.length + 1, arg.length));
480		else if (opt == "push")
481			withPush = strToBool(arg.substring(opt.length + 1, arg.length));
482		else if (opt == "valid")
483			withValid = strToBool(arg.substring(opt.length + 1, arg.length));
484		else if (opt == "sax1")
485			withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
486		else if (opt == "legacy")
487			withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
488		else if (opt == "output")
489			withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
490		else if (opt == "python")
491			withPython = strToBool(arg.substring(opt.length + 1, arg.length));
492		else if (opt == "compiler")
493			compiler = arg.substring(opt.length + 1, arg.length);
494		else if (opt == "cruntime")
495			cruntime = arg.substring(opt.length + 1, arg.length);
496		else if (opt == "dynruntime")
497			dynruntime = strToBool(arg.substring(opt.length + 1, arg.length));
498		else if (opt == "vcmanifest")
499			vcmanifest = strToBool(arg.substring(opt.length + 1, arg.length));
500		else if (opt == "debug")
501			buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
502		else if (opt == "static")
503			buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
504		else if (opt == "prefix")
505			buildPrefix = arg.substring(opt.length + 1, arg.length);
506		else if (opt == "bindir")
507			buildBinPrefix = arg.substring(opt.length + 1, arg.length);
508		else if (opt == "libdir")
509			buildLibPrefix = arg.substring(opt.length + 1, arg.length);
510		else if (opt == "sodir")
511			buildSoPrefix = arg.substring(opt.length + 1, arg.length);
512		else if (opt == "incdir")
513			buildIncPrefix = arg.substring(opt.length + 1, arg.length);
514		else if (opt == "include")
515			buildInclude = arg.substring(opt.length + 1, arg.length);
516		else if (opt == "lib")
517			buildLib = arg.substring(opt.length + 1, arg.length);
518		else if (opt == "release")
519			useCvsVer = false;
520		else
521			error = 1;
522	} else if (i == 0) {
523		if (arg == "genreadme") {
524			// This command comes from the Makefile and will not be checked
525			// for errors, because Makefile will always supply right the parameters.
526			genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
527			WScript.Quit(0);
528		} else if (arg == "help") {
529			usage();
530			WScript.Quit(0);
531		}
532
533	} else {
534		error = 1;
535	}
536}
537
538
539// If we fail here, it is because the user supplied an unrecognised argument.
540if (error != 0) {
541	usage();
542	WScript.Quit(error);
543}
544
545// if user choses to link the c-runtime library statically into libxml2
546// with /MT and friends, then we need to enable static linking for xmllint
547if (cruntime == "/MT" || cruntime == "/MTd" ||
548		cruntime == "/ML" || cruntime == "/MLd") {
549	buildStatic = 1;
550}
551
552dirSep = "\\";
553if (buildBinPrefix == "")
554	buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
555if (buildIncPrefix == "")
556	buildIncPrefix = "$(PREFIX)" + dirSep + "include";
557if (buildLibPrefix == "")
558	buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
559if (buildSoPrefix == "")
560	buildSoPrefix = "$(PREFIX)" + dirSep + "bin";
561
562// Discover the version.
563discoverVersion();
564if (error != 0) {
565	WScript.Echo("Version discovery failed, aborting.");
566	WScript.Quit(error);
567}
568
569var outVerString = baseName + " version: " + verMajor + "." + verMinor + "." + verMicro;
570if (verMicroSuffix && verMicroSuffix != "")
571	outVerString += "-" + verMicroSuffix;
572if (verCvs && verCvs != "")
573	outVerString += "-" + verCvs;
574WScript.Echo(outVerString);
575
576// Configure libxml.
577configureLibxml();
578if (error != 0) {
579	WScript.Echo("Configuration failed, aborting.");
580	WScript.Quit(error);
581}
582
583if (withPython == true) {
584	configureLibxmlPy();
585	if (error != 0) {
586		WScript.Echo("Configuration failed, aborting.");
587		WScript.Quit(error);
588	}
589
590}
591
592// Create the makefile.
593var fso = new ActiveXObject("Scripting.FileSystemObject");
594var makefile = ".\\Makefile.msvc";
595if (compiler == "mingw")
596	makefile = ".\\Makefile.mingw";
597else if (compiler == "bcb")
598	makefile = ".\\Makefile.bcb";
599var new_makefile = ".\\Makefile";
600var f = fso.FileExists(new_makefile);
601if (f) {
602       var t = fso.GetFile(new_makefile);
603       t.Attributes =0;
604}
605fso.CopyFile(makefile, new_makefile, true);
606WScript.Echo("Created Makefile.");
607// Create the config.h.
608var confighsrc = "win32config.h";
609var configh = "..\\config.h";
610var f = fso.FileExists(configh);
611if (f) {
612	var t = fso.GetFile(configh);
613	t.Attributes =0;
614}
615fso.CopyFile(confighsrc, configh, true);
616WScript.Echo("Created config.h.");
617
618
619// Display the final configuration.
620var txtOut = "\nXML processor configuration\n";
621txtOut += "---------------------------\n";
622txtOut += "     Thread safety: " + withThreads + "\n";
623txtOut += "       HTTP client: " + boolToStr(withHttp) + "\n";
624txtOut += "    HTML processor: " + boolToStr(withHtml) + "\n";
625txtOut += "      C14N support: " + boolToStr(withC14n) + "\n";
626txtOut += "   Catalog support: " + boolToStr(withCatalog) + "\n";
627txtOut += "     XPath support: " + boolToStr(withXpath) + "\n";
628txtOut += "  XPointer support: " + boolToStr(withXptr) + "\n";
629txtOut += "  XInclude support: " + boolToStr(withXinclude) + "\n";
630txtOut += "     iconv support: " + boolToStr(withIconv) + "\n";
631txtOut += "     icu   support: " + boolToStr(withIcu) + "\n";
632txtOut += "  iso8859x support: " + boolToStr(withIso8859x) + "\n";
633txtOut += "      zlib support: " + boolToStr(withZlib) + "\n";
634txtOut += "      lzma support: " + boolToStr(withLzma) + "\n";
635txtOut += "  Debugging module: " + boolToStr(withDebug) + "\n";
636txtOut += "    Regexp support: " + boolToStr(withRegExps) + "\n";
637txtOut += "    Module support: " + boolToStr(withModules) + "\n";
638txtOut += "      Tree support: " + boolToStr(withTree) + "\n";
639txtOut += "    Reader support: " + boolToStr(withReader) + "\n";
640txtOut += "    Writer support: " + boolToStr(withWriter) + "\n";
641txtOut += "    Walker support: " + boolToStr(withWalker) + "\n";
642txtOut += "   Pattern support: " + boolToStr(withPattern) + "\n";
643txtOut += "      Push support: " + boolToStr(withPush) + "\n";
644txtOut += "Validation support: " + boolToStr(withValid) + "\n";
645txtOut += "      SAX1 support: " + boolToStr(withSax1) + "\n";
646txtOut += "    Legacy support: " + boolToStr(withLegacy) + "\n";
647txtOut += "    Output support: " + boolToStr(withOutput) + "\n";
648txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
649txtOut += "Schematron support: " + boolToStr(withSchematron) + "\n";
650txtOut += "   Python bindings: " + boolToStr(withPython) + "\n";
651txtOut += "\n";
652txtOut += "Win32 build configuration\n";
653txtOut += "-------------------------\n";
654txtOut += "          Compiler: " + compiler + "\n";
655if (compiler == "msvc") {
656	txtOut += "  C-Runtime option: " + cruntime + "\n";
657	txtOut += "    Embed Manifest: " + boolToStr(vcmanifest) + "\n";
658} else if (compiler == "bcb")
659	txtOut += "   Use dynamic RTL: " + dynruntime + "\n";
660txtOut += "     Debug symbols: " + boolToStr(buildDebug) + "\n";
661txtOut += "    Static xmllint: " + boolToStr(buildStatic) + "\n";
662txtOut += "    Install prefix: " + buildPrefix + "\n";
663txtOut += "      Put tools in: " + buildBinPrefix + "\n";
664txtOut += "    Put headers in: " + buildIncPrefix + "\n";
665txtOut += "Put static libs in: " + buildLibPrefix + "\n";
666txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
667txtOut += "      Include path: " + buildInclude + "\n";
668txtOut += "          Lib path: " + buildLib + "\n";
669txtOut += "\n";
670txtOut += "DEPRECATION WARNING: The build system in the win32 directory is\n";
671txtOut += "deprecated and will be removed in a future release. Please switch\n";
672txtOut += "to CMake.\n";
673WScript.Echo(txtOut);
674
675//
676
677