diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-07-02 19:08:19 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-07-08 10:46:51 +0200 |
commit | 338e1b245d8c234ffbd5407bf3f6c05a9e1b3cb3 (patch) | |
tree | 46e124eeaef515fb8a84757857d0e9f88af4fc0f /win32 | |
parent | 98b6330ab45732dcb16bb714d66ca1d987531406 (diff) | |
download | php-git-338e1b245d8c234ffbd5407bf3f6c05a9e1b3cb3.tar.gz |
Implement FR #77230: Support custom CFLAGS and LDFLAGS from environment
While it is already possible to *set* CFLAGS and LDFLAGS (actually all
variables) from the environment for `nmake` (by passing the `/E`
option), it is not possible to *add* any (C|LD)FLAGS, which can be
useful in some cases. Instead of allowing this for `nmake`, we add
support for additional custom (C|LD)FLAGS to `configure`, similar to
how that works on Linux, so one could actually write:
````
set CFLAGS=foo & set LDFLAGS=bar & configure
````
This also allows us to use these flags during configure.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/build/confutils.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 4248795dac..83d5907a4f 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -431,6 +431,10 @@ can be built that way. \ } STDOUT.WriteLine(" " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext)); } + STDOUT.WriteBlankLines(1); + STDOUT.WriteLine("Some influential environment variables:"); + STDOUT.WriteLine(" CFLAGS C compiler flags"); + STDOUT.WriteLine(" LDFLAGS linker flags"); WScript.Quit(1); } @@ -3207,6 +3211,8 @@ function toolset_setup_linker() function toolset_setup_common_cflags() { + var envCFLAGS = WshShell.Environment("PROCESS").Item("CFLAGS"); + // CFLAGS for building the PHP dll DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ /D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER); @@ -3218,6 +3224,10 @@ function toolset_setup_common_cflags() /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 \ /D _USE_MATH_DEFINES"); + if (envCFLAGS) { + ADD_FLAG("CFLAGS", envCFLAGS); + } + if (VS_TOOLSET) { ADD_FLAG("CFLAGS", " /FD "); @@ -3368,6 +3378,8 @@ function toolset_setup_intrinsic_cflags() function toolset_setup_common_ldlags() { + var envLDFLAGS = WshShell.Environment("PROCESS").Item("LDFLAGS"); + // General DLL link flags DEFINE("DLL_LDFLAGS", "/dll "); @@ -3376,6 +3388,10 @@ function toolset_setup_common_ldlags() DEFINE("LDFLAGS", "/nologo "); + if (envLDFLAGS) { + ADD_FLAG("LDFLAGS", envLDFLAGS); + } + // we want msvcrt in the PHP DLL ADD_FLAG("PHP_LDFLAGS", "/nodefaultlib:libcmt"); |