blob: df3836d4502657b98b1796f19d1371e2b0945158 [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;
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +000051var withPattern = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000052var withPush = true;
53var withValid = true;
54var withSax1 = true;
55var withLegacy = true;
56var withOutput = true;
Igor Zlatkovic853514f2002-11-22 21:41:09 +000057var withPython = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000058/* Win32 build options. */
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000059var dirSep = "\\";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000060var compiler = "msvc";
Igor Zlatkovic4f928212003-11-27 18:39:01 +000061var cruntime = "/MD";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +000062var dynruntime = true;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000063var buildDebug = 0;
64var buildStatic = 0;
65var buildPrefix = ".";
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000066var buildBinPrefix = "";
67var buildIncPrefix = "";
68var buildLibPrefix = "";
69var buildSoPrefix = "";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000070var buildInclude = ".";
71var buildLib = ".";
72/* Local stuff */
73var error = 0;
74
75/* Helper function, transforms the option variable into the 'Enabled'
76 or 'Disabled' string. */
77function boolToStr(opt)
78{
79 if (opt == false)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000080 return "no";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000081 else if (opt == true)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000082 return "yes";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000083 error = 1;
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000084 return "*** undefined ***";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000085}
86
87/* Helper function, transforms the argument string into a boolean
88 value. */
89function strToBool(opt)
90{
91 if (opt == 0 || opt == "no")
92 return false;
93 else if (opt == 1 || opt == "yes")
94 return true;
95 error = 1;
96 return false;
97}
98
99/* Displays the details about how to use this script. */
100function usage()
101{
102 var txt;
103 txt = "Usage:\n";
104 txt += " cscript " + WScript.ScriptName + " <options>\n";
105 txt += " cscript " + WScript.ScriptName + " help\n\n";
106 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000107 txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000108 txt += "\nXML processor options, default value given in parentheses:\n\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000109 txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000110 txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000111 txt += " ftp: Enable FTP client (" + (withFtp? "yes" : "no") + ")\n";
112 txt += " http: Enable HTTP client (" + (withHttp? "yes" : "no") + ")\n";
113 txt += " html: Enable HTML processor (" + (withHtml? "yes" : "no") + ")\n";
114 txt += " c14n: Enable C14N support (" + (withC14n? "yes" : "no") + ")\n";
115 txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n";
116 txt += " docb: Enable DocBook support (" + (withDocb? "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";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000120 txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000121 txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000122 txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000123 txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
124 txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000125 txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000126 txt += " tree: Enable tree api (" + (withTree? "yes" : "no") + ")\n";
127 txt += " reader: Enable xmlReader api (" + (withReader? "yes" : "no") + ")\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000128 txt += " writer: Enable xmlWriter api (" + (withWriter? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000129 txt += " walker: Enable xmlDocWalker api (" + (withWalker? "yes" : "no") + ")\n";
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000130 txt += " pattern: Enable xmlPattern api (" + (withPattern? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000131 txt += " push: Enable push api (" + (withPush? "yes" : "no") + ")\n";
132 txt += " valid: Enable DTD validation support (" + (withValid? "yes" : "no") + ")\n";
133 txt += " sax1: Enable SAX1 api (" + (withSax1? "yes" : "no") + ")\n";
134 txt += " legacy: Enable Deprecated api's (" + (withLegacy? "yes" : "no") + ")\n";
135 txt += " output: Enable serialization support (" + (withOutput? "yes" : "no") + ")\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000136 txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000137 txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000138 txt += "\nWin32 build options, default value given in parentheses:\n\n";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000139 txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000140 txt += " cruntime: C-runtime compiler option (only msvc) (" + cruntime + ")\n";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000141 txt += " dynruntime: Use the dynamic RTL (only bcb) (" + dynruntime + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000142 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
143 txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
144 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
145 txt += " bindir: Directory where xmllint and friends should be installed\n";
146 txt += " (" + buildBinPrefix + ")\n";
147 txt += " incdir: Directory where headers should be installed\n";
148 txt += " (" + buildIncPrefix + ")\n";
149 txt += " libdir: Directory where static and import libraries should be\n";
150 txt += " installed (" + buildLibPrefix + ")\n";
151 txt += " sodir: Directory where shared libraries should be installed\n";
152 txt += " (" + buildSoPrefix + ")\n";
153 txt += " include: Additional search path for the compiler, particularily\n";
154 txt += " where iconv headers can be found (" + buildInclude + ")\n";
155 txt += " lib: Additional search path for the linker, particularily\n";
156 txt += " where iconv library can be found (" + buildLib + ")\n";
157 WScript.Echo(txt);
158}
159
160/* Discovers the version we are working with by reading the apropriate
161 configuration file. Despite its name, this also writes the configuration
162 file included by our makefile. */
163function discoverVersion()
164{
165 var fso, cf, vf, ln, s;
166 fso = new ActiveXObject("Scripting.FileSystemObject");
167 cf = fso.OpenTextFile(configFile, 1);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000168 if (compiler == "msvc")
169 versionFile = ".\\config.msvc";
170 else if (compiler == "mingw")
171 versionFile = ".\\config.mingw";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000172 else if (compiler == "bcb")
173 versionFile = ".\\config.bcb";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000174 vf = fso.CreateTextFile(versionFile, true);
175 vf.WriteLine("# " + versionFile);
176 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
177 vf.WriteBlankLines(1);
178 while (cf.AtEndOfStream != true) {
179 ln = cf.ReadLine();
180 s = new String(ln);
Daniel Veillard70b18562003-09-24 21:45:21 +0000181 if (s.search(/^LIBXML_MAJOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000182 vf.WriteLine(s);
183 verMajor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000184 } else if(s.search(/^LIBXML_MINOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000185 vf.WriteLine(s);
186 verMinor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000187 } else if(s.search(/^LIBXML_MICRO_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000188 vf.WriteLine(s);
189 verMicro = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000190 } else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
191 vf.WriteLine(s);
192 verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length)
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000193 }
194 }
195 cf.Close();
196 vf.WriteLine("XML_SRCDIR=" + srcDirXml);
197 vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000198 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000199 vf.WriteLine("WITH_THREADS=" + withThreads);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000200 vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
201 vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
202 vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
203 vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
204 vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
205 vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
206 vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
207 vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
208 vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
209 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000210 vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000211 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000212 vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
213 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000214 vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000215 vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000216 vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
217 vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000218 vf.WriteLine("WITH_WRITER=" + (withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000219 vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000220 vf.WriteLine("WITH_PATTERN=" + (withPattern? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000221 vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
222 vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
223 vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
224 vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
225 vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000226 vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000227 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
228 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
229 vf.WriteLine("PREFIX=" + buildPrefix);
230 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
231 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
232 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
233 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000234 if (compiler == "msvc") {
235 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
236 vf.WriteLine("LIB=$(LIB);" + buildLib);
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000237 vf.WriteLine("CRUNTIME=" + cruntime);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000238 } else if (compiler == "mingw") {
239 vf.WriteLine("INCLUDE+=;" + buildInclude);
240 vf.WriteLine("LIB+=;" + buildLib);
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000241 } else if (compiler == "bcb") {
242 vf.WriteLine("INCLUDE=" + buildInclude);
243 vf.WriteLine("LIB=" + buildLib);
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000244 vf.WriteLine("DYNRUNTIME=" + (dynruntime? "1" : "0"));
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000245 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000246 vf.Close();
247}
248
249/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
250 taking what the user passed on the command line into account. */
251function configureLibxml()
252{
253 var fso, ofi, of, ln, s;
254 fso = new ActiveXObject("Scripting.FileSystemObject");
255 ofi = fso.OpenTextFile(optsFileIn, 1);
256 of = fso.CreateTextFile(optsFile, true);
257 while (ofi.AtEndOfStream != true) {
258 ln = ofi.ReadLine();
259 s = new String(ln);
260 if (s.search(/\@VERSION\@/) != -1) {
261 of.WriteLine(s.replace(/\@VERSION\@/,
Daniel Veillard70b18562003-09-24 21:45:21 +0000262 verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000263 } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
264 of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
265 verMajor*10000 + verMinor*100 + verMicro*1));
266 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
267 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
268 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000269 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000270 } else if (s.search(/\@WITH_FTP\@/) != -1) {
271 of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
272 } else if (s.search(/\@WITH_HTTP\@/) != -1) {
273 of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
274 } else if (s.search(/\@WITH_HTML\@/) != -1) {
275 of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
276 } else if (s.search(/\@WITH_C14N\@/) != -1) {
277 of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
278 } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
279 of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
280 } else if (s.search(/\@WITH_DOCB\@/) != -1) {
281 of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
282 } else if (s.search(/\@WITH_XPATH\@/) != -1) {
283 of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
284 } else if (s.search(/\@WITH_XPTR\@/) != -1) {
285 of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
286 } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
287 of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
288 } else if (s.search(/\@WITH_ICONV\@/) != -1) {
289 of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000290 } else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
291 of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000292 } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
293 of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000294 } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
295 of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
296 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
297 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000298 } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
299 of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000300 } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
301 of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000302 } else if (s.search(/\@WITH_TREE\@/) != -1) {
303 of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
304 } else if (s.search(/\@WITH_READER\@/) != -1) {
305 of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000306 } else if (s.search(/\@WITH_WRITER\@/) != -1) {
307 of.WriteLine(s.replace(/\@WITH_WRITER\@/, withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000308 } else if (s.search(/\@WITH_WALKER\@/) != -1) {
309 of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000310 } else if (s.search(/\@WITH_PATTERN\@/) != -1) {
311 of.WriteLine(s.replace(/\@WITH_PATTERN\@/, withPattern? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000312 } else if (s.search(/\@WITH_PUSH\@/) != -1) {
313 of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
314 } else if (s.search(/\@WITH_VALID\@/) != -1) {
315 of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
316 } else if (s.search(/\@WITH_SAX1\@/) != -1) {
317 of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
318 } else if (s.search(/\@WITH_LEGACY\@/) != -1) {
319 of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
320 } else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
321 of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000322 } else
323 of.WriteLine(ln);
324 }
325 ofi.Close();
326 of.Close();
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000327}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000328/* Configures Python bindings. Otherwise identical to the above */
329function configureLibxmlPy()
330{
331 var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
332 var pyOptsFile = srcDirXml + "\\python\\setup.py";
333 var fso, ofi, of, ln, s;
334 fso = new ActiveXObject("Scripting.FileSystemObject");
335 ofi = fso.OpenTextFile(pyOptsFileIn, 1);
336 of = fso.CreateTextFile(pyOptsFile, true);
337 while (ofi.AtEndOfStream != true) {
338 ln = ofi.ReadLine();
339 s = new String(ln);
340 if (s.search(/\@LIBXML_VERSION\@/) != -1) {
341 of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
342 verMajor + "." + verMinor + "." + verMicro));
343 } else if (s.search(/\@prefix\@/) != -1) {
344 of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
Daniel Veillard94bb2f12003-04-27 22:14:07 +0000345 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
346 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000347 } else
348 of.WriteLine(ln);
349 }
350 ofi.Close();
351 of.Close();
352}
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000353
354/* Creates the readme file for the binary distribution of 'bname', for the
355 version 'ver' in the file 'file'. This one is called from the Makefile when
356 generating a binary distribution. The parameters are passed by make. */
357function genReadme(bname, ver, file)
358{
359 var fso, f;
360 fso = new ActiveXObject("Scripting.FileSystemObject");
361 f = fso.CreateTextFile(file, true);
362 f.WriteLine(" " + bname + " " + ver);
363 f.WriteLine(" --------------");
364 f.WriteBlankLines(1);
365 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
366 f.WriteLine("platform.");
367 f.WriteBlankLines(1);
368 f.WriteLine(" The directory named 'include' contains the header files. Place its");
369 f.WriteLine("contents somewhere where it can be found by the compiler.");
370 f.WriteLine(" The directory which answers to the name 'lib' contains the static and");
371 f.WriteLine("dynamic libraries. Place them somewhere where they can be found by the");
372 f.WriteLine("linker. The files whose names end with '_a.lib' are aimed for static");
373 f.WriteLine("linking, the other files are lib/dll pairs.");
374 f.WriteLine(" The directory called 'util' contains various programs which count as a");
375 f.WriteLine("part of " + bname + ".");
376 f.WriteBlankLines(1);
Igor Zlatkovic0ceeb8e2002-09-10 19:07:02 +0000377 f.WriteLine(" If you plan to develop your own programme, in C, which uses " + bname + ", then");
378 f.WriteLine("you should know what to do with the files in the binary package. If you don't,");
379 f.WriteLine("know this, then please, please do some research on how to use a");
380 f.WriteLine("third-party library in a C programme. The topic belongs to the very basics");
381 f.WriteLine("and you will not be able to do much without that knowledge.");
382 f.WriteBlankLines(1);
383 f.WriteLine(" If you wish to use " + bname + " solely through the supplied utilities, such as");
384 f.WriteLine("xmllint or xsltproc, then all you need to do is place the");
385 f.WriteLine("contents of the 'lib' and 'util' directories from the binary package in a");
386 f.WriteLine("directory on your disc which is mentioned in your PATH environment");
387 f.WriteLine("variable. You can use an existing directory which is allready in the");
388 f.WriteLine("path, such as 'C:\WINDOWS', or 'C:\WINNT'. You can also create a new");
389 f.WriteLine("directory for " + bname + " and place the files there, but be sure to modify");
390 f.WriteLine("the PATH environment variable and add that new directory to its list.");
391 f.WriteBlankLines(1);
392 f.WriteLine(" If you use other software which needs " + bname + ", such as Apache");
393 f.WriteLine("Web Server in certain configurations, then please consult the");
394 f.WriteLine("documentation of that software and see if it mentions something about");
395 f.WriteLine("how it uses " + bname + " and how it expects it to be installed. If you find");
396 f.WriteLine("nothing, then the default installation, as described in the previous");
397 f.WriteLine("paragraph, should be suficient.");
398 f.WriteBlankLines(1);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000399 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
400 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
401 f.WriteLine("the address below.");
402 f.WriteBlankLines(1);
Daniel Veillardbeb70bd2002-12-18 14:53:54 +0000403 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000404 f.Close();
405}
406
William M. Brack6d13f332003-08-08 16:40:36 +0000407
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000408/*
409 * main(),
410 * Execution begins here.
411 */
412
413// Parse the command-line arguments.
414for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
415 var arg, opt;
416 arg = WScript.Arguments(i);
417 opt = arg.substring(0, arg.indexOf("="));
418 if (opt.length == 0)
419 opt = arg.substring(0, arg.indexOf(":"));
420 if (opt.length > 0) {
421 if (opt == "trio")
422 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
423 else if (opt == "threads")
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000424 withThreads = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000425 else if (opt == "ftp")
426 withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
427 else if (opt == "http")
428 withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
429 else if (opt == "html")
430 withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic9425ce22002-04-10 21:57:11 +0000431 else if (opt == "c14n")
432 withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000433 else if (opt == "catalog")
434 withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
435 else if (opt == "docb")
436 withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
437 else if (opt == "xpath")
438 withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
439 else if (opt == "xptr")
440 withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
441 else if (opt == "xinclude")
442 withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
443 else if (opt == "iconv")
444 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
William M. Brack6d13f332003-08-08 16:40:36 +0000445 else if (opt == "iso8859x")
446 withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000447 else if (opt == "zlib")
448 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000449 else if (opt == "xml_debug")
450 withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
451 else if (opt == "mem_debug")
452 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000453 else if (opt == "schemas")
454 withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000455 else if (opt == "regexps")
456 withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000457 else if (opt == "tree")
458 withTree = strToBool(arg.substring(opt.length + 1, arg.length));
459 else if (opt == "reader")
460 withReader = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillardea048932003-10-21 09:27:57 +0000461 else if (opt == "writer")
462 withWriter = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000463 else if (opt == "walker")
464 withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000465 else if (opt == "pattern")
466 withPattern = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000467 else if (opt == "push")
468 withPush = strToBool(arg.substring(opt.length + 1, arg.length));
469 else if (opt == "valid")
470 withValid = strToBool(arg.substring(opt.length + 1, arg.length));
471 else if (opt == "sax1")
472 withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
473 else if (opt == "legacy")
474 withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
475 else if (opt == "output")
476 withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000477 else if (opt == "python")
478 withPython = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000479 else if (opt == "compiler")
480 compiler = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000481 else if (opt == "cruntime")
482 cruntime = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000483 else if (opt == "dynruntime")
484 dynruntime = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000485 else if (opt == "debug")
486 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
487 else if (opt == "static")
488 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
489 else if (opt == "prefix")
490 buildPrefix = arg.substring(opt.length + 1, arg.length);
491 else if (opt == "incdir")
492 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
493 else if (opt == "bindir")
494 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
495 else if (opt == "libdir")
496 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
497 else if (opt == "sodir")
498 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
499 else if (opt == "incdir")
500 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
501 else if (opt == "include")
502 buildInclude = arg.substring(opt.length + 1, arg.length);
503 else if (opt == "lib")
504 buildLib = arg.substring(opt.length + 1, arg.length);
505 else
506 error = 1;
507 } else if (i == 0) {
508 if (arg == "genreadme") {
509 // This command comes from the Makefile and will not be checked
510 // for errors, because Makefile will always supply right the parameters.
511 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
512 WScript.Quit(0);
513 } else if (arg == "help") {
514 usage();
515 WScript.Quit(0);
516 }
William M. Brack6d13f332003-08-08 16:40:36 +0000517
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000518 } else {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000519 error = 1;
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000520 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000521}
522
William M. Brack6d13f332003-08-08 16:40:36 +0000523
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000524// If we fail here, it is because the user supplied an unrecognised argument.
525if (error != 0) {
526 usage();
527 WScript.Quit(error);
528}
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000529dirSep = "\\";
530if (compiler == "mingw")
531 dirSep = "/";
532if (buildBinPrefix == "")
533 buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
534if (buildIncPrefix == "")
535 buildIncPrefix = "$(PREFIX)" + dirSep + "include";
536if (buildLibPrefix == "")
537 buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
538if (buildSoPrefix == "")
539 buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
William M. Brack6d13f332003-08-08 16:40:36 +0000540
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000541// Discover the version.
542discoverVersion();
543if (error != 0) {
544 WScript.Echo("Version discovery failed, aborting.");
545 WScript.Quit(error);
546}
William M. Brack6d13f332003-08-08 16:40:36 +0000547
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000548WScript.Echo(baseName + " version: " + verMajor + "." + verMinor + "." + verMicro);
549
550// Configure libxml.
551configureLibxml();
552if (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 +0000557if (withPython == true) {
558 configureLibxmlPy();
559 if (error != 0) {
560 WScript.Echo("Configuration failed, aborting.");
561 WScript.Quit(error);
562 }
William M. Brack6d13f332003-08-08 16:40:36 +0000563
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000564}
565
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000566// Create the makefile.
567var fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000568var makefile = ".\\Makefile.msvc";
569if (compiler == "mingw")
570 makefile = ".\\Makefile.mingw";
Igor Zlatkovice8b5b0f2003-06-16 07:12:50 +0000571else if (compiler == "bcb")
572 makefile = ".\\Makefile.bcb";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000573fso.CopyFile(makefile, ".\\Makefile", true);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000574WScript.Echo("Created Makefile.");
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000575// Create the config.h.
576var confighsrc = "..\\include\\win32config.h";
577var configh = "..\\config.h";
Daniel Veillard6b9d6952003-11-05 09:50:55 +0000578var f = fso.FileExists(configh);
579if (f) {
580 var t = fso.GetFile(configh);
581 t.Attributes =0;
582}
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000583fso.CopyFile(confighsrc, configh, true);
584WScript.Echo("Created config.h.");
585
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000586
587// Display the final configuration.
588var txtOut = "\nXML processor configuration\n";
589txtOut += "---------------------------\n";
590txtOut += " Trio: " + boolToStr(withTrio) + "\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000591txtOut += " Thread safety: " + withThreads + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000592txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
593txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
594txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
595txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
596txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
597txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
598txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
599txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
600txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000601txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000602txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000603txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000604txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
605txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000606txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000607txtOut += " Tree support: " + boolToStr(withTree) + "\n";
608txtOut += " Reader support: " + boolToStr(withReader) + "\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000609txtOut += " Writer support: " + boolToStr(withWriter) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000610txtOut += " Walker support: " + boolToStr(withWalker) + "\n";
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000611txtOut += " Pattern support: " + boolToStr(withPattern) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000612txtOut += " Push support: " + boolToStr(withPush) + "\n";
613txtOut += "Validation support: " + boolToStr(withValid) + "\n";
614txtOut += " SAX1 support: " + boolToStr(withSax1) + "\n";
615txtOut += " Legacy support: " + boolToStr(withLegacy) + "\n";
616txtOut += " Output support: " + boolToStr(withOutput) + "\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000617txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000618txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000619txtOut += "\n";
620txtOut += "Win32 build configuration\n";
621txtOut += "-------------------------\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000622txtOut += " Compiler: " + compiler + "\n";
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000623if (compiler == "msvc")
624 txtOut += " C-Runtime option: " + cruntime + "\n";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000625else if (compiler == "bcb")
626 txtOut += " Use dynamic RTL: " + dynruntime + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000627txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
628txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
629txtOut += " Install prefix: " + buildPrefix + "\n";
630txtOut += " Put tools in: " + buildBinPrefix + "\n";
631txtOut += " Put headers in: " + buildIncPrefix + "\n";
632txtOut += "Put static libs in: " + buildLibPrefix + "\n";
633txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
634txtOut += " Include path: " + buildInclude + "\n";
635txtOut += " Lib path: " + buildLib + "\n";
636WScript.Echo(txtOut);
637
William M. Brack6d13f332003-08-08 16:40:36 +0000638//
639