]> granicus.if.org Git - python/commitdiff
Make parse_makefile fallback to environment variables if nothing is
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 25 Apr 2005 07:14:03 +0000 (07:14 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 25 Apr 2005 07:14:03 +0000 (07:14 +0000)
defined in the makefile. Get CFLAGS from the Makefile, instead of
getting OPT, BASE_CFLAGS and EXTRA_CFLAGS individually.

Lib/distutils/sysconfig.py
Misc/NEWS
setup.py

index 1bd62097f04e95344c2f9168e49aed1902642a2b..0be5b6b7cba9044e3445a5292aaedd816d9f1194 100644 (file)
@@ -146,8 +146,8 @@ def customize_compiler(compiler):
     varies across Unices and is stored in Python's Makefile.
     """
     if compiler.compiler_type == "unix":
-        (cc, cxx, opt, extra_cflags, basecflags, ccshared, ldshared, so_ext) = \
-            get_config_vars('CC', 'CXX', 'OPT', 'EXTRA_CFLAGS', 'BASECFLAGS',
+        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \
+            get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 
                             'CCSHARED', 'LDSHARED', 'SO')
 
         if os.environ.has_key('CC'):
@@ -162,17 +162,15 @@ def customize_compiler(compiler):
             cpp = cc + " -E"           # not always
         if os.environ.has_key('LDFLAGS'):
             ldshared = ldshared + ' ' + os.environ['LDFLAGS']
-        if basecflags:
-            opt = basecflags + ' ' + opt
         if os.environ.has_key('CFLAGS'):
-            opt = opt + ' ' + os.environ['CFLAGS']
+            cflags = opt + ' ' + os.environ['CFLAGS']
             ldshared = ldshared + ' ' + os.environ['CFLAGS']
         if os.environ.has_key('CPPFLAGS'):
             cpp = cpp + ' ' + os.environ['CPPFLAGS']
-            opt = opt + ' ' + os.environ['CPPFLAGS']
+            cflags = cflags + ' ' + os.environ['CPPFLAGS']
             ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
 
-        cc_cmd = ' '.join(str(x) for x in (cc, opt, extra_cflags) if x)
+        cc_cmd = cc + ' ' + cflags
         compiler.set_executables(
             preprocessor=cpp,
             compiler=cc_cmd,
@@ -278,25 +276,20 @@ def parse_makefile(fn, g=None):
             m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
             if m:
                 n = m.group(1)
+                found = True
                 if done.has_key(n):
-                    after = value[m.end():]
-                    value = value[:m.start()] + str(done[n]) + after
-                    if "$" in after:
-                        notdone[name] = value
-                    else:
-                        try: value = int(value)
-                        except ValueError:
-                            done[name] = string.strip(value)
-                        else:
-                            done[name] = value
-                        del notdone[name]
+                    item = str(done[n])
                 elif notdone.has_key(n):
                     # get it on a subsequent round
-                    pass
+                    found = False
+                elif os.environ.has_key(n):
+                    # do it like make: fall back to environment
+                    item = os.environ[n]
                 else:
-                    done[n] = ""
+                    done[n] = item = ""
+                if found:
                     after = value[m.end():]
-                    value = value[:m.start()] + after
+                    value = value[:m.start()] + item + after
                     if "$" in after:
                         notdone[name] = value
                     else:
index 1557a46ce1b57a9fd6595b836bf29af2a62e62d7..3c6b6c14841f7d77d1c3dcca9b84c8fd1f72cd86 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -279,7 +279,7 @@ Build
 - EXTRA_CFLAGS has been introduced as an environment variable to hold compiler
   flags that change binary compatibility.  Changes were also made to
   distutils.sysconfig to also use the environment variable when used during
-  compilation of the interpreter.
+  compilation of the interpreter and of C extensions through distutils.
 
 - SF patch 1171735: Darwin 8's headers are anal about POSIX compliance,
   and linking has changed (prebinding is now deprecated, and libcc_dynamic
index 302f5c23fbc6ac4ce32e651c191d5f8190507d49..a8e58042fb74ea584aafbd0c157bc0a63703f0ab 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -171,8 +171,8 @@ class PyBuildExt(build_ext):
         # unfortunately, distutils doesn't let us provide separate C and C++
         # compilers
         if compiler is not None:
-            (ccshared,opt,base) = sysconfig.get_config_vars('CCSHARED','OPT','BASECFLAGS')
-            args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared + ' ' + base
+            (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
+            args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
         self.compiler.set_executables(**args)
 
         build_ext.build_extensions(self)