7 ###########################################################################
8 # Custom configuration checks
11 def CheckSTLCopyN(context):
12 context.Message("Checking for 'copy_n' implementation... ")
13 versions = [ ('<algorithm>', 'std::copy_n', 'STD'),
14 ('<ext/algorithm>', '__gnu_cxx::copy_n', 'GNUCXX') ]
15 for include, name, define in versions:
16 ret = context.TryCompile("#include %s\n"
17 "int main(int,char**) { int *a,*b; %s(a,0,b); }\n"
22 context.sconf.Define("HAVE_%s_COPYN" % define,
25 + ", ".join(("HAVE_%s_COPYN" % elt[2] for elt in versions)))
33 def CheckTempBufferStrategy(context):
34 context.Message("Checking for optimal temporary buffer strategy... ")
38 ret = context.TryCompile("void test(int n){int a[n];}",".cc")
39 if ret: return "locals"
42 ret = context.TryCompile("#include <alloca.h>\n"
43 "void test(int a){void *b(alloca(a));}",
45 if ret: return "alloca"
52 context.sconf.Define("SENF_BUFFER_USE_%s" % ret.upper(),
54 "Define one of SENF_BUFFER_USE_LOCALS, SENF_BUFFER_USE_ALLOCA, "
55 "SENF_BUFFER_USE_NEW")
59 def CheckValgrind(context):
60 context.Message( "Checking for valgrind... " )
61 ret = context.TryAction(['$VALGRIND --version >$TARGET'])
62 context.Result( ret[1].strip() or False )
66 def CheckValgrindWildcards(context):
67 context.Message( "Checking whether valgrind supports '...' wildcards in suppressions... " )
68 ret = context.TryAction(['$VALGRIND --suppressions=$SOURCE /bin/true'],
69 "{\n test_suppression\n Memcheck:Addr4\n ...\n fun:foo\n}\n",
71 context.Result( ret[0] )
74 ###########################################################################
76 conf = env.Configure(clean=False, help=False, config_h="#/senf/autoconf.hh")
79 res = conf.CheckBoostVersion(fail=True)
80 res = conf.CheckBoostVariants()
81 res = conf.CheckCXXHeader("boost/spirit/include/classic.hpp")
82 res = conf.CheckCXXHeader("boost/bimap.hpp"); \
83 conf.env.Replace(NEED_BOOST_EXT = not res)
86 res = conf.CheckTempBufferStrategy()
88 # Standard library stuff
89 res = conf.CheckCHeader("execinfo.h")
90 res = conf.FindCHeader("timerfd.h", [ 'sys', 'linux' ])
91 res = conf.CheckFunc("timerfd_create")
92 res = conf.CheckSymbolWithExpression(
93 "le16toh", "le16toh(0)", "#include <senf/Packets/80211Bundle/radiotap/platform.h>")
94 res = conf.CheckSymbolWithExpression(
95 "le32toh", "le32toh(0)", "#include <senf/Packets/80211Bundle/radiotap/platform.h>")
96 res = conf.CheckByteorder()
97 res = conf.CheckSTLCopyN(); \
98 conf.env.Fail(condition=not res, message="No 'copy_n' implementation found")
101 res = conf.CheckValgrind() and conf.CheckValgrindWildcards(); \
102 conf.env.Replace(HAVE_VALGRIND = res)
104 ###########################################################################
106 # run configure scripts from external modules
109 sconscripts = sorted(glob.glob("senf/Ext/*/SConfigure"))
111 SConscript(sconscripts)
113 ###########################################################################