From ae0c8ca219184bce33ec713b43868b6f5b22f055 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 26 Apr 2014 23:44:15 +0200 Subject: build: conditionally use -Wempty-body -Wempty-body is not available on all gcc versions but we were using it unconditionally. Also remove the usage from the clang case. clang still defines `__GNUC__` so it still gets all the gcc specific flags. This should fix the build on systems with older gcc versions like OpenBSD which still comes bundled with gcc 4.2 for license issues. --- waftools/detections/compiler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'waftools') diff --git a/waftools/detections/compiler.py b/waftools/detections/compiler.py index 1d854bf0ad..670a7b7fbc 100644 --- a/waftools/detections/compiler.py +++ b/waftools/detections/compiler.py @@ -11,6 +11,11 @@ def __get_cc_env_vars__(cc): except Exception: return "" +def __test_and_add_flags__(ctx, flags): + for flag in flags: + ctx.check_cc(cflags=flag, uselib_store="compiler", mandatory=False) + ctx.env.CFLAGS += ctx.env.CFLAGS_compiler + def __add_generic_flags__(ctx): ctx.env.CFLAGS += ["-D_ISOC99_SOURCE", "-D_GNU_SOURCE", "-D_LARGEFILE_SOURCE", "-D_FILE_OFFSET_BITS=64", @@ -21,16 +26,17 @@ def __add_generic_flags__(ctx): ctx.env.CFLAGS += ['-g'] def __add_gcc_flags__(ctx): - ctx.env.CFLAGS += ["-Wundef", "-Wmissing-prototypes", "-Wempty-body", + ctx.env.CFLAGS += ["-Wundef", "-Wmissing-prototypes", "-Wno-switch", "-Wno-parentheses", "-Wpointer-arith", "-Wredundant-decls", "-Wno-pointer-sign", "-Werror=implicit-function-declaration", "-Wno-error=deprecated-declarations", "-Wno-error=unused-function" ] + __test_and_add_flags__(ctx, ["-Wempty-body"]) def __add_clang_flags__(ctx): ctx.env.CFLAGS += ["-Wno-logical-op-parentheses", "-fcolor-diagnostics", - "-Wno-tautological-compare", "-Wempty-body", + "-Wno-tautological-compare", "-Wno-tautological-constant-out-of-range-compare" ] def __add_mingw_flags__(ctx): -- cgit v1.2.3