Fixes for determining "GCC" version when compiler is clang. https://sourceforge.net/p/ggt/bugs/28/ --- SConstruct.orig 2009-11-21 15:31:52.000000000 -0600 +++ SConstruct 2023-03-08 18:28:02.000000000 -0600 @@ -3,6 +3,7 @@ EnsureSConsVersion(0,96) SConsignFile() +from subprocess import Popen, PIPE import os, string, sys import re import distutils.sysconfig @@ -129,26 +126,28 @@ framework_opt = '-F' + m.group(1) CXX = os.environ.get("CXX", WhereIs('g++')) - - ver_re = re.compile(r'gcc version ((\d+)\.(\d+)\.(\d+))') - (gv_stdout, gv_stdin, gv_stderr) = os.popen3(CXX + ' -v') - ver_str = gv_stderr.read() - - match_obj = ver_re.search(ver_str) - LINK = CXX CXXFLAGS = ['-ftemplate-depth-256', '-DBOOST_PYTHON_DYNAMIC_LIB', '-Wall', framework_opt, '-pipe'] - compiler_ver = match_obj.group(1) - compiler_major_ver = int(match_obj.group(2)) - compiler_minor_ver = int(match_obj.group(3)) + p = Popen([CXX, '-dM', '-E', '-x', 'c++', '-'], stdout=PIPE) + preprocessor_macros = p.stdout.read().decode('utf-8') + + ver_re = re.compile(r'#define __GNUC__ (\d+)') + match_obj = ver_re.search(preprocessor_macros) + compiler_major_ver = int(match_obj.group(1)) + + ver_re = re.compile(r'#define __GNUC_MINOR__ (\d+)') + match_obj = ver_re.search(preprocessor_macros) + compiler_minor_ver = int(match_obj.group(1)) + + compiler_ver = f'{compiler_major_ver}.{compiler_minor_ver}' # GCC 4.0 in Mac OS X 10.4 and newer does not have -fcoalesce-templates. if compiler_major_ver < 4: CXXFLAGS.append('-fcoalesce-templates') else: - if compiler_minor_ver < 2: + if compiler_major_ver == 4 and compiler_minor_ver < 2: CXXFLAGS += ['-Wno-long-double', '-no-cpp-precomp'] SHLIBSUFFIX = distutils.sysconfig.get_config_var('SO')