]> granicus.if.org Git - php/commitdiff
Implement FR #77230: Support custom CFLAGS and LDFLAGS from environment
authorChristoph M. Becker <cmbecker69@gmx.de>
Tue, 2 Jul 2019 17:08:19 +0000 (19:08 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 8 Jul 2019 08:46:51 +0000 (10:46 +0200)
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.

NEWS
UPGRADING
win32/build/confutils.js

diff --git a/NEWS b/NEWS
index 4adf431aabb9d27ed839d1b25829e3a8541eb21f..2cdac0aa99d2ab2be5ab9c1affb2d9a18b262068 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #78239 (Deprecation notice during string conversion converted to
     exception hangs). (Nikita)
+  . Implemented FR #77230 (Support custom CFLAGS and LDFLAGS from environment).
+    (cmb)
 
 - Date:
   . Updated timelib to 2018.02. (Derick)
index 900c0694ec31ebb7cf16690986d5df59175ac3c3..07136fdcf654fbbd07eca1e22784239e41d7e265 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -568,6 +568,9 @@ r SQLite3:
 - CTRL+C and CTRL+BREAK on console can be caught by setting a handler function
   with sapi_windows_set_ctrl_handler().
 
+- configure now regards additional CFLAGS and LDFLAGS set as environment
+  variables.
+
 ========================================
 13. Migration to pkg-config
 ========================================
index 4248795dac5cbeddecf42b2444cbab81a50a10f9..83d5907a4f0239224bba01fc9723789f071cf7df 100644 (file)
@@ -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");