blob: 2d434c734ff5dd395d92f42e39283843ecd3ccb1 [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;
29/* Libxml features. */
30var withTrio = false;
Igor Zlatkovice38ab532003-05-17 11:30:54 +000031var withThreads = "native";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000032var withFtp = true;
33var withHttp = true;
34var withHtml = true;
35var withC14n = true;
36var withCatalog = true;
37var withDocb = true;
38var withXpath = true;
39var withXptr = true;
40var withXinclude = true;
41var withIconv = true;
William M. Brack6d13f332003-08-08 16:40:36 +000042var withIso8859x = false;
Igor Zlatkovic3acadf42002-09-20 16:40:17 +000043var withZlib = false;
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000044var withDebug = true;
45var withMemDebug = false;
Igor Zlatkovica6f2d902002-04-16 17:57:17 +000046var withSchemas = true;
Igor Zlatkovic8e040972002-09-20 13:39:53 +000047var withRegExps = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000048var withTree = true;
49var withReader = true;
Daniel Veillardea048932003-10-21 09:27:57 +000050var withWriter = true;
Daniel Veillard141310a2003-10-06 08:47:56 +000051var withWalker = true;
52var 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 Zlatkovicac97f6e2002-03-24 21:00:26 +000061var buildDebug = 0;
62var buildStatic = 0;
63var buildPrefix = ".";
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +000064var buildBinPrefix = "";
65var buildIncPrefix = "";
66var buildLibPrefix = "";
67var buildSoPrefix = "";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000068var buildInclude = ".";
69var buildLib = ".";
70/* Local stuff */
71var error = 0;
72
73/* Helper function, transforms the option variable into the 'Enabled'
74 or 'Disabled' string. */
75function boolToStr(opt)
76{
77 if (opt == false)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000078 return "no";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000079 else if (opt == true)
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000080 return "yes";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000081 error = 1;
Igor Zlatkovic8f536a82002-10-31 16:01:00 +000082 return "*** undefined ***";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +000083}
84
85/* Helper function, transforms the argument string into a boolean
86 value. */
87function strToBool(opt)
88{
89 if (opt == 0 || opt == "no")
90 return false;
91 else if (opt == 1 || opt == "yes")
92 return true;
93 error = 1;
94 return false;
95}
96
97/* Displays the details about how to use this script. */
98function usage()
99{
100 var txt;
101 txt = "Usage:\n";
102 txt += " cscript " + WScript.ScriptName + " <options>\n";
103 txt += " cscript " + WScript.ScriptName + " help\n\n";
104 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000105 txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000106 txt += "\nXML processor options, default value given in parentheses:\n\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000107 txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000108 txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000109 txt += " ftp: Enable FTP client (" + (withFtp? "yes" : "no") + ")\n";
110 txt += " http: Enable HTTP client (" + (withHttp? "yes" : "no") + ")\n";
111 txt += " html: Enable HTML processor (" + (withHtml? "yes" : "no") + ")\n";
112 txt += " c14n: Enable C14N support (" + (withC14n? "yes" : "no") + ")\n";
113 txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n";
114 txt += " docb: Enable DocBook support (" + (withDocb? "yes" : "no") + ")\n";
115 txt += " xpath: Enable XPath support (" + (withXpath? "yes" : "no") + ")\n";
116 txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n";
117 txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000118 txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000119 txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000120 txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000121 txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
122 txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000123 txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000124 txt += " tree: Enable tree api (" + (withTree? "yes" : "no") + ")\n";
125 txt += " reader: Enable xmlReader api (" + (withReader? "yes" : "no") + ")\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000126 txt += " writer: Enable xmlWriter api (" + (withWriter? "yes" : "no") + ")\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000127 txt += " walker: Enable xmlDocWalker api (" + (withWalker? "yes" : "no") + ")\n";
128 txt += " push: Enable push api (" + (withPush? "yes" : "no") + ")\n";
129 txt += " valid: Enable DTD validation support (" + (withValid? "yes" : "no") + ")\n";
130 txt += " sax1: Enable SAX1 api (" + (withSax1? "yes" : "no") + ")\n";
131 txt += " legacy: Enable Deprecated api's (" + (withLegacy? "yes" : "no") + ")\n";
132 txt += " output: Enable serialization support (" + (withOutput? "yes" : "no") + ")\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000133 txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000134 txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000135 txt += "\nWin32 build options, default value given in parentheses:\n\n";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000136 txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000137 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
138 txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
139 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
140 txt += " bindir: Directory where xmllint and friends should be installed\n";
141 txt += " (" + buildBinPrefix + ")\n";
142 txt += " incdir: Directory where headers should be installed\n";
143 txt += " (" + buildIncPrefix + ")\n";
144 txt += " libdir: Directory where static and import libraries should be\n";
145 txt += " installed (" + buildLibPrefix + ")\n";
146 txt += " sodir: Directory where shared libraries should be installed\n";
147 txt += " (" + buildSoPrefix + ")\n";
148 txt += " include: Additional search path for the compiler, particularily\n";
149 txt += " where iconv headers can be found (" + buildInclude + ")\n";
150 txt += " lib: Additional search path for the linker, particularily\n";
151 txt += " where iconv library can be found (" + buildLib + ")\n";
152 WScript.Echo(txt);
153}
154
155/* Discovers the version we are working with by reading the apropriate
156 configuration file. Despite its name, this also writes the configuration
157 file included by our makefile. */
158function discoverVersion()
159{
160 var fso, cf, vf, ln, s;
161 fso = new ActiveXObject("Scripting.FileSystemObject");
162 cf = fso.OpenTextFile(configFile, 1);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000163 if (compiler == "msvc")
164 versionFile = ".\\config.msvc";
165 else if (compiler == "mingw")
166 versionFile = ".\\config.mingw";
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000167 else if (compiler == "bcb")
168 versionFile = ".\\config.bcb";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000169 vf = fso.CreateTextFile(versionFile, true);
170 vf.WriteLine("# " + versionFile);
171 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
172 vf.WriteBlankLines(1);
173 while (cf.AtEndOfStream != true) {
174 ln = cf.ReadLine();
175 s = new String(ln);
Daniel Veillard70b18562003-09-24 21:45:21 +0000176 if (s.search(/^LIBXML_MAJOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000177 vf.WriteLine(s);
178 verMajor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000179 } else if(s.search(/^LIBXML_MINOR_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000180 vf.WriteLine(s);
181 verMinor = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000182 } else if(s.search(/^LIBXML_MICRO_VERSION=/) != -1) {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000183 vf.WriteLine(s);
184 verMicro = s.substring(s.indexOf("=") + 1, s.length)
Daniel Veillard70b18562003-09-24 21:45:21 +0000185 } else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
186 vf.WriteLine(s);
187 verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length)
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000188 }
189 }
190 cf.Close();
191 vf.WriteLine("XML_SRCDIR=" + srcDirXml);
192 vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
193 vf.WriteLine("BINDIR=" + binDir);
194 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000195 vf.WriteLine("WITH_THREADS=" + withThreads);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000196 vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
197 vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
198 vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
199 vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
200 vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
201 vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
202 vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
203 vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
204 vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
205 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000206 vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000207 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000208 vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
209 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000210 vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000211 vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000212 vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
213 vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000214 vf.WriteLine("WITH_WRITER=" + (withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000215 vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
216 vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
217 vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
218 vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
219 vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
220 vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000221 vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000222 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
223 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
224 vf.WriteLine("PREFIX=" + buildPrefix);
225 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
226 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
227 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
228 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000229 if (compiler == "msvc") {
230 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
231 vf.WriteLine("LIB=$(LIB);" + buildLib);
232 } else if (compiler == "mingw") {
233 vf.WriteLine("INCLUDE+=;" + buildInclude);
234 vf.WriteLine("LIB+=;" + buildLib);
Igor Zlatkovic72f92a82003-06-14 16:48:26 +0000235 } else if (compiler == "bcb") {
236 vf.WriteLine("INCLUDE=" + buildInclude);
237 vf.WriteLine("LIB=" + buildLib);
238 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000239 vf.Close();
240}
241
242/* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
243 taking what the user passed on the command line into account. */
244function configureLibxml()
245{
246 var fso, ofi, of, ln, s;
247 fso = new ActiveXObject("Scripting.FileSystemObject");
248 ofi = fso.OpenTextFile(optsFileIn, 1);
249 of = fso.CreateTextFile(optsFile, true);
250 while (ofi.AtEndOfStream != true) {
251 ln = ofi.ReadLine();
252 s = new String(ln);
253 if (s.search(/\@VERSION\@/) != -1) {
254 of.WriteLine(s.replace(/\@VERSION\@/,
Daniel Veillard70b18562003-09-24 21:45:21 +0000255 verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000256 } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
257 of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
258 verMajor*10000 + verMinor*100 + verMicro*1));
259 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
260 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
261 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000262 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000263 } else if (s.search(/\@WITH_FTP\@/) != -1) {
264 of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
265 } else if (s.search(/\@WITH_HTTP\@/) != -1) {
266 of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
267 } else if (s.search(/\@WITH_HTML\@/) != -1) {
268 of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
269 } else if (s.search(/\@WITH_C14N\@/) != -1) {
270 of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
271 } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
272 of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
273 } else if (s.search(/\@WITH_DOCB\@/) != -1) {
274 of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
275 } else if (s.search(/\@WITH_XPATH\@/) != -1) {
276 of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
277 } else if (s.search(/\@WITH_XPTR\@/) != -1) {
278 of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
279 } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
280 of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
281 } else if (s.search(/\@WITH_ICONV\@/) != -1) {
282 of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
William M. Brack6d13f332003-08-08 16:40:36 +0000283 } else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
284 of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000285 } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
286 of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000287 } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
288 of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
289 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
290 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000291 } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
292 of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000293 } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
294 of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000295 } else if (s.search(/\@WITH_TREE\@/) != -1) {
296 of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
297 } else if (s.search(/\@WITH_READER\@/) != -1) {
298 of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
Daniel Veillardea048932003-10-21 09:27:57 +0000299 } else if (s.search(/\@WITH_WRITER\@/) != -1) {
300 of.WriteLine(s.replace(/\@WITH_WRITER\@/, withWriter? "1" : "0"));
Daniel Veillard141310a2003-10-06 08:47:56 +0000301 } else if (s.search(/\@WITH_WALKER\@/) != -1) {
302 of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
303 } else if (s.search(/\@WITH_PUSH\@/) != -1) {
304 of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
305 } else if (s.search(/\@WITH_VALID\@/) != -1) {
306 of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
307 } else if (s.search(/\@WITH_SAX1\@/) != -1) {
308 of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
309 } else if (s.search(/\@WITH_LEGACY\@/) != -1) {
310 of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
311 } else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
312 of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000313 } else
314 of.WriteLine(ln);
315 }
316 ofi.Close();
317 of.Close();
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000318}
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000319/* Configures Python bindings. Otherwise identical to the above */
320function configureLibxmlPy()
321{
322 var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
323 var pyOptsFile = srcDirXml + "\\python\\setup.py";
324 var fso, ofi, of, ln, s;
325 fso = new ActiveXObject("Scripting.FileSystemObject");
326 ofi = fso.OpenTextFile(pyOptsFileIn, 1);
327 of = fso.CreateTextFile(pyOptsFile, true);
328 while (ofi.AtEndOfStream != true) {
329 ln = ofi.ReadLine();
330 s = new String(ln);
331 if (s.search(/\@LIBXML_VERSION\@/) != -1) {
332 of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
333 verMajor + "." + verMinor + "." + verMicro));
334 } else if (s.search(/\@prefix\@/) != -1) {
335 of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
Daniel Veillard94bb2f12003-04-27 22:14:07 +0000336 } else if (s.search(/\@WITH_THREADS\@/) != -1) {
337 of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000338 } else
339 of.WriteLine(ln);
340 }
341 ofi.Close();
342 of.Close();
343}
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000344
345/* Creates the readme file for the binary distribution of 'bname', for the
346 version 'ver' in the file 'file'. This one is called from the Makefile when
347 generating a binary distribution. The parameters are passed by make. */
348function genReadme(bname, ver, file)
349{
350 var fso, f;
351 fso = new ActiveXObject("Scripting.FileSystemObject");
352 f = fso.CreateTextFile(file, true);
353 f.WriteLine(" " + bname + " " + ver);
354 f.WriteLine(" --------------");
355 f.WriteBlankLines(1);
356 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
357 f.WriteLine("platform.");
358 f.WriteBlankLines(1);
359 f.WriteLine(" The directory named 'include' contains the header files. Place its");
360 f.WriteLine("contents somewhere where it can be found by the compiler.");
361 f.WriteLine(" The directory which answers to the name 'lib' contains the static and");
362 f.WriteLine("dynamic libraries. Place them somewhere where they can be found by the");
363 f.WriteLine("linker. The files whose names end with '_a.lib' are aimed for static");
364 f.WriteLine("linking, the other files are lib/dll pairs.");
365 f.WriteLine(" The directory called 'util' contains various programs which count as a");
366 f.WriteLine("part of " + bname + ".");
367 f.WriteBlankLines(1);
Igor Zlatkovic0ceeb8e2002-09-10 19:07:02 +0000368 f.WriteLine(" If you plan to develop your own programme, in C, which uses " + bname + ", then");
369 f.WriteLine("you should know what to do with the files in the binary package. If you don't,");
370 f.WriteLine("know this, then please, please do some research on how to use a");
371 f.WriteLine("third-party library in a C programme. The topic belongs to the very basics");
372 f.WriteLine("and you will not be able to do much without that knowledge.");
373 f.WriteBlankLines(1);
374 f.WriteLine(" If you wish to use " + bname + " solely through the supplied utilities, such as");
375 f.WriteLine("xmllint or xsltproc, then all you need to do is place the");
376 f.WriteLine("contents of the 'lib' and 'util' directories from the binary package in a");
377 f.WriteLine("directory on your disc which is mentioned in your PATH environment");
378 f.WriteLine("variable. You can use an existing directory which is allready in the");
379 f.WriteLine("path, such as 'C:\WINDOWS', or 'C:\WINNT'. You can also create a new");
380 f.WriteLine("directory for " + bname + " and place the files there, but be sure to modify");
381 f.WriteLine("the PATH environment variable and add that new directory to its list.");
382 f.WriteBlankLines(1);
383 f.WriteLine(" If you use other software which needs " + bname + ", such as Apache");
384 f.WriteLine("Web Server in certain configurations, then please consult the");
385 f.WriteLine("documentation of that software and see if it mentions something about");
386 f.WriteLine("how it uses " + bname + " and how it expects it to be installed. If you find");
387 f.WriteLine("nothing, then the default installation, as described in the previous");
388 f.WriteLine("paragraph, should be suficient.");
389 f.WriteBlankLines(1);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000390 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
391 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
392 f.WriteLine("the address below.");
393 f.WriteBlankLines(1);
Daniel Veillardbeb70bd2002-12-18 14:53:54 +0000394 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000395 f.Close();
396}
397
William M. Brack6d13f332003-08-08 16:40:36 +0000398
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000399/*
400 * main(),
401 * Execution begins here.
402 */
403
404// Parse the command-line arguments.
405for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
406 var arg, opt;
407 arg = WScript.Arguments(i);
408 opt = arg.substring(0, arg.indexOf("="));
409 if (opt.length == 0)
410 opt = arg.substring(0, arg.indexOf(":"));
411 if (opt.length > 0) {
412 if (opt == "trio")
413 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
414 else if (opt == "threads")
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000415 withThreads = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000416 else if (opt == "ftp")
417 withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
418 else if (opt == "http")
419 withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
420 else if (opt == "html")
421 withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic9425ce22002-04-10 21:57:11 +0000422 else if (opt == "c14n")
423 withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000424 else if (opt == "catalog")
425 withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
426 else if (opt == "docb")
427 withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
428 else if (opt == "xpath")
429 withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
430 else if (opt == "xptr")
431 withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
432 else if (opt == "xinclude")
433 withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
434 else if (opt == "iconv")
435 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
William M. Brack6d13f332003-08-08 16:40:36 +0000436 else if (opt == "iso8859x")
437 withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000438 else if (opt == "zlib")
439 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000440 else if (opt == "xml_debug")
441 withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
442 else if (opt == "mem_debug")
443 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000444 else if (opt == "schemas")
445 withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000446 else if (opt == "regexps")
447 withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000448 else if (opt == "tree")
449 withTree = strToBool(arg.substring(opt.length + 1, arg.length));
450 else if (opt == "reader")
451 withReader = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillardea048932003-10-21 09:27:57 +0000452 else if (opt == "writer")
453 withWriter = strToBool(arg.substring(opt.length + 1, arg.length));
Daniel Veillard141310a2003-10-06 08:47:56 +0000454 else if (opt == "walker")
455 withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
456 else if (opt == "push")
457 withPush = strToBool(arg.substring(opt.length + 1, arg.length));
458 else if (opt == "valid")
459 withValid = strToBool(arg.substring(opt.length + 1, arg.length));
460 else if (opt == "sax1")
461 withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
462 else if (opt == "legacy")
463 withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
464 else if (opt == "output")
465 withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000466 else if (opt == "python")
467 withPython = strToBool(arg.substring(opt.length + 1, arg.length));
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000468 else if (opt == "compiler")
469 compiler = arg.substring(opt.length + 1, arg.length);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000470 else if (opt == "debug")
471 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
472 else if (opt == "static")
473 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
474 else if (opt == "prefix")
475 buildPrefix = arg.substring(opt.length + 1, arg.length);
476 else if (opt == "incdir")
477 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
478 else if (opt == "bindir")
479 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
480 else if (opt == "libdir")
481 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
482 else if (opt == "sodir")
483 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
484 else if (opt == "incdir")
485 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
486 else if (opt == "include")
487 buildInclude = arg.substring(opt.length + 1, arg.length);
488 else if (opt == "lib")
489 buildLib = arg.substring(opt.length + 1, arg.length);
490 else
491 error = 1;
492 } else if (i == 0) {
493 if (arg == "genreadme") {
494 // This command comes from the Makefile and will not be checked
495 // for errors, because Makefile will always supply right the parameters.
496 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
497 WScript.Quit(0);
498 } else if (arg == "help") {
499 usage();
500 WScript.Quit(0);
501 }
William M. Brack6d13f332003-08-08 16:40:36 +0000502
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000503 } else {
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000504 error = 1;
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000505 }
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000506}
507
William M. Brack6d13f332003-08-08 16:40:36 +0000508
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000509// If we fail here, it is because the user supplied an unrecognised argument.
510if (error != 0) {
511 usage();
512 WScript.Quit(error);
513}
Igor Zlatkovic01c0ced2003-08-28 10:49:25 +0000514dirSep = "\\";
515if (compiler == "mingw")
516 dirSep = "/";
517if (buildBinPrefix == "")
518 buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
519if (buildIncPrefix == "")
520 buildIncPrefix = "$(PREFIX)" + dirSep + "include";
521if (buildLibPrefix == "")
522 buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
523if (buildSoPrefix == "")
524 buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
William M. Brack6d13f332003-08-08 16:40:36 +0000525
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000526// Discover the version.
527discoverVersion();
528if (error != 0) {
529 WScript.Echo("Version discovery failed, aborting.");
530 WScript.Quit(error);
531}
William M. Brack6d13f332003-08-08 16:40:36 +0000532
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000533WScript.Echo(baseName + " version: " + verMajor + "." + verMinor + "." + verMicro);
534
535// Configure libxml.
536configureLibxml();
537if (error != 0) {
538 WScript.Echo("Configuration failed, aborting.");
539 WScript.Quit(error);
540}
William M. Brack6d13f332003-08-08 16:40:36 +0000541
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000542if (withPython == true) {
543 configureLibxmlPy();
544 if (error != 0) {
545 WScript.Echo("Configuration failed, aborting.");
546 WScript.Quit(error);
547 }
William M. Brack6d13f332003-08-08 16:40:36 +0000548
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000549}
550
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000551// Create the makefile.
552var fso = new ActiveXObject("Scripting.FileSystemObject");
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000553var makefile = ".\\Makefile.msvc";
554if (compiler == "mingw")
555 makefile = ".\\Makefile.mingw";
Igor Zlatkovice8b5b0f2003-06-16 07:12:50 +0000556else if (compiler == "bcb")
557 makefile = ".\\Makefile.bcb";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000558fso.CopyFile(makefile, ".\\Makefile", true);
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000559WScript.Echo("Created Makefile.");
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000560// Create the config.h.
561var confighsrc = "..\\include\\win32config.h";
562var configh = "..\\config.h";
563fso.CopyFile(confighsrc, configh, true);
564WScript.Echo("Created config.h.");
565
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000566
567// Display the final configuration.
568var txtOut = "\nXML processor configuration\n";
569txtOut += "---------------------------\n";
570txtOut += " Trio: " + boolToStr(withTrio) + "\n";
Igor Zlatkovic8f536a82002-10-31 16:01:00 +0000571txtOut += " Thread safety: " + withThreads + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000572txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
573txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
574txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
575txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
576txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
577txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
578txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
579txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
580txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000581txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
William M. Brack6d13f332003-08-08 16:40:36 +0000582txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
Igor Zlatkovic3acadf42002-09-20 16:40:17 +0000583txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000584txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
585txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
Igor Zlatkovic8e040972002-09-20 13:39:53 +0000586txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000587txtOut += " Tree support: " + boolToStr(withTree) + "\n";
588txtOut += " Reader support: " + boolToStr(withReader) + "\n";
Daniel Veillardea048932003-10-21 09:27:57 +0000589txtOut += " Writer support: " + boolToStr(withWriter) + "\n";
Daniel Veillard141310a2003-10-06 08:47:56 +0000590txtOut += " Walker support: " + boolToStr(withWalker) + "\n";
591txtOut += " Push support: " + boolToStr(withPush) + "\n";
592txtOut += "Validation support: " + boolToStr(withValid) + "\n";
593txtOut += " SAX1 support: " + boolToStr(withSax1) + "\n";
594txtOut += " Legacy support: " + boolToStr(withLegacy) + "\n";
595txtOut += " Output support: " + boolToStr(withOutput) + "\n";
Igor Zlatkovica6f2d902002-04-16 17:57:17 +0000596txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
Igor Zlatkovic853514f2002-11-22 21:41:09 +0000597txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000598txtOut += "\n";
599txtOut += "Win32 build configuration\n";
600txtOut += "-------------------------\n";
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000601txtOut += " Compiler: " + compiler + "\n";
Igor Zlatkovicac97f6e2002-03-24 21:00:26 +0000602txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
603txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
604txtOut += " Install prefix: " + buildPrefix + "\n";
605txtOut += " Put tools in: " + buildBinPrefix + "\n";
606txtOut += " Put headers in: " + buildIncPrefix + "\n";
607txtOut += "Put static libs in: " + buildLibPrefix + "\n";
608txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
609txtOut += " Include path: " + buildInclude + "\n";
610txtOut += " Lib path: " + buildLib + "\n";
611WScript.Echo(txtOut);
612
William M. Brack6d13f332003-08-08 16:40:36 +0000613//
614