blob: 6c2ec90869d0298ef37d9cafa702702893010b85 [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 = "..";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000013/* 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.in";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000018var versionFile = ".\\config.msvc";
Igor Zlatkovic853514f2002-11-22 21:41:09 +000019/* Input and output files regarding the libxml features. */
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000020var optsFileIn = srcDirXml + "\\include\\libxml\\xmlversion.h.in";
21var optsFile = srcDirXml + "\\include\\libxml\\xmlversion.h";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000022/* Version strings for the binary distribution. Will be filled later
23 in the code. */
24var verMajor;
25var verMinor;
26var verMicro;
Igor Zlatkovic6425b382003-10-25 15:38:34 +000027var verMicroSuffix;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000028/* Libxml features. */
29var withTrio = false;
Igor Zlatkovice38ab532003-05-17 11:30:54 +000030var withThreads = "native";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000031var withFtp = true;
32var withHttp = true;
33var withHtml = true;
34var withC14n = true;
35var withCatalog = true;
36var withDocb = true;
37var withXpath = true;
38var withXptr = true;
39var withXinclude = true;
40var withIconv = true;
William M. Brack6d13f332003-08-08 16:40:36 +000041var withIso8859x = false;
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;
Daniel Veillard141310a2003-10-06 08:47:56 +000047var withTree = true;
48var withReader = true;
Daniel Veillardea048932003-10-21 09:27:57 +000049var withWriter = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000050var 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 Zlatkovic4f928212003-11-27 18:39:01 +000060var cruntime = "/MD";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +000061var dynruntime = true;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000062var buildDebug = 0;
63var buildStatic = 0;
64var buildPrefix = ".";
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000065var buildBinPrefix = "";
66var buildIncPrefix = "";
67var buildLibPrefix = "";
68var buildSoPrefix = "";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000069var buildInclude = ".";
70var buildLib = ".";
71/* Local stuff */
72var error = 0;
73
74/* Helper function, transforms the option variable into the 'Enabled'
75 or 'Disabled' string. */
76function boolToStr(opt)
77{
78 if (opt == false)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000079 return "no";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000080 else if (opt == true)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000081 return "yes";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000082 error = 1;
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000083 return "*** undefined ***";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000084}
85
86/* Helper function, transforms the argument string into a boolean
87 value. */
88function strToBool(opt)
89{
90 if (opt == 0 || opt == "no")
91 return false;
92 else if (opt == 1 || opt == "yes")
93 return true;
94 error = 1;
95 return false;
96}
97
98/* Displays the details about how to use this script. */
99function usage()
100{
101 var txt;
102 txt = "Usage:\n";
103 txt += " cscript " + WScript.ScriptName + " <options>\n";
104 txt += " cscript " + WScript.ScriptName + " help\n\n";
105 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000106 txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000107 txt += "\nXML processor options, default value given in parentheses:\n\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000108 txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000109 txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000110 txt += " ftp: Enable FTP client (" + (withFtp? "yes" : "no") + ")\n";
111 txt += " http: Enable HTTP client (" + (withHttp? "yes" : "no") + ")\n";
112 txt += " html: Enable HTML processor (" + (withHtml? "yes" : "no") + ")\n";
113 txt += " c14n: Enable C14N support (" + (withC14n? "yes" : "no") + ")\n";
114 txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n";
115 txt += " docb: Enable DocBook support (" + (withDocb? "yes" : "no") + ")\n";
116 txt += " xpath: Enable XPath support (" + (withXpath? "yes" : "no") + ")\n";
117 txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n";
118 txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000119 txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000120 txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000121 txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000122 txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
123 txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000124 txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000125 txt += " tree: Enable tree api (" + (withTree? "yes" : "no") + ")\n";
126 txt += " reader: Enable xmlReader api (" + (withReader? "yes" : "no") + ")\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000127 txt += " writer: Enable xmlWriter api (" + (withWriter? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000128 txt += " walker: Enable xmlDocWalker api (" + (withWalker? "yes" : "no") + ")\n";
129 txt += " push: Enable push api (" + (withPush? "yes" : "no") + ")\n";
130 txt += " valid: Enable DTD validation support (" + (withValid? "yes" : "no") + ")\n";
131 txt += " sax1: Enable SAX1 api (" + (withSax1? "yes" : "no") + ")\n";
132 txt += " legacy: Enable Deprecated api's (" + (withLegacy? "yes" : "no") + ")\n";
133 txt += " output: Enable serialization support (" + (withOutput? "yes" : "no") + ")\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000134 txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000135 txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000136 txt += "\nWin32 build options, default value given in parentheses:\n\n";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000137 txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000138 txt += " cruntime: C-runtime compiler option (only msvc) (" + cruntime + ")\n";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000139 txt += " dynruntime: Use the dynamic RTL (only bcb) (" + dynruntime + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000140 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
141 txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
142 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
143 txt += " bindir: Directory where xmllint and friends should be installed\n";
144 txt += " (" + buildBinPrefix + ")\n";
145 txt += " incdir: Directory where headers should be installed\n";
146 txt += " (" + buildIncPrefix + ")\n";
147 txt += " libdir: Directory where static and import libraries should be\n";
148 txt += " installed (" + buildLibPrefix + ")\n";
149 txt += " sodir: Directory where shared libraries should be installed\n";
150 txt += " (" + buildSoPrefix + ")\n";
151 txt += " include: Additional search path for the compiler, particularily\n";
152 txt += " where iconv headers can be found (" + buildInclude + ")\n";
153 txt += " lib: Additional search path for the linker, particularily\n";
154 txt += " where iconv library can be found (" + buildLib + ")\n";
155 WScript.Echo(txt);
156}
157
158/* Discovers the version we are working with by reading the apropriate
159 configuration file. Despite its name, this also writes the configuration
160 file included by our makefile. */
161function discoverVersion()
162{
163 var fso, cf, vf, ln, s;
164 fso = new ActiveXObject("Scripting.FileSystemObject");
165 cf = fso.OpenTextFile(configFile, 1);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000166 if (compiler == "msvc")
167 versionFile = ".\\config.msvc";
168 else if (compiler == "mingw")
169 versionFile = ".\\config.mingw";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000170 else if (compiler == "bcb")
171 versionFile = ".\\config.bcb";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000172 vf = fso.CreateTextFile(versionFile, true);
173 vf.WriteLine("# " + versionFile);
174 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
175 vf.WriteBlankLines(1);
176 while (cf.AtEndOfStream != true) {
177 ln = cf.ReadLine();
178 s = new String(ln);
Daniel Veillard70b18562003-09-24 21:45:21 +0000179 if (s.search(/^LIBXML_MAJOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000180 vf.WriteLine(s);
181 verMajor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000182 } else if(s.search(/^LIBXML_MINOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000183 vf.WriteLine(s);
184 verMinor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000185 } else if(s.search(/^LIBXML_MICRO_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000186 vf.WriteLine(s);
187 verMicro = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000188 } else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
189 vf.WriteLine(s);
190 verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length)
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000191 }
192 }
193 cf.Close();
194 vf.WriteLine("XML_SRCDIR=" + srcDirXml);
195 vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000196 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000197 vf.WriteLine("WITH_THREADS=" + withThreads);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000198 vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
199 vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
200 vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
201 vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
202 vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
203 vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
204 vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
205 vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
206 vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
207 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000208 vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000209 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000210 vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
211 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000212 vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000213 vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000214 vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
215 vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000216 vf.WriteLine("WITH_WRITER=" + (withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000217 vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
218 vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
219 vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
220 vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
221 vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
222 vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000223 vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000224 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
225 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
226 vf.WriteLine("PREFIX=" + buildPrefix);
227 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
228 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
229 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
230 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000231 if (compiler == "msvc") {
232 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
233 vf.WriteLine("LIB=$(LIB);" + buildLib);
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000234 vf.WriteLine("CRUNTIME=" + cruntime);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000235 } else if (compiler == "mingw") {
236 vf.WriteLine("INCLUDE+=;" + buildInclude);
237 vf.WriteLine("LIB+=;" + buildLib);
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000238 } else if (compiler == "bcb") {
239 vf.WriteLine("INCLUDE=" + buildInclude);
240 vf.WriteLine("LIB=" + buildLib);
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000241 vf.WriteLine("DYNRUNTIME=" + (dynruntime? "1" : "0"));
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000242 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000243 vf.Close();
244}
245
246/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
247 taking what the user passed on the command line into account. */
248function configureLibxml()
249{
250 var fso, ofi, of, ln, s;
251 fso = new ActiveXObject("Scripting.FileSystemObject");
252 ofi = fso.OpenTextFile(optsFileIn, 1);
253 of = fso.CreateTextFile(optsFile, true);
254 while (ofi.AtEndOfStream != true) {
255 ln = ofi.ReadLine();
256 s = new String(ln);
257 if (s.search(/\@VERSION\@/) != -1) {
258 of.WriteLine(s.replace(/\@VERSION\@/,
Daniel Veillard70b18562003-09-24 21:45:21 +0000259 verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000260 } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
261 of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
262 verMajor*10000 + verMinor*100 + verMicro*1));
263 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
264 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
265 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000266 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000267 } else if (s.search(/\@WITH_FTP\@/) != -1) {
268 of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
269 } else if (s.search(/\@WITH_HTTP\@/) != -1) {
270 of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
271 } else if (s.search(/\@WITH_HTML\@/) != -1) {
272 of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
273 } else if (s.search(/\@WITH_C14N\@/) != -1) {
274 of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
275 } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
276 of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
277 } else if (s.search(/\@WITH_DOCB\@/) != -1) {
278 of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
279 } else if (s.search(/\@WITH_XPATH\@/) != -1) {
280 of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
281 } else if (s.search(/\@WITH_XPTR\@/) != -1) {
282 of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
283 } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
284 of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
285 } else if (s.search(/\@WITH_ICONV\@/) != -1) {
286 of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000287 } else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
288 of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000289 } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
290 of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000291 } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
292 of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
293 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
294 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000295 } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
296 of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000297 } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
298 of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000299 } else if (s.search(/\@WITH_TREE\@/) != -1) {
300 of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
301 } else if (s.search(/\@WITH_READER\@/) != -1) {
302 of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000303 } else if (s.search(/\@WITH_WRITER\@/) != -1) {
304 of.WriteLine(s.replace(/\@WITH_WRITER\@/, withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000305 } else if (s.search(/\@WITH_WALKER\@/) != -1) {
306 of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
307 } else if (s.search(/\@WITH_PUSH\@/) != -1) {
308 of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
309 } else if (s.search(/\@WITH_VALID\@/) != -1) {
310 of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
311 } else if (s.search(/\@WITH_SAX1\@/) != -1) {
312 of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
313 } else if (s.search(/\@WITH_LEGACY\@/) != -1) {
314 of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
315 } else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
316 of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000317 } else
318 of.WriteLine(ln);
319 }
320 ofi.Close();
321 of.Close();
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000322}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000323/* Configures Python bindings. Otherwise identical to the above */
324function configureLibxmlPy()
325{
326 var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
327 var pyOptsFile = srcDirXml + "\\python\\setup.py";
328 var fso, ofi, of, ln, s;
329 fso = new ActiveXObject("Scripting.FileSystemObject");
330 ofi = fso.OpenTextFile(pyOptsFileIn, 1);
331 of = fso.CreateTextFile(pyOptsFile, true);
332 while (ofi.AtEndOfStream != true) {
333 ln = ofi.ReadLine();
334 s = new String(ln);
335 if (s.search(/\@LIBXML_VERSION\@/) != -1) {
336 of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
337 verMajor + "." + verMinor + "." + verMicro));
338 } else if (s.search(/\@prefix\@/) != -1) {
339 of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
Daniel Veillard94bb2f12003-04-27 22:14:07 +0000340 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
341 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000342 } else
343 of.WriteLine(ln);
344 }
345 ofi.Close();
346 of.Close();
347}
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000348
349/* Creates the readme file for the binary distribution of 'bname', for the
350 version 'ver' in the file 'file'. This one is called from the Makefile when
351 generating a binary distribution. The parameters are passed by make. */
352function genReadme(bname, ver, file)
353{
354 var fso, f;
355 fso = new ActiveXObject("Scripting.FileSystemObject");
356 f = fso.CreateTextFile(file, true);
357 f.WriteLine(" " + bname + " " + ver);
358 f.WriteLine(" --------------");
359 f.WriteBlankLines(1);
360 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
361 f.WriteLine("platform.");
362 f.WriteBlankLines(1);
363 f.WriteLine(" The directory named 'include' contains the header files. Place its");
364 f.WriteLine("contents somewhere where it can be found by the compiler.");
365 f.WriteLine(" The directory which answers to the name 'lib' contains the static and");
366 f.WriteLine("dynamic libraries. Place them somewhere where they can be found by the");
367 f.WriteLine("linker. The files whose names end with '_a.lib' are aimed for static");
368 f.WriteLine("linking, the other files are lib/dll pairs.");
369 f.WriteLine(" The directory called 'util' contains various programs which count as a");
370 f.WriteLine("part of " + bname + ".");
371 f.WriteBlankLines(1);
Igor Zlatkovic0ceeb8e2002-09-10 19:07:02 +0000372 f.WriteLine(" If you plan to develop your own programme, in C, which uses " + bname + ", then");
373 f.WriteLine("you should know what to do with the files in the binary package. If you don't,");
374 f.WriteLine("know this, then please, please do some research on how to use a");
375 f.WriteLine("third-party library in a C programme. The topic belongs to the very basics");
376 f.WriteLine("and you will not be able to do much without that knowledge.");
377 f.WriteBlankLines(1);
378 f.WriteLine(" If you wish to use " + bname + " solely through the supplied utilities, such as");
379 f.WriteLine("xmllint or xsltproc, then all you need to do is place the");
380 f.WriteLine("contents of the 'lib' and 'util' directories from the binary package in a");
381 f.WriteLine("directory on your disc which is mentioned in your PATH environment");
382 f.WriteLine("variable. You can use an existing directory which is allready in the");
383 f.WriteLine("path, such as 'C:\WINDOWS', or 'C:\WINNT'. You can also create a new");
384 f.WriteLine("directory for " + bname + " and place the files there, but be sure to modify");
385 f.WriteLine("the PATH environment variable and add that new directory to its list.");
386 f.WriteBlankLines(1);
387 f.WriteLine(" If you use other software which needs " + bname + ", such as Apache");
388 f.WriteLine("Web Server in certain configurations, then please consult the");
389 f.WriteLine("documentation of that software and see if it mentions something about");
390 f.WriteLine("how it uses " + bname + " and how it expects it to be installed. If you find");
391 f.WriteLine("nothing, then the default installation, as described in the previous");
392 f.WriteLine("paragraph, should be suficient.");
393 f.WriteBlankLines(1);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000394 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
395 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
396 f.WriteLine("the address below.");
397 f.WriteBlankLines(1);
Daniel Veillardbeb70bd2002-12-18 14:53:54 +0000398 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000399 f.Close();
400}
401
William M. Brack6d13f332003-08-08 16:40:36 +0000402
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000403/*
404 * main(),
405 * Execution begins here.
406 */
407
408// Parse the command-line arguments.
409for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
410 var arg, opt;
411 arg = WScript.Arguments(i);
412 opt = arg.substring(0, arg.indexOf("="));
413 if (opt.length == 0)
414 opt = arg.substring(0, arg.indexOf(":"));
415 if (opt.length > 0) {
416 if (opt == "trio")
417 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
418 else if (opt == "threads")
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000419 withThreads = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000420 else if (opt == "ftp")
421 withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
422 else if (opt == "http")
423 withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
424 else if (opt == "html")
425 withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic9425ce22002-04-10 21:57:11 +0000426 else if (opt == "c14n")
427 withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000428 else if (opt == "catalog")
429 withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
430 else if (opt == "docb")
431 withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
432 else if (opt == "xpath")
433 withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
434 else if (opt == "xptr")
435 withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
436 else if (opt == "xinclude")
437 withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
438 else if (opt == "iconv")
439 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
William M. Brack6d13f332003-08-08 16:40:36 +0000440 else if (opt == "iso8859x")
441 withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000442 else if (opt == "zlib")
443 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000444 else if (opt == "xml_debug")
445 withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
446 else if (opt == "mem_debug")
447 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000448 else if (opt == "schemas")
449 withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000450 else if (opt == "regexps")
451 withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000452 else if (opt == "tree")
453 withTree = strToBool(arg.substring(opt.length + 1, arg.length));
454 else if (opt == "reader")
455 withReader = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillardea048932003-10-21 09:27:57 +0000456 else if (opt == "writer")
457 withWriter = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000458 else if (opt == "walker")
459 withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
460 else if (opt == "push")
461 withPush = strToBool(arg.substring(opt.length + 1, arg.length));
462 else if (opt == "valid")
463 withValid = strToBool(arg.substring(opt.length + 1, arg.length));
464 else if (opt == "sax1")
465 withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
466 else if (opt == "legacy")
467 withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
468 else if (opt == "output")
469 withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000470 else if (opt == "python")
471 withPython = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000472 else if (opt == "compiler")
473 compiler = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000474 else if (opt == "cruntime")
475 cruntime = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000476 else if (opt == "dynruntime")
477 dynruntime = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000478 else if (opt == "debug")
479 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
480 else if (opt == "static")
481 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
482 else if (opt == "prefix")
483 buildPrefix = arg.substring(opt.length + 1, arg.length);
484 else if (opt == "incdir")
485 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
486 else if (opt == "bindir")
487 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
488 else if (opt == "libdir")
489 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
490 else if (opt == "sodir")
491 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
492 else if (opt == "incdir")
493 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
494 else if (opt == "include")
495 buildInclude = arg.substring(opt.length + 1, arg.length);
496 else if (opt == "lib")
497 buildLib = arg.substring(opt.length + 1, arg.length);
498 else
499 error = 1;
500 } else if (i == 0) {
501 if (arg == "genreadme") {
502 // This command comes from the Makefile and will not be checked
503 // for errors, because Makefile will always supply right the parameters.
504 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
505 WScript.Quit(0);
506 } else if (arg == "help") {
507 usage();
508 WScript.Quit(0);
509 }
William M. Brack6d13f332003-08-08 16:40:36 +0000510
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000511 } else {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000512 error = 1;
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000513 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000514}
515
William M. Brack6d13f332003-08-08 16:40:36 +0000516
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000517// If we fail here, it is because the user supplied an unrecognised argument.
518if (error != 0) {
519 usage();
520 WScript.Quit(error);
521}
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000522dirSep = "\\";
523if (compiler == "mingw")
524 dirSep = "/";
525if (buildBinPrefix == "")
526 buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
527if (buildIncPrefix == "")
528 buildIncPrefix = "$(PREFIX)" + dirSep + "include";
529if (buildLibPrefix == "")
530 buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
531if (buildSoPrefix == "")
532 buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
William M. Brack6d13f332003-08-08 16:40:36 +0000533
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000534// Discover the version.
535discoverVersion();
536if (error != 0) {
537 WScript.Echo("Version discovery failed, aborting.");
538 WScript.Quit(error);
539}
William M. Brack6d13f332003-08-08 16:40:36 +0000540
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000541WScript.Echo(baseName + " version: " + verMajor + "." + verMinor + "." + verMicro);
542
543// Configure libxml.
544configureLibxml();
545if (error != 0) {
546 WScript.Echo("Configuration failed, aborting.");
547 WScript.Quit(error);
548}
William M. Brack6d13f332003-08-08 16:40:36 +0000549
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000550if (withPython == true) {
551 configureLibxmlPy();
552 if (error != 0) {
553 WScript.Echo("Configuration failed, aborting.");
554 WScript.Quit(error);
555 }
William M. Brack6d13f332003-08-08 16:40:36 +0000556
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000557}
558
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000559// Create the makefile.
560var fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000561var makefile = ".\\Makefile.msvc";
562if (compiler == "mingw")
563 makefile = ".\\Makefile.mingw";
Igor Zlatkovice8b5b0f2003-06-16 07:12:50 +0000564else if (compiler == "bcb")
565 makefile = ".\\Makefile.bcb";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000566fso.CopyFile(makefile, ".\\Makefile", true);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000567WScript.Echo("Created Makefile.");
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000568// Create the config.h.
569var confighsrc = "..\\include\\win32config.h";
570var configh = "..\\config.h";
Daniel Veillard6b9d6952003-11-05 09:50:55 +0000571var f = fso.FileExists(configh);
572if (f) {
573 var t = fso.GetFile(configh);
574 t.Attributes =0;
575}
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000576fso.CopyFile(confighsrc, configh, true);
577WScript.Echo("Created config.h.");
578
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000579
580// Display the final configuration.
581var txtOut = "\nXML processor configuration\n";
582txtOut += "---------------------------\n";
583txtOut += " Trio: " + boolToStr(withTrio) + "\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000584txtOut += " Thread safety: " + withThreads + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000585txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
586txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
587txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
588txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
589txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
590txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
591txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
592txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
593txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000594txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000595txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000596txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000597txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
598txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000599txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000600txtOut += " Tree support: " + boolToStr(withTree) + "\n";
601txtOut += " Reader support: " + boolToStr(withReader) + "\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000602txtOut += " Writer support: " + boolToStr(withWriter) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000603txtOut += " Walker support: " + boolToStr(withWalker) + "\n";
604txtOut += " Push support: " + boolToStr(withPush) + "\n";
605txtOut += "Validation support: " + boolToStr(withValid) + "\n";
606txtOut += " SAX1 support: " + boolToStr(withSax1) + "\n";
607txtOut += " Legacy support: " + boolToStr(withLegacy) + "\n";
608txtOut += " Output support: " + boolToStr(withOutput) + "\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000609txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000610txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000611txtOut += "\n";
612txtOut += "Win32 build configuration\n";
613txtOut += "-------------------------\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000614txtOut += " Compiler: " + compiler + "\n";
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000615if (compiler == "msvc")
616 txtOut += " C-Runtime option: " + cruntime + "\n";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000617else if (compiler == "bcb")
618 txtOut += " Use dynamic RTL: " + dynruntime + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000619txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
620txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
621txtOut += " Install prefix: " + buildPrefix + "\n";
622txtOut += " Put tools in: " + buildBinPrefix + "\n";
623txtOut += " Put headers in: " + buildIncPrefix + "\n";
624txtOut += "Put static libs in: " + buildLibPrefix + "\n";
625txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
626txtOut += " Include path: " + buildInclude + "\n";
627txtOut += " Lib path: " + buildLib + "\n";
628WScript.Echo(txtOut);
629
William M. Brack6d13f332003-08-08 16:40:36 +0000630//
631