]> granicus.if.org Git - python/commitdiff
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
authorAndrew M. Kuchling <amk@amk.ca>
Mon, 4 Nov 2002 19:53:24 +0000 (19:53 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Mon, 4 Nov 2002 19:53:24 +0000 (19:53 +0000)
customize_compiler() now looks at various environment variables and uses
   their values to override the configured C compiler/preprocessor/linker
   binary and flags.

Lib/distutils/sysconfig.py

index 48672d6a1014858d3efef9114ee607d56e721e13..e879fa149a8113febc294028692eb5940cf12410 100644 (file)
@@ -142,9 +142,25 @@ def customize_compiler(compiler):
         (cc, opt, ccshared, ldshared, so_ext) = \
             get_config_vars('CC', 'OPT', 'CCSHARED', 'LDSHARED', 'SO')
 
+        if os.environ.has_key('CC'):
+            cc = os.environ['CC']
+        if os.environ.has_key('CPP'):
+            cpp = os.environ['CPP']
+        else:
+            cpp = cc + " -E"           # not always
+        if os.environ.has_key('LDFLAGS'):
+            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
+        if os.environ.has_key('CFLAGS'):
+            opt = 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']
+            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
+
         cc_cmd = cc + ' ' + opt
         compiler.set_executables(
-            preprocessor=cc + " -E",    # not always!
+            preprocessor=cpp,
             compiler=cc_cmd,
             compiler_so=cc_cmd + ' ' + ccshared,
             linker_so=ldshared,