Skip to content

Commit

Permalink
configure: fix comparing double-digit versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mistydemeo committed Jun 6, 2018
1 parent 227ca87 commit 6462d4e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,8 @@ def try_check_compiler(cc, lang):

values = (proc.communicate()[0].split() + ['0'] * 7)[0:7]
is_clang = values[0] == '1'
gcc_version = '%s.%s.%s' % tuple(values[1:1+3])
clang_version = '%s.%s.%s' % tuple(values[4:4+3])
gcc_version = tuple(values[1:1+3])
clang_version = tuple(values[4:4+3])

return (True, is_clang, clang_version, gcc_version)

Expand Down Expand Up @@ -691,6 +691,18 @@ def get_gas_version(cc):
else:
return '0'

# Compares (major, min, patch) version tuples
def less_than(a, b):
if a[0] < b[0]:
return True
elif a[0] == b[0] and a[1] < b[1]:
return True
elif a[0] == b[0] and a[1] == b[1] and a[2] < b[2]:
return True
else:
return False


# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
# the version check more by accident than anything else but a more rigorous
# check involves checking the build number against a whitelist. I'm not
Expand All @@ -707,13 +719,13 @@ def check_compiler(o):
ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
if not ok:
warn('failed to autodetect C++ compiler version (CXX=%s)' % CXX)
elif clang_version < '3.4.2' if is_clang else gcc_version < '4.9.4':
elif less_than(clang_version, (3, 4, 2)) if is_clang else less_than(gcc_version, (4, 9, 4)):
warn('C++ compiler too old, need g++ 4.9.4 or clang++ 3.4.2 (CXX=%s)' % CXX)

ok, is_clang, clang_version, gcc_version = try_check_compiler(CC, 'c')
if not ok:
warn('failed to autodetect C compiler version (CC=%s)' % CC)
elif not is_clang and gcc_version < '4.2.0':
elif not is_clang and less_than(gcc_version, (4, 2, 0)):
# clang 3.2 is a little white lie because any clang version will probably
# do for the C bits. However, we might as well encourage people to upgrade
# to a version that is not completely ancient.
Expand Down

0 comments on commit 6462d4e

Please sign in to comment.