-AM_CFLAGS = -fvisibility=hidden
-AM_CXXFLAGS = -fvisibility=hidden
-AM_OBJCXXFLAGS = -fvisibility=hidden
-AM_LDFLAGS = -fvisibility=hidden
+CY_FLAGS =
+CY_FLAGS += -fvisibility=hidden
+
+if CY_ANDROID
+CY_FLAGS += -fPIE
+endif
+
+AM_CFLAGS = $(CY_FLAGS)
+AM_CXXFLAGS = $(CY_FLAGS)
+AM_OBJCXXFLAGS = $(CY_FLAGS)
+AM_LDFLAGS = $(CY_FLAGS)
+
+if CY_ANDROID
+AM_LDFLAGS += -rdynamic -fPIE -pie
+endif