diff --git a/tools/build.py b/tools/build.py
index 6c65c7190dd..f4c60446d38 100644
--- a/tools/build.py
+++ b/tools/build.py
@@ -229,6 +229,8 @@
                     print e
     else:
         # Build
+        extra_flags = {'cflags': options.cflags, 'asmflags': options.asmflags,
+                       'ldflags': options.ldflags, 'cxxflags': options.cxxflags}
         for toolchain in toolchains:
             for target in targets:
                 tt_id = "%s::%s" % (toolchain, target)
@@ -249,7 +251,8 @@
                                                         clean=options.clean,
                                                         archive=(not options.no_archive),
                                                         macros=options.macros,
-                                                        name=options.artifact_name)
+                                                        name=options.artifact_name,
+                                                        extra_flags=extra_flags)
                         else:
                             lib_build_res = build_mbed_libs(mcu, toolchain,
                                                         options=options.options,
diff --git a/tools/build_api.py b/tools/build_api.py
index 41688a2c87d..3463ce3f275 100644
--- a/tools/build_api.py
+++ b/tools/build_api.py
@@ -276,7 +276,7 @@ def get_mbed_official_release(version):
 def prepare_toolchain(src_paths, target, toolchain_name,
                       macros=None, options=None, clean=False, jobs=1,
                       notify=None, silent=False, verbose=False,
-                      extra_verbose=False, config=None):
+                      extra_verbose=False, config=None, extra_flags=None):
     """ Prepares resource related objects - toolchain, target, config
 
     Positional arguments:
@@ -318,6 +318,17 @@ def prepare_toolchain(src_paths, target, toolchain_name,
     except KeyError:
         raise KeyError("Toolchain %s not supported" % toolchain_name)
 
+    if extra_flags  and 'cflags' in extra_flags:
+        toolchain.cc.extend(extra_flags['cflags'])
+    if extra_flags  and 'cxxflags' in extra_flags:
+        toolchain.cppc.extend(extra_flags['cxxflags'])
+    if extra_flags and 'ldflags' in extra_flags:
+        toolchain.hook.hook_cmdline_linker(
+            lambda name, flags: flags + extra_flags['ldflags'])
+    if extra_flags and 'asmflags' in extra_flags:
+        toolchain.hook.hook_cmdline_assembler(
+            lambda name, flags: flags + extra_flags['asmflags'])
+
     toolchain.config = config
     toolchain.jobs = jobs
     toolchain.build_all = clean
@@ -369,7 +380,8 @@ def build_project(src_paths, build_path, target, toolchain_name,
                   clean=False, notify=None, verbose=False, name=None,
                   macros=None, inc_dirs=None, jobs=1, silent=False,
                   report=None, properties=None, project_id=None,
-                  project_description=None, extra_verbose=False, config=None):
+                  project_description=None, extra_verbose=False, config=None,
+                  extra_flags=None):
     """ Build a project. A project may be a test or a user program.
 
     Positional arguments:
@@ -415,7 +427,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
     toolchain = prepare_toolchain(
         src_paths, target, toolchain_name, macros=macros, options=options,
         clean=clean, jobs=jobs, notify=notify, silent=silent, verbose=verbose,
-        extra_verbose=extra_verbose, config=config)
+        extra_verbose=extra_verbose, config=config, extra_flags=extra_flags)
 
     # The first path will give the name to the library
     if name is None:
@@ -489,7 +501,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
                   archive=True, notify=None, verbose=False, macros=None,
                   inc_dirs=None, jobs=1, silent=False, report=None,
                   properties=None, extra_verbose=False, project_id=None,
-                  remove_config_header_file=False):
+                  remove_config_header_file=False, extra_flags=None):
     """ Build a library
 
     Positional arguments:
@@ -539,7 +551,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
     toolchain = prepare_toolchain(
         src_paths, target, toolchain_name, macros=macros, options=options,
         clean=clean, jobs=jobs, notify=notify, silent=silent, verbose=verbose,
-        extra_verbose=extra_verbose)
+        extra_verbose=extra_verbose, extra_flags=extra_flags)
 
     # The first path will give the name to the library
     if name is None:
@@ -807,7 +819,8 @@ def build_lib(lib_id, target, toolchain_name, options=None, verbose=False,
 # library
 def build_mbed_libs(target, toolchain_name, options=None, verbose=False,
                     clean=False, macros=None, notify=None, jobs=1, silent=False,
-                    report=None, properties=None, extra_verbose=False):
+                    report=None, properties=None, extra_verbose=False,
+                    extra_flags=None):
     """ Function returns True is library was built and false if building was
     skipped
 
diff --git a/tools/make.py b/tools/make.py
index 3dc5a63c3c6..4a51900d2b2 100644
--- a/tools/make.py
+++ b/tools/make.py
@@ -260,6 +260,8 @@
             build_dir = options.build_dir
 
         try:
