5 ###########################################################################
6 # Custom configuration checks
9 def CheckSTLCopyN(context):
10 context.Message("Checking for 'copy_n' implementation... ")
11 versions = [ ('<algorithm>', 'std::copy_n', 'STD'),
12 ('<ext/algorithm>', '__gnu_cxx::copy_n', 'GNUCXX') ]
13 for include, name, define in versions:
14 ret = context.TryCompile("#include %s\n"
15 "int main(int,char**) { int *a,*b; %s(a,0,b); }\n"
20 context.sconf.Define("HAVE_%s_COPYN" % define,
23 + ", ".join(("HAVE_%s_COPYN" % elt[2] for elt in versions)))
31 def CheckTempBufferStrategy(context):
32 context.Message("Checking for optimal temporary buffer strategy... ")
36 ret = context.TryCompile("void test(int n){int a[n];}",".cc")
37 if ret: return "locals"
40 ret = context.TryCompile("#include <alloca.h>\n"
41 "void test(int a){void *b(alloca(a));}"
43 if ret: return "alloca"
50 context.sconf.Define("SENF_BUFFER_USE_%s" % ret.upper(),
52 "Define one of SENF_BUFFER_USE_LOCALS, SENF_BUFFER_USE_ALLOCA, "
53 "SENF_BUFFER_USE_NEW")
57 def CheckValgrind(context):
58 context.Message( "Checking for valgrind... " )
59 ret = context.TryAction(['$VALGRIND --version >$TARGET'])
60 context.Result( ret[1].strip() or False )
64 def CheckValgrindWildcards(context):
65 context.Message( "Checking whether valgrind supports '...' wildcards in suppressions... " )
66 ret = context.TryAction(['$VALGRIND --suppressions=$SOURCE /bin/true'],
67 "{\n test_suppression\n Memcheck:Addr4\n ...\n fun:foo\n}\n",
69 context.Result( ret[0] )
72 ###########################################################################
74 conf = env.Configure(clean=False, help=False, config_h="#/senf/autoconf.hh")
77 res = conf.CheckBoostVersion(fail=True)
78 res = conf.CheckBoostVariants()
79 res = conf.CheckCXXHeader("boost/spirit/include/classic.hpp")
80 res = conf.CheckCXXHeader("boost/bimap.hpp"); \
81 conf.env.Replace(NEED_BOOST_EXT = not res)
84 res = conf.CheckTempBufferStrategy()
86 # Standard library stuff
87 res = conf.CheckFunc("timerfd_create")
88 res = conf.CheckSymbolWithExpression(
89 "le16toh", "le16toh(0)", "#include <senf/Packets/80211Bundle/radiotap/platform.h>")
90 res = conf.CheckSymbolWithExpression(
91 "le32toh", "le32toh(0)", "#include <senf/Packets/80211Bundle/radiotap/platform.h>")
92 res = conf.CheckByteorder()
93 res = conf.CheckSTLCopyN(); \
94 conf.env.Fail(condition=not res, message="No 'copy_n' implementation found")
97 res = conf.CheckValgrind() and conf.CheckValgrindWildcards(); \
98 conf.env.Replace(HAVE_VALGRIND = res)