Profiling use aprof, enable by LOCAL_ENABLE_APROF or LOCAL_ENABLE_APROF_JNI

Change-Id: Ia95dc7318e17c0804867b22e239edccc5cbec0af
diff --git a/core/binary.mk b/core/binary.mk
index e488200..efcec71 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -133,6 +133,15 @@
   LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
 endif
 
+####################################################
+## Add profiling flags if aprof is turned on
+####################################################
+ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
+  # -ffunction-sections and -fomit-frame-pointer are conflict with -pg
+  LOCAL_CFLAGS += -fno-omit-frame-pointer -fno-function-sections -pg
+  LOCAL_CPPFLAGS += -fno-omit-frame-pointer -fno-function-sections -pg
+endif
+
 ###########################################################
 ## Explicitly declare assembly-only __ASSEMBLY__ macro for
 ## assembly source