Add configure check for timerfd.h path
g0dil [Thu, 30 Sep 2010 14:07:49 +0000 (14:07 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1723 270642c3-0616-0410-b53a-bc976706d245

SConfigure
senf/Scheduler/TimerSource.cc
site_scons/site_tools/CustomTests.py

index 249f9b7..ebf2ae6 100644 (file)
@@ -84,6 +84,7 @@ res = conf.CheckCXXHeader("boost/bimap.hpp"); \
 res = conf.CheckTempBufferStrategy()
 
 # Standard library stuff
+res = conf.FindCHeader("timerfd.h", [ 'sys', 'linux' ])
 res = conf.CheckFunc("timerfd_create")
 res = conf.CheckSymbolWithExpression(
     "le16toh", "le16toh(0)", "#include <senf/Packets/80211Bundle/radiotap/platform.h>")
index dea043b..0c3214a 100644 (file)
@@ -29,7 +29,7 @@
 // Custom includes
 #include "IdleEvent.hh"
 #ifdef HAVE_TIMERFD_CREATE
-#include <sys/timerfd.h>
+#include TIMERFD_H_PATH
 #endif
 #include "senf/Utils/IgnoreValue.hh"
 
index e482f80..6128ea6 100644 (file)
@@ -1,5 +1,5 @@
 import SCons.Environment, SCons.Util, SCons.Script, SCons.Conftest
-import re
+import re, os.path
 
 # Fix for SCons 0.97 compatibility
 import SCons.SConf
@@ -140,14 +140,17 @@ def CheckSymbolWithExpression(context, symbol, expression, header="", language="
 @DefaultTest
 def CheckByteorder(context):
     context.Message("Checking byteorder... ")
-    ret = context.TryRun('#include <stdio.h>\n'
-                         'union byteorder_test { int i; char b; };\n'
-                         'int main() {\n'
-                         '    union byteorder_test t; t.i=1;\n'
-                         '    printf(t.b ? "little\\n" : "big\\n");\n'
-                         '    return 0;\n'
-                         '}\n',
-                         ".c")[-1].strip()
+    if context.env.has_key("BYTEORDER"):
+        ret = context.env["BYTEORDER"]
+    else:
+        ret = context.TryRun('#include <stdio.h>\n'
+                             'union byteorder_test { int i; char b; };\n'
+                             'int main() {\n'
+                             '    union byteorder_test t; t.i=1;\n'
+                             '    printf(t.b ? "little\\n" : "big\\n");\n'
+                             '    return 0;\n'
+                             '}\n',
+                             ".c")[-1].strip()
     if not ret:
         context.Result("failed")
         return False
@@ -157,6 +160,23 @@ def CheckByteorder(context):
                              "Define BYTEORDER_LITTLE_ENDIAN or BYTEORDER_BIG_ENDIAN")
         return ret
 
+@DefaultTest
+def FindCHeader(context, name, dirs):
+    defn = name.upper()
+    defn = re.sub('[^A-Z0-9_]', '_', defn)
+    defn += "_PATH"
+
+    context.Message("Checking for %s... " % name)
+    for dir in dirs:
+        path = os.path.join(dir, name);
+        ret = context.TryCompile("#include <%s>" % path, ".c");
+        if ret:
+            context.Result(path)
+            context.sconf.Define(defn, "<%s>" % path,
+                                 "Define %s as <path/to/%s>" % (defn, name))
+            return ret
+    return False
+
 def generate(env):
     env.Append( CUSTOM_TESTS = DefaultTest.tests )
     env._CustomTests_orig_Configure = env.Configure