diff --git a/SConstruct b/SConstruct index be8bb23..93b8117 100644 --- a/SConstruct +++ b/SConstruct @@ -38,20 +38,6 @@ env.Replace(CCFLAGS = str(env['CCFLAGS']).split(' ')) #################### Tests ################### -# check for other GCC options -def checkForGCCOption(conf,option): - conf.Message("checking whether GCC supports "+option+" ") - lastCFLAGS=conf.env['CCFLAGS'] - conf.env.Append(CCFLAGS = option) - rc = conf.TryCompile(""" -void dummy(void); -void dummy(void) {} -""",'.c') - if not rc: - conf.env.Replace(CCFLAGS = lastCFLAGS) - conf.Result(rc) - return rc - # check for user-supplied lock prefix def checkForLockPrefix(conf): conf.Message("checking for user supplied lockprefix... ") @@ -105,16 +91,18 @@ main () conf.Result(rc) return rc -############ Start configuration ############## +############ Start configuration ############## from maintainer import checkForMaintainerMode -conf = Configure(env,{'checkForGCCOption':checkForGCCOption, +from compilertest import checkForCCOption + +conf = Configure(env,{'checkForCCOption':checkForCCOption, 'MAINTAINER_MODE':checkForMaintainerMode, 'checkForLockPrefix':checkForLockPrefix, 'checkPrefix':checkForUserPrefix, 'sizeOf':getVarSize }) -#check for GCC options +# check for CC options for option in Split(""" -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings @@ -128,7 +116,8 @@ for option in Split(""" -Wpointer-arith -Wno-unused-parameter -Wunreachable-code """): - conf.checkForGCCOption(option) + conf.checkForCCOption(option) + #portability build time config if conf.CheckFunc('srandomdev'): conf.env.Append(CPPFLAGS = '-DHAVE_SRANDOMDEV') diff --git a/site_scons/compilertest.py b/site_scons/compilertest.py new file mode 100644 index 0000000..f866cd6 --- /dev/null +++ b/site_scons/compilertest.py @@ -0,0 +1,24 @@ +# +# Scons compiler tester +# +# Version 1.0 +# 16-Jun-2009 +# + +def checkForCCOption(conf,option): + """Checks if CC compiler supports given command line option. + + Adds option to CCFLAGS option is supported by compiler. + + """ + conf.Message("checking whether %s supports %s " % (conf.env['CC'],option)) + lastCFLAGS=conf.env['CCFLAGS'] + conf.env.Append(CCFLAGS = option) + rc = conf.TryCompile(""" +void dummy(void); +void dummy(void) {} +""",'.c') + if not rc: + conf.env.Replace(CCFLAGS = lastCFLAGS) + conf.Result(rc) + return rc