waf:lib/replace: Fix building with older GCC versions
authorBjörn Baumbach <bb@sernet.de>
Thu, 22 Jun 2017 14:07:27 +0000 (16:07 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 23 Jun 2017 19:01:17 +0000 (21:01 +0200)
Using gcc 4.3.2:
cc1: error: unrecognized command line option "-Wno-format-truncation"

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/replace/wscript

index 33f49eb5aa837339031c2a0b2e9f37042895e89e..7c50e1daf8579d705abfc56a30e6247ab63537f5 100644 (file)
@@ -81,6 +81,9 @@ def configure(conf):
     conf.CHECK_HEADERS('sys/atomic.h')
     conf.CHECK_HEADERS('libgen.h')
 
+    if conf.CHECK_CFLAGS('-Wno-format-truncation'):
+        conf.define('HAVE_WNO_FORMAT_TRUNCATION', '1')
+
     # Check for process set name support
     conf.CHECK_CODE('''
                     #include <sys/prctl.h>
@@ -711,11 +714,14 @@ def build(bld):
                       private_library=True,
                       deps='crypt dl nsl socket rt attr' + extra_libs)
 
+    replace_test_cflags="-Wno-format-zero-length"
+    if bld.CONFIG_SET('HAVE_WNO_FORMAT_TRUNCATION'):
+        replace_test_cflags += " -Wno-format-truncation"
     bld.SAMBA_SUBSYSTEM('replace-test',
                         source='''test/testsuite.c test/strptime.c
                         test/os2_delete.c test/getifaddrs.c''',
                         deps='replace',
-                        cflags="-Wno-format-zero-length -Wno-format-truncation")
+                        cflags=replace_test_cflags)
 
     if bld.env.standalone_replace:
         bld.SAMBA_BINARY('replace_testsuite',