configure.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. /* 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. *
  7. * March 2002, Igor Zlatkovic <igor@zlatkovic.com>
  8. */
  9. /* The source directory, relative to the one where this file resides. */
  10. var srcDirXml = "..";
  11. var srcDirUtils = "..";
  12. /* Base name of what we are building. */
  13. var baseName = "libxml2";
  14. /* Configure file which contains the version and the output file where
  15. we can store our build configuration. */
  16. var configFile = srcDirXml + "\\configure.in";
  17. var versionFile = ".\\config.msvc";
  18. /* Input and output files regarding the libxml features. */
  19. var optsFileIn = srcDirXml + "\\include\\libxml\\xmlversion.h.in";
  20. var optsFile = srcDirXml + "\\include\\libxml\\xmlversion.h";
  21. /* Version strings for the binary distribution. Will be filled later
  22. in the code. */
  23. var verMajor;
  24. var verMinor;
  25. var verMicro;
  26. var verMicroSuffix;
  27. var verCvs;
  28. var useCvsVer = true;
  29. /* Libxml features. */
  30. var withTrio = false;
  31. var withThreads = "native";
  32. var withFtp = true;
  33. var withHttp = true;
  34. var withHtml = true;
  35. var withC14n = true;
  36. var withCatalog = true;
  37. var withDocb = true;
  38. var withXpath = true;
  39. var withXptr = true;
  40. var withXinclude = true;
  41. var withIconv = true;
  42. var withIso8859x = false;
  43. var withZlib = false;
  44. var withDebug = true;
  45. var withMemDebug = false;
  46. var withRunDebug = false;
  47. var withSchemas = true;
  48. var withSchematron = true;
  49. var withRegExps = true;
  50. var withModules = true;
  51. var withTree = true;
  52. var withReader = true;
  53. var withWriter = true;
  54. var withWalker = true;
  55. var withPattern = true;
  56. var withPush = true;
  57. var withValid = true;
  58. var withSax1 = true;
  59. var withLegacy = true;
  60. var withOutput = true;
  61. var withPython = false;
  62. /* Win32 build options. */
  63. var dirSep = "\\";
  64. var compiler = "msvc";
  65. var cruntime = "/MD";
  66. var dynruntime = true;
  67. var vcmanifest = false;
  68. var buildDebug = 0;
  69. var buildStatic = 0;
  70. var buildPrefix = ".";
  71. var buildBinPrefix = "";
  72. var buildIncPrefix = "";
  73. var buildLibPrefix = "";
  74. var buildSoPrefix = "";
  75. var buildInclude = ".";
  76. var buildLib = ".";
  77. /* Local stuff */
  78. var error = 0;
  79. /* Helper function, transforms the option variable into the 'Enabled'
  80. or 'Disabled' string. */
  81. function boolToStr(opt)
  82. {
  83. if (opt == false)
  84. return "no";
  85. else if (opt == true)
  86. return "yes";
  87. error = 1;
  88. return "*** undefined ***";
  89. }
  90. /* Helper function, transforms the argument string into a boolean
  91. value. */
  92. function strToBool(opt)
  93. {
  94. if (opt == 0 || opt == "no")
  95. return false;
  96. else if (opt == 1 || opt == "yes")
  97. return true;
  98. error = 1;
  99. return false;
  100. }
  101. /* Displays the details about how to use this script. */
  102. function 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";
  109. txt += "either 'yes' or 'no', if not stated otherwise.\n\n";
  110. txt += "\nXML processor options, default value given in parentheses:\n\n";
  111. txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n";
  112. txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n";
  113. 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";
  122. txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
  123. txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n";
  124. txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n";
  125. txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n";
  126. txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n";
  127. txt += " run_debug: Enable memory debugger (" + (withRunDebug? "yes" : "no") + ")\n";
  128. txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n";
  129. txt += " modules: Enable module support (" + (withModules? "yes" : "no") + ")\n";
  130. txt += " tree: Enable tree api (" + (withTree? "yes" : "no") + ")\n";
  131. txt += " reader: Enable xmlReader api (" + (withReader? "yes" : "no") + ")\n";
  132. txt += " writer: Enable xmlWriter api (" + (withWriter? "yes" : "no") + ")\n";
  133. txt += " walker: Enable xmlDocWalker api (" + (withWalker? "yes" : "no") + ")\n";
  134. txt += " pattern: Enable xmlPattern api (" + (withPattern? "yes" : "no") + ")\n";
  135. txt += " push: Enable push api (" + (withPush? "yes" : "no") + ")\n";
  136. txt += " valid: Enable DTD validation support (" + (withValid? "yes" : "no") + ")\n";
  137. txt += " sax1: Enable SAX1 api (" + (withSax1? "yes" : "no") + ")\n";
  138. txt += " legacy: Enable Deprecated api's (" + (withLegacy? "yes" : "no") + ")\n";
  139. txt += " output: Enable serialization support (" + (withOutput? "yes" : "no") + ")\n";
  140. txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n";
  141. txt += " schematron: Enable Schematron support (" + (withSchematron? "yes" : "no") + ")\n";
  142. txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n";
  143. txt += "\nWin32 build options, default value given in parentheses:\n\n";
  144. txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n";
  145. txt += " cruntime: C-runtime compiler option (only msvc) (" + cruntime + ")\n";
  146. txt += " dynruntime: Use the dynamic RTL (only bcb) (" + dynruntime + ")\n";
  147. txt += " vcmanifest: Embed VC manifest (only msvc) (" + (vcmanifest? "yes" : "no") + ")\n";
  148. txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n";
  149. txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n";
  150. txt += " Note: automatically enabled if cruntime is not /MD or /MDd\n";
  151. txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n";
  152. txt += " bindir: Directory where xmllint and friends should be installed\n";
  153. txt += " (" + buildBinPrefix + ")\n";
  154. txt += " incdir: Directory where headers should be installed\n";
  155. txt += " (" + buildIncPrefix + ")\n";
  156. txt += " libdir: Directory where static and import libraries should be\n";
  157. txt += " installed (" + buildLibPrefix + ")\n";
  158. txt += " sodir: Directory where shared libraries should be installed\n";
  159. txt += " (" + buildSoPrefix + ")\n";
  160. txt += " include: Additional search path for the compiler, particularily\n";
  161. txt += " where iconv headers can be found (" + buildInclude + ")\n";
  162. txt += " lib: Additional search path for the linker, particularily\n";
  163. txt += " where iconv library can be found (" + buildLib + ")\n";
  164. WScript.Echo(txt);
  165. }
  166. /* Discovers the version we are working with by reading the apropriate
  167. configuration file. Despite its name, this also writes the configuration
  168. file included by our makefile. */
  169. function discoverVersion()
  170. {
  171. var fso, cf, vf, ln, s, iDot, iSlash;
  172. fso = new ActiveXObject("Scripting.FileSystemObject");
  173. verCvs = "";
  174. if (useCvsVer && fso.FileExists("..\\CVS\\Entries")) {
  175. cf = fso.OpenTextFile("..\\CVS\\Entries", 1);
  176. while (cf.AtEndOfStream != true) {
  177. ln = cf.ReadLine();
  178. s = new String(ln);
  179. if (s.search(/^\/ChangeLog\//) != -1) {
  180. iDot = s.indexOf(".");
  181. iSlash = s.indexOf("/", iDot);
  182. verCvs = "CVS" + s.substring(iDot + 1, iSlash);
  183. break;
  184. }
  185. }
  186. cf.Close();
  187. }
  188. cf = fso.OpenTextFile(configFile, 1);
  189. if (compiler == "msvc")
  190. versionFile = ".\\config.msvc";
  191. else if (compiler == "mingw")
  192. versionFile = ".\\config.mingw";
  193. else if (compiler == "bcb")
  194. versionFile = ".\\config.bcb";
  195. vf = fso.CreateTextFile(versionFile, true);
  196. vf.WriteLine("# " + versionFile);
  197. vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + ".");
  198. vf.WriteBlankLines(1);
  199. while (cf.AtEndOfStream != true) {
  200. ln = cf.ReadLine();
  201. s = new String(ln);
  202. if (s.search(/^LIBXML_MAJOR_VERSION=/) != -1) {
  203. vf.WriteLine(s);
  204. verMajor = s.substring(s.indexOf("=") + 1, s.length)
  205. } else if(s.search(/^LIBXML_MINOR_VERSION=/) != -1) {
  206. vf.WriteLine(s);
  207. verMinor = s.substring(s.indexOf("=") + 1, s.length)
  208. } else if(s.search(/^LIBXML_MICRO_VERSION=/) != -1) {
  209. vf.WriteLine(s);
  210. verMicro = s.substring(s.indexOf("=") + 1, s.length)
  211. } else if(s.search(/^LIBXML_MICRO_VERSION_SUFFIX=/) != -1) {
  212. vf.WriteLine(s);
  213. verMicroSuffix = s.substring(s.indexOf("=") + 1, s.length)
  214. }
  215. }
  216. cf.Close();
  217. vf.WriteLine("XML_SRCDIR=" + srcDirXml);
  218. vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils);
  219. vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0"));
  220. vf.WriteLine("WITH_THREADS=" + withThreads);
  221. vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0"));
  222. vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0"));
  223. vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0"));
  224. vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0"));
  225. vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
  226. vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0"));
  227. vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
  228. vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
  229. vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
  230. vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
  231. vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0"));
  232. vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0"));
  233. vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0"));
  234. vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0"));
  235. vf.WriteLine("WITH_RUN_DEBUG=" + (withRunDebug? "1" : "0"));
  236. vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0"));
  237. vf.WriteLine("WITH_SCHEMATRON=" + (withSchematron? "1" : "0"));
  238. vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0"));
  239. vf.WriteLine("WITH_MODULES=" + (withModules? "1" : "0"));
  240. vf.WriteLine("WITH_TREE=" + (withTree? "1" : "0"));
  241. vf.WriteLine("WITH_READER=" + (withReader? "1" : "0"));
  242. vf.WriteLine("WITH_WRITER=" + (withWriter? "1" : "0"));
  243. vf.WriteLine("WITH_WALKER=" + (withWalker? "1" : "0"));
  244. vf.WriteLine("WITH_PATTERN=" + (withPattern? "1" : "0"));
  245. vf.WriteLine("WITH_PUSH=" + (withPush? "1" : "0"));
  246. vf.WriteLine("WITH_VALID=" + (withValid? "1" : "0"));
  247. vf.WriteLine("WITH_SAX1=" + (withSax1? "1" : "0"));
  248. vf.WriteLine("WITH_LEGACY=" + (withLegacy? "1" : "0"));
  249. vf.WriteLine("WITH_OUTPUT=" + (withOutput? "1" : "0"));
  250. vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
  251. vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
  252. vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
  253. vf.WriteLine("PREFIX=" + buildPrefix);
  254. vf.WriteLine("BINPREFIX=" + buildBinPrefix);
  255. vf.WriteLine("INCPREFIX=" + buildIncPrefix);
  256. vf.WriteLine("LIBPREFIX=" + buildLibPrefix);
  257. vf.WriteLine("SOPREFIX=" + buildSoPrefix);
  258. if (compiler == "msvc") {
  259. vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude);
  260. vf.WriteLine("LIB=$(LIB);" + buildLib);
  261. vf.WriteLine("CRUNTIME=" + cruntime);
  262. vf.WriteLine("VCMANIFEST=" + (vcmanifest? "1" : "0"));
  263. } else if (compiler == "mingw") {
  264. vf.WriteLine("INCLUDE+=;" + buildInclude);
  265. vf.WriteLine("LIB+=;" + buildLib);
  266. } else if (compiler == "bcb") {
  267. vf.WriteLine("INCLUDE=" + buildInclude);
  268. vf.WriteLine("LIB=" + buildLib);
  269. vf.WriteLine("DYNRUNTIME=" + (dynruntime? "1" : "0"));
  270. }
  271. vf.Close();
  272. }
  273. /* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in
  274. taking what the user passed on the command line into account. */
  275. function configureLibxml()
  276. {
  277. var fso, ofi, of, ln, s;
  278. fso = new ActiveXObject("Scripting.FileSystemObject");
  279. ofi = fso.OpenTextFile(optsFileIn, 1);
  280. of = fso.CreateTextFile(optsFile, true);
  281. while (ofi.AtEndOfStream != true) {
  282. ln = ofi.ReadLine();
  283. s = new String(ln);
  284. if (s.search(/\@VERSION\@/) != -1) {
  285. of.WriteLine(s.replace(/\@VERSION\@/,
  286. verMajor + "." + verMinor + "." + verMicro + verMicroSuffix));
  287. } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) {
  288. of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/,
  289. verMajor*10000 + verMinor*100 + verMicro*1));
  290. } else if (s.search(/\@LIBXML_VERSION_EXTRA\@/) != -1) {
  291. of.WriteLine(s.replace(/\@LIBXML_VERSION_EXTRA\@/, verCvs));
  292. } else if (s.search(/\@WITH_TRIO\@/) != -1) {
  293. of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
  294. } else if (s.search(/\@WITH_THREADS\@/) != -1) {
  295. of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
  296. } else if (s.search(/\@WITH_FTP\@/) != -1) {
  297. of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0"));
  298. } else if (s.search(/\@WITH_HTTP\@/) != -1) {
  299. of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0"));
  300. } else if (s.search(/\@WITH_HTML\@/) != -1) {
  301. of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0"));
  302. } else if (s.search(/\@WITH_C14N\@/) != -1) {
  303. of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0"));
  304. } else if (s.search(/\@WITH_CATALOG\@/) != -1) {
  305. of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0"));
  306. } else if (s.search(/\@WITH_DOCB\@/) != -1) {
  307. of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0"));
  308. } else if (s.search(/\@WITH_XPATH\@/) != -1) {
  309. of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
  310. } else if (s.search(/\@WITH_XPTR\@/) != -1) {
  311. of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
  312. } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
  313. of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
  314. } else if (s.search(/\@WITH_ICONV\@/) != -1) {
  315. of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0"));
  316. } else if (s.search(/\@WITH_ISO8859X\@/) != -1) {
  317. of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0"));
  318. } else if (s.search(/\@WITH_ZLIB\@/) != -1) {
  319. of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0"));
  320. } else if (s.search(/\@WITH_DEBUG\@/) != -1) {
  321. of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0"));
  322. } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
  323. of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
  324. } else if (s.search(/\@WITH_RUN_DEBUG\@/) != -1) {
  325. of.WriteLine(s.replace(/\@WITH_RUN_DEBUG\@/, withRunDebug? "1" : "0"));
  326. } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) {
  327. of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0"));
  328. } else if (s.search(/\@WITH_SCHEMATRON\@/) != -1) {
  329. of.WriteLine(s.replace(/\@WITH_SCHEMATRON\@/, withSchematron? "1" : "0"));
  330. } else if (s.search(/\@WITH_REGEXPS\@/) != -1) {
  331. of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0"));
  332. } else if (s.search(/\@WITH_MODULES\@/) != -1) {
  333. of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0"));
  334. } else if (s.search(/\@MODULE_EXTENSION\@/) != -1) {
  335. of.WriteLine(s.replace(/\@MODULE_EXTENSION\@/, ".dll"));
  336. } else if (s.search(/\@WITH_TREE\@/) != -1) {
  337. of.WriteLine(s.replace(/\@WITH_TREE\@/, withTree? "1" : "0"));
  338. } else if (s.search(/\@WITH_READER\@/) != -1) {
  339. of.WriteLine(s.replace(/\@WITH_READER\@/, withReader? "1" : "0"));
  340. } else if (s.search(/\@WITH_WRITER\@/) != -1) {
  341. of.WriteLine(s.replace(/\@WITH_WRITER\@/, withWriter? "1" : "0"));
  342. } else if (s.search(/\@WITH_WALKER\@/) != -1) {
  343. of.WriteLine(s.replace(/\@WITH_WALKER\@/, withWalker? "1" : "0"));
  344. } else if (s.search(/\@WITH_PATTERN\@/) != -1) {
  345. of.WriteLine(s.replace(/\@WITH_PATTERN\@/, withPattern? "1" : "0"));
  346. } else if (s.search(/\@WITH_PUSH\@/) != -1) {
  347. of.WriteLine(s.replace(/\@WITH_PUSH\@/, withPush? "1" : "0"));
  348. } else if (s.search(/\@WITH_VALID\@/) != -1) {
  349. of.WriteLine(s.replace(/\@WITH_VALID\@/, withValid? "1" : "0"));
  350. } else if (s.search(/\@WITH_SAX1\@/) != -1) {
  351. of.WriteLine(s.replace(/\@WITH_SAX1\@/, withSax1? "1" : "0"));
  352. } else if (s.search(/\@WITH_LEGACY\@/) != -1) {
  353. of.WriteLine(s.replace(/\@WITH_LEGACY\@/, withLegacy? "1" : "0"));
  354. } else if (s.search(/\@WITH_OUTPUT\@/) != -1) {
  355. of.WriteLine(s.replace(/\@WITH_OUTPUT\@/, withOutput? "1" : "0"));
  356. } else
  357. of.WriteLine(ln);
  358. }
  359. ofi.Close();
  360. of.Close();
  361. }
  362. /* Configures Python bindings. Otherwise identical to the above */
  363. function configureLibxmlPy()
  364. {
  365. var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in";
  366. var pyOptsFile = srcDirXml + "\\python\\setup.py";
  367. var fso, ofi, of, ln, s;
  368. fso = new ActiveXObject("Scripting.FileSystemObject");
  369. ofi = fso.OpenTextFile(pyOptsFileIn, 1);
  370. of = fso.CreateTextFile(pyOptsFile, true);
  371. while (ofi.AtEndOfStream != true) {
  372. ln = ofi.ReadLine();
  373. s = new String(ln);
  374. if (s.search(/\@LIBXML_VERSION\@/) != -1) {
  375. of.WriteLine(s.replace(/\@LIBXML_VERSION\@/,
  376. verMajor + "." + verMinor + "." + verMicro));
  377. } else if (s.search(/\@prefix\@/) != -1) {
  378. of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
  379. } else if (s.search(/\@WITH_THREADS\@/) != -1) {
  380. of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1"));
  381. } else
  382. of.WriteLine(ln);
  383. }
  384. ofi.Close();
  385. of.Close();
  386. }
  387. /* Creates the readme file for the binary distribution of 'bname', for the
  388. version 'ver' in the file 'file'. This one is called from the Makefile when
  389. generating a binary distribution. The parameters are passed by make. */
  390. function genReadme(bname, ver, file)
  391. {
  392. var fso, f;
  393. fso = new ActiveXObject("Scripting.FileSystemObject");
  394. f = fso.CreateTextFile(file, true);
  395. f.WriteLine(" " + bname + " " + ver);
  396. f.WriteLine(" --------------");
  397. f.WriteBlankLines(1);
  398. f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32");
  399. f.WriteLine("platform.");
  400. f.WriteBlankLines(1);
  401. f.WriteLine(" The files in this package do not require any special installation");
  402. f.WriteLine("steps. Extract the contents of the archive whereever you wish and");
  403. f.WriteLine("make sure that your tools which use " + bname + " can find it.");
  404. f.WriteBlankLines(1);
  405. f.WriteLine(" For example, if you want to run the supplied utilities from the command");
  406. f.WriteLine("line, you can, if you wish, add the 'bin' subdirectory to the PATH");
  407. f.WriteLine("environment variable.");
  408. f.WriteLine(" If you want to make programmes in C which use " + bname + ", you'll");
  409. f.WriteLine("likely know how to use the contents of this package. If you don't, please");
  410. f.WriteLine("refer to your compiler's documentation.");
  411. f.WriteBlankLines(1);
  412. f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,");
  413. f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using");
  414. f.WriteLine("the address below.");
  415. f.WriteBlankLines(1);
  416. f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)");
  417. f.Close();
  418. }
  419. /*
  420. * main(),
  421. * Execution begins here.
  422. */
  423. // Parse the command-line arguments.
  424. for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
  425. var arg, opt;
  426. arg = WScript.Arguments(i);
  427. opt = arg.substring(0, arg.indexOf("="));
  428. if (opt.length == 0)
  429. opt = arg.substring(0, arg.indexOf(":"));
  430. if (opt.length > 0) {
  431. if (opt == "trio")
  432. withTrio = strToBool(arg.substring(opt.length + 1, arg.length));
  433. else if (opt == "threads")
  434. withThreads = arg.substring(opt.length + 1, arg.length);
  435. else if (opt == "ftp")
  436. withFtp = strToBool(arg.substring(opt.length + 1, arg.length));
  437. else if (opt == "http")
  438. withHttp = strToBool(arg.substring(opt.length + 1, arg.length));
  439. else if (opt == "html")
  440. withHtml = strToBool(arg.substring(opt.length + 1, arg.length));
  441. else if (opt == "c14n")
  442. withC14n = strToBool(arg.substring(opt.length + 1, arg.length));
  443. else if (opt == "catalog")
  444. withCatalog = strToBool(arg.substring(opt.length + 1, arg.length));
  445. else if (opt == "docb")
  446. withDocb = strToBool(arg.substring(opt.length + 1, arg.length));
  447. else if (opt == "xpath")
  448. withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
  449. else if (opt == "xptr")
  450. withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
  451. else if (opt == "xinclude")
  452. withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
  453. else if (opt == "iconv")
  454. withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
  455. else if (opt == "iso8859x")
  456. withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length));
  457. else if (opt == "zlib")
  458. withZlib = strToBool(arg.substring(opt.length + 1, arg.length));
  459. else if (opt == "xml_debug")
  460. withDebug = strToBool(arg.substring(opt.length + 1, arg.length));
  461. else if (opt == "mem_debug")
  462. withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length));
  463. else if (opt == "run_debug")
  464. withRunDebug = strToBool(arg.substring(opt.length + 1, arg.length));
  465. else if (opt == "schemas")
  466. withSchemas = strToBool(arg.substring(opt.length + 1, arg.length));
  467. else if (opt == "schematron")
  468. withSchematron = strToBool(arg.substring(opt.length + 1, arg.length));
  469. else if (opt == "regexps")
  470. withRegExps = strToBool(arg.substring(opt.length + 1, arg.length));
  471. else if (opt == "modules")
  472. withModules = strToBool(arg.substring(opt.length + 1, arg.length));
  473. else if (opt == "tree")
  474. withTree = strToBool(arg.substring(opt.length + 1, arg.length));
  475. else if (opt == "reader")
  476. withReader = strToBool(arg.substring(opt.length + 1, arg.length));
  477. else if (opt == "writer")
  478. withWriter = strToBool(arg.substring(opt.length + 1, arg.length));
  479. else if (opt == "walker")
  480. withWalker = strToBool(arg.substring(opt.length + 1, arg.length));
  481. else if (opt == "pattern")
  482. withPattern = strToBool(arg.substring(opt.length + 1, arg.length));
  483. else if (opt == "push")
  484. withPush = strToBool(arg.substring(opt.length + 1, arg.length));
  485. else if (opt == "valid")
  486. withValid = strToBool(arg.substring(opt.length + 1, arg.length));
  487. else if (opt == "sax1")
  488. withSax1 = strToBool(arg.substring(opt.length + 1, arg.length));
  489. else if (opt == "legacy")
  490. withLegacy = strToBool(arg.substring(opt.length + 1, arg.length));
  491. else if (opt == "output")
  492. withOutput = strToBool(arg.substring(opt.length + 1, arg.length));
  493. else if (opt == "python")
  494. withPython = strToBool(arg.substring(opt.length + 1, arg.length));
  495. else if (opt == "compiler")
  496. compiler = arg.substring(opt.length + 1, arg.length);
  497. else if (opt == "cruntime")
  498. cruntime = arg.substring(opt.length + 1, arg.length);
  499. else if (opt == "dynruntime")
  500. dynruntime = strToBool(arg.substring(opt.length + 1, arg.length));
  501. else if (opt == "vcmanifest")
  502. vcmanifest = strToBool(arg.substring(opt.length + 1, arg.length));
  503. else if (opt == "debug")
  504. buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
  505. else if (opt == "static")
  506. buildStatic = strToBool(arg.substring(opt.length + 1, arg.length));
  507. else if (opt == "prefix")
  508. buildPrefix = arg.substring(opt.length + 1, arg.length);
  509. else if (opt == "incdir")
  510. buildIncPrefix = arg.substring(opt.length + 1, arg.length);
  511. else if (opt == "bindir")
  512. buildBinPrefix = arg.substring(opt.length + 1, arg.length);
  513. else if (opt == "libdir")
  514. buildLibPrefix = arg.substring(opt.length + 1, arg.length);
  515. else if (opt == "sodir")
  516. buildSoPrefix = arg.substring(opt.length + 1, arg.length);
  517. else if (opt == "incdir")
  518. buildIncPrefix = arg.substring(opt.length + 1, arg.length);
  519. else if (opt == "include")
  520. buildInclude = arg.substring(opt.length + 1, arg.length);
  521. else if (opt == "lib")
  522. buildLib = arg.substring(opt.length + 1, arg.length);
  523. else if (opt == "release")
  524. useCvsVer = false;
  525. else
  526. error = 1;
  527. } else if (i == 0) {
  528. if (arg == "genreadme") {
  529. // This command comes from the Makefile and will not be checked
  530. // for errors, because Makefile will always supply right the parameters.
  531. genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3));
  532. WScript.Quit(0);
  533. } else if (arg == "help") {
  534. usage();
  535. WScript.Quit(0);
  536. }
  537. } else {
  538. error = 1;
  539. }
  540. }
  541. // If we fail here, it is because the user supplied an unrecognised argument.
  542. if (error != 0) {
  543. usage();
  544. WScript.Quit(error);
  545. }
  546. // if user choses to link the c-runtime library statically into libxml2
  547. // with /MT and friends, then we need to enable static linking for xmllint
  548. if (cruntime == "/MT" || cruntime == "/MTd" ||
  549. cruntime == "/ML" || cruntime == "/MLd") {
  550. buildStatic = 1;
  551. }
  552. dirSep = "\\";
  553. if (buildBinPrefix == "")
  554. buildBinPrefix = "$(PREFIX)" + dirSep + "bin";
  555. if (buildIncPrefix == "")
  556. buildIncPrefix = "$(PREFIX)" + dirSep + "include";
  557. if (buildLibPrefix == "")
  558. buildLibPrefix = "$(PREFIX)" + dirSep + "lib";
  559. if (buildSoPrefix == "")
  560. buildSoPrefix = "$(PREFIX)" + dirSep + "lib";
  561. // Discover the version.
  562. discoverVersion();
  563. if (error != 0) {
  564. WScript.Echo("Version discovery failed, aborting.");
  565. WScript.Quit(error);
  566. }
  567. var outVerString = baseName + " version: " + verMajor + "." + verMinor + "." + verMicro;
  568. if (verMicroSuffix && verMicroSuffix != "")
  569. outVerString += "-" + verMicroSuffix;
  570. if (verCvs && verCvs != "")
  571. outVerString += "-" + verCvs;
  572. WScript.Echo(outVerString);
  573. // Configure libxml.
  574. configureLibxml();
  575. if (error != 0) {
  576. WScript.Echo("Configuration failed, aborting.");
  577. WScript.Quit(error);
  578. }
  579. if (withPython == true) {
  580. configureLibxmlPy();
  581. if (error != 0) {
  582. WScript.Echo("Configuration failed, aborting.");
  583. WScript.Quit(error);
  584. }
  585. }
  586. // Create the makefile.
  587. var fso = new ActiveXObject("Scripting.FileSystemObject");
  588. var makefile = ".\\Makefile.msvc";
  589. if (compiler == "mingw")
  590. makefile = ".\\Makefile.mingw";
  591. else if (compiler == "bcb")
  592. makefile = ".\\Makefile.bcb";
  593. fso.CopyFile(makefile, ".\\Makefile", true);
  594. WScript.Echo("Created Makefile.");
  595. // Create the config.h.
  596. var confighsrc = "..\\include\\win32config.h";
  597. var configh = "..\\config.h";
  598. var f = fso.FileExists(configh);
  599. if (f) {
  600. var t = fso.GetFile(configh);
  601. t.Attributes =0;
  602. }
  603. fso.CopyFile(confighsrc, configh, true);
  604. WScript.Echo("Created config.h.");
  605. // Display the final configuration.
  606. var txtOut = "\nXML processor configuration\n";
  607. txtOut += "---------------------------\n";
  608. txtOut += " Trio: " + boolToStr(withTrio) + "\n";
  609. txtOut += " Thread safety: " + withThreads + "\n";
  610. txtOut += " FTP client: " + boolToStr(withFtp) + "\n";
  611. txtOut += " HTTP client: " + boolToStr(withHttp) + "\n";
  612. txtOut += " HTML processor: " + boolToStr(withHtml) + "\n";
  613. txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
  614. txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
  615. txtOut += " DocBook support: " + boolToStr(withDocb) + "\n";
  616. txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
  617. txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
  618. txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
  619. txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
  620. txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n";
  621. txtOut += " zlib support: " + boolToStr(withZlib) + "\n";
  622. txtOut += " Debugging module: " + boolToStr(withDebug) + "\n";
  623. txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n";
  624. txtOut += " Runtime debugging: " + boolToStr(withRunDebug) + "\n";
  625. txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n";
  626. txtOut += " Module support: " + boolToStr(withModules) + "\n";
  627. txtOut += " Tree support: " + boolToStr(withTree) + "\n";
  628. txtOut += " Reader support: " + boolToStr(withReader) + "\n";
  629. txtOut += " Writer support: " + boolToStr(withWriter) + "\n";
  630. txtOut += " Walker support: " + boolToStr(withWalker) + "\n";
  631. txtOut += " Pattern support: " + boolToStr(withPattern) + "\n";
  632. txtOut += " Push support: " + boolToStr(withPush) + "\n";
  633. txtOut += "Validation support: " + boolToStr(withValid) + "\n";
  634. txtOut += " SAX1 support: " + boolToStr(withSax1) + "\n";
  635. txtOut += " Legacy support: " + boolToStr(withLegacy) + "\n";
  636. txtOut += " Output support: " + boolToStr(withOutput) + "\n";
  637. txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n";
  638. txtOut += "Schematron support: " + boolToStr(withSchematron) + "\n";
  639. txtOut += " Python bindings: " + boolToStr(withPython) + "\n";
  640. txtOut += "\n";
  641. txtOut += "Win32 build configuration\n";
  642. txtOut += "-------------------------\n";
  643. txtOut += " Compiler: " + compiler + "\n";
  644. if (compiler == "msvc") {
  645. txtOut += " C-Runtime option: " + cruntime + "\n";
  646. txtOut += " Embed Manifest: " + boolToStr(vcmanifest) + "\n";
  647. } else if (compiler == "bcb")
  648. txtOut += " Use dynamic RTL: " + dynruntime + "\n";
  649. txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n";
  650. txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n";
  651. txtOut += " Install prefix: " + buildPrefix + "\n";
  652. txtOut += " Put tools in: " + buildBinPrefix + "\n";
  653. txtOut += " Put headers in: " + buildIncPrefix + "\n";
  654. txtOut += "Put static libs in: " + buildLibPrefix + "\n";
  655. txtOut += "Put shared libs in: " + buildSoPrefix + "\n";
  656. txtOut += " Include path: " + buildInclude + "\n";
  657. txtOut += " Lib path: " + buildLib + "\n";
  658. WScript.Echo(txtOut);
  659. //