summaryrefslogtreecommitdiff
path: root/win32/build/buildconf.js
blob: 38b33baaaa1f867056a6eeea4bb4ebcb8590907b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// $Id: buildconf.js,v 1.1 2003-12-02 23:17:04 wez Exp $
/*
  +----------------------------------------------------------------------+
  | PHP Version 5                                                        |
  +----------------------------------------------------------------------+
  | Copyright (c) 1997-2003 The PHP Group                                |
  +----------------------------------------------------------------------+
  | This source file is subject to version 3.0 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_0.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: buildconf.js,v 1.1 2003-12-02 23:17:04 wez Exp $ */
// This generates a configure script for win32 build

WScript.StdOut.WriteLine("Rebuilding configure.js");
var FSO = WScript.CreateObject("Scripting.FileSystemObject");
var C = FSO.CreateTextFile("configure.js", true);

var modules = "";

function file_get_contents(filename)
{
	var F = FSO.OpenTextFile(filename, 1);
	var t = F.ReadAll();
	F.Close();
	return t;
}

function find_config_w32(dirname)
{
	var f = FSO.GetFolder(dirname);
	var	fc = new Enumerator(f.SubFolders);
	var c;
	for (; !fc.atEnd(); fc.moveNext())
	{
		c = FSO.BuildPath(fc.item(), "config.w32");
		if (FSO.FileExists(c)) {
			//WScript.StdOut.WriteLine(c);
			modules += file_get_contents(c);
		}
	}
}

// Write the head of the configure script
C.WriteLine("/* This file automatically generated from win32/build/confutils.js */");
C.Write(file_get_contents("win32/build/confutils.js"));

// Pull in code from sapi and extensions
modules = file_get_contents("win32/build/config.w32");
find_config_w32("sapi");
find_config_w32("ext");

// Look for ARG_ENABLE or ARG_WITH calls
re = new RegExp("(ARG_(ENABLE|WITH)\([^;]+\);)", "gm");
calls = modules.match(re);
for (i = 0; i < calls.length; i++) {
	item = calls[i];
	C.WriteLine(item);
}

C.WriteBlankLines(1);
C.WriteLine("conf_process_args();");
C.WriteBlankLines(1);

// Comment out the calls from their original positions
modules = modules.replace(re, "/* $1 */");
C.Write(modules);

C.WriteBlankLines(1);
C.Write(file_get_contents("win32/build/configure.tail"));

WScript.StdOut.WriteLine("Now run 'cscript /nologo configure.js --help'");