[PyQt] Extending configure.py/siputils.py to pass CPPFLAGS

Scott Kitterman debian at kitterman.com
Fri Jun 22 23:45:27 BST 2012


In order to support Debian's goal to have a common set of default build flags 
for the distribution (with a particular focus on hardening related changes), I 
need to pass CPPFLAGS through configure.

I came up with the attached patch for sip4 0.13.3.  I'd appreciate a review.  
It works.  I won't say much for it beyond that as I'm not sure I've fully 
grokked what's going on in siputils.py.  If this seams reasonable, I intend to 
attack PyQt4 and QScintilla2 also.

Scott K

-------------- next part --------------
Description: Extend configure.py and siputils.py to support external
definition of CPPFLAGS
Author: Scott Kitterman <scott at kitterman.com>
Origin: vendor
Forwarded: no
Reviewed-By: Scott Kitterman <scott at kitterman.com>
Last-Update: <2012-06-22>

--- sip4-4.13.3.orig/configure.py
+++ sip4-4.13.3/configure.py
@@ -63,6 +63,7 @@ build_macro_names = [
     "CFLAGS_STL_ON", "CFLAGS_STL_OFF",
     "CFLAGS_WARN_ON", "CFLAGS_WARN_OFF",
     "CHK_DIR_EXISTS", "COPY",
+    "CPPFLAGS", "CPPFLAGS_SHLIB", "CPPFLAGS_RELEASE",
     "CXX",
     "CXXFLAGS",
     "CXXFLAGS_RELEASE", "CXXFLAGS_DEBUG",
--- sip4-4.13.3.orig/siputils.py
+++ sip4-4.13.3/siputils.py
@@ -313,6 +313,7 @@ class Makefile:
 
         # These are what configuration scripts normally only need to change.
         self.extra_cflags = []
+        self.extra_cppflags = []
         self.extra_cxxflags = []
         self.extra_defines = []
         self.extra_include_dirs = []
@@ -369,6 +370,10 @@ class Makefile:
         cflags.extend(self.extra_cflags)
         cflags.extend(self.optional_list("CFLAGS"))
 
+        cppflags = _UniqueList()
+        cppflags.extend(self.extra_cppflags)
+        cppflags.extend(self.optional_list("CPPFLAGS"))
+
         cxxflags = _UniqueList()
         cxxflags.extend(self.extra_cxxflags)
         cxxflags.extend(self.optional_list("CXXFLAGS"))
@@ -767,6 +772,7 @@ class Makefile:
 
         # Save the transformed values.
         self.CFLAGS.set(cflags)
+        self.CPPFLAGS.set(cppflags)
         self.CXXFLAGS.set(cxxflags)
         self.DEFINES.set(defines)
         self.INCDIR.set(incdir)
@@ -1098,7 +1104,7 @@ class Makefile:
         mfile.write("CXX = %s\n" % self.required_string("CXX"))
         mfile.write("LINK = %s\n" % self.required_string("LINK"))
 
-        cppflags = []
+        cppflags = [self.optional_string("CPPFLAGS"),]
 
         if not self._debug:
             cppflags.append("-DNDEBUG")
@@ -1461,6 +1467,7 @@ class ModuleMakefile(Makefile):
             self.DEFINES.append("SIP_STATIC_MODULE")
         else:
             self.CFLAGS.extend(self.optional_list("CFLAGS_SHLIB"))
+            self.CPPFLAGS.extend(self.optional_list("CPPFLAGS_SHLIB"))
             self.CXXFLAGS.extend(self.optional_list("CXXFLAGS_SHLIB"))
 
             lflags_dll = self.optional_list("LFLAGS_DLL")
@@ -1807,6 +1814,7 @@ class ProgramMakefile(Makefile):
             build.append("-I" + _quote(f))
 
         build.extend(self.optional_list("CXXFLAGS"))
+        build.extend(self.optional_list("CPPFLAGS"))
 
         # Borland requires all flags to precede all file names.
         if self.generator != "BMAKE":


More information about the PyQt mailing list