+            extra_flags = {'cflags': options.cflags, 'asmflags': options.asmflags,
+                           'ldflags': options.ldflags, 'cxxflags': options.cxxflags}
             bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, test.dependencies, options.options,
                                      linker_script=options.linker_script,
                                      clean=options.clean,
@@ -268,7 +270,8 @@
                                      silent=options.silent,
                                      macros=options.macros,
                                      jobs=options.jobs,
-                                     name=options.artifact_name)
+                                     name=options.artifact_name,
+                                     extra_flags=extra_flags)
             print 'Image: %s'% bin_file
 
             if options.disk:
diff --git a/tools/options.py b/tools/options.py
index 057394c7b8f..99d834613a2 100644
--- a/tools/options.py
+++ b/tools/options.py
@@ -57,6 +57,10 @@ def get_default_options_parser(add_clean=True, add_options=True):
     parser.add_argument("--cflags", default=[], action="append",
                         help="Extra flags to provide to the C compiler")
 
+    parser.add_argument("--cxxflags", default=[], dest="cxxflags",
+                        action="append",
+                        help="Extra flags to provide to the C++ compiler")
+
     parser.add_argument("--asmflags", default=[], action="append",
                         help="Extra flags to provide to the assembler")
 
diff --git a/tools/test.py b/tools/test.py
index 9b568a5d933..f81877a5d58 100644
--- a/tools/test.py
+++ b/tools/test.py
@@ -166,19 +166,23 @@
 
             library_build_success = False
             try:
+                extra_flags = {'cflags': options.cflags, 'asmflags': options.asmflags,
+                               'ldflags': options.ldflags,
+                               'cxxflags': options.cxxflags}
                 # Build sources
                 build_library(base_source_paths, options.build_dir, mcu, toolchain,
-                                                options=options.options,
-                                                jobs=options.jobs,
-                                                clean=options.clean,
-                                                report=build_report,
-                                                properties=build_properties,
-                                                name="mbed-build",
-                                                macros=options.macros,
-                                                verbose=options.verbose,
-                                                notify=notify,
-                                                archive=False,
-                                                remove_config_header_file=True)
+                              options=options.options,
+                              jobs=options.jobs,
+                              clean=options.clean,
+                              report=build_report,
+                              properties=build_properties,
+                              name="mbed-build",
+                              macros=options.macros,
+                              verbose=options.verbose,
+                              notify=notify,
+                              archive=False,
+                              extra_flags=extra_flags,
+                              remove_config_header_file=True)
 
                 library_build_success = True
             except ToolException, e:
@@ -195,16 +199,22 @@
                 print "Failed to build library"
             else:
                 # Build all the tests
-                test_build_success, test_build = build_tests(tests, [options.build_dir], options.build_dir, mcu, toolchain,
-                        options=options.options,
-                        clean=options.clean,
-                        report=build_report,
-                        properties=build_properties,
-                        macros=options.macros,
-                        verbose=options.verbose,
-                        notify=notify,
-                        jobs=options.jobs,
-                        continue_on_build_fail=options.continue_on_build_fail)
+                extra_flags = {'cflags': options.cflags,
+                               'asmflags': options.asmflags,
+                               'ldflags': options.ldflags,
+                               'cxxflags': options.cxxflags}
+                test_build_success, test_build = build_tests(
+                    tests, [options.build_dir], options.build_dir, mcu, toolchain,
+                    options=options.options,
+                    clean=options.clean,
+                    report=build_report,
+                    properties=build_properties,
+                    macros=options.macros,
+                    verbose=options.verbose,
+                    notify=notify,
+                    jobs=options.jobs,
+                    continue_on_build_fail=options.continue_on_build_fail,
+                    extra_flags=extra_flags)
 
                 # If a path to a test spec is provided, write it to a file
                 if options.test_spec:
diff --git a/tools/test_api.py b/tools/test_api.py
index d995e1bf469..e4a2c5b277e 100644
--- a/tools/test_api.py
+++ b/tools/test_api.py
@@ -2058,9 +2058,9 @@ def norm_relative_path(path, start):
     return path
 
 def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
-        options=None, clean=False, notify=None, verbose=False, jobs=1,
-        macros=None, silent=False, report=None, properties=None,
-        continue_on_build_fail=False):
+                options=None, clean=False, notify=None, verbose=False, jobs=1,
+                macros=None, silent=False, report=None, properties=None,
+                continue_on_build_fail=False, extra_flags=None):
     """Given the data structure from 'find_tests' and the typical build parameters,
     build all the tests
 
@@ -2101,7 +2101,8 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
                                      project_id=test_name,
                                      report=report,
                                      properties=properties,
-                                     verbose=verbose)
+                                     verbose=verbose,
+                                     extra_flags=extra_flags)
 
         except Exception, e:
             if not isinstance(e, NotSupportedException):