Check that the compiler accepts -Wno-error=deprecated-declarations before using it
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Fri, 11 Jul 2008 19:24:33 +0100
changeset 3407 038f13c8741c
parent 3406 3efa652c47ef
child 3418 3ba0b240cff5
Check that the compiler accepts -Wno-error=deprecated-declarations before using it
wscript
--- a/wscript	Fri Jul 11 11:36:59 2008 +0100
+++ b/wscript	Fri Jul 11 19:24:33 2008 +0100
@@ -163,6 +163,27 @@
     opt.sub_options('src')
 
 
+def check_compilation_flag(conf, flag):
+    """
+    Checks if the C++ compiler accepts a certain compilation flag or flags
+    flag: can be a string or a list of strings
+    """
+
+    # Check for -Wno-error=deprecated-declarations
+    save_CXXFLAGS = list(conf.env['CXXFLAGS'])
+    conf.env.append_value('CXXFLAGS', flag)
+    e = conf.create_test_configurator()
+    e.mandatory = 0
+    e.code = '#include <stdio.h>\nint main() { return 0; }\n'
+    e.want_message = 0
+    ok = e.run()
+    conf.check_message_custom(flag, 'compilation flag support',
+                              (ok and 'yes' or 'no'))
+
+    if not ok: # if it doesn't accept, remove it again
+        conf.env['CXXFLAGS'] = save_CXXFLAGS
+    
+
 def configure(conf):
     conf.check_tool('compiler_cxx')
 
@@ -194,8 +215,12 @@
     
     if (os.path.basename(conf.env['CXX']).startswith("g++")
         and 'CXXFLAGS' not in os.environ):
-        variant_env.append_value('CXXFLAGS', ['-Werror', '-Wno-error=deprecated-declarations'])
+
+        variant_env.append_value('CXXFLAGS', '-Werror')
 
+        check_compilation_flag(conf, '-Wno-error=deprecated-declarations')
+
+        
     if 'debug' in Params.g_options.debug_level.lower():
         variant_env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE')
         variant_env.append_value('CXXDEFINES', 'NS3_LOG_ENABLE')