]> granicus.if.org Git - php/commitdiff
- cvs > svn
authorPierre Joye <pajoye@php.net>
Wed, 15 Jul 2009 16:52:50 +0000 (16:52 +0000)
committerPierre Joye <pajoye@php.net>
Wed, 15 Jul 2009 16:52:50 +0000 (16:52 +0000)
win32/build/confutils.js

index 79743cba921bcb2e76d42932477386cfb55e421d..2dd771c66172e2ef7ed7a82ea9602a51e69ba3c6 100644 (file)
-// Utils for configure script
-/*
-  +----------------------------------------------------------------------+
-  | PHP Version 5                                                        |
-  +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2008 The PHP Group                                |
-  +----------------------------------------------------------------------+
-  | This source file is subject to version 3.01 of the PHP license,      |
-  | that is bundled with this package in the file LICENSE, and is        |
-  | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
-  | If you did not receive a copy of the PHP license and are unable to   |
-  | obtain it through the world-wide-web, please send a note to          |
-  | license@php.net so we can mail you a copy immediately.               |
-  +----------------------------------------------------------------------+
-  | Author: Wez Furlong <wez@thebrainroom.com>                           |
-  +----------------------------------------------------------------------+
-*/
-
-// $Id: confutils.js,v 1.83 2009-05-29 07:41:46 kalle Exp $
-
-var STDOUT = WScript.StdOut;
-var STDERR = WScript.StdErr;
-var WshShell = WScript.CreateObject("WScript.Shell");
-var FSO = WScript.CreateObject("Scripting.FileSystemObject");
-var MFO = null;
-var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive");
-var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles");
-var DSP_FLAGS = new Array();
-
-/* Store the enabled extensions (summary + QA check) */
-var extensions_enabled = new Array();
-
-/* Store the SAPI enabled (summary + QA check) */
-var sapi_enabled = new Array();
-
-/* Mapping CL version > human readable name */
-var VC_VERSIONS = new Array();
-VC_VERSIONS[1200] = 'MSVC6 (Visual C++ 6.0)';
-VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)';
-VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)';
-VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)';
-VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)';
-
-var VC_VERSIONS_SHORT = new Array();
-VC_VERSIONS_SHORT[1200] = 'VC6';
-VC_VERSIONS_SHORT[1300] = 'VC7';
-VC_VERSIONS_SHORT[1310] = 'VC7.1';
-VC_VERSIONS_SHORT[1400] = 'VC8';
-VC_VERSIONS_SHORT[1500] = 'VC9';
-
-if (PROGRAM_FILES == null) {
-       PROGRAM_FILES = "C:\\Program Files";
-}
-
-if (!FSO.FileExists("README.CVS-RULES")) {
-       STDERR.WriteLine("Must be run from the root of the php source");
-       WScript.Quit(10);
-}
-       
-var CWD = WshShell.CurrentDirectory;
-
-if (typeof(CWD) == "undefined") {
-       CWD = FSO.GetParentFolderName(FSO.GetAbsolutePathName("README.CVS-RULES"));
-}
-
-/* defaults; we pick up the precise versions from configure.in */
-var PHP_VERSION = 5;
-var PHP_MINOR_VERSION = 0;
-var PHP_RELEASE_VERSION = 0;
-var PHP_EXTRA_VERSION = "";
-var PHP_VERSION_STRING = "5.0.0";
-
-function get_version_numbers()
-{
-       var cin = file_get_contents("configure.in");
-       
-       if (cin.match(new RegExp("PHP_MAJOR_VERSION=(\\d+)"))) {
-               PHP_VERSION = RegExp.$1;
-       }
-       if (cin.match(new RegExp("PHP_MINOR_VERSION=(\\d+)"))) {
-               PHP_MINOR_VERSION = RegExp.$1;
-       }
-       if (cin.match(new RegExp("PHP_RELEASE_VERSION=(\\d+)"))) {
-               PHP_RELEASE_VERSION = RegExp.$1;
-       }
-       PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION;
-
-       if (cin.match(new RegExp("PHP_EXTRA_VERSION=\"([^\"]+)\""))) {
-               PHP_EXTRA_VERSION = RegExp.$1;
-               if (PHP_EXTRA_VERSION.length) {
-                       PHP_VERSION_STRING += PHP_EXTRA_VERSION;
-               }
-       }
-       DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING);
-}
-
-configure_args = new Array();
-configure_subst = WScript.CreateObject("Scripting.Dictionary");
-
-configure_hdr = WScript.CreateObject("Scripting.Dictionary");
-build_dirs = new Array();
-
-extension_include_code = "";
-extension_module_ptrs = "";
-
-get_version_numbers();
-
-/* execute a command and return the output as a string */
-function execute(command_line)
-{
-       var e = WshShell.Exec(command_line);
-       var ret = "";
-
-       ret = e.StdOut.ReadAll();
-
-//STDOUT.WriteLine("command " + command_line);
-//STDOUT.WriteLine(ret);
-
-       return ret;
-}
-
-function probe_binary(EXE, what)
-{
-       // tricky escapes to get stderr redirection to work
-       var command = 'cmd /c ""' + EXE;
-       if (what == "version") {
-               command = command + '" -v"';
-       }
-       var version = execute(command + '" 2>&1"');
-
-       if (what == "64") {
-               if (version.match(/x64/)) {
-                       return 1;
-               }
-       } else {
-               if (version.match(/(\d+\.\d+(\.\d+)?(\.\d+)?)/)) {
-                       return RegExp.$1;
-               }
-       }
-       return 0;
-}
-
-function condense_path(path)
-{
-       path = FSO.GetAbsolutePathName(path);
-
-       if (path.substr(0, CWD.length).toLowerCase()
-                       == CWD.toLowerCase() &&
-                       (path.charCodeAt(CWD.length) == 92 || path.charCodeAt(CWD.length) == 47)) {
-               return path.substr(CWD.length + 1);
-       }
-
-       var a = CWD.split("\\");
-       var b = path.split("\\");
-       var i, j;
-
-       for (i = 0; i < b.length; i++) {
-               if (a[i].toLowerCase() == b[i].toLowerCase())
-                       continue;
-               if (i > 0) {
-                       /* first difference found */
-                       path = "";
-                       for (j = 0; j < a.length - i; j++) {
-                               path += "..\\";
-                       }
-                       for (j = i; j < b.length; j++) {
-                               path += b[j];
-                               if (j < b.length - 1)
-                                       path += "\\";
-                       }
-                       return path;
-               }
-               /* on a different drive */
-               break;
-       }
-       
-       return path;
-}
-
-function ConfigureArg(type, optname, helptext, defval)
-{
-       var opptype = type == "enable" ? "disable" : "without";
-
-       if (defval == "yes" || defval == "yes,shared") {
-               this.arg = "--" + opptype + "-" + optname;
-               this.imparg = "--" + type + "-" + optname;
-       } else {
-               this.arg = "--" + type + "-" + optname;
-               this.imparg = "--" + opptype + "-" + optname;
-       }
-       
-       this.optname = optname;
-       this.helptext = helptext;
-       this.defval = defval;
-       this.symval = optname.toUpperCase().replace(new RegExp("-", "g"), "_");
-       this.seen = false;
-       this.argval = defval;
-}
-
-function ARG_WITH(optname, helptext, defval)
-{
-       configure_args[configure_args.length] = new ConfigureArg("with", optname, helptext, defval);
-}
-
-function ARG_ENABLE(optname, helptext, defval)
-{
-       configure_args[configure_args.length] = new ConfigureArg("enable", optname, helptext, defval);
-}
-
-function analyze_arg(argval)
-{
-       var ret = new Array();
-       var shared = false;
-
-       if (argval == "shared") {
-               shared = true;
-               argval = "yes";
-       } else if (argval == null) {
-               /* nothing */
-       } else if (arg_match = argval.match(new RegExp("^shared,(.*)"))) {
-               shared = true;
-               argval = arg_match[1];
-       } else if (arg_match = argval.match(new RegExp("^(.*),shared$"))) {
-               shared = true;
-               argval = arg_match[1];
-       }
-
-       ret[0] = shared;
-       ret[1] = argval;
-       return ret;
-}
-
-function word_wrap_and_indent(indent, text, line_suffix, indent_char)
-{
-       if (text == null) {
-               return "";
-       }
-       
-       var words = text.split(new RegExp("\\s+", "g"));
-       var i = 0;
-       var ret_text = "";
-       var this_line = "";
-       var t;
-       var space = "";
-       var lines = 0;
-
-       if (line_suffix == null) {
-               line_suffix = "";
-       }
-
-       if (indent_char == null) {
-               indent_char = " ";
-       }
-
-       for (i = 0; i < indent; i++) {
-               space += indent_char;
-       }
-       
-       for (i = 0; i < words.length; i++) {
-               if (this_line.length) {
-                       t = this_line + " " + words[i];
-               } else {
-                       t = words[i];
-               }
-
-               if (t.length + indent > 78) {
-                       if (lines++) {
-                               ret_text += space;
-                       }
-                       ret_text += this_line + line_suffix + "\r\n";
-                       this_line = "";
-               }
-
-               if (this_line.length) {
-                       this_line += " " + words[i];
-               } else {
-                       this_line = words[i];
-               }
-       }
-
-       if (this_line.length) {
-               if (lines)
-                       ret_text += space;
-               ret_text += this_line;
-       }
-
-       return ret_text;
-}
-
-function conf_process_args()
-{
-       var i, j;
-       var configure_help_mode = false;
-       var analyzed = false;
-       var nice = "cscript /nologo configure.js ";
-       var disable_all = false;
-       
-       args = WScript.Arguments;
-       for (i = 0; i < args.length; i++) {
-               arg = args(i);
-               nice += ' "' + arg + '"';
-               if (arg == "--help") {
-                       configure_help_mode = true;
-                       break;
-               }
-               if (arg == "--disable-all") {
-                       disable_all = true;
-                       continue;
-               }
-
-               // If it is --foo=bar, split on the equals sign
-               arg = arg.split("=", 2);
-               argname = arg[0];
-               if (arg.length > 1) {
-                       argval = arg[1];
-               } else {
-                       argval = null;
-               }
-
-               // Find the arg
-               found = false;
-               for (j = 0; j < configure_args.length; j++) {
-                       if (argname == configure_args[j].imparg || argname == configure_args[j].arg) {
-                               found = true;
-
-                               arg = configure_args[j];
-                               arg.seen = true;
-
-                               analyzed = analyze_arg(argval);
-                               shared = analyzed[0];
-                               argval = analyzed[1];
-
-                               if (argname == arg.imparg) {
-                                       /* we matched the implicit, or default arg */
-                                       if (argval == null) {
-                                               argval = arg.defval;
-                                       }
-                               } else {
-                                       /* we matched the non-default arg */
-                                       if (argval == null) {
-                                               argval = arg.defval == "no" ? "yes" : "no";
-                                       }
-                               }
-                               
-                               arg.argval = argval;
-                               eval("PHP_" + arg.symval + " = argval;");
-                               eval("PHP_" + arg.symval + "_SHARED = shared;");
-                               break;
-                       }
-               }
-               if (!found) {
-                       STDERR.WriteLine("Unknown option " + argname + "; please try configure.js --help for a list of valid options");
-                       WScript.Quit(2);
-               }
-       }
-
-       if (configure_help_mode) {
-               STDOUT.WriteLine(word_wrap_and_indent(0,
-"Options that enable extensions and SAPI will accept \
-'yes' or 'no' as a parameter.  They also accept 'shared' \
-as a synonym for 'yes' and request a shared build of that \
-module.  Not all modules can be built as shared modules; \
-configure will display [shared] after the module name if \
-can be built that way. \
-"
-                       ));
-               STDOUT.WriteBlankLines(1);
-
-               // Measure width to pretty-print the output
-               max_width = 0;
-               for (i = 0; i < configure_args.length; i++) {
-                       arg = configure_args[i];
-                       if (arg.arg.length > max_width)
-                               max_width = arg.arg.length;
-               }
-
-               for (i = 0; i < configure_args.length; i++) {
-                       arg = configure_args[i];
-
-                       n = max_width - arg.arg.length;
-                       pad = "   ";
-                       for (j = 0; j < n; j++) {
-                               pad += " ";
-                       }
-                       STDOUT.WriteLine("  " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext));
-               }
-               WScript.Quit(1);
-       }
-
-       var snapshot_build_exclusions = new Array(
-               'debug', 'crt-debug', 'lzf-better-compression',
-                'php-build', 'snapshot-template', 'ereg',
-                'pcre-regex', 'fastcgi', 'force-cgi-redirect',
-                'path-info-check', 'zts', 'ipv6', 'memory-limit',
-                'zend-multibyte', 'fd-setsize', 'memory-manager', 't1lib'
-               );
-       var force;
-
-       // Now set any defaults we might have missed out earlier
-       for (i = 0; i < configure_args.length; i++) {
-               arg = configure_args[i];
-               if (arg.seen)
-                       continue;
-               analyzed = analyze_arg(arg.defval);
-               shared = analyzed[0];
-               argval = analyzed[1];
-               
-               // Don't trust a default "yes" answer for a non-core module
-               // in a snapshot build
-               if (PHP_SNAPSHOT_BUILD != "no" && argval == "yes" && !shared) {
-
-                       force = true;
-                       for (j = 0; j < snapshot_build_exclusions.length; j++) {
-                               if (snapshot_build_exclusions[j] == arg.optname) {
-                                       force = false;
-                                       break;
-                               }
-                       }
-
-                       if (force) {
-                               /* now check if it is a core module */
-                               force = false;
-                               for (j = 0; j < core_module_list.length; j++) {
-                                       if (core_module_list[j] == arg.optname) {
-                                               force = true;
-                                               break;
-                                       }
-                               }
-
-                               if (!force) {
-                                       STDOUT.WriteLine("snapshot: forcing " + arg.arg + " shared");
-                                       shared = true;
-                               }
-                       }
-               }
-               
-               if (PHP_SNAPSHOT_BUILD != "no" && argval == "no") {
-                       force = true;
-                       for (j = 0; j < snapshot_build_exclusions.length; j++) {
-                               if (snapshot_build_exclusions[j] == arg.optname) {
-                                       force = false;
-                                       break;
-                               }
-                       }
-                       if (force) {
-                               STDOUT.WriteLine("snapshot: forcing " + arg.optname + " on");
-                               argval = "yes";
-                               shared = true;
-                       }
-               }
-
-               if (disable_all) {
-                       force = true;
-                       for (j = 0; j < snapshot_build_exclusions.length; j++) {
-                               if (snapshot_build_exclusions[j] == arg.optname) {
-                                       force = false;
-                                       break;
-                               }
-                       }
-                       if (force) {
-                               if (arg.defval == '') {
-                                       argval = '';
-                               } else {
-                                       argval = "no";
-                               }
-                               shared = false;
-                       }
-               }
-
-               eval("PHP_" + arg.symval + " = argval;");
-               eval("PHP_" + arg.symval + "_SHARED = shared;");
-       }
-
-       MFO = FSO.CreateTextFile("Makefile.objects", true);
-
-       STDOUT.WriteLine("Saving configure options to config.nice.bat");
-       var nicefile = FSO.CreateTextFile("config.nice.bat", true);
-       nicefile.WriteLine(nice +  " %*");
-       nicefile.Close();
-
-       AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line");
-}
-
-function DEFINE(name, value)
-{
-       if (configure_subst.Exists(name)) {
-               configure_subst.Remove(name);
-       }
-       configure_subst.Add(name, value);
-}
-
-// Searches a set of paths for a file;
-// returns the dir in which the file was found,
-// true if it was found in the default env path,
-// or false if it was not found at all.
-// env_name is the optional name of an env var
-// specifying the default path to search
-function search_paths(thing_to_find, explicit_path, env_name)
-{
-       var i, found = false, place = false, file, env;
-
-       STDOUT.Write("Checking for " + thing_to_find + " ... ");
-
-       thing_to_find = thing_to_find.replace(new RegExp("/", "g"), "\\");
-
-       if (explicit_path != null) {
-               if (typeof(explicit_path) == "string") {
-                       explicit_path = explicit_path.split(";");
-               }
-
-               for (i = 0; i < explicit_path.length; i++) {
-                       file = glob(explicit_path[i] + "\\" + thing_to_find);
-                       if (file) {
-                               found = true;
-                               place = file[0];
-                               place = place.substr(0, place.length - thing_to_find.length - 1);
-                               break;
-                       }
-               }
-       }
-
-       if (!found && env_name != null) {
-               env = WshShell.Environment("Process").Item(env_name);
-               env = env.split(";");
-               for (i = 0; i < env.length; i++) {
-                       file = glob(env[i] + "\\" + thing_to_find);
-                       if (file) {
-                               found = true;
-                               place = true;
-                               break;
-                       }
-               }
-       }
-
-       if (found && place == true) {
-               STDOUT.WriteLine(" <in default path>");
-       } else if (found) {
-               STDOUT.WriteLine(" " + place);
-       } else {
-               STDOUT.WriteLine(" <not found>");
-       }
-       return place;
-}
-
-function PATH_PROG(progname, additional_paths, symbol)
-{
-       var exe;
-       var place;
-       var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin";
-       var php_build_bin_path = PHP_PHP_BUILD + "\\bin"
-
-       exe = progname + ".exe";
-
-       if (additional_paths == null) {
-               additional_paths = cyg_path;
-       } else {
-               additional_paths += ";" + cyg_path;
-       }
-
-       additional_paths = additional_paths + ";" + php_build_bin_path;
-
-       place = search_paths(exe, additional_paths, "PATH");
-
-       if (place == true) {
-               place = exe;
-       } else if (place != false) {
-               place = place + "\\" + exe;
-       }
-
-       if (place) {
-               if (symbol == null) {
-                       symbol = progname.toUpperCase();
-               }
-               DEFINE(symbol, place);
-       }
-       return place;
-}
-
-function find_pattern_in_path(pattern, path)
-{
-       if (path == null) {
-               return false;
-       }
-
-       var dirs = path.split(';');
-       var i;
-       var items;
-
-       for (i = 0; i < dirs.length; i++) {
-               items = glob(dirs[i] + "\\" + pattern);
-               if (items) {
-                       return condense_path(items[0]);
-               }
-       }
-       return false;
-}
-
-function CHECK_LIB(libnames, target, path_to_check, common_name)
-{
-       STDOUT.Write("Checking for library " + libnames + " ... ");
-
-       if (common_name == null && target != null) {
-               common_name = target;
-       }
-
-       if (path_to_check == null) {
-               path_to_check = "";
-       }
-
-       // if they specified a common name for the package that contains
-       // the library, tag some useful defaults on to the end of the
-       // path to be searched
-       if (common_name != null) {
-               path_to_check += ";" + PHP_PHP_BUILD + "\\" + common_name + "*";
-               path_to_check += ";" + PHP_PHP_BUILD + "\\lib\\" + common_name + "*";
-               path_to_check += ";..\\" + common_name + "*";
-       }
-
-       // Determine target for build flags
-       if (target == null) {
-               target = "";
-       } else {
-               target = "_" + target.toUpperCase();
-       }
-
-       // Expand path to include general dirs
-       path_to_check += ";" + php_usual_lib_suspects;
-
-       // It is common practice to put libs under one of these dir names
-       var subdirs = new Array(PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"), "lib", "libs", "libexec");
-
-       // libnames can be ; separated list of accepted library names
-       libnames = libnames.split(';');
-
-       // for debug builds, lib may have _debug appended, we want that first
-       if (PHP_DEBUG == "yes") {
-               var length = libnames.length;
-               for (var i = 0; i < length; i++) {
-                       var name = new String(libnames[i]);
-                       rExp = /.lib$/i;
-                       name = name.replace(rExp,"_debug.lib");
-                       libnames.unshift(name);
-               }
-       }
-
-       var i, j, k, libname;
-       var location = false;
-       var path = path_to_check.split(';');
-       
-       for (i = 0; i < libnames.length; i++) {
-               libname = libnames[i];
-
-               for (k = 0; k < path.length; k++) {
-                       location = glob(path[k] + "\\" + libname);
-                       if (location) {
-                               location = location[0];
-                               break;
-                       }
-                       for (j = 0; j < subdirs.length; j++) {
-                               location = glob(path[k] + "\\" + subdirs[j] + "\\" + libname);
-                               if (location) {
-                                       location = location[0];
-                                       break;
-                               }
-                       }
-                       if (location)
-                               break;
-               }
-
-               if (location) {
-                       location = condense_path(location);
-                       var libdir = FSO.GetParentFolderName(location);
-                       libname = FSO.GetFileName(location);
-                       ADD_FLAG("LDFLAGS" + target, '/libpath:"' + libdir + '" ');
-                       ADD_FLAG("LIBS" + target, libname);
-
-                       STDOUT.WriteLine(location);
-
-                       return location;
-               }
-
-               // Check in their standard lib path
-               location = find_pattern_in_path(libname, WshShell.Environment("Process").Item("LIB"));
-
-               if (location) {
-                       location = condense_path(location);
-                       libname = FSO.GetFileName(location);
-                       ADD_FLAG("LIBS" + target, libname);
-
-                       STDOUT.WriteLine("<in LIB path> " + libname);
-                       return location;
-               }
-
-               // Check in their general extra libs path
-               location = find_pattern_in_path(libname, PHP_EXTRA_LIBS);
-               if (location) {
-                       location = condense_path(location);
-                       libname = FSO.GetFileName(location);
-                       ADD_FLAG("LIBS" + target, libname);
-                       STDOUT.WriteLine("<in extra libs path>");
-                       return location;
-               }
-       }
-
-       STDOUT.WriteLine("<not found>");
-
-       return false;
-}
-
-function OLD_CHECK_LIB(libnames, target, path_to_check)
-{
-       if (target == null) {
-               target = "";
-       } else {
-               target = "_" + target.toUpperCase();
-       }
-       
-       if (path_to_check == null) {
-               path_to_check = php_usual_lib_suspects;
-       } else {
-               path_to_check += ";" + php_usual_lib_suspects;
-       }
-       var have = 0;
-       var p;
-       var i;
-       var libname;
-
-       var subdir = PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release");
-
-       libnames = libnames.split(';');
-       for (i = 0; i < libnames.length; i++) {
-               libname = libnames[i];
-               p = search_paths(libname, path_to_check, "LIB");
-
-               if (!p) {
-                       p = search_paths(subdir + "\\" + libname, path_to_check, "LIB");
-                       if (p) {
-                               p += "\\" + subdir;
-                       }
-               }
-
-               if (typeof(p) == "string") {
-                       ADD_FLAG("LDFLAGS" + target, '/libpath:"' + p + '" ');
-                       ADD_FLAG("LIBS" + target, libname);
-                       have = 1;
-               } else if (p == true) {
-                       ADD_FLAG("LIBS" + target, libname);
-                       have = 1;
-               } else {
-                       /* not found in the defaults or the explicit paths,
-                        * so check the general extra libs; if we find
-                        * it here, no need to add another /libpath: for it as we
-                        * already have it covered, but we need to add the lib
-                        * to LIBS_XXX */
-                       if (false != search_paths(libname, PHP_EXTRA_LIBS, null)) {
-                               ADD_FLAG("LIBS" + target, libname);
-                               have = 1;
-                       }
-               }
-
-               if (have) {
-                       break;
-               }
-       }
-
-//     AC_DEFINE("HAVE_" + header_name.toUpperCase().replace(new RegExp("/\\\\-\.", "g"), "_"), have);
-
-       return have;
-
-}
-
-function CHECK_FUNC_IN_HEADER(header_name, func_name, path_to_check, add_to_flag)
-{
-       var c = false;
-       var sym;
-
-       STDOUT.Write("Checking for " + func_name + " in " + header_name + " ... ");
-
-       c = GREP_HEADER(header_name, func_name, path_to_check);
-
-       sym = func_name.toUpperCase();
-       sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_");
-
-       if (typeof(add_to_flag) == "undefined") {
-               AC_DEFINE("HAVE_" + sym, c ? 1 : 0);
-       } else {
-               ADD_FLAG(add_to_flag, "/DHAVE_" + sym + "=" + (c ? "1" : "0"));
-       }
-
-       if (c) {
-               STDOUT.WriteLine("OK");
-               return c;
-       }
-       STDOUT.WriteLine("No");
-       return false;   
-}
-
-function GREP_HEADER(header_name, regex, path_to_check)
-{
-       var c = false;
-
-       if (FSO.FileExists(path_to_check + "\\" + header_name)) {
-               c = file_get_contents(path_to_check + "\\" + header_name);
-       }
-
-       if (!c) {
-               /* look in the include path */
-
-               var p = search_paths(header_name, path_to_check, "INCLUDE");
-               if (typeof(p) == "string") {
-                       c = file_get_contents(p);
-               } else if (p == false) {
-                       p = search_paths(header_name, PHP_EXTRA_INCLUDES, null);
-                       if (typeof(p) == "string") {
-                               c = file_get_contents(p);
-                       }
-               } 
-               if (!c) {
-                       return false;
-               }
-       }
-
-       if (typeof(regex) == "string") {
-               regex = new RegExp(regex);
-       }
-
-       if (c.match(regex)) {
-               /* caller can now use RegExp.$1 etc. to get at patterns */
-               return true;
-       }
-       return false;
-}
-
-function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env, add_dir_part, add_to_flag_only)
-{
-       var dir_part_to_add = "";
-       
-       if (use_env == null) {
-               use_env = true;
-       }
-
-       // if true, add the dir part of the header_name to the include path
-       if (add_dir_part == null) {
-               add_dir_part = false;
-       } else if (add_dir_part) {
-               var basename = FSO.GetFileName(header_name);
-               dir_part_to_add = "\\" + header_name.substr(0, header_name.length - basename.length - 1);
-       }
-
-       if (path_to_check == null) {
-               path_to_check = php_usual_include_suspects;
-       } else {
-               path_to_check += ";" + php_usual_include_suspects;
-       }
-       
-       var p = search_paths(header_name, path_to_check, use_env ? "INCLUDE" : null);
-       var have = 0;
-       var sym;
-
-       if (typeof(p) == "string") {
-               ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" ');
-       } else if (p == false) {
-               /* not found in the defaults or the explicit paths,
-                * so check the general extra includes; if we find
-                * it here, no need to add another /I for it as we
-                * already have it covered, unless we are adding
-                * the dir part.... */
-               p = search_paths(header_name, PHP_EXTRA_INCLUDES, null);
-               if (typeof(p) == "string" && add_dir_part) {
-                       ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" ');
-               }
-       } 
-       have = p ? 1 : 0
-
-       sym = header_name.toUpperCase();
-       sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_");
-
-       if (typeof(add_to_flag_only) == "undefined" &&
-                       flag_name.match(new RegExp("^CFLAGS_(.*)$"))) {
-               add_to_flag_only = true;
-       }
-
-       if (typeof(add_to_flag_only) != "undefined") {
-               ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have);
-       } else {
-               AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file");
-       }
-
-       return p;
-}
-
-/* emits rule to generate version info for a SAPI
- * or extension.  Returns the name of the .res file
- * that will be generated */
-function generate_version_info_resource(makefiletarget, basename, creditspath, sapi)
-{
-       var resname = makefiletarget + ".res";
-       var res_desc = makefiletarget;
-       var res_prod_name = "PHP " + makefiletarget;
-       var credits;
-       var thanks = "";
-       var logo = "";
-       var debug = "";
-       var project_url = "http://www.php.net";
-       var project_header = creditspath + "/php_" + basename + ".h";
-       var versioning = "";
-
-       if (sapi) {
-               var internal_name = basename.toUpperCase() + " SAPI";
-       } else {
-               var internal_name = basename.toUpperCase() + " extension";
-       }
-
-       if (FSO.FileExists(creditspath + '/CREDITS')) {
-               credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1);
-               res_desc = credits.ReadLine();
-               try {
-                       thanks = credits.ReadLine();
-               } catch (e) {
-                       thanks = null;
-               }
-               if (thanks == null) {
-                       thanks = "";
-               } else {
-                       thanks = "Thanks to " + thanks;
-               }
-               credits.Close();
-       }
-
-       if (creditspath.match(new RegExp("pecl"))) {
-               /* PECL project url - this will eventually work correctly for all */
-               project_url = "http://pecl.php.net/" + basename;
-
-               /* keep independent versioning PECL-specific for now */
-               if (FSO.FileExists(project_header)) {
-                       if (header = FSO.OpenTextFile(project_header, 1)) {
-                               contents = header.ReadAll();
-                               /* allowed: x.x.x[a|b|-alpha|-beta][RCx][-dev] */
-                               if (contents.match(new RegExp('PHP_' + basename.toUpperCase() + '_VERSION(\\s+)"((\\d+\.\\d+(\.\\d+)?)((a|b)(\\d)?|\-[a-z]{3,5})?(RC\\d+)?(\-dev)?)'))) {
-                                       project_version = RegExp.$2;
-                                       file_version = RegExp.$3.split('.');
-                                       if (!file_version[2]) {
-                                               file_version[2] = 0;
-                                       }
-                                       versioning = '\\"" /d EXT_FILE_VERSION=' + file_version[0] + ',' + file_version[1] + ',' + file_version[2] + ' /d EXT_VERSION="\\"' + project_version;
-                               }
-                               header.Close();
-                       }
-               }
-       }
-
-       if (makefiletarget.match(new RegExp("\\.exe$"))) {
-               logo = " /d WANT_LOGO ";
-       }
-
-       if (PHP_DEBUG != "no") {
-               debug = " /d _DEBUG";
-       }
-
-       /**
-        * Use user supplied template.rc if it exists
-        */
-       if (FSO.FileExists(creditspath + '\\template.rc')) {
-               MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": " + creditspath + "\\template.rc");
-               MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + debug +
-                       ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' +
-                       makefiletarget + '\\"" /d PRODUCT_NAME="\\"' + res_prod_name +
-                       versioning + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" ' +
-                       creditspath + '\\template.rc');
-               return resname;
-       }
-
-       MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": win32\\build\\template.rc");
-       MFO.WriteLine("\t$(RC) /n /fo $(BUILD_DIR)\\" + resname + logo + debug +
-               ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"'
-               + makefiletarget + '\\"" /d URL="\\"' + project_url + 
-               '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + 
-               '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" win32\\build\\template.rc');
-       MFO.WriteBlankLines(1);
-       return resname;
-}
-
-function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
-{
-       var SAPI = sapiname.toUpperCase();
-       var ldflags;
-       var resname;
-       var ld;
-       var manifest;
-
-       if (typeof(obj_dir) == "undefined") {
-               sapiname_for_printing = configure_module_dirname;
-       } else {
-               sapiname_for_printing = configure_module_dirname + " (via " + obj_dir + ")";
-       }
-
-       STDOUT.WriteLine("Enabling SAPI " + sapiname_for_printing);
-
-       MFO.WriteBlankLines(1);
-       MFO.WriteLine("# objects for SAPI " + sapiname);
-       MFO.WriteBlankLines(1);
-
-       if (cflags) {
-               ADD_FLAG('CFLAGS_' + SAPI, cflags);
-       }
-
-       ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir);
-       MFO.WriteBlankLines(1);
-       MFO.WriteLine("# SAPI " + sapiname);
-       MFO.WriteBlankLines(1);
-
-       /* generate a .res file containing version information */
-       resname = generate_version_info_resource(makefiletarget, sapiname, configure_module_dirname, true);
-       
-       MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget);
-       MFO.WriteLine("\t@echo SAPI " + sapiname_for_printing + " build complete");
-       MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname);
-
-       if (makefiletarget.match(new RegExp("\\.dll$"))) {
-               ldflags = "/dll $(LDFLAGS)";
-               manifest = "-@$(_VC_MANIFEST_EMBED_DLL)";
-       } else if (makefiletarget.match(new RegExp("\\.lib$"))) {
-               ldflags = "$(LDFLAGS)";
-               ld = "$(MAKE_LIB)";
-       } else {
-               ldflags = "$(LDFLAGS)";
-               manifest = "-@$(_VC_MANIFEST_EMBED_EXE)";
-       }
-
-       if (ld) {
-               MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname);
-       } else {
-               ld = "@$(CC)";
-               MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")");
-       }
-
-       if (manifest) {
-               MFO.WriteLine("\t" + manifest);
-       }
-               
-       DEFINE('CFLAGS_' + SAPI + '_OBJ', '$(CFLAGS_' + SAPI + ')');
-
-       if (configure_module_dirname.match("pecl")) {
-               ADD_FLAG("PECL_TARGETS", makefiletarget);
-       } else {
-               ADD_FLAG("SAPI_TARGETS", makefiletarget);
-       }
-
-       if (PHP_DSP != "no") {
-               generate_dsp_file(sapiname, configure_module_dirname, file_list, false);
-       }
-
-       MFO.WriteBlankLines(1);
-       sapi_enabled[sapi_enabled.length] = [sapiname];
-}
-
-function ADD_DIST_FILE(filename)
-{
-       if (configure_module_dirname.match("pecl")) {
-               ADD_FLAG("PECL_EXTRA_DIST_FILES", filename);
-       } else {
-               ADD_FLAG("PHP_EXTRA_DIST_FILES", filename);
-       }
-}      
-
-function file_get_contents(filename)
-{
-       var f, c;
-       try {
-               f = FSO.OpenTextFile(filename, 1);
-               c = f.ReadAll();
-               f.Close();
-               return c;
-       } catch (e) {
-               STDOUT.WriteLine("Problem reading " + filename);
-               return false;
-       }
-}
-
-// Add a dependency on another extension, so that
-// the dependencies are built before extname
-function ADD_EXTENSION_DEP(extname, dependson, optional)
-{
-       var EXT = extname.toUpperCase();
-       var DEP = dependson.toUpperCase();
-       var dep_present = false;
-       var dep_shared = false;
-
-       try {
-               dep_present = eval("PHP_" + DEP);
-
-               if (dep_present != "no") {
-                       try {
-                               dep_shared = eval("PHP_" + DEP + "_SHARED");
-                       } catch (e) {
-                               dep_shared = false;
-                       }
-               }
-
-       } catch (e) {
-               dep_present = "no";
-       }
-
-       if (optional) {
-               if (dep_present == "no") {
-                       MESSAGE("\t" + dependson + " not found: " + dependson + " support in " + extname + " disabled");
-                       return false;
-               }
-       }
-
-       var ext_shared = eval("PHP_" + EXT + "_SHARED");
-
-       if (dep_shared) {
-               if (!ext_shared) {
-                       if (optional) {
-                               MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled");
-                               return false;
-                       }
-                       ERROR("static " + extname + " cannot depend on shared " + dependson);
-               }
-
-               ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)");
-               ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib");
-               ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib");
-
-       } else {
-
-               if (dep_present == "no") {
-                       if (ext_shared) {
-                               WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found");
-
-                               if (configure_hdr.Exists('HAVE_' + EXT)) {
-                                       configure_hdr.Remove('HAVE_' + EXT);
-                               }
-
-                               dllname = ' php_' + extname + '.dll';
-
-                               if (!REMOVE_TARGET(dllname, 'EXT_TARGETS')) {
-                                       REMOVE_TARGET(dllname, 'PECL_TARGETS');
-                               }
-
-                               extensions_enabled.pop();
-                               return false;
-
-                       } else {
-                               ERROR("Cannot build " + extname + "; " + dependson + " not enabled");
-                               return false;
-                       }
-               }
-       } // dependency is statically built-in to PHP
-       return true;
-}
-
-function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
-{
-       var objs = null;
-       var EXT = extname.toUpperCase();
-       var extname_for_printing;
-
-       if (shared == null) {
-               eval("shared = PHP_" + EXT + "_SHARED;");
-       } else {
-               eval("PHP_" + EXT + "_SHARED = shared;");
-       }
-
-       if (cflags == null) {
-               cflags = "";
-       }
-
-       if (typeof(obj_dir) == "undefined") {
-               extname_for_printing = configure_module_dirname;
-       } else {
-               extname_for_printing = configure_module_dirname + " (via " + obj_dir + ")";
-       }
-
-       if (shared) {
-               STDOUT.WriteLine("Enabling extension " + extname_for_printing + " [shared]");
-               cflags = "/D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags;
-               ADD_FLAG("CFLAGS_PHP", "/D COMPILE_DL_" + EXT);
-       } else {
-               STDOUT.WriteLine("Enabling extension " + extname_for_printing);
-       }
-
-       MFO.WriteBlankLines(1);
-       MFO.WriteLine("# objects for EXT " + extname);
-       MFO.WriteBlankLines(1);
-
-
-       ADD_SOURCES(configure_module_dirname, file_list, extname, obj_dir);
-       
-       MFO.WriteBlankLines(1);
-
-       if (shared) {
-               if (dllname == null) {
-                       dllname = "php_" + extname + ".dll";
-               }
-               var libname = dllname.substring(0, dllname.length-4) + ".lib";
-
-               var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false);
-               var ld = "@$(CC)";
-
-               MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname);
-               MFO.WriteBlankLines(1);
-               MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname);
-               MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")");
-               MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)");
-               MFO.WriteBlankLines(1);
-
-               if (configure_module_dirname.match("pecl")) {
-                       ADD_FLAG("PECL_TARGETS", dllname);
-               } else {
-                       ADD_FLAG("EXT_TARGETS", dllname);
-               }
-               MFO.WriteLine(dllname + ": $(BUILD_DIR)\\" + dllname);
-               MFO.WriteLine("\t@echo EXT " + extname + " build complete");
-               MFO.WriteBlankLines(1);
-               
-               DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_' + EXT + ')');
-       } else {
-               ADD_FLAG("STATIC_EXT_OBJS", "$(" + EXT + "_GLOBAL_OBJS)");
-               ADD_FLAG("STATIC_EXT_LIBS", "$(LIBS_" + EXT + ")");
-               ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")");
-               ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")");
-
-               /* find the header that declares the module pointer,
-                * so we can include it in internal_functions.c */
-               var ext_dir = FSO.GetFolder(configure_module_dirname);
-               var fc = new Enumerator(ext_dir.Files);
-               var re = /\.h$/;
-               var s, c;
-               for (; !fc.atEnd(); fc.moveNext()) {
-                       s = fc.item() + "";
-                       if (s.match(re)) {
-                               c = file_get_contents(s);
-                               if (c.match("phpext_")) {
-                                       extension_include_code += '#include "' + configure_module_dirname + '/' + FSO.GetFileName(s) + '"\r\n';
-                               }
-                       }
-               }
-       
-               extension_module_ptrs += '\tphpext_' + extname + '_ptr,\r\n';
-       
-               DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')');
-       }
-       ADD_FLAG("CFLAGS_" + EXT, cflags);
-
-       if (PHP_DSP != "no") {
-               generate_dsp_file(extname, configure_module_dirname, file_list, shared);
-       }
-
-       extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static'];
-}
-
-function ADD_SOURCES(dir, file_list, target, obj_dir)
-{
-       var i;
-       var tv;
-       var src, obj, sym, flags;
-
-       if (target == null) {
-               target = "php";
-       }
-
-       sym = target.toUpperCase() + "_GLOBAL_OBJS";
-       flags = "CFLAGS_" + target.toUpperCase() + '_OBJ';
-
-       if (configure_subst.Exists(sym)) {
-               tv = configure_subst.Item(sym);
-       } else {
-               tv = "";
-       }
-
-       file_list = file_list.split(new RegExp("\\s+"));
-       file_list.sort();
-
-       var re = new RegExp("\.[a-z0-9A-Z]+$");
-
-       dir = dir.replace(new RegExp("/", "g"), "\\");
-       var objs_line = "";
-       var srcs_line = "";
-
-       var sub_build = "$(BUILD_DIR)\\";
-
-       /* if module dir is not a child of the main source dir,
-        * we need to tweak it; we should have detected such a
-        * case in condense_path and rewritten the path to
-        * be relative.
-        * This probably breaks for non-sibling dirs, but that
-        * is not a problem as buildconf only checks for pecl
-        * as either a child or a sibling */
-       if (obj_dir == null) {
-               var build_dir = dir.replace(new RegExp("^..\\\\"), "");
-               var mangle_dir = build_dir.replace(new RegExp("[\\\\/.]", "g"), "_");
-               var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase();
-       }
-       else {
-               var build_dir = obj_dir.replace(new RegExp("^..\\\\"), "");
-               var mangle_dir = build_dir.replace(new RegExp("[\\\\/.]", "g"), "_");
-               var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase();
-       }
-       
-       var dirs = build_dir.split("\\");
-       var i, d = "";
-       for (i = 0; i < dirs.length; i++) {
-               d += dirs[i];
-               build_dirs[build_dirs.length] = d;
-               d += "\\";
-       }
-       sub_build += d;
-
-
-       DEFINE(bd_flags_name, " /Fd" + sub_build + " /Fp" + sub_build + " /FR" + sub_build + " ");
-
-       for (i in file_list) {
-               src = file_list[i];
-               obj = src.replace(re, ".obj");
-               tv += " " + sub_build + obj;
-
-               if (PHP_ONE_SHOT == "yes") {
-                       if (i > 0) {
-                               objs_line += " " + sub_build + obj;     
-                               srcs_line += " " + dir + "\\" + src;
-                       } else {
-                               objs_line = sub_build + obj;    
-                               srcs_line = dir + "\\" + src;
-                       }
-               } else {
-                       MFO.WriteLine(sub_build + obj + ": " + dir + "\\" + src);
-                       MFO.WriteLine("\t@$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " /Fo" + sub_build + obj);
-               }
-       }
-
-       if (PHP_ONE_SHOT == "yes") {
-               MFO.WriteLine(objs_line + ": " + srcs_line);
-               MFO.WriteLine("\t$(CC) $(" + flags + ") $(CFLAGS) /Fo" + sub_build + " $(" + bd_flags_name + ") /c " + srcs_line);
-       }
-
-       DEFINE(sym, tv);
-}
-
-function REMOVE_TARGET(dllname, flag)
-{
-       if (configure_subst.Exists(flag)) {
-               targets = configure_subst.Item(flag);
-               if (targets.match(dllname)) {
-                       configure_subst.Remove(flag);
-                       targets = targets.replace(dllname, "");
-                       configure_subst.Add(flag, targets);
-                       return true;
-               }
-       }
-       return false;
-}
-
-function generate_internal_functions()
-{
-       var infile, outfile;
-       var indata;
-
-       STDOUT.WriteLine("Generating main/internal_functions.c");
-       
-       infile = FSO.OpenTextFile("main/internal_functions.c.in", 1);
-       indata = infile.ReadAll();
-       infile.Close();
-       
-       indata = indata.replace("@EXT_INCLUDE_CODE@", extension_include_code);
-       indata = indata.replace("@EXT_MODULE_PTRS@", extension_module_ptrs);
-
-       if (FSO.FileExists("main/internal_functions.c")) {
-               var origdata = file_get_contents("main/internal_functions.c");
-
-               if (origdata == indata) {
-                       STDOUT.WriteLine("\t[content unchanged; skipping]");
-                       return;
-               }
-       }
-
-       outfile = FSO.CreateTextFile("main/internal_functions.c", true);
-       outfile.Write(indata);
-       outfile.Close();
-}
-
-function output_as_table(header, ar_out)
-{
-       var l = header.length;
-       var cols = 80;
-       var fixedlenght = "";
-       var t = 0;
-       var i,j,k,m;
-       var out = "| ";
-       var min = new Array(l);
-       var max = new Array(l);
-
-       if (l != ar_out[0].length) {
-               STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length  );
-               return;
-       }
-
-       for (j=0; j < l; j++) {
-               var tmax, tmin;
-
-               /*Figure out the max length per column */
-               tmin = 0;
-               tmax = 0;
-               for (k = 0; k < ar_out.length; k++) {
-                       var t = ar_out[k][j].length;
-                       if (t > tmax) tmax = t;
-                       else if (t < tmin) tmin = t;
-               }
-               if (tmax > header[j].length) {
-                       max[j] = tmax;
-               } else {
-                       max[j] = header[j].length;
-               }
-               if (tmin < header[j].length) {
-                       min[j] = header[j].length;
-               }
-       }
-
-       sep = "";
-       k = 0;
-       for (i = 0; i < l; i++) {
-               k += max[i] + 3;
-       }
-       k++;
-
-       for (j=0; j < k; j++) {
-               sep += "-";
-       }
-
-       STDOUT.WriteLine(sep);
-       out = "|";
-       for (j=0; j < l; j++) {
-               out += " " + header[j];
-               for (var i = 0; i < (max[j] - header[j].length); i++){
-                       out += " ";
-               }
-               out += " |";
-       }
-       STDOUT.WriteLine(out);
-
-       STDOUT.WriteLine(sep);
-
-       out = "|";
-       for (i=0; i < ar_out.length; i++) {
-               line = ar_out[i];
-               for (j=0; j < l; j++) {
-                       out += " " + line[j];
-                       for (var k = 0; k < (max[j] - line[j].length); k++){
-                               out += " ";
-                       }
-                       out += " |";
-               }
-               STDOUT.WriteLine(out);
-               out = "|";
-       }
-
-       STDOUT.WriteLine(sep);
-}
-
-function write_summary()
-{
-       var ar = new Array();
-
-       STDOUT.WriteBlankLines(2);
-
-       STDOUT.WriteLine("Enabled extensions:");
-       output_as_table(["Extension", "Mode"], extensions_enabled.sort());
-       STDOUT.WriteBlankLines(2);
-
-       STDOUT.WriteLine("Enabled SAPI:");
-       output_as_table(["Sapi Name"], sapi_enabled);
-       STDOUT.WriteBlankLines(2);
-
-       ar[0] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"];
-       ar[1] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"];
-       ar[2] = ['Compiler', VC_VERSIONS[VCVERS]];
-       ar[3] = ['Architecture', X64 ? 'x64' : 'x86'];
-
-       output_as_table(["",""], ar);
-       STDOUT.WriteBlankLines(2);
-}
-
-function generate_files()
-{
-       var i, dir, bd, last;
-
-       STDOUT.WriteBlankLines(1);
-       STDOUT.WriteLine("Creating build dirs...");
-       dir = get_define("BUILD_DIR");
-       build_dirs.sort();
-       last = null;
-
-       if (!FSO.FolderExists(dir)) {
-               FSO.CreateFolder(dir);
-       }
-
-       for (i = 0; i < build_dirs.length; i++) {
-               bd = FSO.BuildPath(dir, build_dirs[i]);
-               if (bd == last) {
-                       continue;
-               }
-               last = bd;
-               ADD_FLAG("BUILD_DIRS_SUB", bd.replace(new RegExp('^'+dir+'\\\\'), '$(BUILD_DIR)\\'));
-               if (!FSO.FolderExists(bd)) {
-                       FSO.CreateFolder(bd);
-               }
-       }
-
-       if (PHP_DSP != "no") {
-               generate_dsp_file("TSRM", "TSRM", null, false);
-               generate_dsp_file("Zend", "Zend", null, false);
-               generate_dsp_file("win32", "win32", null, false);
-               generate_dsp_file("main", "main", null, false);
-               generate_dsp_file("streams", "main\\streams", null, false);
-               copy_dsp_files();
-       }
-
-       STDOUT.WriteLine("Generating files...");
-       generate_makefile();
-       generate_internal_functions();
-       generate_config_h();
-
-       STDOUT.WriteLine("Done.");
-       STDOUT.WriteBlankLines(1);
-       write_summary();
-
-       if (PHP_SNAPSHOT_BUILD != "no") {
-               STDOUT.WriteLine("Type 'nmake snap' to build a PHP snapshot");
-       } else {
-               STDOUT.WriteLine("Type 'nmake' to build PHP");
-       }
-}
-
-function generate_config_h()
-{
-       var infile, outfile;
-       var indata;
-       var prefix;
-
-       prefix = PHP_PREFIX.replace(new RegExp("\\\\", "g"), "\\\\");
-
-       STDOUT.WriteLine("Generating main/config.w32.h");
-       
-       infile = FSO.OpenTextFile("win32/build/config.w32.h.in", 1);
-       indata = infile.ReadAll();
-       infile.Close();
-       
-       outfile = FSO.CreateTextFile("main/config.w32.h", true);
-
-       indata = indata.replace(new RegExp("@PREFIX@", "g"), prefix);
-       outfile.Write(indata);
-
-       var keys = (new VBArray(configure_hdr.Keys())).toArray();
-       var i, j;
-       var item;
-       var pieces, stuff_to_crack, chunk;
-
-       outfile.WriteBlankLines(1);
-       outfile.WriteLine("/* values determined by configure.js */");
-
-       for (i in keys) {
-               item = configure_hdr.Item(keys[i]);
-               outfile.WriteBlankLines(1);
-               pieces = item[0];
-
-               if (item[1] != undefined) {
-                       outfile.WriteLine("/* " + item[1] + " */");
-               }
-
-
-               if (typeof(pieces) == "string" && pieces.charCodeAt(0) == 34) {
-                       /* quoted string have a maximal length of 2k under vc.
-                        * solution is to crack them and let the compiler concat
-                        * them implicitly */
-                       stuff_to_crack = pieces;
-                       pieces = "";
-
-                       while (stuff_to_crack.length) {
-                               j = 65;
-                               while (stuff_to_crack.charCodeAt(j) != 32 && j < stuff_to_crack.length)
-                                       j++;
-
-                               chunk = stuff_to_crack.substr(0, j);
-                               pieces += chunk;
-                               stuff_to_crack = stuff_to_crack.substr(chunk.length);
-                               if (stuff_to_crack.length)
-                                       pieces += '" "';
-                       }
-               }
-               
-               outfile.WriteLine("#define " + keys[i] + " " + pieces);
-       }
-       
-       outfile.Close();
-}
-
-function generate_makefile()
-{
-       STDOUT.WriteLine("Generating Makefile");
-       var MF = FSO.CreateTextFile("Makefile", true);
-
-       MF.WriteLine("# Generated by configure.js");
-
-       /* spit out variable definitions */
-       var keys = (new VBArray(configure_subst.Keys())).toArray();
-       var i;
-
-       for (i in keys) {
-               // The trailing space is needed to prevent the trailing backslash
-               // that is part of the build dir flags (CFLAGS_BD_XXX) from being
-               // seen as a line continuation character
-               MF.WriteLine(keys[i] + "=" + 
-                       //word_wrap_and_indent(1, configure_subst.Item(keys[i]), ' \\', '\t') + " "
-                       configure_subst.Item(keys[i]) + " "
-                       );
-               MF.WriteBlankLines(1);
-       }
-
-       MF.WriteBlankLines(1);
-
-       var TF = FSO.OpenTextFile("win32/build/Makefile", 1);
-       MF.Write(TF.ReadAll());
-       TF.Close();
-
-       MF.WriteBlankLines(2);
-
-       MFO.Close();
-       TF = FSO.OpenTextFile("Makefile.objects", 1);
-       MF.Write(TF.ReadAll());
-       TF.Close();
-
-       MF.Close();     
-}
-
-function ADD_FLAG(name, flags, target)
-{
-       if (target != null) {
-               name = target.toUpperCase() + "_" + name;
-       }
-       if (configure_subst.Exists(name)) {
-               var curr_flags = configure_subst.Item(name);
-
-               if (curr_flags.indexOf(flags) >= 0) {
-                       return;
-               }
-               
-               flags = curr_flags + " " + flags;
-               configure_subst.Remove(name);
-       }
-       configure_subst.Add(name, flags);
-
-       if (PHP_DSP != "no") {
-               if (flags && (name.substr(name.length-3) != "PHP") && (name.substr(0, 7) == "CFLAGS_")) {
-                       DSP_FLAGS[DSP_FLAGS.length] = new Array(name, flags);
-               }
-       }
-}
-
-function get_define(name)
-{
-       if (configure_subst.Exists(name)) {
-               return configure_subst.Item(name);
-       }
-       return "";
-}
-
-// Add a .def to the core to export symbols
-function ADD_DEF_FILE(name)
-{
-       if (!configure_subst.Exists("PHPDEF")) {
-               DEFINE("PHPDEF", "$(BUILD_DIR)\\$(PHPDLL).def");
-               ADD_FLAG("PHP_LDFLAGS", "/def:$(PHPDEF)");
-       }
-       ADD_FLAG("PHP_DLL_DEF_SOURCES", name);
-}
-
-function AC_DEFINE(name, value, comment, quote)
-{
-       if (quote == null) {
-               quote = true;
-       }
-       if (quote && typeof(value) == "string") {
-               value = '"' + value.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"';
-       } else if (value.length == 0) {
-               value = '""';
-       }
-       var item = new Array(value, comment);
-       if (configure_hdr.Exists(name)) {
-               var orig_item = configure_hdr.Item(name);
-               STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]);
-       } else {
-               configure_hdr.Add(name, item);
-       }
-}
-
-function MESSAGE(msg)
-{
-       STDOUT.WriteLine("" + msg);
-}
-
-function ERROR(msg)
-{
-       STDERR.WriteLine("ERROR: " + msg);
-       WScript.Quit(3);
-}
-
-function WARNING(msg)
-{
-       STDERR.WriteLine("WARNING: " + msg);
-       STDERR.WriteBlankLines(1);
-}
-
-function copy_and_subst(srcname, destname, subst_array)
-{
-       if (!FSO.FileExists(srcname)) {
-               srcname = configure_module_dirname + "\\" + srcname;
-               destname = configure_module_dirname + "\\" + destname;
-       }
-
-       var content = file_get_contents(srcname);
-       var i;
-
-       for (i = 0; i < subst_array.length; i+=2) {
-               var re = subst_array[i];
-               var rep = subst_array[i+1];
-
-               content = content.replace(re, rep);
-       }
-       
-       var f = FSO.CreateTextFile(destname, true);
-       f.Write(content);
-       f.Close();
-}
-
-// glob using simple filename wildcards
-// returns an array of matches that are found
-// in the filesystem
-function glob(path_pattern)
-{
-       var path_parts = path_pattern.replace(new RegExp("/", "g"), "\\").split("\\");
-       var p;
-       var base = "";
-       var is_pat_re = /\*/;
-
-//STDOUT.WriteLine("glob: " + path_pattern);
-
-       if (FSO.FileExists(path_pattern)) {
-               return new Array(path_pattern);
-       }
-       
-       // first, build as much as possible that doesn't have a pattern
-       for (p = 0; p < path_parts.length; p++) {
-               if (path_parts[p].match(is_pat_re))
-                       break;
-               if (p)
-                       base += "\\";
-               base += path_parts[p];  
-       }
-
-       return _inner_glob(base, p, path_parts);
-}
-
-function _inner_glob(base, p, parts)
-{
-       var pat = parts[p];
-       var full_name = base + "\\" + pat;
-       var re = null;
-       var items = null;
-
-       if (p == parts.length) {
-               return false;
-       }
-
-//STDOUT.WriteLine("inner: base=" + base + " p=" + p + " pat=" + pat);
-
-       if (FSO.FileExists(full_name)) {
-               if (p < parts.length - 1) {
-                       // we didn't reach the full extent of the pattern
-                       return false;
-               }
-               return new Array(full_name);
-       }
-
-       if (FSO.FolderExists(full_name) && p == parts.length - 1) {
-               // we have reached the end of the pattern; no need to recurse
-               return new Array(full_name);
-       }
-
-       // Convert the pattern into a regexp
-       re = new RegExp("^" + pat.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.') + "$", "i");
-
-       items = new Array();
-
-       if (!FSO.FolderExists(base)) {
-               return false;
-       }
-
-       var folder = FSO.GetFolder(base);
-       var fc = null;
-       var subitems = null;
-       var item_name = null;
-       var j;
-
-       fc = new Enumerator(folder.SubFolders);
-       for (; !fc.atEnd(); fc.moveNext()) {
-               item_name = FSO.GetFileName(fc.item());
-
-               if (item_name.match(re)) {
-                       // got a match; if we are at the end of the pattern, just add these
-                       // things to the items array
-                       if (p == parts.length - 1) {
-                               items[items.length] = fc.item();
-                       } else {
-                               // we should recurse and do more matches
-                               subitems = _inner_glob(base + "\\" + item_name, p + 1, parts);
-                               if (subitems) {
-                                       for (j = 0; j < subitems.length; j++) {
-                                               items[items.length] = subitems[j];
-                                       }
-                               }
-                       }
-               }
-       }
-
-       // if we are at the end of the pattern, we should match
-       // files too
-       if (p == parts.length - 1) {
-               fc = new Enumerator(folder.Files);
-               for (; !fc.atEnd(); fc.moveNext()) {
-                       item_name = FSO.GetFileName(fc.item());
-                       if (item_name.match(re)) {
-                               items[items.length] = fc.item();
-                       }
-               }
-       }
-
-       if (items.length == 0)
-               return false;
-
-       return items;
-}
-
-// for snapshot builders, this option will attempt to enable everything
-// and you can then build everything, ignoring fatal errors within a module
-// by running "nmake snap"
-PHP_SNAPSHOT_BUILD = "no";
-ARG_ENABLE('snapshot-build', 'Build a snapshot; turns on everything it can and ignores build errors', 'no');
-
-// one-shot build optimizes build by asking compiler to build
-// several objects at once, reducing overhead of starting new
-// compiler processes.
-ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no');
-
+// Utils for configure script\r
+/*\r
+  +----------------------------------------------------------------------+\r
+  | PHP Version 5                                                        |\r
+  +----------------------------------------------------------------------+\r
+  | Copyright (c) 1997-2008 The PHP Group                                |\r
+  +----------------------------------------------------------------------+\r
+  | This source file is subject to version 3.01 of the PHP license,      |\r
+  | that is bundled with this package in the file LICENSE, and is        |\r
+  | available through the world-wide-web at the following url:           |\r
+  | http://www.php.net/license/3_01.txt                                  |\r
+  | If you did not receive a copy of the PHP license and are unable to   |\r
+  | obtain it through the world-wide-web, please send a note to          |\r
+  | license@php.net so we can mail you a copy immediately.               |\r
+  +----------------------------------------------------------------------+\r
+  | Author: Wez Furlong <wez@thebrainroom.com>                           |\r
+  +----------------------------------------------------------------------+\r
+*/\r
+\r
+// $Id: confutils.js,v 1.83 2009-05-29 07:41:46 kalle Exp $\r
+\r
+var STDOUT = WScript.StdOut;\r
+var STDERR = WScript.StdErr;\r
+var WshShell = WScript.CreateObject("WScript.Shell");\r
+var FSO = WScript.CreateObject("Scripting.FileSystemObject");\r
+var MFO = null;\r
+var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive");\r
+var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles");\r
+var DSP_FLAGS = new Array();\r
+\r
+/* Store the enabled extensions (summary + QA check) */\r
+var extensions_enabled = new Array();\r
+\r
+/* Store the SAPI enabled (summary + QA check) */\r
+var sapi_enabled = new Array();\r
+\r
+/* Mapping CL version > human readable name */\r
+var VC_VERSIONS = new Array();\r
+VC_VERSIONS[1200] = 'MSVC6 (Visual C++ 6.0)';\r
+VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)';\r
+VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)';\r
+VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)';\r
+VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)';\r
+\r
+var VC_VERSIONS_SHORT = new Array();\r
+VC_VERSIONS_SHORT[1200] = 'VC6';\r
+VC_VERSIONS_SHORT[1300] = 'VC7';\r
+VC_VERSIONS_SHORT[1310] = 'VC7.1';\r
+VC_VERSIONS_SHORT[1400] = 'VC8';\r
+VC_VERSIONS_SHORT[1500] = 'VC9';\r
+\r
+if (PROGRAM_FILES == null) {\r
+       PROGRAM_FILES = "C:\\Program Files";\r
+}\r
+\r
+if (!FSO.FileExists("README.SVN-RULES")) {\r
+       STDERR.WriteLine("Must be run from the root of the php source");\r
+       WScript.Quit(10);\r
+}\r
+       \r
+var CWD = WshShell.CurrentDirectory;\r
+\r
+if (typeof(CWD) == "undefined") {\r
+       CWD = FSO.GetParentFolderName(FSO.GetAbsolutePathName("README.SVN-RULES"));\r
+}\r
+\r
+/* defaults; we pick up the precise versions from configure.in */\r
+var PHP_VERSION = 5;\r
+var PHP_MINOR_VERSION = 0;\r
+var PHP_RELEASE_VERSION = 0;\r
+var PHP_EXTRA_VERSION = "";\r
+var PHP_VERSION_STRING = "5.0.0";\r
+\r
+function get_version_numbers()\r
+{\r
+       var cin = file_get_contents("configure.in");\r
+       \r
+       if (cin.match(new RegExp("PHP_MAJOR_VERSION=(\\d+)"))) {\r
+               PHP_VERSION = RegExp.$1;\r
+       }\r
+       if (cin.match(new RegExp("PHP_MINOR_VERSION=(\\d+)"))) {\r
+               PHP_MINOR_VERSION = RegExp.$1;\r
+       }\r
+       if (cin.match(new RegExp("PHP_RELEASE_VERSION=(\\d+)"))) {\r
+               PHP_RELEASE_VERSION = RegExp.$1;\r
+       }\r
+       PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION;\r
+\r
+       if (cin.match(new RegExp("PHP_EXTRA_VERSION=\"([^\"]+)\""))) {\r
+               PHP_EXTRA_VERSION = RegExp.$1;\r
+               if (PHP_EXTRA_VERSION.length) {\r
+                       PHP_VERSION_STRING += PHP_EXTRA_VERSION;\r
+               }\r
+       }\r
+       DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING);\r
+}\r
+\r
+configure_args = new Array();\r
+configure_subst = WScript.CreateObject("Scripting.Dictionary");\r
+\r
+configure_hdr = WScript.CreateObject("Scripting.Dictionary");\r
+build_dirs = new Array();\r
+\r
+extension_include_code = "";\r
+extension_module_ptrs = "";\r
+\r
+get_version_numbers();\r
+\r
+/* execute a command and return the output as a string */\r
+function execute(command_line)\r
+{\r
+       var e = WshShell.Exec(command_line);\r
+       var ret = "";\r
+\r
+       ret = e.StdOut.ReadAll();\r
+\r
+//STDOUT.WriteLine("command " + command_line);\r
+//STDOUT.WriteLine(ret);\r
+\r
+       return ret;\r
+}\r
+\r
+function probe_binary(EXE, what)\r
+{\r
+       // tricky escapes to get stderr redirection to work\r
+       var command = 'cmd /c ""' + EXE;\r
+       if (what == "version") {\r
+               command = command + '" -v"';\r
+       }\r
+       var version = execute(command + '" 2>&1"');\r
+\r
+       if (what == "64") {\r
+               if (version.match(/x64/)) {\r
+                       return 1;\r
+               }\r
+       } else {\r
+               if (version.match(/(\d+\.\d+(\.\d+)?(\.\d+)?)/)) {\r
+                       return RegExp.$1;\r
+               }\r
+       }\r
+       return 0;\r
+}\r
+\r
+function condense_path(path)\r
+{\r
+       path = FSO.GetAbsolutePathName(path);\r
+\r
+       if (path.substr(0, CWD.length).toLowerCase()\r
+                       == CWD.toLowerCase() &&\r
+                       (path.charCodeAt(CWD.length) == 92 || path.charCodeAt(CWD.length) == 47)) {\r
+               return path.substr(CWD.length + 1);\r
+       }\r
+\r
+       var a = CWD.split("\\");\r
+       var b = path.split("\\");\r
+       var i, j;\r
+\r
+       for (i = 0; i < b.length; i++) {\r
+               if (a[i].toLowerCase() == b[i].toLowerCase())\r
+                       continue;\r
+               if (i > 0) {\r
+                       /* first difference found */\r
+                       path = "";\r
+                       for (j = 0; j < a.length - i; j++) {\r
+                               path += "..\\";\r
+                       }\r
+                       for (j = i; j < b.length; j++) {\r
+                               path += b[j];\r
+                               if (j < b.length - 1)\r
+                                       path += "\\";\r
+                       }\r
+                       return path;\r
+               }\r
+               /* on a different drive */\r
+               break;\r
+       }\r
+       \r
+       return path;\r
+}\r
+\r
+function ConfigureArg(type, optname, helptext, defval)\r
+{\r
+       var opptype = type == "enable" ? "disable" : "without";\r
+\r
+       if (defval == "yes" || defval == "yes,shared") {\r
+               this.arg = "--" + opptype + "-" + optname;\r
+               this.imparg = "--" + type + "-" + optname;\r
+       } else {\r
+               this.arg = "--" + type + "-" + optname;\r
+               this.imparg = "--" + opptype + "-" + optname;\r
+       }\r
+       \r
+       this.optname = optname;\r
+       this.helptext = helptext;\r
+       this.defval = defval;\r
+       this.symval = optname.toUpperCase().replace(new RegExp("-", "g"), "_");\r
+       this.seen = false;\r
+       this.argval = defval;\r
+}\r
+\r
+function ARG_WITH(optname, helptext, defval)\r
+{\r
+       configure_args[configure_args.length] = new ConfigureArg("with", optname, helptext, defval);\r
+}\r
+\r
+function ARG_ENABLE(optname, helptext, defval)\r
+{\r
+       configure_args[configure_args.length] = new ConfigureArg("enable", optname, helptext, defval);\r
+}\r
+\r
+function analyze_arg(argval)\r
+{\r
+       var ret = new Array();\r
+       var shared = false;\r
+\r
+       if (argval == "shared") {\r
+               shared = true;\r
+               argval = "yes";\r
+       } else if (argval == null) {\r
+               /* nothing */\r
+       } else if (arg_match = argval.match(new RegExp("^shared,(.*)"))) {\r
+               shared = true;\r
+               argval = arg_match[1];\r
+       } else if (arg_match = argval.match(new RegExp("^(.*),shared$"))) {\r
+               shared = true;\r
+               argval = arg_match[1];\r
+       }\r
+\r
+       ret[0] = shared;\r
+       ret[1] = argval;\r
+       return ret;\r
+}\r
+\r
+function word_wrap_and_indent(indent, text, line_suffix, indent_char)\r
+{\r
+       if (text == null) {\r
+               return "";\r
+       }\r
+       \r
+       var words = text.split(new RegExp("\\s+", "g"));\r
+       var i = 0;\r
+       var ret_text = "";\r
+       var this_line = "";\r
+       var t;\r
+       var space = "";\r
+       var lines = 0;\r
+\r
+       if (line_suffix == null) {\r
+               line_suffix = "";\r
+       }\r
+\r
+       if (indent_char == null) {\r
+               indent_char = " ";\r
+       }\r
+\r
+       for (i = 0; i < indent; i++) {\r
+               space += indent_char;\r
+       }\r
+       \r
+       for (i = 0; i < words.length; i++) {\r
+               if (this_line.length) {\r
+                       t = this_line + " " + words[i];\r
+               } else {\r
+                       t = words[i];\r
+               }\r
+\r
+               if (t.length + indent > 78) {\r
+                       if (lines++) {\r
+                               ret_text += space;\r
+                       }\r
+                       ret_text += this_line + line_suffix + "\r\n";\r
+                       this_line = "";\r
+               }\r
+\r
+               if (this_line.length) {\r
+                       this_line += " " + words[i];\r
+               } else {\r
+                       this_line = words[i];\r
+               }\r
+       }\r
+\r
+       if (this_line.length) {\r
+               if (lines)\r
+                       ret_text += space;\r
+               ret_text += this_line;\r
+       }\r
+\r
+       return ret_text;\r
+}\r
+\r
+function conf_process_args()\r
+{\r
+       var i, j;\r
+       var configure_help_mode = false;\r
+       var analyzed = false;\r
+       var nice = "cscript /nologo configure.js ";\r
+       var disable_all = false;\r
+       \r
+       args = WScript.Arguments;\r
+       for (i = 0; i < args.length; i++) {\r
+               arg = args(i);\r
+               nice += ' "' + arg + '"';\r
+               if (arg == "--help") {\r
+                       configure_help_mode = true;\r
+                       break;\r
+               }\r
+               if (arg == "--disable-all") {\r
+                       disable_all = true;\r
+                       continue;\r
+               }\r
+\r
+               // If it is --foo=bar, split on the equals sign\r
+               arg = arg.split("=", 2);\r
+               argname = arg[0];\r
+               if (arg.length > 1) {\r
+                       argval = arg[1];\r
+               } else {\r
+                       argval = null;\r
+               }\r
+\r
+               // Find the arg\r
+               found = false;\r
+               for (j = 0; j < configure_args.length; j++) {\r
+                       if (argname == configure_args[j].imparg || argname == configure_args[j].arg) {\r
+                               found = true;\r
+\r
+                               arg = configure_args[j];\r
+                               arg.seen = true;\r
+\r
+                               analyzed = analyze_arg(argval);\r
+                               shared = analyzed[0];\r
+                               argval = analyzed[1];\r
+\r
+                               if (argname == arg.imparg) {\r
+                                       /* we matched the implicit, or default arg */\r
+                                       if (argval == null) {\r
+                                               argval = arg.defval;\r
+                                       }\r
+                               } else {\r
+                                       /* we matched the non-default arg */\r
+                                       if (argval == null) {\r
+                                               argval = arg.defval == "no" ? "yes" : "no";\r
+                                       }\r
+                               }\r
+                               \r
+                               arg.argval = argval;\r
+                               eval("PHP_" + arg.symval + " = argval;");\r
+                               eval("PHP_" + arg.symval + "_SHARED = shared;");\r
+                               break;\r
+                       }\r
+               }\r
+               if (!found) {\r
+                       STDERR.WriteLine("Unknown option " + argname + "; please try configure.js --help for a list of valid options");\r
+                       WScript.Quit(2);\r
+               }\r
+       }\r
+\r
+       if (configure_help_mode) {\r
+               STDOUT.WriteLine(word_wrap_and_indent(0,\r
+"Options that enable extensions and SAPI will accept \\r
+'yes' or 'no' as a parameter.  They also accept 'shared' \\r
+as a synonym for 'yes' and request a shared build of that \\r
+module.  Not all modules can be built as shared modules; \\r
+configure will display [shared] after the module name if \\r
+can be built that way. \\r
+"\r
+                       ));\r
+               STDOUT.WriteBlankLines(1);\r
+\r
+               // Measure width to pretty-print the output\r
+               max_width = 0;\r
+               for (i = 0; i < configure_args.length; i++) {\r
+                       arg = configure_args[i];\r
+                       if (arg.arg.length > max_width)\r
+                               max_width = arg.arg.length;\r
+               }\r
+\r
+               for (i = 0; i < configure_args.length; i++) {\r
+                       arg = configure_args[i];\r
+\r
+                       n = max_width - arg.arg.length;\r
+                       pad = "   ";\r
+                       for (j = 0; j < n; j++) {\r
+                               pad += " ";\r
+                       }\r
+                       STDOUT.WriteLine("  " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext));\r
+               }\r
+               WScript.Quit(1);\r
+       }\r
+\r
+       var snapshot_build_exclusions = new Array(\r
+               'debug', 'crt-debug', 'lzf-better-compression',\r
+                'php-build', 'snapshot-template', 'ereg',\r
+                'pcre-regex', 'fastcgi', 'force-cgi-redirect',\r
+                'path-info-check', 'zts', 'ipv6', 'memory-limit',\r
+                'zend-multibyte', 'fd-setsize', 'memory-manager', 't1lib'\r
+               );\r
+       var force;\r
+\r
+       // Now set any defaults we might have missed out earlier\r
+       for (i = 0; i < configure_args.length; i++) {\r
+               arg = configure_args[i];\r
+               if (arg.seen)\r
+                       continue;\r
+               analyzed = analyze_arg(arg.defval);\r
+               shared = analyzed[0];\r
+               argval = analyzed[1];\r
+               \r
+               // Don't trust a default "yes" answer for a non-core module\r
+               // in a snapshot build\r
+               if (PHP_SNAPSHOT_BUILD != "no" && argval == "yes" && !shared) {\r
+\r
+                       force = true;\r
+                       for (j = 0; j < snapshot_build_exclusions.length; j++) {\r
+                               if (snapshot_build_exclusions[j] == arg.optname) {\r
+                                       force = false;\r
+                                       break;\r
+                               }\r
+                       }\r
+\r
+                       if (force) {\r
+                               /* now check if it is a core module */\r
+                               force = false;\r
+                               for (j = 0; j < core_module_list.length; j++) {\r
+                                       if (core_module_list[j] == arg.optname) {\r
+                                               force = true;\r
+                                               break;\r
+                                       }\r
+                               }\r
+\r
+                               if (!force) {\r
+                                       STDOUT.WriteLine("snapshot: forcing " + arg.arg + " shared");\r
+                                       shared = true;\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               if (PHP_SNAPSHOT_BUILD != "no" && argval == "no") {\r
+                       force = true;\r
+                       for (j = 0; j < snapshot_build_exclusions.length; j++) {\r
+                               if (snapshot_build_exclusions[j] == arg.optname) {\r
+                                       force = false;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if (force) {\r
+                               STDOUT.WriteLine("snapshot: forcing " + arg.optname + " on");\r
+                               argval = "yes";\r
+                               shared = true;\r
+                       }\r
+               }\r
+\r
+               if (disable_all) {\r
+                       force = true;\r
+                       for (j = 0; j < snapshot_build_exclusions.length; j++) {\r
+                               if (snapshot_build_exclusions[j] == arg.optname) {\r
+                                       force = false;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if (force) {\r
+                               if (arg.defval == '') {\r
+                                       argval = '';\r
+                               } else {\r
+                                       argval = "no";\r
+                               }\r
+                               shared = false;\r
+                       }\r
+               }\r
+\r
+               eval("PHP_" + arg.symval + " = argval;");\r
+               eval("PHP_" + arg.symval + "_SHARED = shared;");\r
+       }\r
+\r
+       MFO = FSO.CreateTextFile("Makefile.objects", true);\r
+\r
+       STDOUT.WriteLine("Saving configure options to config.nice.bat");\r
+       var nicefile = FSO.CreateTextFile("config.nice.bat", true);\r
+       nicefile.WriteLine(nice +  " %*");\r
+       nicefile.Close();\r
+\r
+       AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line");\r
+}\r
+\r
+function DEFINE(name, value)\r
+{\r
+       if (configure_subst.Exists(name)) {\r
+               configure_subst.Remove(name);\r
+       }\r
+       configure_subst.Add(name, value);\r
+}\r
+\r
+// Searches a set of paths for a file;\r
+// returns the dir in which the file was found,\r
+// true if it was found in the default env path,\r
+// or false if it was not found at all.\r
+// env_name is the optional name of an env var\r
+// specifying the default path to search\r
+function search_paths(thing_to_find, explicit_path, env_name)\r
+{\r
+       var i, found = false, place = false, file, env;\r
+\r
+       STDOUT.Write("Checking for " + thing_to_find + " ... ");\r
+\r
+       thing_to_find = thing_to_find.replace(new RegExp("/", "g"), "\\");\r
+\r
+       if (explicit_path != null) {\r
+               if (typeof(explicit_path) == "string") {\r
+                       explicit_path = explicit_path.split(";");\r
+               }\r
+\r
+               for (i = 0; i < explicit_path.length; i++) {\r
+                       file = glob(explicit_path[i] + "\\" + thing_to_find);\r
+                       if (file) {\r
+                               found = true;\r
+                               place = file[0];\r
+                               place = place.substr(0, place.length - thing_to_find.length - 1);\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
+\r
+       if (!found && env_name != null) {\r
+               env = WshShell.Environment("Process").Item(env_name);\r
+               env = env.split(";");\r
+               for (i = 0; i < env.length; i++) {\r
+                       file = glob(env[i] + "\\" + thing_to_find);\r
+                       if (file) {\r
+                               found = true;\r
+                               place = true;\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
+\r
+       if (found && place == true) {\r
+               STDOUT.WriteLine(" <in default path>");\r
+       } else if (found) {\r
+               STDOUT.WriteLine(" " + place);\r
+       } else {\r
+               STDOUT.WriteLine(" <not found>");\r
+       }\r
+       return place;\r
+}\r
+\r
+function PATH_PROG(progname, additional_paths, symbol)\r
+{\r
+       var exe;\r
+       var place;\r
+       var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin";\r
+       var php_build_bin_path = PHP_PHP_BUILD + "\\bin"\r
+\r
+       exe = progname + ".exe";\r
+\r
+       if (additional_paths == null) {\r
+               additional_paths = cyg_path;\r
+       } else {\r
+               additional_paths += ";" + cyg_path;\r
+       }\r
+\r
+       additional_paths = additional_paths + ";" + php_build_bin_path;\r
+\r
+       place = search_paths(exe, additional_paths, "PATH");\r
+\r
+       if (place == true) {\r
+               place = exe;\r
+       } else if (place != false) {\r
+               place = place + "\\" + exe;\r
+       }\r
+\r
+       if (place) {\r
+               if (symbol == null) {\r
+                       symbol = progname.toUpperCase();\r
+               }\r
+               DEFINE(symbol, place);\r
+       }\r
+       return place;\r
+}\r
+\r
+function find_pattern_in_path(pattern, path)\r
+{\r
+       if (path == null) {\r
+               return false;\r
+       }\r
+\r
+       var dirs = path.split(';');\r
+       var i;\r
+       var items;\r
+\r
+       for (i = 0; i < dirs.length; i++) {\r
+               items = glob(dirs[i] + "\\" + pattern);\r
+               if (items) {\r
+                       return condense_path(items[0]);\r
+               }\r
+       }\r
+       return false;\r
+}\r
+\r
+function CHECK_LIB(libnames, target, path_to_check, common_name)\r
+{\r
+       STDOUT.Write("Checking for library " + libnames + " ... ");\r
+\r
+       if (common_name == null && target != null) {\r
+               common_name = target;\r
+       }\r
+\r
+       if (path_to_check == null) {\r
+               path_to_check = "";\r
+       }\r
+\r
+       // if they specified a common name for the package that contains\r
+       // the library, tag some useful defaults on to the end of the\r
+       // path to be searched\r
+       if (common_name != null) {\r
+               path_to_check += ";" + PHP_PHP_BUILD + "\\" + common_name + "*";\r
+               path_to_check += ";" + PHP_PHP_BUILD + "\\lib\\" + common_name + "*";\r
+               path_to_check += ";..\\" + common_name + "*";\r
+       }\r
+\r
+       // Determine target for build flags\r
+       if (target == null) {\r
+               target = "";\r
+       } else {\r
+               target = "_" + target.toUpperCase();\r
+       }\r
+\r
+       // Expand path to include general dirs\r
+       path_to_check += ";" + php_usual_lib_suspects;\r
+\r
+       // It is common practice to put libs under one of these dir names\r
+       var subdirs = new Array(PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"), "lib", "libs", "libexec");\r
+\r
+       // libnames can be ; separated list of accepted library names\r
+       libnames = libnames.split(';');\r
+\r
+       // for debug builds, lib may have _debug appended, we want that first\r
+       if (PHP_DEBUG == "yes") {\r
+               var length = libnames.length;\r
+               for (var i = 0; i < length; i++) {\r
+                       var name = new String(libnames[i]);\r
+                       rExp = /.lib$/i;\r
+                       name = name.replace(rExp,"_debug.lib");\r
+                       libnames.unshift(name);\r
+               }\r
+       }\r
+\r
+       var i, j, k, libname;\r
+       var location = false;\r
+       var path = path_to_check.split(';');\r
+       \r
+       for (i = 0; i < libnames.length; i++) {\r
+               libname = libnames[i];\r
+\r
+               for (k = 0; k < path.length; k++) {\r
+                       location = glob(path[k] + "\\" + libname);\r
+                       if (location) {\r
+                               location = location[0];\r
+                               break;\r
+                       }\r
+                       for (j = 0; j < subdirs.length; j++) {\r
+                               location = glob(path[k] + "\\" + subdirs[j] + "\\" + libname);\r
+                               if (location) {\r
+                                       location = location[0];\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if (location)\r
+                               break;\r
+               }\r
+\r
+               if (location) {\r
+                       location = condense_path(location);\r
+                       var libdir = FSO.GetParentFolderName(location);\r
+                       libname = FSO.GetFileName(location);\r
+                       ADD_FLAG("LDFLAGS" + target, '/libpath:"' + libdir + '" ');\r
+                       ADD_FLAG("LIBS" + target, libname);\r
+\r
+                       STDOUT.WriteLine(location);\r
+\r
+                       return location;\r
+               }\r
+\r
+               // Check in their standard lib path\r
+               location = find_pattern_in_path(libname, WshShell.Environment("Process").Item("LIB"));\r
+\r
+               if (location) {\r
+                       location = condense_path(location);\r
+                       libname = FSO.GetFileName(location);\r
+                       ADD_FLAG("LIBS" + target, libname);\r
+\r
+                       STDOUT.WriteLine("<in LIB path> " + libname);\r
+                       return location;\r
+               }\r
+\r
+               // Check in their general extra libs path\r
+               location = find_pattern_in_path(libname, PHP_EXTRA_LIBS);\r
+               if (location) {\r
+                       location = condense_path(location);\r
+                       libname = FSO.GetFileName(location);\r
+                       ADD_FLAG("LIBS" + target, libname);\r
+                       STDOUT.WriteLine("<in extra libs path>");\r
+                       return location;\r
+               }\r
+       }\r
+\r
+       STDOUT.WriteLine("<not found>");\r
+\r
+       return false;\r
+}\r
+\r
+function OLD_CHECK_LIB(libnames, target, path_to_check)\r
+{\r
+       if (target == null) {\r
+               target = "";\r
+       } else {\r
+               target = "_" + target.toUpperCase();\r
+       }\r
+       \r
+       if (path_to_check == null) {\r
+               path_to_check = php_usual_lib_suspects;\r
+       } else {\r
+               path_to_check += ";" + php_usual_lib_suspects;\r
+       }\r
+       var have = 0;\r
+       var p;\r
+       var i;\r
+       var libname;\r
+\r
+       var subdir = PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release");\r
+\r
+       libnames = libnames.split(';');\r
+       for (i = 0; i < libnames.length; i++) {\r
+               libname = libnames[i];\r
+               p = search_paths(libname, path_to_check, "LIB");\r
+\r
+               if (!p) {\r
+                       p = search_paths(subdir + "\\" + libname, path_to_check, "LIB");\r
+                       if (p) {\r
+                               p += "\\" + subdir;\r
+                       }\r
+               }\r
+\r
+               if (typeof(p) == "string") {\r
+                       ADD_FLAG("LDFLAGS" + target, '/libpath:"' + p + '" ');\r
+                       ADD_FLAG("LIBS" + target, libname);\r
+                       have = 1;\r
+               } else if (p == true) {\r
+                       ADD_FLAG("LIBS" + target, libname);\r
+                       have = 1;\r
+               } else {\r
+                       /* not found in the defaults or the explicit paths,\r
+                        * so check the general extra libs; if we find\r
+                        * it here, no need to add another /libpath: for it as we\r
+                        * already have it covered, but we need to add the lib\r
+                        * to LIBS_XXX */\r
+                       if (false != search_paths(libname, PHP_EXTRA_LIBS, null)) {\r
+                               ADD_FLAG("LIBS" + target, libname);\r
+                               have = 1;\r
+                       }\r
+               }\r
+\r
+               if (have) {\r
+                       break;\r
+               }\r
+       }\r
+\r
+//     AC_DEFINE("HAVE_" + header_name.toUpperCase().replace(new RegExp("/\\\\-\.", "g"), "_"), have);\r
+\r
+       return have;\r
+\r
+}\r
+\r
+function CHECK_FUNC_IN_HEADER(header_name, func_name, path_to_check, add_to_flag)\r
+{\r
+       var c = false;\r
+       var sym;\r
+\r
+       STDOUT.Write("Checking for " + func_name + " in " + header_name + " ... ");\r
+\r
+       c = GREP_HEADER(header_name, func_name, path_to_check);\r
+\r
+       sym = func_name.toUpperCase();\r
+       sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_");\r
+\r
+       if (typeof(add_to_flag) == "undefined") {\r
+               AC_DEFINE("HAVE_" + sym, c ? 1 : 0);\r
+       } else {\r
+               ADD_FLAG(add_to_flag, "/DHAVE_" + sym + "=" + (c ? "1" : "0"));\r
+       }\r
+\r
+       if (c) {\r
+               STDOUT.WriteLine("OK");\r
+               return c;\r
+       }\r
+       STDOUT.WriteLine("No");\r
+       return false;   \r
+}\r
+\r
+function GREP_HEADER(header_name, regex, path_to_check)\r
+{\r
+       var c = false;\r
+\r
+       if (FSO.FileExists(path_to_check + "\\" + header_name)) {\r
+               c = file_get_contents(path_to_check + "\\" + header_name);\r
+       }\r
+\r
+       if (!c) {\r
+               /* look in the include path */\r
+\r
+               var p = search_paths(header_name, path_to_check, "INCLUDE");\r
+               if (typeof(p) == "string") {\r
+                       c = file_get_contents(p);\r
+               } else if (p == false) {\r
+                       p = search_paths(header_name, PHP_EXTRA_INCLUDES, null);\r
+                       if (typeof(p) == "string") {\r
+                               c = file_get_contents(p);\r
+                       }\r
+               } \r
+               if (!c) {\r
+                       return false;\r
+               }\r
+       }\r
+\r
+       if (typeof(regex) == "string") {\r
+               regex = new RegExp(regex);\r
+       }\r
+\r
+       if (c.match(regex)) {\r
+               /* caller can now use RegExp.$1 etc. to get at patterns */\r
+               return true;\r
+       }\r
+       return false;\r
+}\r
+\r
+function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env, add_dir_part, add_to_flag_only)\r
+{\r
+       var dir_part_to_add = "";\r
+       \r
+       if (use_env == null) {\r
+               use_env = true;\r
+       }\r
+\r
+       // if true, add the dir part of the header_name to the include path\r
+       if (add_dir_part == null) {\r
+               add_dir_part = false;\r
+       } else if (add_dir_part) {\r
+               var basename = FSO.GetFileName(header_name);\r
+               dir_part_to_add = "\\" + header_name.substr(0, header_name.length - basename.length - 1);\r
+       }\r
+\r
+       if (path_to_check == null) {\r
+               path_to_check = php_usual_include_suspects;\r
+       } else {\r
+               path_to_check += ";" + php_usual_include_suspects;\r
+       }\r
+       \r
+       var p = search_paths(header_name, path_to_check, use_env ? "INCLUDE" : null);\r
+       var have = 0;\r
+       var sym;\r
+\r
+       if (typeof(p) == "string") {\r
+               ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" ');\r
+       } else if (p == false) {\r
+               /* not found in the defaults or the explicit paths,\r
+                * so check the general extra includes; if we find\r
+                * it here, no need to add another /I for it as we\r
+                * already have it covered, unless we are adding\r
+                * the dir part.... */\r
+               p = search_paths(header_name, PHP_EXTRA_INCLUDES, null);\r
+               if (typeof(p) == "string" && add_dir_part) {\r
+                       ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" ');\r
+               }\r
+       } \r
+       have = p ? 1 : 0\r
+\r
+       sym = header_name.toUpperCase();\r
+       sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_");\r
+\r
+       if (typeof(add_to_flag_only) == "undefined" &&\r
+                       flag_name.match(new RegExp("^CFLAGS_(.*)$"))) {\r
+               add_to_flag_only = true;\r
+       }\r
+\r
+       if (typeof(add_to_flag_only) != "undefined") {\r
+               ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have);\r
+       } else {\r
+               AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file");\r
+       }\r
+\r
+       return p;\r
+}\r
+\r
+/* emits rule to generate version info for a SAPI\r
+ * or extension.  Returns the name of the .res file\r
+ * that will be generated */\r
+function generate_version_info_resource(makefiletarget, basename, creditspath, sapi)\r
+{\r
+       var resname = makefiletarget + ".res";\r
+       var res_desc = makefiletarget;\r
+       var res_prod_name = "PHP " + makefiletarget;\r
+       var credits;\r
+       var thanks = "";\r
+       var logo = "";\r
+       var debug = "";\r
+       var project_url = "http://www.php.net";\r
+       var project_header = creditspath + "/php_" + basename + ".h";\r
+       var versioning = "";\r
+\r
+       if (sapi) {\r
+               var internal_name = basename.toUpperCase() + " SAPI";\r
+       } else {\r
+               var internal_name = basename.toUpperCase() + " extension";\r
+       }\r
+\r
+       if (FSO.FileExists(creditspath + '/CREDITS')) {\r
+               credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1);\r
+               res_desc = credits.ReadLine();\r
+               try {\r
+                       thanks = credits.ReadLine();\r
+               } catch (e) {\r
+                       thanks = null;\r
+               }\r
+               if (thanks == null) {\r
+                       thanks = "";\r
+               } else {\r
+                       thanks = "Thanks to " + thanks;\r
+               }\r
+               credits.Close();\r
+       }\r
+\r
+       if (creditspath.match(new RegExp("pecl"))) {\r
+               /* PECL project url - this will eventually work correctly for all */\r
+               project_url = "http://pecl.php.net/" + basename;\r
+\r
+               /* keep independent versioning PECL-specific for now */\r
+               if (FSO.FileExists(project_header)) {\r
+                       if (header = FSO.OpenTextFile(project_header, 1)) {\r
+                               contents = header.ReadAll();\r
+                               /* allowed: x.x.x[a|b|-alpha|-beta][RCx][-dev] */\r
+                               if (contents.match(new RegExp('PHP_' + basename.toUpperCase() + '_VERSION(\\s+)"((\\d+\.\\d+(\.\\d+)?)((a|b)(\\d)?|\-[a-z]{3,5})?(RC\\d+)?(\-dev)?)'))) {\r
+                                       project_version = RegExp.$2;\r
+                                       file_version = RegExp.$3.split('.');\r
+                                       if (!file_version[2]) {\r
+                                               file_version[2] = 0;\r
+                                       }\r
+                                       versioning = '\\"" /d EXT_FILE_VERSION=' + file_version[0] + ',' + file_version[1] + ',' + file_version[2] + ' /d EXT_VERSION="\\"' + project_version;\r
+                               }\r
+                               header.Close();\r
+                       }\r
+               }\r
+       }\r
+\r
+       if (makefiletarget.match(new RegExp("\\.exe$"))) {\r
+               logo = " /d WANT_LOGO ";\r
+       }\r
+\r
+       if (PHP_DEBUG != "no") {\r
+               debug = " /d _DEBUG";\r
+       }\r
+\r
+       /**\r
+        * Use user supplied template.rc if it exists\r
+        */\r
+       if (FSO.FileExists(creditspath + '\\template.rc')) {\r
+               MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": " + creditspath + "\\template.rc");\r
+               MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + debug +\r
+                       ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' +\r
+                       makefiletarget + '\\"" /d PRODUCT_NAME="\\"' + res_prod_name +\r
+                       versioning + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" ' +\r
+                       creditspath + '\\template.rc');\r
+               return resname;\r
+       }\r
+\r
+       MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": win32\\build\\template.rc");\r
+       MFO.WriteLine("\t$(RC) /n /fo $(BUILD_DIR)\\" + resname + logo + debug +\r
+               ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"'\r
+               + makefiletarget + '\\"" /d URL="\\"' + project_url + \r
+               '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + \r
+               '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" win32\\build\\template.rc');\r
+       MFO.WriteBlankLines(1);\r
+       return resname;\r
+}\r
+\r
+function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)\r
+{\r
+       var SAPI = sapiname.toUpperCase();\r
+       var ldflags;\r
+       var resname;\r
+       var ld;\r
+       var manifest;\r
+\r
+       if (typeof(obj_dir) == "undefined") {\r
+               sapiname_for_printing = configure_module_dirname;\r
+       } else {\r
+               sapiname_for_printing = configure_module_dirname + " (via " + obj_dir + ")";\r
+       }\r
+\r
+       STDOUT.WriteLine("Enabling SAPI " + sapiname_for_printing);\r
+\r
+       MFO.WriteBlankLines(1);\r
+       MFO.WriteLine("# objects for SAPI " + sapiname);\r
+       MFO.WriteBlankLines(1);\r
+\r
+       if (cflags) {\r
+               ADD_FLAG('CFLAGS_' + SAPI, cflags);\r
+       }\r
+\r
+       ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir);\r
+       MFO.WriteBlankLines(1);\r
+       MFO.WriteLine("# SAPI " + sapiname);\r
+       MFO.WriteBlankLines(1);\r
+\r
+       /* generate a .res file containing version information */\r
+       resname = generate_version_info_resource(makefiletarget, sapiname, configure_module_dirname, true);\r
+       \r
+       MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget);\r
+       MFO.WriteLine("\t@echo SAPI " + sapiname_for_printing + " build complete");\r
+       MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname);\r
+\r
+       if (makefiletarget.match(new RegExp("\\.dll$"))) {\r
+               ldflags = "/dll $(LDFLAGS)";\r
+               manifest = "-@$(_VC_MANIFEST_EMBED_DLL)";\r
+       } else if (makefiletarget.match(new RegExp("\\.lib$"))) {\r
+               ldflags = "$(LDFLAGS)";\r
+               ld = "$(MAKE_LIB)";\r
+       } else {\r
+               ldflags = "$(LDFLAGS)";\r
+               manifest = "-@$(_VC_MANIFEST_EMBED_EXE)";\r
+       }\r
+\r
+       if (ld) {\r
+               MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname);\r
+       } else {\r
+               ld = "@$(CC)";\r
+               MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")");\r
+       }\r
+\r
+       if (manifest) {\r
+               MFO.WriteLine("\t" + manifest);\r
+       }\r
+               \r
+       DEFINE('CFLAGS_' + SAPI + '_OBJ', '$(CFLAGS_' + SAPI + ')');\r
+\r
+       if (configure_module_dirname.match("pecl")) {\r
+               ADD_FLAG("PECL_TARGETS", makefiletarget);\r
+       } else {\r
+               ADD_FLAG("SAPI_TARGETS", makefiletarget);\r
+       }\r
+\r
+       if (PHP_DSP != "no") {\r
+               generate_dsp_file(sapiname, configure_module_dirname, file_list, false);\r
+       }\r
+\r
+       MFO.WriteBlankLines(1);\r
+       sapi_enabled[sapi_enabled.length] = [sapiname];\r
+}\r
+\r
+function ADD_DIST_FILE(filename)\r
+{\r
+       if (configure_module_dirname.match("pecl")) {\r
+               ADD_FLAG("PECL_EXTRA_DIST_FILES", filename);\r
+       } else {\r
+               ADD_FLAG("PHP_EXTRA_DIST_FILES", filename);\r
+       }\r
+}      \r
+\r
+function file_get_contents(filename)\r
+{\r
+       var f, c;\r
+       try {\r
+               f = FSO.OpenTextFile(filename, 1);\r
+               c = f.ReadAll();\r
+               f.Close();\r
+               return c;\r
+       } catch (e) {\r
+               STDOUT.WriteLine("Problem reading " + filename);\r
+               return false;\r
+       }\r
+}\r
+\r
+// Add a dependency on another extension, so that\r
+// the dependencies are built before extname\r
+function ADD_EXTENSION_DEP(extname, dependson, optional)\r
+{\r
+       var EXT = extname.toUpperCase();\r
+       var DEP = dependson.toUpperCase();\r
+       var dep_present = false;\r
+       var dep_shared = false;\r
+\r
+       try {\r
+               dep_present = eval("PHP_" + DEP);\r
+\r
+               if (dep_present != "no") {\r
+                       try {\r
+                               dep_shared = eval("PHP_" + DEP + "_SHARED");\r
+                       } catch (e) {\r
+                               dep_shared = false;\r
+                       }\r
+               }\r
+\r
+       } catch (e) {\r
+               dep_present = "no";\r
+       }\r
+\r
+       if (optional) {\r
+               if (dep_present == "no") {\r
+                       MESSAGE("\t" + dependson + " not found: " + dependson + " support in " + extname + " disabled");\r
+                       return false;\r
+               }\r
+       }\r
+\r
+       var ext_shared = eval("PHP_" + EXT + "_SHARED");\r
+\r
+       if (dep_shared) {\r
+               if (!ext_shared) {\r
+                       if (optional) {\r
+                               MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled");\r
+                               return false;\r
+                       }\r
+                       ERROR("static " + extname + " cannot depend on shared " + dependson);\r
+               }\r
+\r
+               ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)");\r
+               ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib");\r
+               ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib");\r
+\r
+       } else {\r
+\r
+               if (dep_present == "no") {\r
+                       if (ext_shared) {\r
+                               WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found");\r
+\r
+                               if (configure_hdr.Exists('HAVE_' + EXT)) {\r
+                                       configure_hdr.Remove('HAVE_' + EXT);\r
+                               }\r
+\r
+                               dllname = ' php_' + extname + '.dll';\r
+\r
+                               if (!REMOVE_TARGET(dllname, 'EXT_TARGETS')) {\r
+                                       REMOVE_TARGET(dllname, 'PECL_TARGETS');\r
+                               }\r
+\r
+                               extensions_enabled.pop();\r
+                               return false;\r
+\r
+                       } else {\r
+                               ERROR("Cannot build " + extname + "; " + dependson + " not enabled");\r
+                               return false;\r
+                       }\r
+               }\r
+       } // dependency is statically built-in to PHP\r
+       return true;\r
+}\r
+\r
+function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)\r
+{\r
+       var objs = null;\r
+       var EXT = extname.toUpperCase();\r
+       var extname_for_printing;\r
+\r
+       if (shared == null) {\r
+               eval("shared = PHP_" + EXT + "_SHARED;");\r
+       } else {\r
+               eval("PHP_" + EXT + "_SHARED = shared;");\r
+       }\r
+\r
+       if (cflags == null) {\r
+               cflags = "";\r
+       }\r
+\r
+       if (typeof(obj_dir) == "undefined") {\r
+               extname_for_printing = configure_module_dirname;\r
+       } else {\r
+               extname_for_printing = configure_module_dirname + " (via " + obj_dir + ")";\r
+       }\r
+\r
+       if (shared) {\r
+               STDOUT.WriteLine("Enabling extension " + extname_for_printing + " [shared]");\r
+               cflags = "/D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags;\r
+               ADD_FLAG("CFLAGS_PHP", "/D COMPILE_DL_" + EXT);\r
+       } else {\r
+               STDOUT.WriteLine("Enabling extension " + extname_for_printing);\r
+       }\r
+\r
+       MFO.WriteBlankLines(1);\r
+       MFO.WriteLine("# objects for EXT " + extname);\r
+       MFO.WriteBlankLines(1);\r
+\r
+\r
+       ADD_SOURCES(configure_module_dirname, file_list, extname, obj_dir);\r
+       \r
+       MFO.WriteBlankLines(1);\r
+\r
+       if (shared) {\r
+               if (dllname == null) {\r
+                       dllname = "php_" + extname + ".dll";\r
+               }\r
+               var libname = dllname.substring(0, dllname.length-4) + ".lib";\r
+\r
+               var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false);\r
+               var ld = "@$(CC)";\r
+\r
+               MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname);\r
+               MFO.WriteBlankLines(1);\r
+               MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname);\r
+               MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")");\r
+               MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)");\r
+               MFO.WriteBlankLines(1);\r
+\r
+               if (configure_module_dirname.match("pecl")) {\r
+                       ADD_FLAG("PECL_TARGETS", dllname);\r
+               } else {\r
+                       ADD_FLAG("EXT_TARGETS", dllname);\r
+               }\r
+               MFO.WriteLine(dllname + ": $(BUILD_DIR)\\" + dllname);\r
+               MFO.WriteLine("\t@echo EXT " + extname + " build complete");\r
+               MFO.WriteBlankLines(1);\r
+               \r
+               DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_' + EXT + ')');\r
+       } else {\r
+               ADD_FLAG("STATIC_EXT_OBJS", "$(" + EXT + "_GLOBAL_OBJS)");\r
+               ADD_FLAG("STATIC_EXT_LIBS", "$(LIBS_" + EXT + ")");\r
+               ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")");\r
+               ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")");\r
+\r
+               /* find the header that declares the module pointer,\r
+                * so we can include it in internal_functions.c */\r
+               var ext_dir = FSO.GetFolder(configure_module_dirname);\r
+               var fc = new Enumerator(ext_dir.Files);\r
+               var re = /\.h$/;\r
+               var s, c;\r
+               for (; !fc.atEnd(); fc.moveNext()) {\r
+                       s = fc.item() + "";\r
+                       if (s.match(re)) {\r
+                               c = file_get_contents(s);\r
+                               if (c.match("phpext_")) {\r
+                                       extension_include_code += '#include "' + configure_module_dirname + '/' + FSO.GetFileName(s) + '"\r\n';\r
+                               }\r
+                       }\r
+               }\r
+       \r
+               extension_module_ptrs += '\tphpext_' + extname + '_ptr,\r\n';\r
+       \r
+               DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')');\r
+       }\r
+       ADD_FLAG("CFLAGS_" + EXT, cflags);\r
+\r
+       if (PHP_DSP != "no") {\r
+               generate_dsp_file(extname, configure_module_dirname, file_list, shared);\r
+       }\r
+\r
+       extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static'];\r
+}\r
+\r
+function ADD_SOURCES(dir, file_list, target, obj_dir)\r
+{\r
+       var i;\r
+       var tv;\r
+       var src, obj, sym, flags;\r
+\r
+       if (target == null) {\r
+               target = "php";\r
+       }\r
+\r
+       sym = target.toUpperCase() + "_GLOBAL_OBJS";\r
+       flags = "CFLAGS_" + target.toUpperCase() + '_OBJ';\r
+\r
+       if (configure_subst.Exists(sym)) {\r
+               tv = configure_subst.Item(sym);\r
+       } else {\r
+               tv = "";\r
+       }\r
+\r
+       file_list = file_list.split(new RegExp("\\s+"));\r
+       file_list.sort();\r
+\r
+       var re = new RegExp("\.[a-z0-9A-Z]+$");\r
+\r
+       dir = dir.replace(new RegExp("/", "g"), "\\");\r
+       var objs_line = "";\r
+       var srcs_line = "";\r
+\r
+       var sub_build = "$(BUILD_DIR)\\";\r
+\r
+       /* if module dir is not a child of the main source dir,\r
+        * we need to tweak it; we should have detected such a\r
+        * case in condense_path and rewritten the path to\r
+        * be relative.\r
+        * This probably breaks for non-sibling dirs, but that\r
+        * is not a problem as buildconf only checks for pecl\r
+        * as either a child or a sibling */\r
+       if (obj_dir == null) {\r
+               var build_dir = dir.replace(new RegExp("^..\\\\"), "");\r
+               var mangle_dir = build_dir.replace(new RegExp("[\\\\/.]", "g"), "_");\r
+               var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase();\r
+       }\r
+       else {\r
+               var build_dir = obj_dir.replace(new RegExp("^..\\\\"), "");\r
+               var mangle_dir = build_dir.replace(new RegExp("[\\\\/.]", "g"), "_");\r
+               var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase();\r
+       }\r
+       \r
+       var dirs = build_dir.split("\\");\r
+       var i, d = "";\r
+       for (i = 0; i < dirs.length; i++) {\r
+               d += dirs[i];\r
+               build_dirs[build_dirs.length] = d;\r
+               d += "\\";\r
+       }\r
+       sub_build += d;\r
+\r
+\r
+       DEFINE(bd_flags_name, " /Fd" + sub_build + " /Fp" + sub_build + " /FR" + sub_build + " ");\r
+\r
+       for (i in file_list) {\r
+               src = file_list[i];\r
+               obj = src.replace(re, ".obj");\r
+               tv += " " + sub_build + obj;\r
+\r
+               if (PHP_ONE_SHOT == "yes") {\r
+                       if (i > 0) {\r
+                               objs_line += " " + sub_build + obj;     \r
+                               srcs_line += " " + dir + "\\" + src;\r
+                       } else {\r
+                               objs_line = sub_build + obj;    \r
+                               srcs_line = dir + "\\" + src;\r
+                       }\r
+               } else {\r
+                       MFO.WriteLine(sub_build + obj + ": " + dir + "\\" + src);\r
+                       MFO.WriteLine("\t@$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " /Fo" + sub_build + obj);\r
+               }\r
+       }\r
+\r
+       if (PHP_ONE_SHOT == "yes") {\r
+               MFO.WriteLine(objs_line + ": " + srcs_line);\r
+               MFO.WriteLine("\t$(CC) $(" + flags + ") $(CFLAGS) /Fo" + sub_build + " $(" + bd_flags_name + ") /c " + srcs_line);\r
+       }\r
+\r
+       DEFINE(sym, tv);\r
+}\r
+\r
+function REMOVE_TARGET(dllname, flag)\r
+{\r
+       if (configure_subst.Exists(flag)) {\r
+               targets = configure_subst.Item(flag);\r
+               if (targets.match(dllname)) {\r
+                       configure_subst.Remove(flag);\r
+                       targets = targets.replace(dllname, "");\r
+                       configure_subst.Add(flag, targets);\r
+                       return true;\r
+               }\r
+       }\r
+       return false;\r
+}\r
+\r
+function generate_internal_functions()\r
+{\r
+       var infile, outfile;\r
+       var indata;\r
+\r
+       STDOUT.WriteLine("Generating main/internal_functions.c");\r
+       \r
+       infile = FSO.OpenTextFile("main/internal_functions.c.in", 1);\r
+       indata = infile.ReadAll();\r
+       infile.Close();\r
+       \r
+       indata = indata.replace("@EXT_INCLUDE_CODE@", extension_include_code);\r
+       indata = indata.replace("@EXT_MODULE_PTRS@", extension_module_ptrs);\r
+\r
+       if (FSO.FileExists("main/internal_functions.c")) {\r
+               var origdata = file_get_contents("main/internal_functions.c");\r
+\r
+               if (origdata == indata) {\r
+                       STDOUT.WriteLine("\t[content unchanged; skipping]");\r
+                       return;\r
+               }\r
+       }\r
+\r
+       outfile = FSO.CreateTextFile("main/internal_functions.c", true);\r
+       outfile.Write(indata);\r
+       outfile.Close();\r
+}\r
+\r
+function output_as_table(header, ar_out)\r
+{\r
+       var l = header.length;\r
+       var cols = 80;\r
+       var fixedlenght = "";\r
+       var t = 0;\r
+       var i,j,k,m;\r
+       var out = "| ";\r
+       var min = new Array(l);\r
+       var max = new Array(l);\r
+\r
+       if (l != ar_out[0].length) {\r
+               STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length  );\r
+               return;\r
+       }\r
+\r
+       for (j=0; j < l; j++) {\r
+               var tmax, tmin;\r
+\r
+               /*Figure out the max length per column */\r
+               tmin = 0;\r
+               tmax = 0;\r
+               for (k = 0; k < ar_out.length; k++) {\r
+                       var t = ar_out[k][j].length;\r
+                       if (t > tmax) tmax = t;\r
+                       else if (t < tmin) tmin = t;\r
+               }\r
+               if (tmax > header[j].length) {\r
+                       max[j] = tmax;\r
+               } else {\r
+                       max[j] = header[j].length;\r
+               }\r
+               if (tmin < header[j].length) {\r
+                       min[j] = header[j].length;\r
+               }\r
+       }\r
+\r
+       sep = "";\r
+       k = 0;\r
+       for (i = 0; i < l; i++) {\r
+               k += max[i] + 3;\r
+       }\r
+       k++;\r
+\r
+       for (j=0; j < k; j++) {\r
+               sep += "-";\r
+       }\r
+\r
+       STDOUT.WriteLine(sep);\r
+       out = "|";\r
+       for (j=0; j < l; j++) {\r
+               out += " " + header[j];\r
+               for (var i = 0; i < (max[j] - header[j].length); i++){\r
+                       out += " ";\r
+               }\r
+               out += " |";\r
+       }\r
+       STDOUT.WriteLine(out);\r
+\r
+       STDOUT.WriteLine(sep);\r
+\r
+       out = "|";\r
+       for (i=0; i < ar_out.length; i++) {\r
+               line = ar_out[i];\r
+               for (j=0; j < l; j++) {\r
+                       out += " " + line[j];\r
+                       for (var k = 0; k < (max[j] - line[j].length); k++){\r
+                               out += " ";\r
+                       }\r
+                       out += " |";\r
+               }\r
+               STDOUT.WriteLine(out);\r
+               out = "|";\r
+       }\r
+\r
+       STDOUT.WriteLine(sep);\r
+}\r
+\r
+function write_summary()\r
+{\r
+       var ar = new Array();\r
+\r
+       STDOUT.WriteBlankLines(2);\r
+\r
+       STDOUT.WriteLine("Enabled extensions:");\r
+       output_as_table(["Extension", "Mode"], extensions_enabled.sort());\r
+       STDOUT.WriteBlankLines(2);\r
+\r
+       STDOUT.WriteLine("Enabled SAPI:");\r
+       output_as_table(["Sapi Name"], sapi_enabled);\r
+       STDOUT.WriteBlankLines(2);\r
+\r
+       ar[0] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"];\r
+       ar[1] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"];\r
+       ar[2] = ['Compiler', VC_VERSIONS[VCVERS]];\r
+       ar[3] = ['Architecture', X64 ? 'x64' : 'x86'];\r
+\r
+       output_as_table(["",""], ar);\r
+       STDOUT.WriteBlankLines(2);\r
+}\r
+\r
+function generate_files()\r
+{\r
+       var i, dir, bd, last;\r
+\r
+       STDOUT.WriteBlankLines(1);\r
+       STDOUT.WriteLine("Creating build dirs...");\r
+       dir = get_define("BUILD_DIR");\r
+       build_dirs.sort();\r
+       last = null;\r
+\r
+       if (!FSO.FolderExists(dir)) {\r
+               FSO.CreateFolder(dir);\r
+       }\r
+\r
+       for (i = 0; i < build_dirs.length; i++) {\r
+               bd = FSO.BuildPath(dir, build_dirs[i]);\r
+               if (bd == last) {\r
+                       continue;\r
+               }\r
+               last = bd;\r
+               ADD_FLAG("BUILD_DIRS_SUB", bd.replace(new RegExp('^'+dir+'\\\\'), '$(BUILD_DIR)\\'));\r
+               if (!FSO.FolderExists(bd)) {\r
+                       FSO.CreateFolder(bd);\r
+               }\r
+       }\r
+\r
+       if (PHP_DSP != "no") {\r
+               generate_dsp_file("TSRM", "TSRM", null, false);\r
+               generate_dsp_file("Zend", "Zend", null, false);\r
+               generate_dsp_file("win32", "win32", null, false);\r
+               generate_dsp_file("main", "main", null, false);\r
+               generate_dsp_file("streams", "main\\streams", null, false);\r
+               copy_dsp_files();\r
+       }\r
+\r
+       STDOUT.WriteLine("Generating files...");\r
+       generate_makefile();\r
+       generate_internal_functions();\r
+       generate_config_h();\r
+\r
+       STDOUT.WriteLine("Done.");\r
+       STDOUT.WriteBlankLines(1);\r
+       write_summary();\r
+\r
+       if (PHP_SNAPSHOT_BUILD != "no") {\r
+               STDOUT.WriteLine("Type 'nmake snap' to build a PHP snapshot");\r
+       } else {\r
+               STDOUT.WriteLine("Type 'nmake' to build PHP");\r
+       }\r
+}\r
+\r
+function generate_config_h()\r
+{\r
+       var infile, outfile;\r
+       var indata;\r
+       var prefix;\r
+\r
+       prefix = PHP_PREFIX.replace(new RegExp("\\\\", "g"), "\\\\");\r
+\r
+       STDOUT.WriteLine("Generating main/config.w32.h");\r
+       \r
+       infile = FSO.OpenTextFile("win32/build/config.w32.h.in", 1);\r
+       indata = infile.ReadAll();\r
+       infile.Close();\r
+       \r
+       outfile = FSO.CreateTextFile("main/config.w32.h", true);\r
+\r
+       indata = indata.replace(new RegExp("@PREFIX@", "g"), prefix);\r
+       outfile.Write(indata);\r
+\r
+       var keys = (new VBArray(configure_hdr.Keys())).toArray();\r
+       var i, j;\r
+       var item;\r
+       var pieces, stuff_to_crack, chunk;\r
+\r
+       outfile.WriteBlankLines(1);\r
+       outfile.WriteLine("/* values determined by configure.js */");\r
+\r
+       for (i in keys) {\r
+               item = configure_hdr.Item(keys[i]);\r
+               outfile.WriteBlankLines(1);\r
+               pieces = item[0];\r
+\r
+               if (item[1] != undefined) {\r
+                       outfile.WriteLine("/* " + item[1] + " */");\r
+               }\r
+\r
+\r
+               if (typeof(pieces) == "string" && pieces.charCodeAt(0) == 34) {\r
+                       /* quoted string have a maximal length of 2k under vc.\r
+                        * solution is to crack them and let the compiler concat\r
+                        * them implicitly */\r
+                       stuff_to_crack = pieces;\r
+                       pieces = "";\r
+\r
+                       while (stuff_to_crack.length) {\r
+                               j = 65;\r
+                               while (stuff_to_crack.charCodeAt(j) != 32 && j < stuff_to_crack.length)\r
+                                       j++;\r
+\r
+                               chunk = stuff_to_crack.substr(0, j);\r
+                               pieces += chunk;\r
+                               stuff_to_crack = stuff_to_crack.substr(chunk.length);\r
+                               if (stuff_to_crack.length)\r
+                                       pieces += '" "';\r
+                       }\r
+               }\r
+               \r
+               outfile.WriteLine("#define " + keys[i] + " " + pieces);\r
+       }\r
+       \r
+       outfile.Close();\r
+}\r
+\r
+function generate_makefile()\r
+{\r
+       STDOUT.WriteLine("Generating Makefile");\r
+       var MF = FSO.CreateTextFile("Makefile", true);\r
+\r
+       MF.WriteLine("# Generated by configure.js");\r
+\r
+       /* spit out variable definitions */\r
+       var keys = (new VBArray(configure_subst.Keys())).toArray();\r
+       var i;\r
+\r
+       for (i in keys) {\r
+               // The trailing space is needed to prevent the trailing backslash\r
+               // that is part of the build dir flags (CFLAGS_BD_XXX) from being\r
+               // seen as a line continuation character\r
+               MF.WriteLine(keys[i] + "=" + \r
+                       //word_wrap_and_indent(1, configure_subst.Item(keys[i]), ' \\', '\t') + " "\r
+                       configure_subst.Item(keys[i]) + " "\r
+                       );\r
+               MF.WriteBlankLines(1);\r
+       }\r
+\r
+       MF.WriteBlankLines(1);\r
+\r
+       var TF = FSO.OpenTextFile("win32/build/Makefile", 1);\r
+       MF.Write(TF.ReadAll());\r
+       TF.Close();\r
+\r
+       MF.WriteBlankLines(2);\r
+\r
+       MFO.Close();\r
+       TF = FSO.OpenTextFile("Makefile.objects", 1);\r
+       MF.Write(TF.ReadAll());\r
+       TF.Close();\r
+\r
+       MF.Close();     \r
+}\r
+\r
+function ADD_FLAG(name, flags, target)\r
+{\r
+       if (target != null) {\r
+               name = target.toUpperCase() + "_" + name;\r
+       }\r
+       if (configure_subst.Exists(name)) {\r
+               var curr_flags = configure_subst.Item(name);\r
+\r
+               if (curr_flags.indexOf(flags) >= 0) {\r
+                       return;\r
+               }\r
+               \r
+               flags = curr_flags + " " + flags;\r
+               configure_subst.Remove(name);\r
+       }\r
+       configure_subst.Add(name, flags);\r
+\r
+       if (PHP_DSP != "no") {\r
+               if (flags && (name.substr(name.length-3) != "PHP") && (name.substr(0, 7) == "CFLAGS_")) {\r
+                       DSP_FLAGS[DSP_FLAGS.length] = new Array(name, flags);\r
+               }\r
+       }\r
+}\r
+\r
+function get_define(name)\r
+{\r
+       if (configure_subst.Exists(name)) {\r
+               return configure_subst.Item(name);\r
+       }\r
+       return "";\r
+}\r
+\r
+// Add a .def to the core to export symbols\r
+function ADD_DEF_FILE(name)\r
+{\r
+       if (!configure_subst.Exists("PHPDEF")) {\r
+               DEFINE("PHPDEF", "$(BUILD_DIR)\\$(PHPDLL).def");\r
+               ADD_FLAG("PHP_LDFLAGS", "/def:$(PHPDEF)");\r
+       }\r
+       ADD_FLAG("PHP_DLL_DEF_SOURCES", name);\r
+}\r
+\r
+function AC_DEFINE(name, value, comment, quote)\r
+{\r
+       if (quote == null) {\r
+               quote = true;\r
+       }\r
+       if (quote && typeof(value) == "string") {\r
+               value = '"' + value.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"';\r
+       } else if (value.length == 0) {\r
+               value = '""';\r
+       }\r
+       var item = new Array(value, comment);\r
+       if (configure_hdr.Exists(name)) {\r
+               var orig_item = configure_hdr.Item(name);\r
+               STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]);\r
+       } else {\r
+               configure_hdr.Add(name, item);\r
+       }\r
+}\r
+\r
+function MESSAGE(msg)\r
+{\r
+       STDOUT.WriteLine("" + msg);\r
+}\r
+\r
+function ERROR(msg)\r
+{\r
+       STDERR.WriteLine("ERROR: " + msg);\r
+       WScript.Quit(3);\r
+}\r
+\r
+function WARNING(msg)\r
+{\r
+       STDERR.WriteLine("WARNING: " + msg);\r
+       STDERR.WriteBlankLines(1);\r
+}\r
+\r
+function copy_and_subst(srcname, destname, subst_array)\r
+{\r
+       if (!FSO.FileExists(srcname)) {\r
+               srcname = configure_module_dirname + "\\" + srcname;\r
+               destname = configure_module_dirname + "\\" + destname;\r
+       }\r
+\r
+       var content = file_get_contents(srcname);\r
+       var i;\r
+\r
+       for (i = 0; i < subst_array.length; i+=2) {\r
+               var re = subst_array[i];\r
+               var rep = subst_array[i+1];\r
+\r
+               content = content.replace(re, rep);\r
+       }\r
+       \r
+       var f = FSO.CreateTextFile(destname, true);\r
+       f.Write(content);\r
+       f.Close();\r
+}\r
+\r
+// glob using simple filename wildcards\r
+// returns an array of matches that are found\r
+// in the filesystem\r
+function glob(path_pattern)\r
+{\r
+       var path_parts = path_pattern.replace(new RegExp("/", "g"), "\\").split("\\");\r
+       var p;\r
+       var base = "";\r
+       var is_pat_re = /\*/;\r
+\r
+//STDOUT.WriteLine("glob: " + path_pattern);\r
+\r
+       if (FSO.FileExists(path_pattern)) {\r
+               return new Array(path_pattern);\r
+       }\r
+       \r
+       // first, build as much as possible that doesn't have a pattern\r
+       for (p = 0; p < path_parts.length; p++) {\r
+               if (path_parts[p].match(is_pat_re))\r
+                       break;\r
+               if (p)\r
+                       base += "\\";\r
+               base += path_parts[p];  \r
+       }\r
+\r
+       return _inner_glob(base, p, path_parts);\r
+}\r
+\r
+function _inner_glob(base, p, parts)\r
+{\r
+       var pat = parts[p];\r
+       var full_name = base + "\\" + pat;\r
+       var re = null;\r
+       var items = null;\r
+\r
+       if (p == parts.length) {\r
+               return false;\r
+       }\r
+\r
+//STDOUT.WriteLine("inner: base=" + base + " p=" + p + " pat=" + pat);\r
+\r
+       if (FSO.FileExists(full_name)) {\r
+               if (p < parts.length - 1) {\r
+                       // we didn't reach the full extent of the pattern\r
+                       return false;\r
+               }\r
+               return new Array(full_name);\r
+       }\r
+\r
+       if (FSO.FolderExists(full_name) && p == parts.length - 1) {\r
+               // we have reached the end of the pattern; no need to recurse\r
+               return new Array(full_name);\r
+       }\r
+\r
+       // Convert the pattern into a regexp\r
+       re = new RegExp("^" + pat.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.') + "$", "i");\r
+\r
+       items = new Array();\r
+\r
+       if (!FSO.FolderExists(base)) {\r
+               return false;\r
+       }\r
+\r
+       var folder = FSO.GetFolder(base);\r
+       var fc = null;\r
+       var subitems = null;\r
+       var item_name = null;\r
+       var j;\r
+\r
+       fc = new Enumerator(folder.SubFolders);\r
+       for (; !fc.atEnd(); fc.moveNext()) {\r
+               item_name = FSO.GetFileName(fc.item());\r
+\r
+               if (item_name.match(re)) {\r
+                       // got a match; if we are at the end of the pattern, just add these\r
+                       // things to the items array\r
+                       if (p == parts.length - 1) {\r
+                               items[items.length] = fc.item();\r
+                       } else {\r
+                               // we should recurse and do more matches\r
+                               subitems = _inner_glob(base + "\\" + item_name, p + 1, parts);\r
+                               if (subitems) {\r
+                                       for (j = 0; j < subitems.length; j++) {\r
+                                               items[items.length] = subitems[j];\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       // if we are at the end of the pattern, we should match\r
+       // files too\r
+       if (p == parts.length - 1) {\r
+               fc = new Enumerator(folder.Files);\r
+               for (; !fc.atEnd(); fc.moveNext()) {\r
+                       item_name = FSO.GetFileName(fc.item());\r
+                       if (item_name.match(re)) {\r
+                               items[items.length] = fc.item();\r
+                       }\r
+               }\r
+       }\r
+\r
+       if (items.length == 0)\r
+               return false;\r
+\r
+       return items;\r
+}\r
+\r
+// for snapshot builders, this option will attempt to enable everything\r
+// and you can then build everything, ignoring fatal errors within a module\r
+// by running "nmake snap"\r
+PHP_SNAPSHOT_BUILD = "no";\r
+ARG_ENABLE('snapshot-build', 'Build a snapshot; turns on everything it can and ignores build errors', 'no');\r
+\r
+// one-shot build optimizes build by asking compiler to build\r
+// several objects at once, reducing overhead of starting new\r
+// compiler processes.\r
+ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no');\r
+\r