diff --git a/Makefile.rules b/Makefile.rules
index d39640ee29..7319a1a6bb 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -82,17 +82,21 @@ ifeq ($(CC),gcc)
endif
endif
-ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)
+ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(findstring CODE_COVERAGE,$(MENUSELECT_CFLAGS))$(findstring CODE_PROFILE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)
_ASTCFLAGS+=$(OPTIMIZE)
else
_ASTCFLAGS+=-O0
endif
-ifeq ($(AST_CODE_COVERAGE),yes)
+ifeq ($(findstring CODE_COVERAGE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)
+ _ASTCFLAGS_COVERAGE=
+else
_ASTCFLAGS_COVERAGE=-ftest-coverage -fprofile-arcs
_ASTLDFLAGS+=-ftest-coverage -fprofile-arcs
-else
- _ASTCFLAGS_COVERAGE=
+endif
+
+ifneq ($(findstring KEEP_FRAME_POINTERS,$(MENUSELECT_CFLAGS)),)
+ _ASTCFLAGS+=-fno-omit-frame-pointer
endif
ifeq ($(findstring $(CONFIG_CFLAGS),$(_ASTCFLAGS)),)
diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml
index 38a2683f96..41d35e7757 100644
--- a/build_tools/cflags.xml
+++ b/build_tools/cflags.xml
@@ -5,6 +5,8 @@
DONT_OPTIMIZE
+ KEEP_FRAME_POINTERS
+ CODE_COVERAGE
core
@@ -132,4 +134,13 @@
core
no
+
+ COMPILE_DOUBLE
+ core
+
+
+ extended
+ DONT_OPTIMIZE
+
+