build+ci: Update default build flags and CI scripts

This commit also fixes a few compilation errors.

Change-Id: I19bcbe360423dad2532b9caee4edcdc6356b0075
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index dd78c1c..f82fe10 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -14,22 +14,21 @@
         flags = ClangFlags()
     else:
         flags = CompilerFlags()
-        Logs.warn('The code has not been yet tested with %s compiler' % cxx)
+        Logs.warn('The code has not yet been tested with %s compiler' % cxx)
 
     areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
 
-    # General flags will alway be applied (e.g., selecting C++11 mode)
+    # General flags are always applied (e.g., selecting C++11 mode)
     generalFlags = flags.getGeneralFlags(conf)
     conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
     conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
     conf.env.DEFINES += generalFlags['DEFINES']
 
-    # Debug or optimization CXXFLAGS and LINKFLAGS  will be applied only if the
+    # Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
     # corresponding environment variables are not set.
-    # DEFINES will be always applied
+    # DEFINES are always applied.
     if conf.options.debug:
         extraFlags = flags.getDebugFlags(conf)
-
         if areCustomCxxflagsPresent:
             missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
             if len(missingFlags) > 0:
@@ -96,20 +95,27 @@
         return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
 
 class GccBasicFlags(CompilerFlags):
-    """This class defines base flags that work for gcc and clang compiler"""
+    """
+    This class defines basic flags that work for both gcc and clang compilers
+    """
     def getDebugFlags(self, conf):
         flags = super(GccBasicFlags, self).getDebugFlags(conf)
-        flags['CXXFLAGS'] += ['-Wall',
+        flags['CXXFLAGS'] += ['-pedantic',
+                              '-Wall',
                               '-O0',
                               '-g3',
                               '-Werror',
                               '-Wno-error=maybe-uninitialized', # Bug #1615
-                             ]
+                              ]
         return flags
 
     def getOptimizedFlags(self, conf):
         flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
-        flags['CXXFLAGS'] += ['-Wall', '-O2', '-g']
+        flags['CXXFLAGS'] += ['-pedantic',
+                              '-Wall',
+                              '-O2',
+                              '-g',
+                              ]
         return flags
 
 class GccFlags(GccBasicFlags):
@@ -124,28 +130,44 @@
             flags['CXXFLAGS'] += ['-std=c++0x']
         else:
             flags['CXXFLAGS'] += ['-std=c++11']
+        if version < (4, 8, 0):
+            flags['DEFINES'] += ['_GLIBCXX_USE_NANOSLEEP'] # Bug #2499
         return flags
 
     def getDebugFlags(self, conf):
         flags = super(GccFlags, self).getDebugFlags(conf)
         flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
                               '-fdiagnostics-color', # gcc >= 4.9
-                             ]
+                              ]
+        return flags
+
+    def getOptimizedFlags(self, conf):
+        flags = super(GccFlags, self).getOptimizedFlags(conf)
+        flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
         return flags
 
 class ClangFlags(GccBasicFlags):
     def getGeneralFlags(self, conf):
         flags = super(ClangFlags, self).getGeneralFlags(conf)
-        flags['CXXFLAGS'] += ['-std=c++11',
-                              '-Wno-error=unneeded-internal-declaration', # Bug #1588
-                              '-Wno-error=deprecated-register',
-                              ]
-        if Utils.unversioned_sys_platform() == "darwin":
+        flags['CXXFLAGS'] += ['-std=c++11']
+        if Utils.unversioned_sys_platform() == 'darwin':
             flags['CXXFLAGS'] += ['-stdlib=libc++']
             flags['LINKFLAGS'] += ['-stdlib=libc++']
         return flags
 
     def getDebugFlags(self, conf):
         flags = super(ClangFlags, self).getDebugFlags(conf)
-        flags['CXXFLAGS'] += ['-fcolor-diagnostics']
+        flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+                              '-Wno-unused-local-typedef', # Bugs #2657 and #3209
+                              '-Wno-error=unneeded-internal-declaration', # Bug #1588
+                              '-Wno-error=deprecated-register',
+                              '-Wno-error=keyword-macro', # Bug #3235
+                              ]
+        return flags
+
+    def getOptimizedFlags(self, conf):
+        flags = super(ClangFlags, self).getOptimizedFlags(conf)
+        flags['CXXFLAGS'] += ['-fcolor-diagnostics',
+                              '-Wno-unused-local-typedef', # Bugs #2657 and #3209
+                              ]
         return flags