Skip to content

Commit 6462d4e

Browse files
committed
configure: fix comparing double-digit versions
1 parent 227ca87 commit 6462d4e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

configure

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,8 @@ def try_check_compiler(cc, lang):
612612

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

618618
return (True, is_clang, clang_version, gcc_version)
619619

@@ -691,6 +691,18 @@ def get_gas_version(cc):
691691
else:
692692
return '0'
693693

694+
# Compares (major, min, patch) version tuples
695+
def less_than(a, b):
696+
if a[0] < b[0]:
697+
return True
698+
elif a[0] == b[0] and a[1] < b[1]:
699+
return True
700+
elif a[0] == b[0] and a[1] == b[1] and a[2] < b[2]:
701+
return True
702+
else:
703+
return False
704+
705+
694706
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
695707
# the version check more by accident than anything else but a more rigorous
696708
# check involves checking the build number against a whitelist. I'm not
@@ -707,13 +719,13 @@ def check_compiler(o):
707719
ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
708720
if not ok:
709721
warn('failed to autodetect C++ compiler version (CXX=%s)' % CXX)
710-
elif clang_version < '3.4.2' if is_clang else gcc_version < '4.9.4':
722+
elif less_than(clang_version, (3, 4, 2)) if is_clang else less_than(gcc_version, (4, 9, 4)):
711723
warn('C++ compiler too old, need g++ 4.9.4 or clang++ 3.4.2 (CXX=%s)' % CXX)
712724

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

0 commit comments

Comments
 (0)