# DP: Allow setting BASECFLAGS, OPT and EXTRA_LDFLAGS (like, CC, CXX, CPP,
# DP: CFLAGS, CPPFLAGS, CCSHARED, LDSHARED) from the environment.

Index: python2.6-2.6.5+20100521/Lib/distutils/sysconfig.py
===================================================================
--- python2.6-2.6.5+20100521.orig/Lib/distutils/sysconfig.py	2010-05-21 15:44:39.599722521 +0200
+++ python2.6-2.6.5+20100521/Lib/distutils/sysconfig.py	2010-05-21 15:44:39.607707825 +0200
@@ -169,8 +169,9 @@
     varies across Unices and is stored in Python's Makefile.
     """
     if compiler.compiler_type == "unix":
-        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \
+        (cc, cxx, opt, cflags, opt, extra_cflags, basecflags, ccshared, ldshared, so_ext) = \
             get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+                            'OPT', 'EXTRA_CFLAGS', 'BASECFLAGS',
                             'CCSHARED', 'LDSHARED', 'SO')
 
         if 'CC' in os.environ:
@@ -185,8 +186,13 @@
             cpp = cc + " -E"           # not always
         if 'LDFLAGS' in os.environ:
             ldshared = ldshared + ' ' + os.environ['LDFLAGS']
+        if 'BASECFLAGS' in os.environ:
+            basecflags = os.environ['BASECFLAGS']
+        if 'OPT' in os.environ:
+            opt = os.environ['OPT']
+        cflags = ' '.join(str(x) for x in (basecflags, opt, extra_cflags) if x)
         if 'CFLAGS' in os.environ:
-            cflags = opt + ' ' + os.environ['CFLAGS']
+            cflags = ' '.join(str(x) for x in (basecflags, opt, os.environ['CFLAGS'], extra_cflags) if x)
             ldshared = ldshared + ' ' + os.environ['CFLAGS']
         if 'CPPFLAGS' in os.environ:
             cpp = cpp + ' ' + os.environ['CPPFLAGS']
