freetype: Don't force -O2

There's a -O2 hardcode in Android.mk - its purpose is to make
sure freetype gets built with optimizations enabled, but it
is done in a way that overrides other optimization flags such
as -O3 or -Os.

Only set -O2 if no other optimization level is requested.

Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
diff --git a/Android.mk b/Android.mk
index bc15d5c..08d0c49 100644
--- a/Android.mk
+++ b/Android.mk
@@ -49,7 +49,15 @@
 # of the product
 #LOCAL_CFLAGS += "-DTT_CONFIG_OPTION_BYTECODE_INTERPRETER"
 
+# Freetype can't be built without optimizations, so we enforce -O2 if no
+# other optimization flag is set - but we don't override what the global
+# flags are saying if something else is given (-Os or -O3 are useful)
+ifeq ($(findstring -O, $(TARGET_GLOBAL_CFLAGS)),)
 LOCAL_CFLAGS += -O2
+endif
+ifneq ($(findstring -O0, $(TARGET_GLOBAL_CFLAGS)),)
+LOCAL_CFLAGS += -O2
+endif
 
 LOCAL_MODULE:= libft2