1 /* Configure script for xmlsec, specific for Windows with Scripting Host.
3 * This script will configure the libxmlsec 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@stud.fh-frankfurt.de>
8 * Created for LibXML and LibXSLT
9 * April 2002, Aleksey Sanin <aleksey@aleksey.com>
10 * Modified for XMLSec Libary
13 /* The source directory, relative to the one where this file resides. */
15 var srcDir = baseDir + "\\src";
16 var srcDirApps = baseDir + "\\apps";
17 /* The directory where we put the binaries after compilation. */
18 var binDir = "binaries";
19 /* Base name of what we are building. */
20 var baseName = "libxmlsec";
22 /* Configure file which contains the version and the output file where
23 we can store our build configuration. */
24 var configFile = baseDir + "\\configure.in";
25 var versionFile = ".\\configure.txt";
27 /* Input and output files regarding the lib(e)xml features. The second
28 output file is there for the compatibility reasons, otherwise it
29 is identical to the first. */
30 var optsFileIn = baseDir + "\\config.h.in";
31 var optsFile = baseDir + "\\config.h";
33 /* Version strings for the binary distribution. Will be filled later
39 /* Libxmlsec features. */
40 var withCrypto = "openssl";
41 var withDefaultCrypto = "openssl";
43 var withOpenSSLVersion = "";
50 /* Win32 build options. */
53 var buildWithDLSupport = 1;
54 var buildPrefix = ".";
55 var buildBinPrefix = "$(PREFIX)\\bin";
56 var buildIncPrefix = "$(PREFIX)\\include";
57 var buildLibPrefix = "$(PREFIX)\\lib";
58 var buildSoPrefix = "$(PREFIX)\\lib";
59 var buildInclude = ".";
64 /* Helper function, transforms the option variable into the 'Enabled'
65 or 'Disabled' string. */
66 function boolToStr(opt)
76 /* Helper function, transforms the argument string into the boolean
78 function strToBool(opt)
80 if (opt == "0" || opt == "no")
82 else if (opt == "1" || opt == "yes")
88 /* Displays the details about how to use this script. */
93 txt += " cscript " + WScript.ScriptName + " <options>\n";
94 txt += " cscript " + WScript.ScriptName + " help\n\n";
95 txt += "Options can be specified in the form <option>=<value>, where the value is\n";
96 txt += "either 'yes' or 'no'.\n\n";
97 txt += "XmlSec Library options, default value given in parentheses:\n\n";
98 txt += " crypto: Crypto engines list, first is default: \"openssl\",\n";
99 txt += " \"openssl=096\", \"openssl=097\", \"openssl=098\", \n";
100 txt += " \"nss\", \"mscrypto\" (\"" + withCrypto + "\");\n"
101 txt += " xslt: LibXSLT is used (" + (withLibXSLT? "yes" : "no") + ")\n";
102 txt += " iconv: Use the iconv library (" + (withIconv? "yes" : "no") + ")\n";
103 txt += " nt4: Enable NT 4.0 support (" + (withNT4? "yes" : "no") + ")\n";
104 txt += "\nWin32 build options, default value given in parentheses:\n\n";
105 txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
106 txt += " static: Link libxmlsec statically to xmlsec (" + (buildStatic? "yes" : "no") + ")\n";
107 txt += " with-dl: Enable dynamic loading of xmlsec-crypto libraries (" + (buildWithDLSupport? "yes" : "no") + ")\n";
108 txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
109 txt += " bindir: Directory where xmlsec and friends should be installed\n";
110 txt += " (" + buildBinPrefix + ")\n";
111 txt += " incdir: Directory where headers should be installed\n";
112 txt += " (" + buildIncPrefix + ")\n";
113 txt += " libdir: Directory where static and import libraries should be\n";
114 txt += " installed (" + buildLibPrefix + ")\n";
115 txt += " sodir: Directory where shared libraries should be installed\n";
116 txt += " (" + buildSoPrefix + ")\n";
117 txt += " include: Additional search path for the compiler, particularily\n";
118 txt += " where libxml headers can be found (" + buildInclude + ")\n";
119 txt += " lib: Additional search path for the linker, particularily\n";
120 txt += " where libxml library can be found (" + buildLib + ")\n";
124 /* Discovers the version we are working with by reading the apropriate
125 configuration file. Despite its name, this also writes the configuration
126 file included by our makefile. */
127 function discoverVersion()
129 var fso, cf, vf, ln, s;
131 fso = new ActiveXObject("Scripting.FileSystemObject");
132 cf = fso.OpenTextFile(configFile, 1);
133 vf = fso.CreateTextFile(versionFile, true);
134 vf.WriteLine("# " + versionFile);
135 vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
136 vf.WriteBlankLines(1);
137 while (cf.AtEndOfStream != true) {
140 if (s.search(/^XMLSEC_VERSION_MAJOR/) != -1) {
141 WScript.Echo(verMajorXmlSec);
143 verMajorXmlSec = s.substring(s.indexOf("=") + 1, s.length)
144 } else if(s.search(/^XMLSEC_VERSION_MINOR/) != -1) {
146 verMinorXmlSec = s.substring(s.indexOf("=") + 1, s.length)
147 } else if(s.search(/^XMLSEC_VERSION_SUBMINOR/) != -1) {
149 verMicroXmlSec = s.substring(s.indexOf("=") + 1, s.length)
153 vf.WriteLine("BASEDIR=" + baseDir);
154 vf.WriteLine("XMLSEC_SRCDIR=" + srcDir);
155 vf.WriteLine("APPS_SRCDIR=" + srcDirApps);
156 vf.WriteLine("BINDIR=" + binDir);
157 vf.WriteLine("WITH_CRYPTO=" + withCrypto);
158 vf.WriteLine("WITH_DEFAULT_CRYPTO=" + withDefaultCrypto);
159 vf.WriteLine("WITH_OPENSSL=" + withOpenSSL);
160 vf.WriteLine("WITH_OPENSSL_VERSION=" + withOpenSSLVersion);
161 vf.WriteLine("WITH_NSS=" + withNss);
162 vf.WriteLine("WITH_MSCRYPTO=" + withMSCrypto);
163 vf.WriteLine("WITH_LIBXSLT=" + (withLibXSLT ? "1" : "0"));
164 vf.WriteLine("WITH_ICONV=" + (withIconv ? "1" : "0"));
165 vf.WriteLine("WITH_NT4=" + (withNT4 ? "1" : "0"));
166 vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
167 vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
168 vf.WriteLine("WITH_DL=" + (buildWithDLSupport ? "1" : "0"));
169 vf.WriteLine("PREFIX=" + buildPrefix);
170 vf.WriteLine("BINPREFIX=" + buildBinPrefix);
171 vf.WriteLine("INCPREFIX=" + buildIncPrefix);
172 vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
173 vf.WriteLine("SOPREFIX=" + buildSoPrefix);
174 vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
175 vf.WriteLine("LIB=$(LIB);" + buildLib);
179 /* Configures xmlsec. This one will generate config.h from config.h.in
180 taking what the user passed on the command line into account. */
181 function configureXmlSec()
183 var fso, ofi, of, ln, s;
184 fso = new ActiveXObject("Scripting.FileSystemObject");
185 ofi = fso.OpenTextFile(optsFileIn, 1);
186 of = fso.CreateTextFile(optsFile, true);
187 while (ofi.AtEndOfStream != true) {
190 if (s.search(/\@VERSION\@/) != -1) {
191 of.WriteLine(s.replace(/\@VERSION\@/,
192 verMajorXmlSec + "." + verMinorXmlSec + "." + verMicroXmlSec));
193 } else if (s.search(/\@XMLSECVERSION_NUMBER\@/) != -1) {
194 of.WriteLine(s.replace(/\@XMLSECVERSION_NUMBER\@/,
195 verMajorXmlSec*10000 + verMinorXmlSec*100 + verMicroXmlSec*1));
203 /* Creates the readme file for the binary distribution of 'bname', for the
204 version 'ver' in the file 'file'. This one is called from the Makefile when
205 generating a binary distribution. The parameters are passed by make. */
206 function genReadme(bname, ver, file)
209 fso = new ActiveXObject("Scripting.FileSystemObject");
210 f = fso.CreateTextFile(file, true);
211 f.WriteLine(" " + bname + " " + ver);
212 f.WriteLine(" --------------");
213 f.WriteBlankLines(1);
214 f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
215 f.WriteLine("platform.");
216 f.WriteBlankLines(1);
217 f.WriteLine(" The files in this package do not require any special installation");
218 f.WriteLine("steps. Extract the contents of the archive whereever you wish and");
219 f.WriteLine("make sure that your tools which use " + bname + " can find it.");
220 f.WriteBlankLines(1);
221 f.WriteLine(" For example, if you want to run the supplied utilities from the command");
222 f.WriteLine("line, you can, if you wish, add the 'bin' subdirectory to the PATH");
223 f.WriteLine("environment variable.");
224 f.WriteLine(" If you want to make programmes in C which use " + bname + ", you'll");
225 f.WriteLine("likely know how to use the contents of this package. If you don't, please");
226 f.WriteLine("refer to your compiler's documentation.");
227 f.WriteBlankLines(1);
228 f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
229 f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
230 f.WriteLine("the address below.");
231 f.WriteBlankLines(1);
232 f.WriteLine("Igor Zlatkovic (igor@zlatkovic.com)");
238 * Execution begins here.
241 /* Parse the command-line arguments. */
242 for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
244 arg = WScript.Arguments(i);
245 opt = arg.substring(0, arg.indexOf("="));
247 opt = arg.substring(0, arg.indexOf(":"));
248 if (opt.length > 0) {
250 withCrypto = arg.substring(opt.length + 1, arg.length);
251 else if (opt == "xslt")
252 withLibXSLT = strToBool(arg.substring(opt.length + 1, arg.length));
253 else if (opt == "iconv")
254 withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
255 else if (opt == "nt4")
256 withNT4 = strToBool(arg.substring(opt.length + 1, arg.length));
257 else if (opt == "debug")
258 buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
259 else if (opt == "static")
260 buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
261 else if (opt == "with-dl")
262 buildWithDLSupport = strToBool(arg.substring(opt.length + 1, arg.length));
263 else if (opt == "prefix")
264 buildPrefix = arg.substring(opt.length + 1, arg.length);
265 else if (opt == "incdir")
266 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
267 else if (opt == "bindir")
268 buildBinPrefix = arg.substring(opt.length + 1, arg.length);
269 else if (opt == "libdir")
270 buildLibPrefix = arg.substring(opt.length + 1, arg.length);
271 else if (opt == "sodir")
272 buildSoPrefix = arg.substring(opt.length + 1, arg.length);
273 else if (opt == "incdir")
274 buildIncPrefix = arg.substring(opt.length + 1, arg.length);
275 else if (opt == "include")
276 buildInclude = arg.substring(opt.length + 1, arg.length);
277 else if (opt == "lib")
278 buildLib = arg.substring(opt.length + 1, arg.length);
282 if (arg == "genreadme") {
283 // This command comes from the Makefile and will not be checked
284 // for errors, because Makefile will always supply right parameters.
285 genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
287 } else if (arg == "help") {
294 // If we have an error here, it is because the user supplied bad parameters.
300 // Discover crypto support
301 var crlist, j, curcrypto;
302 crlist = withCrypto.split(",");
304 withDefaultCrypto = "";
305 for (j = 0; j < crlist.length; j++) {
306 if (crlist[j] == "openssl") {
309 withOpenSSLVersion = "XMLSEC_OPENSSL_098"; /* default */
310 } else if (crlist[j] == "openssl=096") {
313 withOpenSSLVersion = "XMLSEC_OPENSSL_096";
314 } else if (crlist[j] == "openssl=097") {
317 withOpenSSLVersion = "XMLSEC_OPENSSL_097";
318 } else if (crlist[j] == "openssl=098") {
321 withOpenSSLVersion = "XMLSEC_OPENSSL_098";
322 } else if (crlist[j] == "nss") {
325 } else if (crlist[j] == "mscrypto") {
326 curcrypto="mscrypto";
329 WScript.Echo("Unknown crypto engine \"" + crlist[j] + "\" is found. Aborting.");
333 withDefaultCrypto = curcrypto;
334 withCrypto = curcrypto;
336 withCrypto = withCrypto + " " + curcrypto;
340 // Discover the version.
343 WScript.Echo("Version discovery failed, aborting.");
346 WScript.Echo(baseName + " version: " + verMajorXmlSec + "." + verMinorXmlSec + "." + verMicroXmlSec);
349 // Configure libxmlsec.
352 WScript.Echo("Configuration failed, aborting.");
357 // Create the Makefile.
358 var fso = new ActiveXObject("Scripting.FileSystemObject");
359 fso.CopyFile(".\\Makefile.msvc", ".\\Makefile", true);
360 WScript.Echo("Created Makefile.");
362 // Display the final configuration.
363 var txtOut = "\nXMLSEC configuration\n";
364 txtOut += "----------------------------\n";
365 txtOut += " Use Crypto: " + withCrypto + "\n";
366 txtOut += " Use Default Crypto: " + withDefaultCrypto + "\n";
367 txtOut += " Use OpenSSL: " + boolToStr(withOpenSSL) + "\n";
368 txtOut += "Use OpenSSL Version: " + boolToStr(withOpenSSLVersion) + "\n";
369 txtOut += " Use NSS: " + boolToStr(withNss) + "\n";
370 txtOut += " Use MSCrypto: " + boolToStr(withMSCrypto) + "\n";
371 txtOut += " Use LibXSLT: " + boolToStr(withLibXSLT) + "\n";
372 txtOut += " Use iconv: " + boolToStr(withIconv) + "\n";
373 txtOut += " NT 4.0 support: " + boolToStr(withNT4) + "\n";
375 txtOut += "Win32 build configuration\n";
376 txtOut += "-------------------------\n";
377 txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
378 txtOut += " Static xmlsec: " + boolToStr(buildStatic) + "\n";
379 txtOut += " Enable DL suport: " + boolToStr(buildWithDLSupport) + "\n";
380 txtOut += " Install prefix: " + buildPrefix + "\n";
381 txtOut += " Put tools in: " + buildBinPrefix + "\n";
382 txtOut += " Put headers in: " + buildIncPrefix + "\n";
383 txtOut += "Put static libs in: " + buildLibPrefix + "\n";
384 txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
385 txtOut += " Include path: " + buildInclude + "\n";
386 txtOut += " Lib path: " + buildLib + "\n";
387 WScript.Echo(txtOut);