1 /* Configure script for libxslt, specific for Windows with Scripting Host.
3 * This script will configure the libxslt build process and create necessary files.
4 * Run it with an 'help', or an invalid option and it will tell you what options
7 * March 2002, Igor Zlatkovic <igor@zlatkovic.com>
10 /* The source directory, relative to the one where this file resides. */
12 var srcDirXslt = baseDir + "\\libxslt";
13 var srcDirExslt = baseDir + "\\libexslt";
14 var srcDirUtils = baseDir + "\\xsltproc";
15 /* The directory where we put the binaries after compilation. */
16 var binDir = "binaries";
17 /* Base name of what we are building. */
18 var baseNameXslt = "libxslt";
19 var baseNameExslt = "libexslt";
20 /* Configure file which contains the version and the output file where
21 we can store our build configuration. */
22 var configFile = baseDir + "\\configure.in";
23 var versionFile = ".\\config.msvc";
24 /* Input and output files regarding the lib(e)xml features. The second
25 output file is there for the compatibility reasons, otherwise it
26 is identical to the first. */
27 var optsFileInXslt = srcDirXslt + "\\xsltconfig.h.in";
28 var optsFileXslt = srcDirXslt + "\\xsltconfig.h";
29 var optsFileInExslt = srcDirExslt + "\\exsltconfig.h.in";
30 var optsFileExslt = srcDirExslt + "\\exsltconfig.h";
31 /* Version strings for the binary distribution. Will be filled later
41 /* Libxslt features. */
43 var withXsltDebug = true;
44 var withMemDebug = false;
45 var withDebugger = true;
48 var withCrypto = true;
49 var withModules = false;
50 var withLocale = true;
51 /* Win32 build options. */
53 var compiler = "msvc";
55 var vcmanifest = false;
58 var buildPrefix = ".";
59 var buildBinPrefix = "";
60 var buildIncPrefix = "";
61 var buildLibPrefix = "";
62 var buildSoPrefix = "";
63 var buildInclude = ".";
68 /* Helper function, transforms the option variable into the 'Enabled'
69 or 'Disabled' string. */
70 function boolToStr(opt)
77 return "*** undefined ***";
80 /* Helper function, transforms the argument string into the boolean
82 function strToBool(opt)
84 if (opt == "0" || opt == "no")
86 else if (opt == "1" || opt == "yes")
92 /* Displays the details about how to use this script. */
97 txt += " cscript " + WScript.ScriptName + " <options>\n";
98 txt += " cscript " + WScript.ScriptName + " help\n\n";
99 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
100 txt += "either 'yes' or 'no'.\n\n";
101 txt += "XSLT processor options, default value given in parentheses:\n\n";
102 txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
103 txt += " xslt_debug: Enable XSLT debbugging module (" + (withXsltDebug? "yes" : "no") + ")\n";
104 txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
105 txt += " debugger: Enable external debugger support (" + (withDebugger? "yes" : "no") + ")\n";
106 txt += " iconv: Use iconv library (" + (withIconv? "yes" : "no") + ")\n";
107 txt += " zlib: Use zlib library (" + (withZlib? "yes" : "no") + ")\n";
108 txt += " crypto: Enable Crypto support (" + (withCrypto? "yes" : "no") + ")\n";
109 txt += " modules: Enable Module support (" + (withModules? "yes" : "no") + ")\n";
110 txt += " locale: Enable Locale support, requires unicode OS support (" + (withLocale? "yes" : "no") + ")\n";
111 txt += "\nWin32 build options, default value given in parentheses:\n\n";
112 txt += " compiler: Compiler to be used [msvc|mingw] (" + compiler + ")\n";
113 txt += " cruntime: C-runtime compiler option (only msvc) (" + cruntime + ")\n";
114 txt += " vcmanifest: Embed VC manifest (only msvc) (" + (vcmanifest? "yes" : "no") + ")\n";
115 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
116 txt += " static: Link xsltproc statically to libxslt (" + (buildStatic? "yes" : "no") + ")\n";
117 txt += " Note: automatically enabled if cruntime is not /MD or /MDd\n";
118 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
119 txt += " bindir: Directory where xsltproc and friends should be installed\n";
120 txt += " (" + buildBinPrefix + ")\n";
121 txt += " incdir: Directory where headers should be installed\n";
122 txt += " (" + buildIncPrefix + ")\n";
123 txt += " libdir: Directory where static and import libraries should be\n";
124 txt += " installed (" + buildLibPrefix + ")\n";
125 txt += " sodir: Directory where shared libraries should be installed\n";
126 txt += " (" + buildSoPrefix + ")\n";
127 txt += " include: Additional search path for the compiler, particularily\n";
128 txt += " where libxml headers can be found (" + buildInclude + ")\n";
129 txt += " lib: Additional search path for the linker, particularily\n";
130 txt += " where libxml library can be found (" + buildLib + ")\n";
134 /* Discovers the version we are working with by reading the apropriate
135 configuration file. Despite its name, this also writes the configuration
136 file included by our makefile. */
137 function discoverVersion()
139 var fso, cf, vf, ln, s;
140 fso = new ActiveXObject("Scripting.FileSystemObject");
142 if (useCvsVer && fso.FileExists("..\\CVS\\Entries")) {
143 cf = fso.OpenTextFile("..\\CVS\\Entries", 1);
144 while (cf.AtEndOfStream != true) {
147 if (s.search(/^\/ChangeLog\//) != -1) {
148 iDot = s.indexOf(".");
149 iSlash = s.indexOf("/", iDot);
150 verCvs = "CVS" + s.substring(iDot + 1, iSlash);
156 cf = fso.OpenTextFile(configFile, 1);
157 if (compiler == "msvc")
158 versionFile = ".\\config.msvc";
159 else if (compiler == "mingw")
160 versionFile = ".\\config.mingw";
161 vf = fso.CreateTextFile(versionFile, true);
162 vf.WriteLine("# " + versionFile);
163 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
164 vf.WriteBlankLines(1);
165 while (cf.AtEndOfStream != true) {
168 if (s.search(/^LIBXSLT_MAJOR_VERSION=/) != -1) {
170 verMajorXslt = s.substring(s.indexOf("=") + 1, s.length)
171 } else if(s.search(/^LIBXSLT_MINOR_VERSION=/) != -1) {
173 verMinorXslt = s.substring(s.indexOf("=") + 1, s.length)
174 } else if(s.search(/^LIBXSLT_MICRO_VERSION=/) != -1) {
176 verMicroXslt = s.substring(s.indexOf("=") + 1, s.length)
177 } else if (s.search(/^LIBEXSLT_MAJOR_VERSION=/) != -1) {
179 verMajorExslt = s.substring(s.indexOf("=") + 1, s.length)
180 } else if(s.search(/^LIBEXSLT_MINOR_VERSION=/) != -1) {
182 verMinorExslt = s.substring(s.indexOf("=") + 1, s.length)
183 } else if(s.search(/^LIBEXSLT_MICRO_VERSION=/) != -1) {
185 verMicroExslt = s.substring(s.indexOf("=") + 1, s.length)
189 vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
190 vf.WriteLine("WITH_DEBUG=" + (withXsltDebug? "1" : "0"));
191 vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
192 vf.WriteLine("WITH_DEBUGGER=" + (withDebugger? "1" : "0"));
193 vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
194 vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
195 vf.WriteLine("WITH_CRYPTO=" + (withCrypto? "1" : "0"));
196 vf.WriteLine("WITH_MODULES=" + (withModules? "1" : "0"));
197 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
198 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
199 vf.WriteLine("PREFIX=" + buildPrefix);
200 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
201 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
202 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
203 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
204 if (compiler == "msvc") {
205 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
206 vf.WriteLine("LIB=$(LIB);" + buildLib);
207 vf.WriteLine("CRUNTIME=" + cruntime);
208 vf.WriteLine("VCMANIFEST=" + (vcmanifest? "1" : "0"));
209 } else if (compiler == "mingw") {
210 vf.WriteLine("INCLUDE+=;" + buildInclude);
211 vf.WriteLine("LIB+=;" + buildLib);
216 /* Configures libxslt. This one will generate xsltconfig.h from xsltconfig.h.in
217 taking what the user passed on the command line into account. */
218 function configureXslt()
220 var fso, ofi, of, ln, s;
221 fso = new ActiveXObject("Scripting.FileSystemObject");
222 ofi = fso.OpenTextFile(optsFileInXslt, 1);
223 of = fso.CreateTextFile(optsFileXslt, true);
224 while (ofi.AtEndOfStream != true) {
227 if (s.search(/\@VERSION\@/) != -1) {
228 of.WriteLine(s.replace(/\@VERSION\@/,
229 verMajorXslt + "." + verMinorXslt + "." + verMicroXslt));
230 } else if (s.search(/\@LIBXSLT_VERSION_NUMBER\@/) != -1) {
231 of.WriteLine(s.replace(/\@LIBXSLT_VERSION_NUMBER\@/,
232 verMajorXslt*10000 + verMinorXslt*100 + verMicroXslt*1));
233 } else if (s.search(/\@LIBXSLT_VERSION_EXTRA\@/) != -1) {
234 of.WriteLine(s.replace(/\@LIBXSLT_VERSION_EXTRA\@/, verCvs));
235 } else if (s.search(/\@WITH_TRIO\@/) != -1) {
236 of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
237 } else if (s.search(/\@WITH_XSLT_DEBUG\@/) != -1) {
238 of.WriteLine(s.replace(/\@WITH_XSLT_DEBUG\@/, withXsltDebug? "1" : "0"));
239 } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
240 of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
241 } else if (s.search(/\@WITH_DEBUGGER\@/) != -1) {
242 of.WriteLine(s.replace(/\@WITH_DEBUGGER\@/, withDebugger? "1" : "0"));
243 } else if (s.search(/\@WITH_MODULES\@/) != -1) {
244 of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0"));
245 } else if (s.search(/\@XSLT_LOCALE_XLOCALE\@/) != -1) {
246 of.WriteLine(s.replace(/\@XSLT_LOCALE_XLOCALE\@/, "0"));
247 } else if (s.search(/\@XSLT_LOCALE_WINAPI\@/) != -1) {
248 of.WriteLine(s.replace(/\@XSLT_LOCALE_WINAPI\@/, withLocale? "1" : "0"));
249 } else if (s.search(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/) != -1) {
250 of.WriteLine(s.replace(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/, "NULL"));
258 /* Configures libexslt. This one will generate exsltconfig.h from exsltconfig.h.in
259 taking what the user passed on the command line into account. */
260 function configureExslt()
262 var fso, ofi, of, ln, s;
263 fso = new ActiveXObject("Scripting.FileSystemObject");
264 ofi = fso.OpenTextFile(optsFileInExslt, 1);
265 of = fso.CreateTextFile(optsFileExslt, true);
266 while (ofi.AtEndOfStream != true) {
269 if (s.search(/\@VERSION\@/) != -1) {
270 of.WriteLine(s.replace(/\@VERSION\@/,
271 verMajorExslt + "." + verMinorExslt + "." + verMicroExslt));
272 } else if (s.search(/\@LIBEXSLT_VERSION_NUMBER\@/) != -1) {
273 of.WriteLine(s.replace(/\@LIBEXSLT_VERSION_NUMBER\@/,
274 verMajorExslt*10000 + verMinorExslt*100 + verMicroExslt*1));
275 } else if (s.search(/\@LIBEXSLT_VERSION_EXTRA\@/) != -1) {
276 of.WriteLine(s.replace(/\@LIBEXSLT_VERSION_EXTRA\@/, verCvs));
277 } else if (s.search(/\@WITH_CRYPTO\@/) != -1) {
278 of.WriteLine(s.replace(/\@WITH_CRYPTO\@/, withCrypto? "1" : "0"));
279 } else if (s.search(/\@WITH_MODULES\@/) != -1) {
280 of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0"));
288 /* Creates the readme file for the binary distribution of 'bname', for the
289 version 'ver' in the file 'file'. This one is called from the Makefile when
290 generating a binary distribution. The parameters are passed by make. */
291 function genReadme(bname, ver, file)
294 fso = new ActiveXObject("Scripting.FileSystemObject");
295 f = fso.CreateTextFile(file, true);
296 f.WriteLine(" " + bname + " " + ver);
297 f.WriteLine(" --------------");
298 f.WriteBlankLines(1);
299 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
300 f.WriteLine("platform.");
301 f.WriteBlankLines(1);
302 f.WriteLine(" The files in this package do not require any special installation");
303 f.WriteLine("steps. Extract the contents of the archive whereever you wish and");
304 f.WriteLine("make sure that your tools which use " + bname + " can find it.");
305 f.WriteBlankLines(1);
306 f.WriteLine(" For example, if you want to run the supplied utilities from the command");
307 f.WriteLine("line, you can, if you wish, add the 'bin' subdirectory to the PATH");
308 f.WriteLine("environment variable.");
309 f.WriteLine(" If you want to make programmes in C which use " + bname + ", you'll");
310 f.WriteLine("likely know how to use the contents of this package. If you don't, please");
311 f.WriteLine("refer to your compiler's documentation.");
312 f.WriteBlankLines(1);
313 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
314 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
315 f.WriteLine("the address below.");
316 f.WriteBlankLines(1);
317 f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
323 * Execution begins here.
326 /* Parse the command-line arguments. */
327 for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
329 arg = WScript.Arguments(i);
330 opt = arg.substring(0, arg.indexOf("="));
332 opt = arg.substring(0, arg.indexOf(":"));
333 if (opt.length > 0) {
334 if (opt == "xslt_debug")
335 withXsltDebug = strToBool(arg.substring(opt.length + 1, arg.length));
336 else if (opt == "trio")
337 withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
338 else if (opt == "mem_debug")
339 withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
340 else if (opt == "debugger")
341 withDebugger = strToBool(arg.substring(opt.length + 1, arg.length));
342 else if (opt == "debug")
343 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
344 else if (opt == "iconv")
345 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
346 else if (opt == "zlib")
347 withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
348 else if (opt == "crypto")
349 withCrypto = strToBool(arg.substring(opt.length + 1, arg.length));
350 else if (opt == "modules")
351 withModules = strToBool(arg.substring(opt.length + 1, arg.length));
352 else if (opt == "locale")
353 withLocale = strToBool(arg.substring(opt.length + 1, arg.length));
354 else if (opt == "compiler")
355 compiler = arg.substring(opt.length + 1, arg.length);
356 else if (opt == "cruntime")
357 cruntime = arg.substring(opt.length + 1, arg.length);
358 else if (opt == "vcmanifest")
359 vcmanifest = strToBool(arg.substring(opt.length + 1, arg.length));
360 else if (opt == "static")
361 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
362 else if (opt == "prefix")
363 buildPrefix = arg.substring(opt.length + 1, arg.length);
364 else if (opt == "incdir")
365 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
366 else if (opt == "bindir")
367 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
368 else if (opt == "libdir")
369 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
370 else if (opt == "sodir")
371 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
372 else if (opt == "incdir")
373 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
374 else if (opt == "include")
375 buildInclude = arg.substring(opt.length + 1, arg.length);
376 else if (opt == "lib")
377 buildLib = arg.substring(opt.length + 1, arg.length);
378 else if (opt == "release")
383 if (arg == "genreadme") {
384 // This command comes from the Makefile and will not be checked
385 // for errors, because Makefile will always supply right parameters.
386 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
388 } else if (arg == "help") {
395 // If we have an error here, it is because the user supplied bad parameters.
401 // if user choses to link the c-runtime library statically into libxslt
402 // with /MT and friends, then we need to enable static linking for xsltproc
403 if (cruntime == "/MT" || cruntime == "/MTd" ||
404 cruntime == "/ML" || cruntime == "/MLd") {
408 if (buildStatic == 1 && withModules == 1) {
409 WScript.Echo("Warning: Disabling plugin support.");
411 WScript.Echo("Modules cannot be enabled when a statically linked cruntime has");
412 WScript.Echo("been selected, or when xsltproc.exe is linked statically to libxslt.");
418 //if (compiler == "mingw")
420 if (buildBinPrefix == "")
421 buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
422 if (buildIncPrefix == "")
423 buildIncPrefix = "$(PREFIX)" + dirSep + "include";
424 if (buildLibPrefix == "")
425 buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
426 if (buildSoPrefix == "")
427 buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
429 // Discover the version.
432 WScript.Echo("Version discovery failed, aborting.");
436 var outVerString = baseNameXslt + " version: " + verMajorXslt + "." + verMinorXslt + "." + verMicroXslt;
437 if (verCvs && verCvs != "")
438 outVerString += "-" + verCvs;
439 WScript.Echo(outVerString);
440 outVerString = baseNameExslt + " version: " + verMajorExslt + "." + verMinorExslt + "." + verMicroExslt;
441 if (verCvs && verCvs != "")
442 outVerString += "-" + verCvs;
443 WScript.Echo(outVerString);
445 // Configure libxslt.
448 WScript.Echo("Configuration failed, aborting.");
452 // Configure libexslt.
455 WScript.Echo("Configuration failed, aborting.");
459 // Create the Makefile.
460 var fso = new ActiveXObject("Scripting.FileSystemObject");
461 var makefile = ".\\Makefile.msvc";
462 if (compiler == "mingw")
463 makefile = ".\\Makefile.mingw";
464 fso.CopyFile(makefile, ".\\Makefile", true);
465 WScript.Echo("Created Makefile.");
466 // Create the config.h.
467 var confighsrc = "..\\libxslt\\win32config.h";
468 var configh = "..\\config.h";
469 var f = fso.FileExists(configh);
471 var t = fso.GetFile(configh);
474 fso.CopyFile(confighsrc, configh, true);
475 WScript.Echo("Created config.h.");
477 // Display the final configuration.
478 var txtOut = "\nXSLT processor configuration\n";
479 txtOut += "----------------------------\n";
480 txtOut += " Trio: " + boolToStr(withTrio) + "\n";
481 txtOut += " Debugging module: " + boolToStr(withXsltDebug) + "\n";
482 txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
483 txtOut += " Debugger support: " + boolToStr(withDebugger) + "\n";
484 txtOut += " Use iconv: " + boolToStr(withIconv) + "\n";
485 txtOut += " With zlib: " + boolToStr(withZlib) + "\n";
486 txtOut += " Crypto: " + boolToStr(withCrypto) + "\n";
487 txtOut += " Modules: " + boolToStr(withModules) + "\n";
488 txtOut += " Locale: " + boolToStr(withLocale) + "\n";
490 txtOut += "Win32 build configuration\n";
491 txtOut += "-------------------------\n";
492 txtOut += " Compiler: " + compiler + "\n";
493 if (compiler == "msvc")
494 txtOut += " C-Runtime option: " + cruntime + "\n";
495 txtOut += " Embed Manifest: " + boolToStr(vcmanifest) + "\n";
496 txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
497 txtOut += " Static xsltproc: " + boolToStr(buildStatic) + "\n";
498 txtOut += " Install prefix: " + buildPrefix + "\n";
499 txtOut += " Put tools in: " + buildBinPrefix + "\n";
500 txtOut += " Put headers in: " + buildIncPrefix + "\n";
501 txtOut += "Put static libs in: " + buildLibPrefix + "\n";
502 txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
503 txtOut += " Include path: " + buildInclude + "\n";
504 txtOut += " Lib path: " + buildLib + "\n";
505 WScript.Echo(txtOut);