adb: Don't force -O2
Don't force -O2 over -O3 -- the O2 hardcode is there to force
optimizations, not to reduce them...
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
diff --git a/adb/Android.mk b/adb/Android.mk
index a803978..3813c09 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -75,7 +75,16 @@
LOCAL_SRC_FILES += fdevent.c
endif
-LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter
+LOCAL_CFLAGS += -g -DADB_HOST=1 -Wall -Wno-unused-parameter
+# adb 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, $(HOST_GLOBAL_CFLAGS)),)
+LOCAL_CFLAGS += -O2
+endif
+ifneq ($(findstring -O0, $(HOST_GLOBAL_CFLAGS)),)
+LOCAL_CFLAGS += -O2
+endif
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
LOCAL_MODULE := adb
LOCAL_MODULE_TAGS := debug
@@ -119,7 +128,16 @@
log_service.c \
utils.c
-LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
+LOCAL_CFLAGS := -g -DADB_HOST=0 -Wall -Wno-unused-parameter
+# adb 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_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
@@ -162,7 +180,6 @@
fdevent.c
LOCAL_CFLAGS := \
- -O2 \
-g \
-DADB_HOST=1 \
-DADB_HOST_ON_TARGET=1 \
@@ -173,6 +190,16 @@
LOCAL_C_INCLUDES += external/openssl/include
+# adb 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 := adb
LOCAL_STATIC_LIBRARIES := libzipfile libunz libcutils