# -*- python -*- import glob Import('env') ########################################################################### # Custom configuration checks @env.ConfTest() def CheckSTLCopyN(context): context.Message("Checking for 'copy_n' implementation... ") versions = [ ('', 'std::copy_n', 'STD'), ('', '__gnu_cxx::copy_n', 'GNUCXX') ] for include, name, define in versions: ret = context.TryCompile("#include %s\n" "int main(int,char**) { int *a (NULL); int *b (NULL); %s(a,0,b); }\n" % (include, name), ".cc") if ret: context.Result(name) context.sconf.Define("HAVE_%s_COPYN" % define, 1, "Define one of " + ", ".join(("HAVE_%s_COPYN" % elt[2] for elt in versions))) return ret context.Result(False) return False @env.ConfTest() def CheckTempBufferStrategy(context): context.Message("Checking for optimal temporary buffer strategy... ") def check(): # locals ret = context.TryCompile("void test(int n){int a[n];}",".cc") if ret: return "locals" # alloca ret = context.TryCompile("#include \n" "void test(int a){void *b(alloca(a));}", ".cc") if ret: return "alloca" # fallback: new return "new" ret = check() context.Result(ret) context.sconf.Define("SENF_BUFFER_USE_%s" % ret.upper(), 1, "Define one of SENF_BUFFER_USE_LOCALS, SENF_BUFFER_USE_ALLOCA, " "SENF_BUFFER_USE_NEW") return ret @env.ConfTest() def CheckValgrind(context): context.Message( "Checking for valgrind... " ) ret = context.TryAction(['$VALGRIND --version >$TARGET']) context.Result( ret[1].strip() or False ) return ret[0] @env.ConfTest() def CheckValgrindWildcards(context): context.Message( "Checking whether valgrind supports '...' wildcards in suppressions... " ) ret = context.TryAction(['$VALGRIND --suppressions=$SOURCE /bin/true'], "{\n test_suppression\n Memcheck:Addr4\n ...\n fun:foo\n}\n", ".sup") context.Result( ret[0] ) return ret[0] ########################################################################### conf = env.Configure(clean=False, help=False, config_h="#/senf/autoconf.hh") # Boost res = conf.CheckBoostVersion(fail=True) res = conf.CheckBoostVariants() res = conf.CheckCXXHeader("boost/spirit/include/classic.hpp") res = conf.CheckCXXHeader("boost/bimap.hpp"); \ conf.env.Replace(NEED_BOOST_EXT = not res) # Compiler support res = conf.CheckTempBufferStrategy() # Standard library stuff res = conf.CheckCHeader("execinfo.h") res = conf.FindCHeader("timerfd.h", [ 'sys', 'linux' ]) res = conf.CheckFunc("timerfd_create") res = conf.CheckSymbolWithExpression( "le16toh", "le16toh(0)", "#include ") res = conf.CheckSymbolWithExpression( "le32toh", "le32toh(0)", "#include ") res = conf.CheckByteorder() res = conf.CheckSTLCopyN(); \ conf.env.Fail(condition=not res, message="No 'copy_n' implementation found") # valgrind res = conf.CheckValgrind() and conf.CheckValgrindWildcards(); \ conf.env.Replace(HAVE_VALGRIND = res) ########################################################################### # run configure scripts from external modules Export('conf') sconscripts = sorted(glob.glob("senf/Ext/*/SConfigure")) if sconscripts: SConscript(sconscripts) ########################################################################### env = conf.Finish()