blob: f77308d69cd23bf7e98d46648a5d8935f216576e [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 Zlatkovic8ea667f2004-08-24 14:42:29 +000028var verCvs;
29var useCvsVer = true;
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;
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +000053var withPattern = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000054var withPush = true;
55var withValid = true;
56var withSax1 = true;
57var withLegacy = true;
58var withOutput = true;
Igor Zlatkovic853514f2002-11-22 21:41:09 +000059var withPython = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000060/* Win32 build options. */
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000061var dirSep = "\\";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000062var compiler = "msvc";
Igor Zlatkovic4f928212003-11-27 18:39:01 +000063var cruntime = "/MD";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +000064var dynruntime = true;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000065var buildDebug = 0;
66var buildStatic = 0;
67var buildPrefix = ".";
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000068var buildBinPrefix = "";
69var buildIncPrefix = "";
70var buildLibPrefix = "";
71var buildSoPrefix = "";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000072var buildInclude = ".";
73var buildLib = ".";
74/* Local stuff */
75var error = 0;
76
77/* Helper function, transforms the option variable into the 'Enabled'
78 or 'Disabled' string. */
79function boolToStr(opt)
80{
81 if (opt == false)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000082 return "no";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000083 else if (opt == true)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000084 return "yes";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000085 error = 1;
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000086 return "*** undefined ***";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000087}
88
89/* Helper function, transforms the argument string into a boolean
90 value. */
91function strToBool(opt)
92{
93 if (opt == 0 || opt == "no")
94 return false;
95 else if (opt == 1 || opt == "yes")
96 return true;
97 error = 1;
98 return false;
99}
100
101/* Displays the details about how to use this script. */
102function usage()
103{
104 var txt;
105 txt = "Usage:\n";
106 txt += " cscript " + WScript.ScriptName + " <options>\n";
107 txt += " cscript " + WScript.ScriptName + " help\n\n";
108 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000109 txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000110 txt += "\nXML processor options, default value given in parentheses:\n\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000111 txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000112 txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000113 txt += " ftp: Enable FTP client (" + (withFtp? "yes" : "no") + ")\n";
114 txt += " http: Enable HTTP client (" + (withHttp? "yes" : "no") + ")\n";
115 txt += " html: Enable HTML processor (" + (withHtml? "yes" : "no") + ")\n";
116 txt += " c14n: Enable C14N support (" + (withC14n? "yes" : "no") + ")\n";
117 txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n";
118 txt += " docb: Enable DocBook support (" + (withDocb? "yes" : "no") + ")\n";
119 txt += " xpath: Enable XPath support (" + (withXpath? "yes" : "no") + ")\n";
120 txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n";
121 txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000122 txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000123 txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000124 txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000125 txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
126 txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000127 txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000128 txt += " tree: Enable tree api (" + (withTree? "yes" : "no") + ")\n";
129 txt += " reader: Enable xmlReader api (" + (withReader? "yes" : "no") + ")\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000130 txt += " writer: Enable xmlWriter api (" + (withWriter? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000131 txt += " walker: Enable xmlDocWalker api (" + (withWalker? "yes" : "no") + ")\n";
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000132 txt += " pattern: Enable xmlPattern api (" + (withPattern? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000133 txt += " push: Enable push api (" + (withPush? "yes" : "no") + ")\n";
134 txt += " valid: Enable DTD validation support (" + (withValid? "yes" : "no") + ")\n";
135 txt += " sax1: Enable SAX1 api (" + (withSax1? "yes" : "no") + ")\n";
136 txt += " legacy: Enable Deprecated api's (" + (withLegacy? "yes" : "no") + ")\n";
137 txt += " output: Enable serialization support (" + (withOutput? "yes" : "no") + ")\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000138 txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000139 txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000140 txt += "\nWin32 build options, default value given in parentheses:\n\n";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000141 txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000142 txt += " cruntime: C-runtime compiler option (only msvc) (" + cruntime + ")\n";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000143 txt += " dynruntime: Use the dynamic RTL (only bcb) (" + dynruntime + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000144 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
145 txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
146 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
147 txt += " bindir: Directory where xmllint and friends should be installed\n";
148 txt += " (" + buildBinPrefix + ")\n";
149 txt += " incdir: Directory where headers should be installed\n";
150 txt += " (" + buildIncPrefix + ")\n";
151 txt += " libdir: Directory where static and import libraries should be\n";
152 txt += " installed (" + buildLibPrefix + ")\n";
153 txt += " sodir: Directory where shared libraries should be installed\n";
154 txt += " (" + buildSoPrefix + ")\n";
155 txt += " include: Additional search path for the compiler, particularily\n";
156 txt += " where iconv headers can be found (" + buildInclude + ")\n";
157 txt += " lib: Additional search path for the linker, particularily\n";
158 txt += " where iconv library can be found (" + buildLib + ")\n";
159 WScript.Echo(txt);
160}
161
162/* Discovers the version we are working with by reading the apropriate
163 configuration file. Despite its name, this also writes the configuration
164 file included by our makefile. */
165function discoverVersion()
166{
Igor Zlatkovic8ea667f2004-08-24 14:42:29 +0000167 var fso, cf, vf, ln, s, iDot, iSlash;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000168 fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovic8ea667f2004-08-24 14:42:29 +0000169 verCvs = "";
170 if (useCvsVer && fso.FileExists("..\\CVS\\Entries")) {
171 cf = fso.OpenTextFile("..\\CVS\\Entries", 1);
172 while (cf.AtEndOfStream != true) {
173 ln = cf.ReadLine();
174 s = new String(ln);
175 if (s.search(/^\/ChangeLog\//) != -1) {
176 iDot = s.indexOf(".");
177 iSlash = s.indexOf("/", iDot);
178 verCvs = "CVS" + s.substring(iDot + 1, iSlash);
179 break;
180 }
181 }
182 cf.Close();
183 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000184 cf = fso.OpenTextFile(configFile, 1);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000185 if (compiler == "msvc")
186 versionFile = ".\\config.msvc";
187 else if (compiler == "mingw")
188 versionFile = ".\\config.mingw";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000189 else if (compiler == "bcb")
190 versionFile = ".\\config.bcb";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000191 vf = fso.CreateTextFile(versionFile, true);
192 vf.WriteLine("# " + versionFile);
193 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
194 vf.WriteBlankLines(1);
195 while (cf.AtEndOfStream != true) {
196 ln = cf.ReadLine();
197 s = new String(ln);
Daniel Veillard70b18562003-09-24 21:45:21 +0000198 if (s.search(/^LIBXML_MAJOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000199 vf.WriteLine(s);
200 verMajor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000201 } else if(s.search(/^LIBXML_MINOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000202 vf.WriteLine(s);
203 verMinor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000204 } else if(s.search(/^LIBXML_MICRO_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000205 vf.WriteLine(s);
206 verMicro = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000207 } else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
208 vf.WriteLine(s);
209 verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length)
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000210 }
211 }
212 cf.Close();
213 vf.WriteLine("XML_SRCDIR=" + srcDirXml);
214 vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000215 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000216 vf.WriteLine("WITH_THREADS=" + withThreads);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000217 vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
218 vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
219 vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
220 vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
221 vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
222 vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
223 vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
224 vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
225 vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
226 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000227 vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000228 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000229 vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
230 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000231 vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000232 vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000233 vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
234 vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000235 vf.WriteLine("WITH_WRITER=" + (withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000236 vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000237 vf.WriteLine("WITH_PATTERN=" + (withPattern? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000238 vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
239 vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
240 vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
241 vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
242 vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000243 vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000244 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
245 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
246 vf.WriteLine("PREFIX=" + buildPrefix);
247 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
248 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
249 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
250 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000251 if (compiler == "msvc") {
252 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
253 vf.WriteLine("LIB=$(LIB);" + buildLib);
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000254 vf.WriteLine("CRUNTIME=" + cruntime);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000255 } else if (compiler == "mingw") {
256 vf.WriteLine("INCLUDE+=;" + buildInclude);
257 vf.WriteLine("LIB+=;" + buildLib);
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000258 } else if (compiler == "bcb") {
259 vf.WriteLine("INCLUDE=" + buildInclude);
260 vf.WriteLine("LIB=" + buildLib);
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000261 vf.WriteLine("DYNRUNTIME=" + (dynruntime? "1" : "0"));
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000262 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000263 vf.Close();
264}
265
266/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
267 taking what the user passed on the command line into account. */
268function configureLibxml()
269{
270 var fso, ofi, of, ln, s;
271 fso = new ActiveXObject("Scripting.FileSystemObject");
272 ofi = fso.OpenTextFile(optsFileIn, 1);
273 of = fso.CreateTextFile(optsFile, true);
274 while (ofi.AtEndOfStream != true) {
275 ln = ofi.ReadLine();
276 s = new String(ln);
277 if (s.search(/\@VERSION\@/) != -1) {
278 of.WriteLine(s.replace(/\@VERSION\@/,
Daniel Veillard70b18562003-09-24 21:45:21 +0000279 verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000280 } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
281 of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
282 verMajor*10000 + verMinor*100 + verMicro*1));
Igor Zlatkovic8ea667f2004-08-24 14:42:29 +0000283 } else if (s.search(/\@LIBXML_VERSION_EXTRA\@/) != -1) {
284 of.WriteLine(s.replace(/\@LIBXML_VERSION_EXTRA\@/, verCvs));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000285 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
286 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
287 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000288 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000289 } else if (s.search(/\@WITH_FTP\@/) != -1) {
290 of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
291 } else if (s.search(/\@WITH_HTTP\@/) != -1) {
292 of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
293 } else if (s.search(/\@WITH_HTML\@/) != -1) {
294 of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
295 } else if (s.search(/\@WITH_C14N\@/) != -1) {
296 of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
297 } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
298 of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
299 } else if (s.search(/\@WITH_DOCB\@/) != -1) {
300 of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
301 } else if (s.search(/\@WITH_XPATH\@/) != -1) {
302 of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
303 } else if (s.search(/\@WITH_XPTR\@/) != -1) {
304 of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
305 } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
306 of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
307 } else if (s.search(/\@WITH_ICONV\@/) != -1) {
308 of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000309 } else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
310 of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000311 } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
312 of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000313 } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
314 of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
315 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
316 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000317 } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
318 of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000319 } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
320 of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000321 } else if (s.search(/\@WITH_TREE\@/) != -1) {
322 of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
323 } else if (s.search(/\@WITH_READER\@/) != -1) {
324 of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000325 } else if (s.search(/\@WITH_WRITER\@/) != -1) {
326 of.WriteLine(s.replace(/\@WITH_WRITER\@/, withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000327 } else if (s.search(/\@WITH_WALKER\@/) != -1) {
328 of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000329 } else if (s.search(/\@WITH_PATTERN\@/) != -1) {
330 of.WriteLine(s.replace(/\@WITH_PATTERN\@/, withPattern? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000331 } else if (s.search(/\@WITH_PUSH\@/) != -1) {
332 of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
333 } else if (s.search(/\@WITH_VALID\@/) != -1) {
334 of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
335 } else if (s.search(/\@WITH_SAX1\@/) != -1) {
336 of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
337 } else if (s.search(/\@WITH_LEGACY\@/) != -1) {
338 of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
339 } else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
340 of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000341 } else
342 of.WriteLine(ln);
343 }
344 ofi.Close();
345 of.Close();
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000346}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000347/* Configures Python bindings. Otherwise identical to the above */
348function configureLibxmlPy()
349{
350 var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
351 var pyOptsFile = srcDirXml + "\\python\\setup.py";
352 var fso, ofi, of, ln, s;
353 fso = new ActiveXObject("Scripting.FileSystemObject");
354 ofi = fso.OpenTextFile(pyOptsFileIn, 1);
355 of = fso.CreateTextFile(pyOptsFile, true);
356 while (ofi.AtEndOfStream != true) {
357 ln = ofi.ReadLine();
358 s = new String(ln);
359 if (s.search(/\@LIBXML_VERSION\@/) != -1) {
360 of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
361 verMajor + "." + verMinor + "." + verMicro));
362 } else if (s.search(/\@prefix\@/) != -1) {
363 of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
Daniel Veillard94bb2f12003-04-27 22:14:07 +0000364 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
365 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000366 } else
367 of.WriteLine(ln);
368 }
369 ofi.Close();
370 of.Close();
371}
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000372
373/* Creates the readme file for the binary distribution of 'bname', for the
374 version 'ver' in the file 'file'. This one is called from the Makefile when
375 generating a binary distribution. The parameters are passed by make. */
376function genReadme(bname, ver, file)
377{
378 var fso, f;
379 fso = new ActiveXObject("Scripting.FileSystemObject");
380 f = fso.CreateTextFile(file, true);
381 f.WriteLine(" " + bname + " " + ver);
382 f.WriteLine(" --------------");
383 f.WriteBlankLines(1);
384 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
385 f.WriteLine("platform.");
386 f.WriteBlankLines(1);
Igor Zlatkovic72c28582004-06-09 14:32:47 +0000387 f.WriteLine(" The files in this package do not require any special installation");
388 f.WriteLine("steps. Extract the contents of the archive whereever you wish and");
389 f.WriteLine("make sure that your tools which use " + bname + " can find it.");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000390 f.WriteBlankLines(1);
Igor Zlatkovic72c28582004-06-09 14:32:47 +0000391 f.WriteLine(" For example, if you want to run the supplied utilities from the command");
392 f.WriteLine("line, you can, if you wish, add the 'bin' subdirectory to the PATH");
393 f.WriteLine("environment variable.");
394 f.WriteLine(" If you want to make programmes in C which use " + bname + ", you'll");
395 f.WriteLine("likely know how to use the contents of this package. If you don't, please");
396 f.WriteLine("refer to your compiler's documentation.");
Igor Zlatkovic0ceeb8e2002-09-10 19:07:02 +0000397 f.WriteBlankLines(1);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000398 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
399 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
400 f.WriteLine("the address below.");
401 f.WriteBlankLines(1);
Daniel Veillardbeb70bd2002-12-18 14:53:54 +0000402 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000403 f.Close();
404}
405
William M. Brack6d13f332003-08-08 16:40:36 +0000406
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000407/*
408 * main(),
409 * Execution begins here.
410 */
411
412// Parse the command-line arguments.
413for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
414 var arg, opt;
415 arg = WScript.Arguments(i);
416 opt = arg.substring(0, arg.indexOf("="));
417 if (opt.length == 0)
418 opt = arg.substring(0, arg.indexOf(":"));
419 if (opt.length > 0) {
420 if (opt == "trio")
421 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
422 else if (opt == "threads")
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000423 withThreads = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000424 else if (opt == "ftp")
425 withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
426 else if (opt == "http")
427 withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
428 else if (opt == "html")
429 withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic9425ce22002-04-10 21:57:11 +0000430 else if (opt == "c14n")
431 withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000432 else if (opt == "catalog")
433 withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
434 else if (opt == "docb")
435 withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
436 else if (opt == "xpath")
437 withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
438 else if (opt == "xptr")
439 withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
440 else if (opt == "xinclude")
441 withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
442 else if (opt == "iconv")
443 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
William M. Brack6d13f332003-08-08 16:40:36 +0000444 else if (opt == "iso8859x")
445 withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000446 else if (opt == "zlib")
447 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000448 else if (opt == "xml_debug")
449 withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
450 else if (opt == "mem_debug")
451 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000452 else if (opt == "schemas")
453 withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000454 else if (opt == "regexps")
455 withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000456 else if (opt == "tree")
457 withTree = strToBool(arg.substring(opt.length + 1, arg.length));
458 else if (opt == "reader")
459 withReader = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillardea048932003-10-21 09:27:57 +0000460 else if (opt == "writer")
461 withWriter = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000462 else if (opt == "walker")
463 withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000464 else if (opt == "pattern")
465 withPattern = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000466 else if (opt == "push")
467 withPush = strToBool(arg.substring(opt.length + 1, arg.length));
468 else if (opt == "valid")
469 withValid = strToBool(arg.substring(opt.length + 1, arg.length));
470 else if (opt == "sax1")
471 withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
472 else if (opt == "legacy")
473 withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
474 else if (opt == "output")
475 withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000476 else if (opt == "python")
477 withPython = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000478 else if (opt == "compiler")
479 compiler = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000480 else if (opt == "cruntime")
481 cruntime = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000482 else if (opt == "dynruntime")
483 dynruntime = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000484 else if (opt == "debug")
485 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
486 else if (opt == "static")
487 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
488 else if (opt == "prefix")
489 buildPrefix = arg.substring(opt.length + 1, arg.length);
490 else if (opt == "incdir")
491 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
492 else if (opt == "bindir")
493 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
494 else if (opt == "libdir")
495 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
496 else if (opt == "sodir")
497 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
498 else if (opt == "incdir")
499 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
500 else if (opt == "include")
501 buildInclude = arg.substring(opt.length + 1, arg.length);
502 else if (opt == "lib")
503 buildLib = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovic8ea667f2004-08-24 14:42:29 +0000504 else if (opt == "release")
505 useCvsVer = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000506 else
507 error = 1;
508 } else if (i == 0) {
509 if (arg == "genreadme") {
510 // This command comes from the Makefile and will not be checked
511 // for errors, because Makefile will always supply right the parameters.
512 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
513 WScript.Quit(0);
514 } else if (arg == "help") {
515 usage();
516 WScript.Quit(0);
517 }
William M. Brack6d13f332003-08-08 16:40:36 +0000518
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000519 } else {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000520 error = 1;
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000521 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000522}
523
William M. Brack6d13f332003-08-08 16:40:36 +0000524
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000525// If we fail here, it is because the user supplied an unrecognised argument.
526if (error != 0) {
527 usage();
528 WScript.Quit(error);
529}
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000530dirSep = "\\";
531if (compiler == "mingw")
532 dirSep = "/";
533if (buildBinPrefix == "")
534 buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
535if (buildIncPrefix == "")
536 buildIncPrefix = "$(PREFIX)" + dirSep + "include";
537if (buildLibPrefix == "")
538 buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
539if (buildSoPrefix == "")
540 buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
William M. Brack6d13f332003-08-08 16:40:36 +0000541
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000542// Discover the version.
543discoverVersion();
544if (error != 0) {
545 WScript.Echo("Version discovery failed, aborting.");
546 WScript.Quit(error);
547}
William M. Brack6d13f332003-08-08 16:40:36 +0000548
Igor Zlatkovic8ea667f2004-08-24 14:42:29 +0000549var outVerString = baseName + " version: " + verMajor + "." + verMinor + "." + verMicro;
550if (verMicroSuffix && verMicroSuffix != "")
551 outVerString += "-" + verMicroSuffix;
552if (verCvs && verCvs != "")
553 outVerString += "-" + verCvs;
554WScript.Echo(outVerString);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000555
556// Configure libxml.
557configureLibxml();
558if (error != 0) {
559 WScript.Echo("Configuration failed, aborting.");
560 WScript.Quit(error);
561}
William M. Brack6d13f332003-08-08 16:40:36 +0000562
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000563if (withPython == true) {
564 configureLibxmlPy();
565 if (error != 0) {
566 WScript.Echo("Configuration failed, aborting.");
567 WScript.Quit(error);
568 }
William M. Brack6d13f332003-08-08 16:40:36 +0000569
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000570}
571
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000572// Create the makefile.
573var fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000574var makefile = ".\\Makefile.msvc";
575if (compiler == "mingw")
576 makefile = ".\\Makefile.mingw";
Igor Zlatkovice8b5b0f2003-06-16 07:12:50 +0000577else if (compiler == "bcb")
578 makefile = ".\\Makefile.bcb";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000579fso.CopyFile(makefile, ".\\Makefile", true);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000580WScript.Echo("Created Makefile.");
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000581// Create the config.h.
582var confighsrc = "..\\include\\win32config.h";
583var configh = "..\\config.h";
Daniel Veillard6b9d6952003-11-05 09:50:55 +0000584var f = fso.FileExists(configh);
585if (f) {
586 var t = fso.GetFile(configh);
587 t.Attributes =0;
588}
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000589fso.CopyFile(confighsrc, configh, true);
590WScript.Echo("Created config.h.");
591
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000592
593// Display the final configuration.
594var txtOut = "\nXML processor configuration\n";
595txtOut += "---------------------------\n";
596txtOut += " Trio: " + boolToStr(withTrio) + "\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000597txtOut += " Thread safety: " + withThreads + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000598txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
599txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
600txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
601txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
602txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
603txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
604txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
605txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
606txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000607txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000608txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000609txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000610txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
611txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000612txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000613txtOut += " Tree support: " + boolToStr(withTree) + "\n";
614txtOut += " Reader support: " + boolToStr(withReader) + "\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000615txtOut += " Writer support: " + boolToStr(withWriter) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000616txtOut += " Walker support: " + boolToStr(withWalker) + "\n";
Igor Zlatkovicc5a29ca2003-12-11 13:56:54 +0000617txtOut += " Pattern support: " + boolToStr(withPattern) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000618txtOut += " Push support: " + boolToStr(withPush) + "\n";
619txtOut += "Validation support: " + boolToStr(withValid) + "\n";
620txtOut += " SAX1 support: " + boolToStr(withSax1) + "\n";
621txtOut += " Legacy support: " + boolToStr(withLegacy) + "\n";
622txtOut += " Output support: " + boolToStr(withOutput) + "\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000623txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000624txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000625txtOut += "\n";
626txtOut += "Win32 build configuration\n";
627txtOut += "-------------------------\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000628txtOut += " Compiler: " + compiler + "\n";
Igor Zlatkovic4f928212003-11-27 18:39:01 +0000629if (compiler == "msvc")
630 txtOut += " C-Runtime option: " + cruntime + "\n";
Igor Zlatkovicc7646e62003-12-01 11:33:27 +0000631else if (compiler == "bcb")
632 txtOut += " Use dynamic RTL: " + dynruntime + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000633txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
634txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
635txtOut += " Install prefix: " + buildPrefix + "\n";
636txtOut += " Put tools in: " + buildBinPrefix + "\n";
637txtOut += " Put headers in: " + buildIncPrefix + "\n";
638txtOut += "Put static libs in: " + buildLibPrefix + "\n";
639txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
640txtOut += " Include path: " + buildInclude + "\n";
641txtOut += " Lib path: " + buildLib + "\n";
642WScript.Echo(txtOut);
643
William M. Brack6d13f332003-08-08 16:40:36 +0000644//
645