Enhance senfutil client-project handling
[senf.git] / site_scons / senfconf.py
index c6fc6c8..89ef0c2 100644 (file)
@@ -2,6 +2,26 @@
 
 _configTests = {}
 
+# Fix for SCons 0.97 compatibility
+import SCons.SConf
+try: SCons.SConf.SConfBase.Define
+except AttributeError:
+    import string
+    def Define(self, name, value = None, comment = None):
+        lines = []
+        if comment:
+            comment_str = "/* %s */" % comment
+            lines.append(comment_str)
+        if value is not None:
+            define_str = "#define %s %s" % (name, value)
+        else:
+            define_str = "#define %s" % name
+        lines.append(define_str)
+        lines.append('')
+        self.config_h_text = self.config_h_text + string.join(lines, '\n')
+    SCons.SConf.SConfBase.Define = Define
+
+
 def Tests():
     global _configTests
     return _configTests
@@ -9,6 +29,7 @@ def Tests():
 def Test(func):
     global _configTests
     _configTests[func.__name__] = func
+    return func
 
 # class TemporaryContext:
 #     def __init__(self, context):
@@ -28,12 +49,14 @@ def CheckBoostVersion(context):
     ret = context.TryRun("#include <boost/version.hpp>\n"
                          "#include <iostream>\n"
                          "int main(int, char **) { std::cout << BOOST_LIB_VERSION << std::endl; }",
-                         ".cc")[1].strip()
+                         ".cc")[-1].strip()
     if not ret:
         context.Result("no boost includes found")
+        context.env.Replace( BOOST_VERSION = '' )
         return None
     else:
         context.Result(ret)
+        context.env.Replace( BOOST_VERSION = ret )
         return ret
 
 @Test
@@ -61,4 +84,5 @@ def CheckBoostVariants(context, *variants):
     if useVariant is not None and not context.env.GetOption('no_progress'):
         print  "Using %s boost variant." % (
             useVariant and "'%s'" % useVariant or "default")
+    context.env.Replace( BOOST_VARIANT = useVariant )
     return useVariant