Commit a9aaf538 authored by Martin v. Löwis's avatar Martin v. Löwis

Make parse_makefile fallback to environment variables if nothing is

defined in the makefile. Get CFLAGS from the Makefile, instead of
getting OPT, BASE_CFLAGS and EXTRA_CFLAGS individually.
parent 1133a2e0
...@@ -146,8 +146,8 @@ def customize_compiler(compiler): ...@@ -146,8 +146,8 @@ def customize_compiler(compiler):
varies across Unices and is stored in Python's Makefile. varies across Unices and is stored in Python's Makefile.
""" """
if compiler.compiler_type == "unix": if compiler.compiler_type == "unix":
(cc, cxx, opt, extra_cflags, basecflags, ccshared, ldshared, so_ext) = \ (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \
get_config_vars('CC', 'CXX', 'OPT', 'EXTRA_CFLAGS', 'BASECFLAGS', get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SO') 'CCSHARED', 'LDSHARED', 'SO')
if os.environ.has_key('CC'): if os.environ.has_key('CC'):
...@@ -162,17 +162,15 @@ def customize_compiler(compiler): ...@@ -162,17 +162,15 @@ def customize_compiler(compiler):
cpp = cc + " -E" # not always cpp = cc + " -E" # not always
if os.environ.has_key('LDFLAGS'): if os.environ.has_key('LDFLAGS'):
ldshared = ldshared + ' ' + os.environ['LDFLAGS'] ldshared = ldshared + ' ' + os.environ['LDFLAGS']
if basecflags:
opt = basecflags + ' ' + opt
if os.environ.has_key('CFLAGS'): if os.environ.has_key('CFLAGS'):
opt = opt + ' ' + os.environ['CFLAGS'] cflags = opt + ' ' + os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS']
if os.environ.has_key('CPPFLAGS'): if os.environ.has_key('CPPFLAGS'):
cpp = cpp + ' ' + os.environ['CPPFLAGS'] cpp = cpp + ' ' + os.environ['CPPFLAGS']
opt = opt + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS']
ldshared = ldshared + ' ' + 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( compiler.set_executables(
preprocessor=cpp, preprocessor=cpp,
compiler=cc_cmd, compiler=cc_cmd,
...@@ -278,25 +276,20 @@ def parse_makefile(fn, g=None): ...@@ -278,25 +276,20 @@ def parse_makefile(fn, g=None):
m = _findvar1_rx.search(value) or _findvar2_rx.search(value) m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
if m: if m:
n = m.group(1) n = m.group(1)
found = True
if done.has_key(n): if done.has_key(n):
after = value[m.end():] item = str(done[n])
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]
elif notdone.has_key(n): elif notdone.has_key(n):
# get it on a subsequent round # 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: else:
done[n] = "" done[n] = item = ""
if found:
after = value[m.end():] after = value[m.end():]
value = value[:m.start()] + after value = value[:m.start()] + item + after
if "$" in after: if "$" in after:
notdone[name] = value notdone[name] = value
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment