catch up the toolset changes with phpize

also packed common parts into functions so there's less code duplication
This commit is contained in:
Anatol Belski 2014-11-07 11:48:03 +01:00
parent 46d6baf6a0
commit 4d8c28af60
3 changed files with 147 additions and 188 deletions

View File

@ -4,69 +4,11 @@
// equivalent.
ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs");
if ("clang" == PHP_TOOLSET) {
VS_TOOLSET = false;
CLANG_TOOLSET = true;
INTEL_TOOLSET = false;
} else if ("intel" == PHP_TOOLSET) {
VS_TOOLSET = false;
CLANG_TOOLSET = false;
INTEL_TOOLSET = true;
} else {
/* Visual Studio is the default toolset. */
PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET;
if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) {
ERROR("Unsupported toolset name '" + PHP_TOOLSET + "'");
}
VS_TOOLSET = true;
CLANG_TOOLSET = false;
INTEL_TOOLSET = false;
}
toolset_option_handle();
ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin');
PHP_CL = toolset_get_compiler();
if (!PHP_CL) {
ERROR("MS C++ compiler is required");
}
COMPILER_NUMERIC_VERSION = toolset_get_compiler_version();
COMPILER_NAME = toolset_get_compiler_name();
if (VS_TOOLSET) {
/* 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 = COMPILER_NUMERIC_VERSION;
if (VCVERS < 1500) {
ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required");
}
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
} else if (CLANG_TOOLSET) {
CLANGVERS = COMPILER_NUMERIC_VERSION;
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", "clang");
AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */
} else if (INTEL_TOOLSET) {
INTELVERS = COMPILER_NUMERIC_VERSION;
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", "icc");
AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */
}
STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME);
toolset_setup_compiler();
// do we use x64 or 80x86 version of compiler?
X64 = toolset_is_64();
@ -78,53 +20,8 @@ if (X64) {
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
toolset_get_linker();
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 (VS_TOOLSET && VCVERS > 1200) {
PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"));
}
toolset_setup_linker();
toolset_setup_project_tools();
// stick objects somewhere outside of the source tree
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)');
// General CFLAGS for building objects
DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \
/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
if (VS_TOOLSET) {
ADD_FLAG("CFLAGS", " /FD ");
}
if (CLANG_TOOLSET) {
if (X64) {
ADD_FLAG('CFLAGS', ' -m64 ');
@ -420,6 +321,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \
zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \
zend_inheritance.c");
/* XXX inspect this for other toolsets */
if (VS_TOOLSET && VCVERS == 1200) {
AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
}

View File

@ -3,32 +3,15 @@
// "Master" config file; think of it as a configure.in
// equivalent.
ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, intel", "vs");
toolset_option_handle()
var PHP_CYGWIN="notset";
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");
toolset_setup_compiler();
// do we use x64 or 80x86 version of compiler?
X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL');
X64 = toolset_is_64();
if (X64) {
STDOUT.WriteLine(" Detected 64-bit compiler");
} else {
@ -37,52 +20,8 @@ if (X64) {
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"));
}
toolset_setup_linker();
toolset_setup_project_tools();
// stick objects somewhere outside of the source tree
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 \
DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
// General CFLAGS for building objects
DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \
DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \
/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
if (VS_TOOLSET) {
ADD_FLAG("CFLAGS", " /FD ");
}
if (VCVERS < 1400) {
if (VS_TOOLSET && VCVERS < 1400) {
// Enable automatic precompiled headers
ADD_FLAG('CFLAGS', ' /YX ');
@ -134,7 +76,7 @@ if (VCVERS < 1400) {
}
}
if (VCVERS >= 1400) {
if (VS_TOOLSET && 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.
@ -153,7 +95,7 @@ if (VCVERS >= 1400) {
ARG_WITH('prefix', 'PHP installation prefix', '');
ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto');
var PHP_MP_DISABLED = true;
if (VCVERS >= 1500 && PHP_MP != 'disable') {
if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') {
// no from disable-all
if(PHP_MP == 'auto' || PHP_MP == 'no') {
ADD_FLAG('CFLAGS', ' /MP ');
@ -334,11 +276,12 @@ STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR'));
STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB'));
if (VCVERS == 1200) {
/* XXX inspect this for other toolsets */
if (VS_TOOLSET && VCVERS == 1200) {
AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
}
if (VCVERS >= 1400) {
if (INTEL_TOOLSET || VS_TOOLSET && VCVERS >= 1400) {
AC_DEFINE('HAVE_STRNLEN', 1);
}

View File

@ -39,6 +39,9 @@ var INTELVERS = -1;
var COMPILER_NUMERIC_VERSION = -1;
var COMPILER_NAME = "unknown";
// There's a minimum requirement for re2c..
var MINRE2C = "0.13.4";
/* Store the enabled extensions (summary + QA check) */
var extensions_enabled = new Array();
@ -2292,6 +2295,118 @@ if (!MODE_PHPIZE) {
ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no');
}
function toolset_option_handle()
{
if ("clang" == PHP_TOOLSET) {
VS_TOOLSET = false;
CLANG_TOOLSET = true;
INTEL_TOOLSET = false;
} else if ("intel" == PHP_TOOLSET) {
VS_TOOLSET = false;
CLANG_TOOLSET = false;
INTEL_TOOLSET = true;
} else {
/* Visual Studio is the default toolset. */
PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET;
if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) {
ERROR("Unsupported toolset name '" + PHP_TOOLSET + "'");
}
VS_TOOLSET = true;
CLANG_TOOLSET = false;
INTEL_TOOLSET = false;
}
}
function toolset_setup_compiler()
{
PHP_CL = toolset_get_compiler();
if (!PHP_CL) {
ERROR("Compiler not found");
}
COMPILER_NUMERIC_VERSION = toolset_get_compiler_version();
COMPILER_NAME = toolset_get_compiler_name();
if (VS_TOOLSET) {
/* 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 = COMPILER_NUMERIC_VERSION;
if (VCVERS < 1500) {
ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required");
}
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
} else if (CLANG_TOOLSET) {
CLANGVERS = COMPILER_NUMERIC_VERSION;
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", "clang");
AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */
} else if (INTEL_TOOLSET) {
INTELVERS = COMPILER_NUMERIC_VERSION;
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
DEFINE("PHP_COMPILER_SHORT", "icc");
AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */
}
STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME);
}
function toolset_setup_project_tools()
{
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')
}
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 (VS_TOOLSET && VCVERS > 1200) {
PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"));
}
}
function toolset_get_compiler()
{
if (VS_TOOLSET) {
@ -2302,7 +2417,7 @@ function toolset_get_compiler()
return PATH_PROG('icl', null, 'PHP_CL')
}
ERROR("Wrong toolset");
ERROR("Unsupported toolset");
}
function toolset_get_compiler_version()
@ -2337,7 +2452,7 @@ function toolset_get_compiler_version()
}
}
ERROR("Failed to parse compiler out for compiler version");
ERROR("Failed to parse compiler version or unsupported toolset");
}
function toolset_get_compiler_name()
@ -2354,7 +2469,7 @@ function toolset_get_compiler_name()
return full.split(/\n/)[0].replace(/\s/g, ' ');
}
ERROR("Wrong toolset");
WARNING("Unsupported toolset");
}
@ -2374,11 +2489,11 @@ function toolset_is_64()
return null != full.match(/Intel\(R\) 64/);
}
ERROR("Wrong toolset");
ERROR("Unsupported toolset");
}
function toolset_get_linker()
function toolset_setup_linker()
{
if (VS_TOOLSET) {
return PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
@ -2389,7 +2504,6 @@ function toolset_get_linker()
return PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK");
}
ERROR("Wrong toolset");
ERROR("Unsupported toolset");
}