Skip to content

Commit 4d8c28a

Browse files
committed
catch up the toolset changes with phpize
also packed common parts into functions so there's less code duplication
1 parent 46d6baf commit 4d8c28a

File tree

3 files changed

+147
-188
lines changed

3 files changed

+147
-188
lines changed

win32/build/config.w32

Lines changed: 9 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,11 @@
44
// equivalent.
55

66
ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs");
7-
if ("clang" == PHP_TOOLSET) {
8-
VS_TOOLSET = false;
9-
CLANG_TOOLSET = true;
10-
INTEL_TOOLSET = false;
11-
} else if ("intel" == PHP_TOOLSET) {
12-
VS_TOOLSET = false;
13-
CLANG_TOOLSET = false;
14-
INTEL_TOOLSET = true;
15-
} else {
16-
/* Visual Studio is the default toolset. */
17-
PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET;
18-
if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) {
19-
ERROR("Unsupported toolset name '" + PHP_TOOLSET + "'");
20-
}
21-
VS_TOOLSET = true;
22-
CLANG_TOOLSET = false;
23-
INTEL_TOOLSET = false;
24-
}
25-
7+
toolset_option_handle();
268

279
ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin');
2810

29-
PHP_CL = toolset_get_compiler();
30-
if (!PHP_CL) {
31-
ERROR("MS C++ compiler is required");
32-
}
33-
34-
COMPILER_NUMERIC_VERSION = toolset_get_compiler_version();
35-
COMPILER_NAME = toolset_get_compiler_name();
36-
37-
if (VS_TOOLSET) {
38-
/* For the record here: */
39-
// 1200 is VC6
40-
// 1300 is vs.net 2002
41-
// 1310 is vs.net 2003
42-
// 1400 is vs.net 2005
43-
// 1500 is vs.net 2008
44-
// 1600 is vs.net 2010
45-
// Which version of the compiler do we have?
46-
VCVERS = COMPILER_NUMERIC_VERSION;
47-
48-
if (VCVERS < 1500) {
49-
ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required");
50-
}
51-
52-
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
53-
DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
54-
AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
55-
} else if (CLANG_TOOLSET) {
56-
CLANGVERS = COMPILER_NUMERIC_VERSION;
57-
58-
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
59-
DEFINE("PHP_COMPILER_SHORT", "clang");
60-
AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */
61-
62-
} else if (INTEL_TOOLSET) {
63-
INTELVERS = COMPILER_NUMERIC_VERSION;
64-
65-
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
66-
DEFINE("PHP_COMPILER_SHORT", "icc");
67-
AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */
68-
}
69-
STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME);
11+
toolset_setup_compiler();
7012

7113
// do we use x64 or 80x86 version of compiler?
7214
X64 = toolset_is_64();
@@ -78,53 +20,8 @@ if (X64) {
7820
AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture");
7921
DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86');
8022

81-
// cygwin now ships with link.exe. Avoid searching the cygwin path
82-
// for this, as we want the MS linker, not the fileutil
83-
toolset_get_linker();
84-
85-
PATH_PROG('nmake');
86-
87-
// we don't want to define LIB, as that will override the default library path
88-
// that is set in that env var
89-
PATH_PROG('lib', null, 'MAKE_LIB');
90-
if (!PATH_PROG('bison')) {
91-
ERROR('bison is required')
92-
}
93-
94-
// There's a minimum requirement for re2c..
95-
MINRE2C = "0.13.4";
96-
97-
RE2C = PATH_PROG('re2c');
98-
if (RE2C) {
99-
var intvers, intmin;
100-
var pattern = /\./g;
101-
102-
RE2CVERS = probe_binary(RE2C, "version");
103-
STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS);
104-
105-
intvers = RE2CVERS.replace(pattern, '') - 0;
106-
intmin = MINRE2C.replace(pattern, '') - 0;
107-
108-
if (intvers < intmin) {
109-
STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C);
110-
STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c');
111-
DEFINE('RE2C', '');
112-
} else {
113-
DEFINE('RE2C_FLAGS', '');
114-
}
115-
} else {
116-
STDOUT.WriteLine('Parsers will not be regenerated');
117-
}
118-
PATH_PROG('zip');
119-
PATH_PROG('lemon');
120-
121-
// avoid picking up midnight commander from cygwin
122-
PATH_PROG('mc', WshShell.Environment("Process").Item("PATH"));
123-
124-
// Try locating manifest tool
125-
if (VS_TOOLSET && VCVERS > 1200) {
126-
PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"));
127-
}
23+
toolset_setup_linker();
24+
toolset_setup_project_tools();
12825

