# Check the compilation environment, unless we are just cleaning up.
if not env.GetOption('clean'):
- conf = Configure(env)
+ def check_ccflags(context, flags):
+ '''Check if given CCFLAGS are supported'''
+ context.Message('Checking support for CCFLAGS="%s"... ' % flags)
+ oldflags = context.env['CCFLAGS']
+ context.env.Append(CCFLAGS = flags)
+ result = context.TryCompile("int main() {return 0;}", '.c')
+ context.env.Replace(CCFLAGS = oldflags)
+ context.Result(result)
+ return result
+
+ conf = Configure(env, custom_tests = {'CheckCCFLAGS': check_ccflags})
# If the platform doesn't support C99, use our own header file instead.
stdbool = conf.CheckCHeader('stdbool.h')
string = conf.CheckCHeader('string.h')
if not stdbool or not stdint or not stddef or not string:
conf.env.Append(CPPDEFINES = {'PB_SYSTEM_HEADER': '\\"pb_syshdr.h\\"'})
- conf.env.Append(CPPPATH = "#../compat")
+ conf.env.Append(CPPPATH = "#../extra")
if stdbool: conf.env.Append(CPPDEFINES = {'HAVE_STDBOOL_H': 1})
if stdint: conf.env.Append(CPPDEFINES = {'HAVE_STDINT_H': 1})
conf.env.Append(CCFLAGS = '-fmudflap')
conf.env.Append(LINKFLAGS = '-lmudflap -fmudflap')
+ # Check if we can use extra strict warning flags (only with GCC)
+ extra = '-Wcast-qual -Wlogical-op -Wconversion'
+ extra += ' -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls'
+ extra += ' -Wstack-protector '
+ if 'gcc' in env['CC']:
+ if conf.CheckCCFLAGS(extra):
+ conf.env.Append(CORECFLAGS = extra)
+
# End the config stuff
env = conf.Finish()
# Debug info, warnings as errors
env.Append(CFLAGS = '-ansi -pedantic -g -O0 -Wall -Werror --coverage -fstack-protector-all')
+ env.Append(CORECFLAGS = '-Wextra')
env.Append(LINKFLAGS = '--coverage')
# We currently need uint64_t anyway, even though ANSI C90 otherwise..
env.Append(CFLAGS = '-Wno-long-long')
-
- # More strict checks on the nanopb core
- env.Append(CORECFLAGS = '-Wextra -Wcast-qual -Wlogical-op -Wconversion')
- env.Append(CORECFLAGS = ' -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls')
- env.Append(CORECFLAGS = ' -Wstack-protector')
elif 'clang' in env['CC']:
# CLang
env.Append(CFLAGS = '-ansi -g -O0 -Wall -Werror')