Dynamically check for the existence of utilities. (sam th)
[scons.git] / src / engine / SCons / Tool / g++.py
index f631b0b064b5d92b8fd5b3e670159f4889a02796..3c6dd3656518d5e972ae2ce1fc203bde079a69aa 100644 (file)
@@ -37,6 +37,15 @@ import os.path
 
 import SCons.Defaults
 import SCons.Tool
+import SCons.Util
+
+compilers = ['c++', 'g++']
+
+for i in compilers:
+    if SCons.Util.WhereIs(i):
+        cxx = i
+        break
+    cxx = None
 
 CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++']
 if os.path.normcase('.c') != os.path.normcase('.C'):
@@ -50,7 +59,7 @@ def generate(env, platform):
         static_obj.add_action(suffix, SCons.Defaults.CXXAction)
         shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction)
 
-    env['CXX']        = 'c++'
+    env['CXX']        = cxx
     env['CXXFLAGS']   = '$CCFLAGS'
     env['CXXCOM']     = '$CXX $CXXFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
     env['SHCXX']      = '$CXX'
@@ -60,3 +69,6 @@ def generate(env, platform):
     env['INCSUFFIX']  = ''
 
     env['CXXFILESUFFIX'] = '.cc'
+
+def exists():
+    return cxx