12926
// stick objects somewhere outside of the source tree
13027
ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', '');
@@ -180,6 +77,10 @@ DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
18077
// General CFLAGS for building objects
18178
DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \
18279
/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
80+
if (VS_TOOLSET) {
81+
ADD_FLAG("CFLAGS", " /FD ");
82+
}
83+
18384
if (CLANG_TOOLSET) {
18485
if (X64) {
18586
ADD_FLAG('CFLAGS', ' -m64 ');
@@ -420,6 +321,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \
420321
zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \
421322
zend_inheritance.c");
422323

324+
/* XXX inspect this for other toolsets */
423325
if (VS_TOOLSET && VCVERS == 1200) {
424326
AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
425327
}

win32/build/config.w32.phpize.in

Lines changed: 17 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,15 @@
33
// "Master" config file; think of it as a configure.in
44
// equivalent.
55

6+
ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs");
7+
toolset_option_handle()
8+
69
var PHP_CYGWIN="notset";
7-
PHP_CL = PATH_PROG('cl', null, 'PHP_CL');
8-
if (!PHP_CL) {
9-
ERROR("MS C++ compiler is required");
10-
}
11-
/* For the record here: */
12-
// 1200 is VC6
13-
// 1300 is vs.net 2002
14-
// 1310 is vs.net 2003
15-
// 1400 is vs.net 2005
16-
// 1500 is vs.net 2008
17-
// 1600 is vs.net 2010
18-
// Which version of the compiler do we have?
19-
VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
20-
STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]);
21-
22-
if (VCVERS < 1500) {
23-
ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required");
24-
}
2510

26-
AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version");
27-
DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
28-
AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
11+
toolset_setup_compiler();
2912

3013
// do we use x64 or 80x86 version of compiler?
31-
X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL');
14+
X64 = toolset_is_64();
3215
if (X64) {
3316
STDOUT.WriteLine(" Detected 64-bit compiler");
3417
} else {
@@ -37,52 +20,8 @@ if (X64) {
3720
AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture");
3821
DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86');
3922

40-
// cygwin now ships with link.exe. Avoid searching the cygwin path
41-
// for this, as we want the MS linker, not the fileutil
42-
PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
43-
PATH_PROG('nmake');
44-
45-
// we don't want to define LIB, as that will override the default library path
46-
// that is set in that env var
47-
PATH_PROG('lib', null, 'MAKE_LIB');
48-
if (!PATH_PROG('bison')) {
49-
ERROR('bison is required')
50-
}
51-
52-
// There's a minimum requirement for re2c..
53-
MINRE2C = "0.13.4";
54-
55-
RE2C = PATH_PROG('re2c');
56-
if (RE2C) {
57-
var intvers, intmin;
58-
var pattern = /\./g;
59-
60-
RE2CVERS = probe_binary(RE2C, "version");
61-
STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS);
62-
63-
intvers = RE2CVERS.replace(pattern, '') - 0;
64-
intmin = MINRE2C.replace(pattern, '') - 0;
65-
66-
if (intvers < intmin) {
67-
STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C);
68-
STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c');
69-
DEFINE('RE2C', '');
70-
} else {
71-
DEFINE('RE2C_FLAGS', '');
72-
}
73-
} else {
74-
STDOUT.WriteLine('Parsers will not be regenerated');
75-
}
76-
PATH_PROG('zip');
77-
PATH_PROG('lemon');
78-
79-
// avoid picking up midnight commander from cygwin
80-
PATH_PROG('mc', WshShell.Environment("Process").Item("PATH"));
81-
82-
// Try locating manifest tool
83-
if (VCVERS > 1200) {
84-
PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"));
85-
}
23+
toolset_setup_linker();
24+
toolset_setup_project_tools();
8625

8726
// stick objects somewhere outside of the source tree
8827
ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', '');
@@ -121,10 +60,13 @@ DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \
12160
DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
12261

12362
// General CFLAGS for building objects
124-
DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \
63+
DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \
12564
/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
65+
if (VS_TOOLSET) {
66+
ADD_FLAG("CFLAGS", " /FD ");
67+
}
12668

127-
if (VCVERS < 1400) {
69+
if (VS_TOOLSET && VCVERS < 1400) {
12870
// Enable automatic precompiled headers
12971
ADD_FLAG('CFLAGS', ' /YX ');
13072

@@ -134,7 +76,7 @@ if (VCVERS < 1400) {
13476
}
13577
}
13678

137-
if (VCVERS >= 1400) {
79+
if (VS_TOOLSET && VCVERS >= 1400) {
13880
// fun stuff: MS deprecated ANSI stdio and similar functions
13981
// disable annoying warnings. In addition, time_t defaults
14082
// to 64-bit. Ask for 32-bit.
@@ -153,7 +95,7 @@ if (VCVERS >= 1400) {
15395
ARG_WITH('prefix', 'PHP installation prefix', '');
15496
ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto');
15597
var PHP_MP_DISABLED = true;
156-
if (VCVERS >= 1500 && PHP_MP != 'disable') {
98+
if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') {
15799
// no from disable-all
158100
if(PHP_MP == 'auto' || PHP_MP == 'no') {
159101
ADD_FLAG('CFLAGS', ' /MP ');
@@ -334,11 +276,12 @@ STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR'));
334276
STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB'));
335277

336278

337-
if (VCVERS == 1200) {
279+
/* XXX inspect this for other toolsets */
280+
if (VS_TOOLSET && VCVERS == 1200) {
338281
AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
339282
}
340283

341-
if (VCVERS >= 1400) {
284+
if (INTEL_TOOLSET || VS_TOOLSET && VCVERS >= 1400) {
342285
AC_DEFINE('HAVE_STRNLEN', 1);
343286
}
344287

0 commit comments

Comments
 (0)