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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
// vim:ft=javascript
// $Id$
// "Master" config file; think of it as a configure.in
// equivalent.
ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin');
PHP_CL = PATH_PROG('cl', null, 'PHP_CL');
if (!PHP_CL) {
ERROR("MS C++ compiler is required");
}
/* For the record here: */
// 1200 is VC6
// 1300 is vs.net 2002
// 1310 is vs.net 2003
// 1400 is vs.net 2005
// 1500 is vs.net 2008
// 1600 is vs.net 2010
// Which version of the compiler do we have?
VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]);
if (VCVERS < 1500) {
ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required");
}
AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
// do we use x64 or 80x86 version of compiler?
X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL');
if (X64) {
STDOUT.WriteLine(" Detected 64-bit compiler");
} else {
STDOUT.WriteLine(" Detected 32-bit compiler");
}
AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture");
DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86');
// cygwin now ships with link.exe. Avoid searching the cygwin path
// for this, as we want the MS linker, not the fileutil
PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
PATH_PROG('nmake');
// we don't want to define LIB, as that will override the default library path
// that is set in that env var
PATH_PROG('lib', null, 'MAKE_LIB');
if (!PATH_PROG('bison')) {
ERROR('bison is required')
}
// There's a minimum requirement for re2c..
MINRE2C = "0.13.4";
RE2C = PATH_PROG('re2c');
if (RE2C) {
var intvers, intmin;
var pattern = /\./g;
RE2CVERS = probe_binary(RE2C, "version");
STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS);
intvers = RE2CVERS.replace(pattern, '') - 0;
intmin = MINRE2C.replace(pattern, '') - 0;
if (intvers < intmin) {
STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C);
STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c');
DEFINE('RE2C', '');
} else {
DEFINE('RE2C_FLAGS', '');
}
} else {
STDOUT.WriteLine('Parsers will not be regenerated');
}
PATH_PROG('zip');
PATH_PROG('lemon');
// avoid picking up midnight commander from cygwin
PATH_PROG('mc', WshShell.Environment("Process").Item("PATH"));
// Try locating manifest tool
if (VCVERS > 1200) {
PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"));
}
// stick objects somewhere outside of the source tree
ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', '');
if (PHP_OBJECT_OUT_DIR.length) {
PHP_OBJECT_OUT_DIR = FSO.GetAbsolutePathName(PHP_OBJECT_OUT_DIR);
if (!FSO.FolderExists(PHP_OBJECT_OUT_DIR)) {
ERROR('you chosen output directory ' + PHP_OBJECT_OUT_DIR + ' does not exist');
}
PHP_OBJECT_OUT_DIR += '\\';
} else if (X64) {
if (!FSO.FolderExists("x64")) {
FSO.CreateFolder("x64");
}
PHP_OBJECT_OUT_DIR = 'x64\\';
}
ARG_ENABLE('debug', 'Compile with debugging symbols', "no");
ARG_ENABLE('debug-pack', 'Release binaries with external debug symbols (--enable-debug must not be specified)', 'no');
if (PHP_DEBUG == "yes" && PHP_DEBUG_PACK == "yes") {
ERROR("Use of both --enable-debug and --enable-debug-pack not allowed.");
}
ARG_ENABLE('pgi', 'Generate PGO instrumented binaries', 'no');
ARG_WITH('pgo', 'Compile optimized binaries using training data from folder', 'no');
if (PHP_PGI == "yes" || PHP_PGO != "no") {
PGOMGR = PATH_PROG('pgomgr', WshShell.Environment("Process").Item("PATH"));
if (!PGOMGR) {
ERROR("--enable-pgi and --with-pgo options can only be used if PGO capable compiler is present.");
}
if (PHP_PGI == "yes" && PHP_PGO != "no") {
ERROR("Use of both --enable-pgi and --with-pgo not allowed.");
}
}
ARG_ENABLE('zts', 'Thread safety', 'yes');
// Configures the hard-coded installation dir
ARG_WITH('prefix', 'where PHP will be installed', '');
if (PHP_PREFIX == '') {
PHP_PREFIX = "C:\\php";
if (PHP_DEBUG == "yes")
PHP_PREFIX += "\\debug";
}
DEFINE('PHP_PREFIX', PHP_PREFIX);
DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext ");
// CFLAGS for building the PHP dll
DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP5DLLTS_EXPORTS /D PHP_EXPORTS \
/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500");
DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
// General CFLAGS for building objects
DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \
/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
if (VCVERS < 1400) {
// Enable automatic precompiled headers
ADD_FLAG('CFLAGS', ' /YX ');
if (PHP_DEBUG == "yes") {
// Set some debug/release specific options
ADD_FLAG('CFLAGS', ' /GZ ');
}
}
if (VCVERS >= 1400) {
// fun stuff: MS deprecated ANSI stdio and similar functions
// disable annoying warnings. In addition, time_t defaults
// to 64-bit. Ask for 32-bit.
if (X64) {
ADD_FLAG('CFLAGS', ' /wd4996 /Wp64 ');
} else {
ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 ');
}
if (PHP_DEBUG == "yes") {
// Set some debug/release specific options
ADD_FLAG('CFLAGS', ' /RTC1 ');
}
}
ARG_WITH('mp', 'Tell VC9+ use up to [n,auto,disable] processes for compilation', 'auto');
if (VCVERS >= 1500 && PHP_MP != 'disable') {
// no from disable-all
if(PHP_MP == 'auto' || PHP_MP == 'no') {
ADD_FLAG('CFLAGS', ' /MP ');
} else {
if(parseInt(PHP_MP) != 0) {
ADD_FLAG('CFLAGS', ' /MP'+ PHP_MP +' ');
} else {
STDOUT.WriteLine('WARNING: Invalid argument for MP: ' + PHP_MP);
}
}
}
// General link flags
DEFINE("LDFLAGS", "/nologo /version:" +
PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION);
// General DLL link flags
DEFINE("DLL_LDFLAGS", "/dll ");
// PHP DLL link flags
DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)");
// General libs
// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib
DEFINE("LIBS", "kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib");
// Set some debug/release specific options
if (PHP_DEBUG == "yes") {
ADD_FLAG("CFLAGS", "/LDd /MDd /W3 /Gm /Od /D _DEBUG /D ZEND_DEBUG=1 " +
(X64?"/Zi":"/ZI"));
ADD_FLAG("LDFLAGS", "/debug");
// Avoid problems when linking to release libraries that use the release
// version of the libc
ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:msvcrt");
} else {
// Generate external debug files when --enable-debug-pack is specified
if (PHP_DEBUG_PACK == "yes") {
ADD_FLAG("CFLAGS", "/Zi");
ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf");
}
// Equivalent to Release_TSInline build -> best optimization
ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0");
// if you have VS.Net /GS hardens the binary against buffer overruns
// ADD_FLAG("CFLAGS", "/GS");
}
if (PHP_ZTS == "yes") {
ADD_FLAG("CFLAGS", "/D ZTS=1");
ADD_FLAG("ZTS", "1");
} else {
ADD_FLAG("ZTS", "0");
}
DEFINE("PHP_ZTS_ARCHIVE_POSTFIX", PHP_ZTS == "yes" ? '' : "-nts");
// we want msvcrt in the PHP DLL
ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt");
// set up the build dir and DLL name
if (PHP_DEBUG == "yes" && PHP_ZTS == "yes") {
DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug_TS");
DEFINE("PHPDLL", "php" + PHP_VERSION + "ts_debug.dll");
DEFINE("PHPLIB", "php" + PHP_VERSION + "ts_debug.lib");
} else if (PHP_DEBUG == "yes" && PHP_ZTS == "no") {
DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Debug");
DEFINE("PHPDLL", "php" + PHP_VERSION + "_debug.dll");
DEFINE("PHPLIB", "php" + PHP_VERSION + "_debug.lib");
} else if (PHP_DEBUG == "no" && PHP_ZTS == "yes") {
DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release_TS");
DEFINE("PHPDLL", "php" + PHP_VERSION + "ts.dll");
DEFINE("PHPLIB", "php" + PHP_VERSION + "ts.lib");
} else if (PHP_DEBUG == "no" && PHP_ZTS == "no") {
DEFINE("BUILD_DIR", PHP_OBJECT_OUT_DIR + "Release");
DEFINE("PHPDLL", "php" + PHP_VERSION + ".dll");
DEFINE("PHPLIB", "php" + PHP_VERSION + ".lib");
}
// CFLAGS, LDFLAGS and BUILD_DIR are defined
// Add compiler and link flags if PGO options are selected
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
ADD_FLAG('DLL_LDFLAGS', "/LTCG:PGINSTRUMENT");
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
DEFINE("PGOPGD_DIR", "$(BUILD_DIR)");
}
else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
ADD_FLAG('DLL_LDFLAGS', "/LTCG:PGUPDATE");
ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
DEFINE("PGOPGD_DIR", ((PHP_PGO.length == 0 || PHP_PGO == "yes") ? "$(BUILD_DIR)" : PHP_PGO));
}
// Find the php_build dir - it contains headers and libraries
// that we need
ARG_WITH('php-build', 'Path to where you extracted the development libraries (http://wiki.php.net/internals/windows/libs). Assumes that it is a sibling of this source dir (..\\deps) if not specified', 'no');
if (PHP_PHP_BUILD == 'no') {
if (FSO.FolderExists("..\\deps")) {
PHP_PHP_BUILD = "..\\deps";
} else {
if (FSO.FolderExists("..\\php_build")) {
PHP_PHP_BUILD = "..\\php_build";
} else {
if (X64) {
if (FSO.FolderExists("..\\win64build")) {
PHP_PHP_BUILD = "..\\win64build";
} else if (FSO.FolderExists("..\\php-win64-dev\\php_build")) {
PHP_PHP_BUILD = "..\\php-win64-dev\\php_build";
}
} else {
if (FSO.FolderExists("..\\win32build")) {
PHP_PHP_BUILD = "..\\win32build";
} else if (FSO.FolderExists("..\\php-win32-dev\\php_build")) {
PHP_PHP_BUILD = "..\\php-win32-dev\\php_build";
}
}
}
}
PHP_PHP_BUILD = FSO.GetAbsolutePathName(PHP_PHP_BUILD);
}
DEFINE("PHP_BUILD", PHP_PHP_BUILD);
ARG_WITH('extra-includes', 'Extra include path to use when building everything', '');
ARG_WITH('extra-libs', 'Extra library path to use when linking everything', '');
var php_usual_include_suspects = PHP_PHP_BUILD+"\\include";
var php_usual_lib_suspects = PHP_PHP_BUILD+"\\lib";
ADD_FLAG("CFLAGS", '/I "' + php_usual_include_suspects + '" ');
ADD_FLAG("LDFLAGS", '/libpath:"' + php_usual_lib_suspects + '" ');
// Poke around for some headers
function probe_basic_headers()
{
var p;
if (PHP_PHP_BUILD != "no") {
php_usual_include_suspects += ";" + PHP_PHP_BUILD + "\\include";
php_usual_lib_suspects += ";" + PHP_PHP_BUILD + "\\lib";
}
}
function add_extra_dirs()
{
var path, i, f;
if (PHP_EXTRA_INCLUDES.length) {
path = PHP_EXTRA_INCLUDES.split(';');
for (i = 0; i < path.length; i++) {
f = FSO.GetAbsolutePathName(path[i]);
if (FSO.FolderExists(f)) {
ADD_FLAG("CFLAGS", '/I "' + f + '" ');
}
}
}
if (PHP_EXTRA_LIBS.length) {
path = PHP_EXTRA_LIBS.split(';');
for (i = 0; i < path.length; i++) {
f = FSO.GetAbsolutePathName(path[i]);
if (FSO.FolderExists(f)) {
if (VCVERS <= 1200 && f.indexOf(" ") >= 0) {
ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" ');
} else {
ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" ');
}
}
}
}
}
probe_basic_headers();
add_extra_dirs();
//DEFINE("PHP_BUILD", PHP_PHP_BUILD);
STDOUT.WriteBlankLines(1);
STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR'));
STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB'));
ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \
zend_ini_parser.c zend_ini_scanner.c zend_alloc.c zend_compile.c \
zend_constants.c zend_dynamic_array.c zend_exceptions.c \
zend_execute_API.c zend_highlight.c \
zend_llist.c zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c \
zend_stack.c zend_variables.c zend.c zend_API.c zend_extensions.c \
zend_hash.c zend_list.c zend_indent.c zend_builtin_functions.c \
zend_sprintf.c zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c \
zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \
zend_object_handlers.c zend_objects_API.c \
zend_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c \
zend_float.c zend_string.c");
if (VCVERS == 1200) {
AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
}
ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \
php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \
php_open_temporary_file.c php_logos.c output.c internal_functions.c php_sprintf.c");
ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c");
// Newer versions have it
if (VCVERS <= 1300) {
ADD_SOURCES("win32", "strtoi64.c");
}
if (VCVERS >= 1400) {
AC_DEFINE('HAVE_STRNLEN', 1);
}
ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c \
userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c");
ADD_SOURCES("win32", "glob.c readdir.c \
registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c");
PHP_INSTALL_HEADERS("", "Zend/ TSRM/ main/ main/streams/ win32/");
STDOUT.WriteBlankLines(1);
/* Can we build with IPv6 support? */
ARG_ENABLE("ipv6", "Disable IPv6 support (default is turn it on if available)", "yes");
var main_network_has_ipv6 = 0;
if (PHP_IPV6 == "yes") {
main_network_has_ipv6 = CHECK_HEADER_ADD_INCLUDE("wspiapi.h", "CFLAGS") ? 1 : 0;
}
if (main_network_has_ipv6) {
STDOUT.WriteLine("Enabling IPv6 support");
}
AC_DEFINE('HAVE_GETADDRINFO', main_network_has_ipv6);
AC_DEFINE('HAVE_GAI_STRERROR', main_network_has_ipv6);
AC_DEFINE('HAVE_IPV6', main_network_has_ipv6);
/* this allows up to 256 sockets to be select()ed in a single
* call to select(), instead of the usual 64 */
ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
AC_DEFINE('HAVE_USLEEP', 1);
AC_DEFINE('HAVE_STRCOLL', 1);
/* For snapshot builders, where can we find the additional
* files that make up the snapshot template? */
ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no");
if (PHP_SNAPSHOT_TEMPLATE == "no") {
/* default is as a sibling of the php_build dir */
if (FSO.FolderExists(PHP_PHP_BUILD + "\\template")) {
PHP_SNAPSHOT_TEMPLATE = FSO.GetAbsolutePathName(PHP_PHP_BUILD + "\\template");
} else if (FSO.FolderExists(PHP_PHP_BUILD + "\\..\\template")) {
PHP_SNAPSHOT_TEMPLATE = FSO.GetAbsolutePathName(PHP_PHP_BUILD + "\\..\\template");
}
}
DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE);
if (PHP_DSP != "no") {
if (FSO.FolderExists("tmp")) {
FSO.DeleteFolder("tmp");
}
FSO.CreateFolder("tmp");
}
ARG_ENABLE("security-flags", "Disable the compiler security flags", "yes");
if (PHP_SECURITY_FLAGS == "yes") {
ADD_FLAG("LDFLAGS", "/NXCOMPAT /DYNAMICBASE ");
}
ARG_ENABLE("static-analyze", "Enable the VC compiler static analyze", "no");
if (PHP_STATIC_ANALYZE == "yes") {
ADD_FLAG("CFLAGS", " /analyze ");
ADD_FLAG("CFLAGS", " /wd6308 ");
}
|