Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 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 | * |
Daniel Veillard | beb70bd | 2002-12-18 14:53:54 +0000 | [diff] [blame] | 7 | * March 2002, Igor Zlatkovic <igor@zlatkovic.com> |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /* The source directory, relative to the one where this file resides. */ |
| 11 | var srcDirXml = ".."; |
| 12 | var srcDirUtils = ".."; |
| 13 | /* The directory where we put the binaries after compilation. */ |
| 14 | var binDir = "binaries"; |
| 15 | /* Base name of what we are building. */ |
| 16 | var baseName = "libxml2"; |
| 17 | /* Configure file which contains the version and the output file where |
| 18 | we can store our build configuration. */ |
| 19 | var configFile = srcDirXml + "\\configure.in"; |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 20 | var versionFile = ".\\config.msvc"; |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 21 | /* Input and output files regarding the libxml features. */ |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 22 | var optsFileIn = srcDirXml + "\\include\\libxml\\xmlversion.h.in"; |
| 23 | var optsFile = srcDirXml + "\\include\\libxml\\xmlversion.h"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 24 | /* Version strings for the binary distribution. Will be filled later |
| 25 | in the code. */ |
| 26 | var verMajor; |
| 27 | var verMinor; |
| 28 | var verMicro; |
| 29 | /* Libxml features. */ |
| 30 | var withTrio = false; |
Igor Zlatkovic | e38ab53 | 2003-05-17 11:30:54 +0000 | [diff] [blame] | 31 | var withThreads = "native"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 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; |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 42 | var withIso8859x = false; |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 43 | var withZlib = false; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 44 | var withDebug = true; |
| 45 | var withMemDebug = false; |
Igor Zlatkovic | a6f2d90 | 2002-04-16 17:57:17 +0000 | [diff] [blame] | 46 | var withSchemas = true; |
Igor Zlatkovic | 8e04097 | 2002-09-20 13:39:53 +0000 | [diff] [blame] | 47 | var withRegExps = true; |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 48 | var withPython = false; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 49 | /* Win32 build options. */ |
Igor Zlatkovic | 1bab92d | 2003-08-28 10:24:40 +0000 | [diff] [blame^] | 50 | var dirSep = "/"; |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 51 | var compiler = "msvc"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 52 | var buildDebug = 0; |
| 53 | var buildStatic = 0; |
| 54 | var buildPrefix = "."; |
Igor Zlatkovic | 1bab92d | 2003-08-28 10:24:40 +0000 | [diff] [blame^] | 55 | var buildBinPrefix = "$(PREFIX)" + dirSep + "bin"; |
| 56 | var buildIncPrefix = "$(PREFIX)" + dirSep + "include"; |
| 57 | var buildLibPrefix = "$(PREFIX)" + dirSep + "lib"; |
| 58 | var buildSoPrefix = "$(PREFIX)" + dirSep + "lib"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 59 | var buildInclude = "."; |
| 60 | var buildLib = "."; |
| 61 | /* Local stuff */ |
| 62 | var error = 0; |
| 63 | |
| 64 | /* Helper function, transforms the option variable into the 'Enabled' |
| 65 | or 'Disabled' string. */ |
| 66 | function boolToStr(opt) |
| 67 | { |
| 68 | if (opt == false) |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 69 | return "no"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 70 | else if (opt == true) |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 71 | return "yes"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 72 | error = 1; |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 73 | return "*** undefined ***"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | /* Helper function, transforms the argument string into a boolean |
| 77 | value. */ |
| 78 | function strToBool(opt) |
| 79 | { |
| 80 | if (opt == 0 || opt == "no") |
| 81 | return false; |
| 82 | else if (opt == 1 || opt == "yes") |
| 83 | return true; |
| 84 | error = 1; |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | /* Displays the details about how to use this script. */ |
| 89 | function usage() |
| 90 | { |
| 91 | var txt; |
| 92 | txt = "Usage:\n"; |
| 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"; |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 96 | txt += "either 'yes' or 'no', if not stated otherwise.\n\n"; |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 97 | txt += "\nXML processor options, default value given in parentheses:\n\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 98 | txt += " trio: Enable TRIO string manipulator (" + (withTrio? "yes" : "no") + ")\n"; |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 99 | txt += " threads: Enable thread safety [no|ctls|native|posix] (" + (withThreads) + ") \n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 100 | txt += " ftp: Enable FTP client (" + (withFtp? "yes" : "no") + ")\n"; |
| 101 | txt += " http: Enable HTTP client (" + (withHttp? "yes" : "no") + ")\n"; |
| 102 | txt += " html: Enable HTML processor (" + (withHtml? "yes" : "no") + ")\n"; |
| 103 | txt += " c14n: Enable C14N support (" + (withC14n? "yes" : "no") + ")\n"; |
| 104 | txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n"; |
| 105 | txt += " docb: Enable DocBook support (" + (withDocb? "yes" : "no") + ")\n"; |
| 106 | txt += " xpath: Enable XPath support (" + (withXpath? "yes" : "no") + ")\n"; |
| 107 | txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n"; |
| 108 | txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n"; |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 109 | txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n"; |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 110 | txt += " iso8859x: Enable ISO8859X support (" + (withIso8859x? "yes" : "no") + ")\n"; |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 111 | txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 112 | txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n"; |
| 113 | txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n"; |
Igor Zlatkovic | 8e04097 | 2002-09-20 13:39:53 +0000 | [diff] [blame] | 114 | txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n"; |
Igor Zlatkovic | a6f2d90 | 2002-04-16 17:57:17 +0000 | [diff] [blame] | 115 | txt += " schemas: Enable XML Schema support (" + (withSchemas? "yes" : "no") + ")\n"; |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 116 | txt += " python: Build Python bindings (" + (withPython? "yes" : "no") + ")\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 117 | txt += "\nWin32 build options, default value given in parentheses:\n\n"; |
Igor Zlatkovic | 72f92a8 | 2003-06-14 16:48:26 +0000 | [diff] [blame] | 118 | txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 119 | txt += " debug: Build unoptimised debug executables (" + (buildDebug? "yes" : "no") + ")\n"; |
| 120 | txt += " static: Link xmllint statically to libxml2 (" + (buildStatic? "yes" : "no") + ")\n"; |
| 121 | txt += " prefix: Base directory for the installation (" + buildPrefix + ")\n"; |
| 122 | txt += " bindir: Directory where xmllint and friends should be installed\n"; |
| 123 | txt += " (" + buildBinPrefix + ")\n"; |
| 124 | txt += " incdir: Directory where headers should be installed\n"; |
| 125 | txt += " (" + buildIncPrefix + ")\n"; |
| 126 | txt += " libdir: Directory where static and import libraries should be\n"; |
| 127 | txt += " installed (" + buildLibPrefix + ")\n"; |
| 128 | txt += " sodir: Directory where shared libraries should be installed\n"; |
| 129 | txt += " (" + buildSoPrefix + ")\n"; |
| 130 | txt += " include: Additional search path for the compiler, particularily\n"; |
| 131 | txt += " where iconv headers can be found (" + buildInclude + ")\n"; |
| 132 | txt += " lib: Additional search path for the linker, particularily\n"; |
| 133 | txt += " where iconv library can be found (" + buildLib + ")\n"; |
| 134 | WScript.Echo(txt); |
| 135 | } |
| 136 | |
| 137 | /* Discovers the version we are working with by reading the apropriate |
| 138 | configuration file. Despite its name, this also writes the configuration |
| 139 | file included by our makefile. */ |
| 140 | function discoverVersion() |
| 141 | { |
| 142 | var fso, cf, vf, ln, s; |
| 143 | fso = new ActiveXObject("Scripting.FileSystemObject"); |
| 144 | cf = fso.OpenTextFile(configFile, 1); |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 145 | if (compiler == "msvc") |
| 146 | versionFile = ".\\config.msvc"; |
| 147 | else if (compiler == "mingw") |
| 148 | versionFile = ".\\config.mingw"; |
Igor Zlatkovic | 72f92a8 | 2003-06-14 16:48:26 +0000 | [diff] [blame] | 149 | else if (compiler == "bcb") |
| 150 | versionFile = ".\\config.bcb"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 151 | vf = fso.CreateTextFile(versionFile, true); |
| 152 | vf.WriteLine("# " + versionFile); |
| 153 | vf.WriteLine("# This file is generated automatically by " + WScript.ScriptName + "."); |
| 154 | vf.WriteBlankLines(1); |
| 155 | while (cf.AtEndOfStream != true) { |
| 156 | ln = cf.ReadLine(); |
| 157 | s = new String(ln); |
| 158 | if (s.search(/^LIBXML_MAJOR_VERSION/) != -1) { |
| 159 | vf.WriteLine(s); |
| 160 | verMajor = s.substring(s.indexOf("=") + 1, s.length) |
| 161 | } else if(s.search(/^LIBXML_MINOR_VERSION/) != -1) { |
| 162 | vf.WriteLine(s); |
| 163 | verMinor = s.substring(s.indexOf("=") + 1, s.length) |
| 164 | } else if(s.search(/^LIBXML_MICRO_VERSION/) != -1) { |
| 165 | vf.WriteLine(s); |
| 166 | verMicro = s.substring(s.indexOf("=") + 1, s.length) |
| 167 | } |
| 168 | } |
| 169 | cf.Close(); |
| 170 | vf.WriteLine("XML_SRCDIR=" + srcDirXml); |
| 171 | vf.WriteLine("UTILS_SRCDIR=" + srcDirUtils); |
| 172 | vf.WriteLine("BINDIR=" + binDir); |
| 173 | vf.WriteLine("WITH_TRIO=" + (withTrio? "1" : "0")); |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 174 | vf.WriteLine("WITH_THREADS=" + withThreads); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 175 | vf.WriteLine("WITH_FTP=" + (withFtp? "1" : "0")); |
| 176 | vf.WriteLine("WITH_HTTP=" + (withHttp? "1" : "0")); |
| 177 | vf.WriteLine("WITH_HTML=" + (withHtml? "1" : "0")); |
| 178 | vf.WriteLine("WITH_C14N=" + (withC14n? "1" : "0")); |
| 179 | vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0")); |
| 180 | vf.WriteLine("WITH_DOCB=" + (withDocb? "1" : "0")); |
| 181 | vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0")); |
| 182 | vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0")); |
| 183 | vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0")); |
| 184 | vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0")); |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 185 | vf.WriteLine("WITH_ISO8859X=" + (withIso8859x? "1" : "0")); |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 186 | vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0")); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 187 | vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0")); |
| 188 | vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0")); |
Igor Zlatkovic | a6f2d90 | 2002-04-16 17:57:17 +0000 | [diff] [blame] | 189 | vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0")); |
Igor Zlatkovic | 8e04097 | 2002-09-20 13:39:53 +0000 | [diff] [blame] | 190 | vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0")); |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 191 | vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0")); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 192 | vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0")); |
| 193 | vf.WriteLine("STATIC=" + (buildStatic? "1" : "0")); |
| 194 | vf.WriteLine("PREFIX=" + buildPrefix); |
| 195 | vf.WriteLine("BINPREFIX=" + buildBinPrefix); |
| 196 | vf.WriteLine("INCPREFIX=" + buildIncPrefix); |
| 197 | vf.WriteLine("LIBPREFIX=" + buildLibPrefix); |
| 198 | vf.WriteLine("SOPREFIX=" + buildSoPrefix); |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 199 | if (compiler == "msvc") { |
| 200 | vf.WriteLine("INCLUDE=$(INCLUDE);" + buildInclude); |
| 201 | vf.WriteLine("LIB=$(LIB);" + buildLib); |
| 202 | } else if (compiler == "mingw") { |
| 203 | vf.WriteLine("INCLUDE+=;" + buildInclude); |
| 204 | vf.WriteLine("LIB+=;" + buildLib); |
Igor Zlatkovic | 72f92a8 | 2003-06-14 16:48:26 +0000 | [diff] [blame] | 205 | } else if (compiler == "bcb") { |
| 206 | vf.WriteLine("INCLUDE=" + buildInclude); |
| 207 | vf.WriteLine("LIB=" + buildLib); |
| 208 | } |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 209 | vf.Close(); |
| 210 | } |
| 211 | |
| 212 | /* Configures libxml. This one will generate xmlversion.h from xmlversion.h.in |
| 213 | taking what the user passed on the command line into account. */ |
| 214 | function configureLibxml() |
| 215 | { |
| 216 | var fso, ofi, of, ln, s; |
| 217 | fso = new ActiveXObject("Scripting.FileSystemObject"); |
| 218 | ofi = fso.OpenTextFile(optsFileIn, 1); |
| 219 | of = fso.CreateTextFile(optsFile, true); |
| 220 | while (ofi.AtEndOfStream != true) { |
| 221 | ln = ofi.ReadLine(); |
| 222 | s = new String(ln); |
| 223 | if (s.search(/\@VERSION\@/) != -1) { |
| 224 | of.WriteLine(s.replace(/\@VERSION\@/, |
| 225 | verMajor + "." + verMinor + "." + verMicro)); |
| 226 | } else if (s.search(/\@LIBXML_VERSION_NUMBER\@/) != -1) { |
| 227 | of.WriteLine(s.replace(/\@LIBXML_VERSION_NUMBER\@/, |
| 228 | verMajor*10000 + verMinor*100 + verMicro*1)); |
| 229 | } else if (s.search(/\@WITH_TRIO\@/) != -1) { |
| 230 | of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0")); |
| 231 | } else if (s.search(/\@WITH_THREADS\@/) != -1) { |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 232 | of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1")); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 233 | } else if (s.search(/\@WITH_FTP\@/) != -1) { |
| 234 | of.WriteLine(s.replace(/\@WITH_FTP\@/, withFtp? "1" : "0")); |
| 235 | } else if (s.search(/\@WITH_HTTP\@/) != -1) { |
| 236 | of.WriteLine(s.replace(/\@WITH_HTTP\@/, withHttp? "1" : "0")); |
| 237 | } else if (s.search(/\@WITH_HTML\@/) != -1) { |
| 238 | of.WriteLine(s.replace(/\@WITH_HTML\@/, withHtml? "1" : "0")); |
| 239 | } else if (s.search(/\@WITH_C14N\@/) != -1) { |
| 240 | of.WriteLine(s.replace(/\@WITH_C14N\@/, withC14n? "1" : "0")); |
| 241 | } else if (s.search(/\@WITH_CATALOG\@/) != -1) { |
| 242 | of.WriteLine(s.replace(/\@WITH_CATALOG\@/, withCatalog? "1" : "0")); |
| 243 | } else if (s.search(/\@WITH_DOCB\@/) != -1) { |
| 244 | of.WriteLine(s.replace(/\@WITH_DOCB\@/, withDocb? "1" : "0")); |
| 245 | } else if (s.search(/\@WITH_XPATH\@/) != -1) { |
| 246 | of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0")); |
| 247 | } else if (s.search(/\@WITH_XPTR\@/) != -1) { |
| 248 | of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0")); |
| 249 | } else if (s.search(/\@WITH_XINCLUDE\@/) != -1) { |
| 250 | of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0")); |
| 251 | } else if (s.search(/\@WITH_ICONV\@/) != -1) { |
| 252 | of.WriteLine(s.replace(/\@WITH_ICONV\@/, withIconv? "1" : "0")); |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 253 | } else if (s.search(/\@WITH_ISO8859X\@/) != -1) { |
| 254 | of.WriteLine(s.replace(/\@WITH_ISO8859X\@/, withIso8859x? "1" : "0")); |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 255 | } else if (s.search(/\@WITH_ZLIB\@/) != -1) { |
| 256 | of.WriteLine(s.replace(/\@WITH_ZLIB\@/, withZlib? "1" : "0")); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 257 | } else if (s.search(/\@WITH_DEBUG\@/) != -1) { |
| 258 | of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0")); |
| 259 | } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) { |
| 260 | of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0")); |
Igor Zlatkovic | a6f2d90 | 2002-04-16 17:57:17 +0000 | [diff] [blame] | 261 | } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) { |
| 262 | of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0")); |
Igor Zlatkovic | 8e04097 | 2002-09-20 13:39:53 +0000 | [diff] [blame] | 263 | } else if (s.search(/\@WITH_REGEXPS\@/) != -1) { |
| 264 | of.WriteLine(s.replace(/\@WITH_REGEXPS\@/, withRegExps? "1" : "0")); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 265 | } else |
| 266 | of.WriteLine(ln); |
| 267 | } |
| 268 | ofi.Close(); |
| 269 | of.Close(); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 270 | } |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 271 | /* Configures Python bindings. Otherwise identical to the above */ |
| 272 | function configureLibxmlPy() |
| 273 | { |
| 274 | var pyOptsFileIn = srcDirXml + "\\python\\setup.py.in"; |
| 275 | var pyOptsFile = srcDirXml + "\\python\\setup.py"; |
| 276 | var fso, ofi, of, ln, s; |
| 277 | fso = new ActiveXObject("Scripting.FileSystemObject"); |
| 278 | ofi = fso.OpenTextFile(pyOptsFileIn, 1); |
| 279 | of = fso.CreateTextFile(pyOptsFile, true); |
| 280 | while (ofi.AtEndOfStream != true) { |
| 281 | ln = ofi.ReadLine(); |
| 282 | s = new String(ln); |
| 283 | if (s.search(/\@LIBXML_VERSION\@/) != -1) { |
| 284 | of.WriteLine(s.replace(/\@LIBXML_VERSION\@/, |
| 285 | verMajor + "." + verMinor + "." + verMicro)); |
| 286 | } else if (s.search(/\@prefix\@/) != -1) { |
| 287 | of.WriteLine(s.replace(/\@prefix\@/, buildPrefix)); |
Daniel Veillard | 94bb2f1 | 2003-04-27 22:14:07 +0000 | [diff] [blame] | 288 | } else if (s.search(/\@WITH_THREADS\@/) != -1) { |
| 289 | of.WriteLine(s.replace(/\@WITH_THREADS\@/, withThreads == "no"? "0" : "1")); |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 290 | } else |
| 291 | of.WriteLine(ln); |
| 292 | } |
| 293 | ofi.Close(); |
| 294 | of.Close(); |
| 295 | } |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 296 | |
| 297 | /* Creates the readme file for the binary distribution of 'bname', for the |
| 298 | version 'ver' in the file 'file'. This one is called from the Makefile when |
| 299 | generating a binary distribution. The parameters are passed by make. */ |
| 300 | function genReadme(bname, ver, file) |
| 301 | { |
| 302 | var fso, f; |
| 303 | fso = new ActiveXObject("Scripting.FileSystemObject"); |
| 304 | f = fso.CreateTextFile(file, true); |
| 305 | f.WriteLine(" " + bname + " " + ver); |
| 306 | f.WriteLine(" --------------"); |
| 307 | f.WriteBlankLines(1); |
| 308 | f.WriteLine(" This is " + bname + ", version " + ver + ", binary package for the native Win32/IA32"); |
| 309 | f.WriteLine("platform."); |
| 310 | f.WriteBlankLines(1); |
| 311 | f.WriteLine(" The directory named 'include' contains the header files. Place its"); |
| 312 | f.WriteLine("contents somewhere where it can be found by the compiler."); |
| 313 | f.WriteLine(" The directory which answers to the name 'lib' contains the static and"); |
| 314 | f.WriteLine("dynamic libraries. Place them somewhere where they can be found by the"); |
| 315 | f.WriteLine("linker. The files whose names end with '_a.lib' are aimed for static"); |
| 316 | f.WriteLine("linking, the other files are lib/dll pairs."); |
| 317 | f.WriteLine(" The directory called 'util' contains various programs which count as a"); |
| 318 | f.WriteLine("part of " + bname + "."); |
| 319 | f.WriteBlankLines(1); |
Igor Zlatkovic | 0ceeb8e | 2002-09-10 19:07:02 +0000 | [diff] [blame] | 320 | f.WriteLine(" If you plan to develop your own programme, in C, which uses " + bname + ", then"); |
| 321 | f.WriteLine("you should know what to do with the files in the binary package. If you don't,"); |
| 322 | f.WriteLine("know this, then please, please do some research on how to use a"); |
| 323 | f.WriteLine("third-party library in a C programme. The topic belongs to the very basics"); |
| 324 | f.WriteLine("and you will not be able to do much without that knowledge."); |
| 325 | f.WriteBlankLines(1); |
| 326 | f.WriteLine(" If you wish to use " + bname + " solely through the supplied utilities, such as"); |
| 327 | f.WriteLine("xmllint or xsltproc, then all you need to do is place the"); |
| 328 | f.WriteLine("contents of the 'lib' and 'util' directories from the binary package in a"); |
| 329 | f.WriteLine("directory on your disc which is mentioned in your PATH environment"); |
| 330 | f.WriteLine("variable. You can use an existing directory which is allready in the"); |
| 331 | f.WriteLine("path, such as 'C:\WINDOWS', or 'C:\WINNT'. You can also create a new"); |
| 332 | f.WriteLine("directory for " + bname + " and place the files there, but be sure to modify"); |
| 333 | f.WriteLine("the PATH environment variable and add that new directory to its list."); |
| 334 | f.WriteBlankLines(1); |
| 335 | f.WriteLine(" If you use other software which needs " + bname + ", such as Apache"); |
| 336 | f.WriteLine("Web Server in certain configurations, then please consult the"); |
| 337 | f.WriteLine("documentation of that software and see if it mentions something about"); |
| 338 | f.WriteLine("how it uses " + bname + " and how it expects it to be installed. If you find"); |
| 339 | f.WriteLine("nothing, then the default installation, as described in the previous"); |
| 340 | f.WriteLine("paragraph, should be suficient."); |
| 341 | f.WriteBlankLines(1); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 342 | f.WriteLine(" If there is something you cannot keep for yourself, such as a problem,"); |
| 343 | f.WriteLine("a cheer of joy, a comment or a suggestion, feel free to contact me using"); |
| 344 | f.WriteLine("the address below."); |
| 345 | f.WriteBlankLines(1); |
Daniel Veillard | beb70bd | 2002-12-18 14:53:54 +0000 | [diff] [blame] | 346 | f.WriteLine(" Igor Zlatkovic (igor@zlatkovic.com)"); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 347 | f.Close(); |
| 348 | } |
| 349 | |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 350 | |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 351 | /* |
| 352 | * main(), |
| 353 | * Execution begins here. |
| 354 | */ |
| 355 | |
| 356 | // Parse the command-line arguments. |
| 357 | for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) { |
| 358 | var arg, opt; |
| 359 | arg = WScript.Arguments(i); |
| 360 | opt = arg.substring(0, arg.indexOf("=")); |
| 361 | if (opt.length == 0) |
| 362 | opt = arg.substring(0, arg.indexOf(":")); |
| 363 | if (opt.length > 0) { |
| 364 | if (opt == "trio") |
| 365 | withTrio = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 366 | else if (opt == "threads") |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 367 | withThreads = arg.substring(opt.length + 1, arg.length); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 368 | else if (opt == "ftp") |
| 369 | withFtp = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 370 | else if (opt == "http") |
| 371 | withHttp = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 372 | else if (opt == "html") |
| 373 | withHtml = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | 9425ce2 | 2002-04-10 21:57:11 +0000 | [diff] [blame] | 374 | else if (opt == "c14n") |
| 375 | withC14n = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 376 | else if (opt == "catalog") |
| 377 | withCatalog = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 378 | else if (opt == "docb") |
| 379 | withDocb = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 380 | else if (opt == "xpath") |
| 381 | withXpath = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 382 | else if (opt == "xptr") |
| 383 | withXptr = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 384 | else if (opt == "xinclude") |
| 385 | withXinclude = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 386 | else if (opt == "iconv") |
| 387 | withIconv = strToBool(arg.substring(opt.length + 1, arg.length)); |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 388 | else if (opt == "iso8859x") |
| 389 | withIso8859x = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 390 | else if (opt == "zlib") |
| 391 | withZlib = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 392 | else if (opt == "xml_debug") |
| 393 | withDebug = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 394 | else if (opt == "mem_debug") |
| 395 | withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | a6f2d90 | 2002-04-16 17:57:17 +0000 | [diff] [blame] | 396 | else if (opt == "schemas") |
| 397 | withSchemas = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | 8e04097 | 2002-09-20 13:39:53 +0000 | [diff] [blame] | 398 | else if (opt == "regexps") |
| 399 | withRegExps = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 400 | else if (opt == "python") |
| 401 | withPython = strToBool(arg.substring(opt.length + 1, arg.length)); |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 402 | else if (opt == "compiler") |
| 403 | compiler = arg.substring(opt.length + 1, arg.length); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 404 | else if (opt == "debug") |
| 405 | buildDebug = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 406 | else if (opt == "static") |
| 407 | buildStatic = strToBool(arg.substring(opt.length + 1, arg.length)); |
| 408 | else if (opt == "prefix") |
| 409 | buildPrefix = arg.substring(opt.length + 1, arg.length); |
| 410 | else if (opt == "incdir") |
| 411 | buildIncPrefix = arg.substring(opt.length + 1, arg.length); |
| 412 | else if (opt == "bindir") |
| 413 | buildBinPrefix = arg.substring(opt.length + 1, arg.length); |
| 414 | else if (opt == "libdir") |
| 415 | buildLibPrefix = arg.substring(opt.length + 1, arg.length); |
| 416 | else if (opt == "sodir") |
| 417 | buildSoPrefix = arg.substring(opt.length + 1, arg.length); |
| 418 | else if (opt == "incdir") |
| 419 | buildIncPrefix = arg.substring(opt.length + 1, arg.length); |
| 420 | else if (opt == "include") |
| 421 | buildInclude = arg.substring(opt.length + 1, arg.length); |
| 422 | else if (opt == "lib") |
| 423 | buildLib = arg.substring(opt.length + 1, arg.length); |
| 424 | else |
| 425 | error = 1; |
| 426 | } else if (i == 0) { |
| 427 | if (arg == "genreadme") { |
| 428 | // This command comes from the Makefile and will not be checked |
| 429 | // for errors, because Makefile will always supply right the parameters. |
| 430 | genReadme(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3)); |
| 431 | WScript.Quit(0); |
| 432 | } else if (arg == "help") { |
| 433 | usage(); |
| 434 | WScript.Quit(0); |
| 435 | } |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 436 | |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 437 | } else |
| 438 | error = 1; |
| 439 | } |
| 440 | |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 441 | |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 442 | // If we fail here, it is because the user supplied an unrecognised argument. |
| 443 | if (error != 0) { |
| 444 | usage(); |
| 445 | WScript.Quit(error); |
| 446 | } |
| 447 | |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 448 | |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 449 | // Discover the version. |
| 450 | discoverVersion(); |
| 451 | if (error != 0) { |
| 452 | WScript.Echo("Version discovery failed, aborting."); |
| 453 | WScript.Quit(error); |
| 454 | } |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 455 | |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 456 | WScript.Echo(baseName + " version: " + verMajor + "." + verMinor + "." + verMicro); |
| 457 | |
| 458 | // Configure libxml. |
| 459 | configureLibxml(); |
| 460 | if (error != 0) { |
| 461 | WScript.Echo("Configuration failed, aborting."); |
| 462 | WScript.Quit(error); |
| 463 | } |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 464 | |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 465 | if (withPython == true) { |
| 466 | configureLibxmlPy(); |
| 467 | if (error != 0) { |
| 468 | WScript.Echo("Configuration failed, aborting."); |
| 469 | WScript.Quit(error); |
| 470 | } |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 471 | |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 472 | } |
| 473 | |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 474 | // Create the makefile. |
| 475 | var fso = new ActiveXObject("Scripting.FileSystemObject"); |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 476 | var makefile = ".\\Makefile.msvc"; |
| 477 | if (compiler == "mingw") |
| 478 | makefile = ".\\Makefile.mingw"; |
Igor Zlatkovic | e8b5b0f | 2003-06-16 07:12:50 +0000 | [diff] [blame] | 479 | else if (compiler == "bcb") |
| 480 | makefile = ".\\Makefile.bcb"; |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 481 | fso.CopyFile(makefile, ".\\Makefile", true); |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 482 | WScript.Echo("Created Makefile."); |
Igor Zlatkovic | 1bab92d | 2003-08-28 10:24:40 +0000 | [diff] [blame^] | 483 | // Create the config.h. |
| 484 | var confighsrc = "..\\include\\win32config.h"; |
| 485 | var configh = "..\\config.h"; |
| 486 | fso.CopyFile(confighsrc, configh, true); |
| 487 | WScript.Echo("Created config.h."); |
| 488 | |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 489 | |
| 490 | // Display the final configuration. |
| 491 | var txtOut = "\nXML processor configuration\n"; |
| 492 | txtOut += "---------------------------\n"; |
| 493 | txtOut += " Trio: " + boolToStr(withTrio) + "\n"; |
Igor Zlatkovic | 8f536a8 | 2002-10-31 16:01:00 +0000 | [diff] [blame] | 494 | txtOut += " Thread safety: " + withThreads + "\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 495 | txtOut += " FTP client: " + boolToStr(withFtp) + "\n"; |
| 496 | txtOut += " HTTP client: " + boolToStr(withHttp) + "\n"; |
| 497 | txtOut += " HTML processor: " + boolToStr(withHtml) + "\n"; |
| 498 | txtOut += " C14N support: " + boolToStr(withC14n) + "\n"; |
| 499 | txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n"; |
| 500 | txtOut += " DocBook support: " + boolToStr(withDocb) + "\n"; |
| 501 | txtOut += " XPath support: " + boolToStr(withXpath) + "\n"; |
| 502 | txtOut += " XPointer support: " + boolToStr(withXptr) + "\n"; |
| 503 | txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n"; |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 504 | txtOut += " iconv support: " + boolToStr(withIconv) + "\n"; |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 505 | txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n"; |
Igor Zlatkovic | 3acadf4 | 2002-09-20 16:40:17 +0000 | [diff] [blame] | 506 | txtOut += " zlib support: " + boolToStr(withZlib) + "\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 507 | txtOut += " Debugging module: " + boolToStr(withDebug) + "\n"; |
| 508 | txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n"; |
Igor Zlatkovic | 8e04097 | 2002-09-20 13:39:53 +0000 | [diff] [blame] | 509 | txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n"; |
Igor Zlatkovic | a6f2d90 | 2002-04-16 17:57:17 +0000 | [diff] [blame] | 510 | txtOut += "XML Schema support: " + boolToStr(withSchemas) + "\n"; |
Igor Zlatkovic | 853514f | 2002-11-22 21:41:09 +0000 | [diff] [blame] | 511 | txtOut += " Python bindings: " + boolToStr(withPython) + "\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 512 | txtOut += "\n"; |
| 513 | txtOut += "Win32 build configuration\n"; |
| 514 | txtOut += "-------------------------\n"; |
Igor Zlatkovic | bd1a306 | 2002-11-14 17:43:24 +0000 | [diff] [blame] | 515 | txtOut += " Compiler: " + compiler + "\n"; |
Igor Zlatkovic | ac97f6e | 2002-03-24 21:00:26 +0000 | [diff] [blame] | 516 | txtOut += " Debug symbols: " + boolToStr(buildDebug) + "\n"; |
| 517 | txtOut += " Static xmllint: " + boolToStr(buildStatic) + "\n"; |
| 518 | txtOut += " Install prefix: " + buildPrefix + "\n"; |
| 519 | txtOut += " Put tools in: " + buildBinPrefix + "\n"; |
| 520 | txtOut += " Put headers in: " + buildIncPrefix + "\n"; |
| 521 | txtOut += "Put static libs in: " + buildLibPrefix + "\n"; |
| 522 | txtOut += "Put shared libs in: " + buildSoPrefix + "\n"; |
| 523 | txtOut += " Include path: " + buildInclude + "\n"; |
| 524 | txtOut += " Lib path: " + buildLib + "\n"; |
| 525 | WScript.Echo(txtOut); |
| 526 | |
William M. Brack | 6d13f33 | 2003-08-08 16:40:36 +0000 | [diff] [blame] | 527 | // |
| 528 | |