blob: 461287908006cca7a24ad7808515175a4682aacd [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;
Igor Zlatkovic6425b382003-10-25 15:38:34 +000029var verMicroSuffix;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000030/* Libxml features. */
31var withTrio = false;
Igor Zlatkovice38ab532003-05-17 11:30:54 +000032var withThreads = "native";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000033var withFtp = true;
34var withHttp = true;
35var withHtml = true;
36var withC14n = true;
37var withCatalog = true;
38var withDocb = true;
39var withXpath = true;
40var withXptr = true;
41var withXinclude = true;
42var withIconv = true;
William M. Brack6d13f332003-08-08 16:40:36 +000043var withIso8859x = false;
Igor Zlatkovic3acadf42002-09-20 16:40:17 +000044var withZlib = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000045var withDebug = true;
46var withMemDebug = false;
Igor Zlatkovica6f2d902002-04-16 17:57:17 +000047var withSchemas = true;
Igor Zlatkovic8e040972002-09-20 13:39:53 +000048var withRegExps = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000049var withTree = true;
50var withReader = true;
Daniel Veillardea048932003-10-21 09:27:57 +000051var withWriter = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000052var withWalker = true;
53var withPush = true;
54var withValid = true;
55var withSax1 = true;
56var withLegacy = true;
57var withOutput = true;
Igor Zlatkovic853514f2002-11-22 21:41:09 +000058var withPython = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000059/* Win32 build options. */
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000060var dirSep = "\\";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000061var compiler = "msvc";
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 Zlatkovicac97f6e2002-03-24 21:00:26 +0000138 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
139 txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
140 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
141 txt += " bindir: Directory where xmllint and friends should be installed\n";
142 txt += " (" + buildBinPrefix + ")\n";
143 txt += " incdir: Directory where headers should be installed\n";
144 txt += " (" + buildIncPrefix + ")\n";
145 txt += " libdir: Directory where static and import libraries should be\n";
146 txt += " installed (" + buildLibPrefix + ")\n";
147 txt += " sodir: Directory where shared libraries should be installed\n";
148 txt += " (" + buildSoPrefix + ")\n";
149 txt += " include: Additional search path for the compiler, particularily\n";
150 txt += " where iconv headers can be found (" + buildInclude + ")\n";
151 txt += " lib: Additional search path for the linker, particularily\n";
152 txt += " where iconv library can be found (" + buildLib + ")\n";
153 WScript.Echo(txt);
154}
155
156/* Discovers the version we are working with by reading the apropriate
157 configuration file. Despite its name, this also writes the configuration
158 file included by our makefile. */
159function discoverVersion()
160{
161 var fso, cf, vf, ln, s;
162 fso = new ActiveXObject("Scripting.FileSystemObject");
163 cf = fso.OpenTextFile(configFile, 1);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000164 if (compiler == "msvc")
165 versionFile = ".\\config.msvc";
166 else if (compiler == "mingw")
167 versionFile = ".\\config.mingw";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000168 else if (compiler == "bcb")
169 versionFile = ".\\config.bcb";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000170 vf = fso.CreateTextFile(versionFile, true);
171 vf.WriteLine("# " + versionFile);
172 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
173 vf.WriteBlankLines(1);
174 while (cf.AtEndOfStream != true) {
175 ln = cf.ReadLine();
176 s = new String(ln);
Daniel Veillard70b18562003-09-24 21:45:21 +0000177 if (s.search(/^LIBXML_MAJOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000178 vf.WriteLine(s);
179 verMajor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000180 } else if(s.search(/^LIBXML_MINOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000181 vf.WriteLine(s);
182 verMinor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000183 } else if(s.search(/^LIBXML_MICRO_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000184 vf.WriteLine(s);
185 verMicro = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000186 } else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
187 vf.WriteLine(s);
188 verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length)
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000189 }
190 }
191 cf.Close();
192 vf.WriteLine("XML_SRCDIR=" + srcDirXml);
193 vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
194 vf.WriteLine("BINDIR=" + binDir);
195 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000196 vf.WriteLine("WITH_THREADS=" + withThreads);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000197 vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
198 vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
199 vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
200 vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
201 vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
202 vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
203 vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
204 vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
205 vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
206 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000207 vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000208 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000209 vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
210 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000211 vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000212 vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000213 vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
214 vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000215 vf.WriteLine("WITH_WRITER=" + (withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000216 vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
217 vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
218 vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
219 vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
220 vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
221 vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000222 vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000223 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
224 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
225 vf.WriteLine("PREFIX=" + buildPrefix);
226 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
227 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
228 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
229 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000230 if (compiler == "msvc") {
231 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
232 vf.WriteLine("LIB=$(LIB);" + buildLib);
233 } else if (compiler == "mingw") {
234 vf.WriteLine("INCLUDE+=;" + buildInclude);
235 vf.WriteLine("LIB+=;" + buildLib);
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000236 } else if (compiler == "bcb") {
237 vf.WriteLine("INCLUDE=" + buildInclude);
238 vf.WriteLine("LIB=" + buildLib);
239 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000240 vf.Close();
241}
242
243/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
244 taking what the user passed on the command line into account. */
245function configureLibxml()
246{
247 var fso, ofi, of, ln, s;
248 fso = new ActiveXObject("Scripting.FileSystemObject");
249 ofi = fso.OpenTextFile(optsFileIn, 1);
250 of = fso.CreateTextFile(optsFile, true);
251 while (ofi.AtEndOfStream != true) {
252 ln = ofi.ReadLine();
253 s = new String(ln);
254 if (s.search(/\@VERSION\@/) != -1) {
255 of.WriteLine(s.replace(/\@VERSION\@/,
Daniel Veillard70b18562003-09-24 21:45:21 +0000256 verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000257 } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
258 of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
259 verMajor*10000 + verMinor*100 + verMicro*1));
260 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
261 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
262 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000263 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000264 } else if (s.search(/\@WITH_FTP\@/) != -1) {
265 of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
266 } else if (s.search(/\@WITH_HTTP\@/) != -1) {
267 of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
268 } else if (s.search(/\@WITH_HTML\@/) != -1) {
269 of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
270 } else if (s.search(/\@WITH_C14N\@/) != -1) {
271 of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
272 } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
273 of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
274 } else if (s.search(/\@WITH_DOCB\@/) != -1) {
275 of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
276 } else if (s.search(/\@WITH_XPATH\@/) != -1) {
277 of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
278 } else if (s.search(/\@WITH_XPTR\@/) != -1) {
279 of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
280 } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
281 of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
282 } else if (s.search(/\@WITH_ICONV\@/) != -1) {
283 of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000284 } else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
285 of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000286 } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
287 of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000288 } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
289 of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
290 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
291 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000292 } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
293 of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000294 } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
295 of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000296 } else if (s.search(/\@WITH_TREE\@/) != -1) {
297 of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
298 } else if (s.search(/\@WITH_READER\@/) != -1) {
299 of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000300 } else if (s.search(/\@WITH_WRITER\@/) != -1) {
301 of.WriteLine(s.replace(/\@WITH_WRITER\@/, withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000302 } else if (s.search(/\@WITH_WALKER\@/) != -1) {
303 of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
304 } else if (s.search(/\@WITH_PUSH\@/) != -1) {
305 of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
306 } else if (s.search(/\@WITH_VALID\@/) != -1) {
307 of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
308 } else if (s.search(/\@WITH_SAX1\@/) != -1) {
309 of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
310 } else if (s.search(/\@WITH_LEGACY\@/) != -1) {
311 of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
312 } else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
313 of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000314 } else
315 of.WriteLine(ln);
316 }
317 ofi.Close();
318 of.Close();
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000319}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000320/* Configures Python bindings. Otherwise identical to the above */
321function configureLibxmlPy()
322{
323 var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
324 var pyOptsFile = srcDirXml + "\\python\\setup.py";
325 var fso, ofi, of, ln, s;
326 fso = new ActiveXObject("Scripting.FileSystemObject");
327 ofi = fso.OpenTextFile(pyOptsFileIn, 1);
328 of = fso.CreateTextFile(pyOptsFile, true);
329 while (ofi.AtEndOfStream != true) {
330 ln = ofi.ReadLine();
331 s = new String(ln);
332 if (s.search(/\@LIBXML_VERSION\@/) != -1) {
333 of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
334 verMajor + "." + verMinor + "." + verMicro));
335 } else if (s.search(/\@prefix\@/) != -1) {
336 of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
Daniel Veillard94bb2f12003-04-27 22:14:07 +0000337 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
338 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000339 } else
340 of.WriteLine(ln);
341 }
342 ofi.Close();
343 of.Close();
344}
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000345
346/* Creates the readme file for the binary distribution of 'bname', for the
347 version 'ver' in the file 'file'. This one is called from the Makefile when
348 generating a binary distribution. The parameters are passed by make. */
349function genReadme(bname, ver, file)
350{
351 var fso, f;
352 fso = new ActiveXObject("Scripting.FileSystemObject");
353 f = fso.CreateTextFile(file, true);
354 f.WriteLine(" " + bname + " " + ver);
355 f.WriteLine(" --------------");
356 f.WriteBlankLines(1);
357 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
358 f.WriteLine("platform.");
359 f.WriteBlankLines(1);
360 f.WriteLine(" The directory named 'include' contains the header files. Place its");
361 f.WriteLine("contents somewhere where it can be found by the compiler.");
362 f.WriteLine(" The directory which answers to the name 'lib' contains the static and");
363 f.WriteLine("dynamic libraries. Place them somewhere where they can be found by the");
364 f.WriteLine("linker. The files whose names end with '_a.lib' are aimed for static");
365 f.WriteLine("linking, the other files are lib/dll pairs.");
366 f.WriteLine(" The directory called 'util' contains various programs which count as a");
367 f.WriteLine("part of " + bname + ".");
368 f.WriteBlankLines(1);
Igor Zlatkovic0ceeb8e2002-09-10 19:07:02 +0000369 f.WriteLine(" If you plan to develop your own programme, in C, which uses " + bname + ", then");
370 f.WriteLine("you should know what to do with the files in the binary package. If you don't,");
371 f.WriteLine("know this, then please, please do some research on how to use a");
372 f.WriteLine("third-party library in a C programme. The topic belongs to the very basics");
373 f.WriteLine("and you will not be able to do much without that knowledge.");
374 f.WriteBlankLines(1);
375 f.WriteLine(" If you wish to use " + bname + " solely through the supplied utilities, such as");
376 f.WriteLine("xmllint or xsltproc, then all you need to do is place the");
377 f.WriteLine("contents of the 'lib' and 'util' directories from the binary package in a");
378 f.WriteLine("directory on your disc which is mentioned in your PATH environment");
379 f.WriteLine("variable. You can use an existing directory which is allready in the");
380 f.WriteLine("path, such as 'C:\WINDOWS', or 'C:\WINNT'. You can also create a new");
381 f.WriteLine("directory for " + bname + " and place the files there, but be sure to modify");
382 f.WriteLine("the PATH environment variable and add that new directory to its list.");
383 f.WriteBlankLines(1);
384 f.WriteLine(" If you use other software which needs " + bname + ", such as Apache");
385 f.WriteLine("Web Server in certain configurations, then please consult the");
386 f.WriteLine("documentation of that software and see if it mentions something about");
387 f.WriteLine("how it uses " + bname + " and how it expects it to be installed. If you find");
388 f.WriteLine("nothing, then the default installation, as described in the previous");
389 f.WriteLine("paragraph, should be suficient.");
390 f.WriteBlankLines(1);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000391 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
392 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
393 f.WriteLine("the address below.");
394 f.WriteBlankLines(1);
Daniel Veillardbeb70bd2002-12-18 14:53:54 +0000395 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000396 f.Close();
397}
398
William M. Brack6d13f332003-08-08 16:40:36 +0000399
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000400/*
401 * main(),
402 * Execution begins here.
403 */
404
405// Parse the command-line arguments.
406for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
407 var arg, opt;
408 arg = WScript.Arguments(i);
409 opt = arg.substring(0, arg.indexOf("="));
410 if (opt.length == 0)
411 opt = arg.substring(0, arg.indexOf(":"));
412 if (opt.length > 0) {
413 if (opt == "trio")
414 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
415 else if (opt == "threads")
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000416 withThreads = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000417 else if (opt == "ftp")
418 withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
419 else if (opt == "http")
420 withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
421 else if (opt == "html")
422 withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic9425ce22002-04-10 21:57:11 +0000423 else if (opt == "c14n")
424 withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000425 else if (opt == "catalog")
426 withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
427 else if (opt == "docb")
428 withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
429 else if (opt == "xpath")
430 withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
431 else if (opt == "xptr")
432 withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
433 else if (opt == "xinclude")
434 withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
435 else if (opt == "iconv")
436 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
William M. Brack6d13f332003-08-08 16:40:36 +0000437 else if (opt == "iso8859x")
438 withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000439 else if (opt == "zlib")
440 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000441 else if (opt == "xml_debug")
442 withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
443 else if (opt == "mem_debug")
444 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000445 else if (opt == "schemas")
446 withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000447 else if (opt == "regexps")
448 withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000449 else if (opt == "tree")
450 withTree = strToBool(arg.substring(opt.length + 1, arg.length));
451 else if (opt == "reader")
452 withReader = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillardea048932003-10-21 09:27:57 +0000453 else if (opt == "writer")
454 withWriter = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000455 else if (opt == "walker")
456 withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
457 else if (opt == "push")
458 withPush = strToBool(arg.substring(opt.length + 1, arg.length));
459 else if (opt == "valid")
460 withValid = strToBool(arg.substring(opt.length + 1, arg.length));
461 else if (opt == "sax1")
462 withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
463 else if (opt == "legacy")
464 withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
465 else if (opt == "output")
466 withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000467 else if (opt == "python")
468 withPython = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000469 else if (opt == "compiler")
470 compiler = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000471 else if (opt == "debug")
472 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
473 else if (opt == "static")
474 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
475 else if (opt == "prefix")
476 buildPrefix = arg.substring(opt.length + 1, arg.length);
477 else if (opt == "incdir")
478 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
479 else if (opt == "bindir")
480 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
481 else if (opt == "libdir")
482 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
483 else if (opt == "sodir")
484 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
485 else if (opt == "incdir")
486 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
487 else if (opt == "include")
488 buildInclude = arg.substring(opt.length + 1, arg.length);
489 else if (opt == "lib")
490 buildLib = arg.substring(opt.length + 1, arg.length);
491 else
492 error = 1;
493 } else if (i == 0) {
494 if (arg == "genreadme") {
495 // This command comes from the Makefile and will not be checked
496 // for errors, because Makefile will always supply right the parameters.
497 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
498 WScript.Quit(0);
499 } else if (arg == "help") {
500 usage();
501 WScript.Quit(0);
502 }
William M. Brack6d13f332003-08-08 16:40:36 +0000503
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000504 } else {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000505 error = 1;
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000506 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000507}
508
William M. Brack6d13f332003-08-08 16:40:36 +0000509
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000510// If we fail here, it is because the user supplied an unrecognised argument.
511if (error != 0) {
512 usage();
513 WScript.Quit(error);
514}
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000515dirSep = "\\";
516if (compiler == "mingw")
517 dirSep = "/";
518if (buildBinPrefix == "")
519 buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
520if (buildIncPrefix == "")
521 buildIncPrefix = "$(PREFIX)" + dirSep + "include";
522if (buildLibPrefix == "")
523 buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
524if (buildSoPrefix == "")
525 buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
William M. Brack6d13f332003-08-08 16:40:36 +0000526
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000527// Discover the version.
528discoverVersion();
529if (error != 0) {
530 WScript.Echo("Version discovery failed, aborting.");
531 WScript.Quit(error);
532}
William M. Brack6d13f332003-08-08 16:40:36 +0000533
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000534WScript.Echo(baseName + " version: " + verMajor + "." + verMinor + "." + verMicro);
535
536// Configure libxml.
537configureLibxml();
538if (error != 0) {
539 WScript.Echo("Configuration failed, aborting.");
540 WScript.Quit(error);
541}
William M. Brack6d13f332003-08-08 16:40:36 +0000542
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000543if (withPython == true) {
544 configureLibxmlPy();
545 if (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 +0000550}
551
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000552// Create the makefile.
553var fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000554var makefile = ".\\Makefile.msvc";
555if (compiler == "mingw")
556 makefile = ".\\Makefile.mingw";
Igor Zlatkovice8b5b0f2003-06-16 07:12:50 +0000557else if (compiler == "bcb")
558 makefile = ".\\Makefile.bcb";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000559fso.CopyFile(makefile, ".\\Makefile", true);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000560WScript.Echo("Created Makefile.");
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000561// Create the config.h.
562var confighsrc = "..\\include\\win32config.h";
563var configh = "..\\config.h";
Daniel Veillard6b9d6952003-11-05 09:50:55 +0000564var f = fso.FileExists(configh);
565if (f) {
566 var t = fso.GetFile(configh);
567 t.Attributes =0;
568}
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000569fso.CopyFile(confighsrc, configh, true);
570WScript.Echo("Created config.h.");
571
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000572
573// Display the final configuration.
574var txtOut = "\nXML processor configuration\n";
575txtOut += "---------------------------\n";
576txtOut += " Trio: " + boolToStr(withTrio) + "\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000577txtOut += " Thread safety: " + withThreads + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000578txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
579txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
580txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
581txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
582txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
583txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
584txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
585txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
586txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000587txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000588txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000589txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000590txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
591txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000592txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000593txtOut += " Tree support: " + boolToStr(withTree) + "\n";
594txtOut += " Reader support: " + boolToStr(withReader) + "\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000595txtOut += " Writer support: " + boolToStr(withWriter) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000596txtOut += " Walker support: " + boolToStr(withWalker) + "\n";
597txtOut += " Push support: " + boolToStr(withPush) + "\n";
598txtOut += "Validation support: " + boolToStr(withValid) + "\n";
599txtOut += " SAX1 support: " + boolToStr(withSax1) + "\n";
600txtOut += " Legacy support: " + boolToStr(withLegacy) + "\n";
601txtOut += " Output support: " + boolToStr(withOutput) + "\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000602txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000603txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000604txtOut += "\n";
605txtOut += "Win32 build configuration\n";
606txtOut += "-------------------------\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000607txtOut += " Compiler: " + compiler + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000608txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
609txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
610txtOut += " Install prefix: " + buildPrefix + "\n";
611txtOut += " Put tools in: " + buildBinPrefix + "\n";
612txtOut += " Put headers in: " + buildIncPrefix + "\n";
613txtOut += "Put static libs in: " + buildLibPrefix + "\n";
614txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
615txtOut += " Include path: " + buildInclude + "\n";
616txtOut += " Lib path: " + buildLib + "\n";
617WScript.Echo(txtOut);
618
William M. Brack6d13f332003-08-08 16:40:36 +0000619//
620