From 310dec47f08484a60fc2439d2d8a0412e0d656c4 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 17 Jan 2012 23:58:33 +0000 Subject: [PATCH] Supress warnings in externally-supplied code (f2c, cvode) --- ext/SConscript | 64 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/ext/SConscript b/ext/SConscript index 959725e37..1ade91dfb 100644 --- a/ext/SConscript +++ b/ext/SConscript @@ -3,11 +3,11 @@ from buildutils import * Import('env', 'buildDir', 'buildTargets', 'installTargets') localenv = env.Clone() -# (subdir, library name, (file extensions)) -libs = [('tpx','tpx',['cpp'])] +def prep_default(env): + return env.Clone() -if env['build_with_f2c']: - libs.append(('f2c_math', 'ctmath', ['cpp','c'])) +def prep_f2c(env): + localenv = env.Clone() localenv.Append(CPPPATH=Dir('#ext/f2c_libs')) if not localenv['HAS_TIMES_H']: @@ -15,9 +15,35 @@ if env['build_with_f2c']: if not localenv['HAS_UNISTD_H']: localenv.Append(CPPDEFINES=['MSDOS']) + # The F2C code generates a lot of warnings designed to catch + # programmer errors, but since this is autogenerated code, those + # warnings are irrelevant. + if '-Wall' in localenv['CCFLAGS']: + localenv['CCFLAGS'].remove('-Wall') + localenv['CCFLAGS'].append('-Wno-format-security') + + return localenv + +def prep_sundials(env): + localenv = env.Clone() + localenv.Append(CPPPATH=Dir('#ext/cvode/include')) + + # Suppress warnings from external code + if '-Wall' in localenv['CCFLAGS']: + localenv['CCFLAGS'].append('-Wno-format') + + return localenv + +# (subdir, library name, (file extensions), prepfunction) +libs = [('tpx','tpx',['cpp'],prep_default)] + +if env['build_with_f2c']: + libs.append(('f2c_math', 'ctmath', ['cpp','c'], prep_f2c)) + # Create arith.h using the arithchk program if not os.path.exists('arith.h'): - arithenv = env.Clone() + arithenv = prep_f2c(env) + # TODO: make link flag more general arithenv.Append(CPPFLAGS='-DNO_FPINIT') arithenv.Program('f2c_libs/arithchk/arithchk', source='f2c_libs/arithchk/arithchk.c', @@ -25,31 +51,33 @@ if env['build_with_f2c']: arithenv.Command('#ext/f2c_libs/arith.h', 'f2c_libs/arithchk/arithchk$PROGSUFFIX', '$SOURCE > $TARGET') + headerenv = prep_f2c(env) # Possibly system-depenent headers - localenv.Command('#ext/f2c_libs/signal1.h', 'f2c_libs/signal1.h0', - Copy('$TARGET', '$SOURCE')) + headerenv.Command('#ext/f2c_libs/signal1.h', 'f2c_libs/signal1.h0', + Copy('$TARGET', '$SOURCE')) - localenv.Command('#ext/f2c_libs/sysdep1.h', 'f2c_libs/sysdep1.h0', - Copy('$TARGET', '$SOURCE')) + headerenv.Command('#ext/f2c_libs/sysdep1.h', 'f2c_libs/sysdep1.h0', + Copy('$TARGET', '$SOURCE')) - libs.append(('f2c_libs', 'ctf2c', 'c')) + libs.append(('f2c_libs', 'ctf2c', 'c', prep_f2c)) if env['BUILD_BLAS_LAPACK']: - libs.append(('f2c_blas', 'ctblas', ['c'])) - libs.append(('f2c_lapack', 'ctlapack', ['c'])) + libs.append(('f2c_blas', 'ctblas', ['c'], prep_f2c)) + libs.append(('f2c_lapack', 'ctlapack', ['c'], prep_f2c)) else: - libs.append(('math', 'ctmath', ['cpp','c','f'])) + libs.append(('math', 'ctmath', ['cpp','c','f'], prep_default)) if env['BUILD_BLAS_LAPACK']: - libs.append(('blas', 'ctblas', ['f'])) - libs.append(('lapack', 'ctlapack', ['f'])) + libs.append(('blas', 'ctblas', ['f'], prep_default)) + libs.append(('lapack', 'ctlapack', ['f'], prep_default)) if env['use_sundials'] == 'n': - libs.append(('cvode/source', 'cvode', ['c'])) - localenv.Append(CPPPATH=Dir('#ext/cvode/include')) + libs.append(('cvode/source', 'cvode', ['c'], prep_sundials)) -for subdir, libname, extensions in libs: + +for subdir, libname, extensions, prepFunction in libs: + localenv = prepFunction(env) lib = localenv.Library(pjoin('../lib', libname), source=mglob(localenv, subdir, *extensions)) inst = localenv.Install('$inst_libdir', lib)