From 5c2f553ed2650fb551a6b7d3a1468c4113ab2bf5 Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 3 Apr 2018 15:37:14 +0930 Subject: [PATCH] Change Android.mk to only compile a single .a file This will require any android application to include their own shared library rules similar to the following; include $(CLEAR_VARS) LOCAL_STATIC_LIBRARIES := servaldstatic LOCAL_C_INCLUDES += $(LOCAL_PATH)/serval-dna LOCAL_SRC_FILES := $(LOCAL_PATH)/features.c LOCAL_MODULE := servaldaemon LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog include $(BUILD_SHARED_LIBRARY) Allowing just the set of required features to be linked into the final binary --- Android.mk | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/Android.mk b/Android.mk index 28d585bb..cc8a6866 100644 --- a/Android.mk +++ b/Android.mk @@ -56,36 +56,11 @@ SERVALD_LOCAL_CFLAGS = \ SERVALD_LOCAL_LDLIBS = -L$(SYSROOT)/usr/lib -llog SERVALD_LOCAL_STATIC_LIBRARIES += sodium -# Build libservald.so +# Build libservaldtatic.a include $(CLEAR_VARS) LOCAL_STATIC_LIBRARIES := $(SERVALD_LOCAL_STATIC_LIBRARIES) LOCAL_SRC_FILES := $(SERVALD_SRC_FILES) version_servald.c LOCAL_CFLAGS += $(SERVALD_LOCAL_CFLAGS) LOCAL_C_INCLUDES += $(SODIUM_INCLUDE) -LOCAL_LDLIBS := $(SERVALD_LOCAL_LDLIBS) -LOCAL_MODULE := servaldaemon -include $(BUILD_SHARED_LIBRARY) - -# Build servald executable, a wrapper around libservald.so -ifdef SERVALD_WRAP - include $(CLEAR_VARS) - LOCAL_SRC_FILES:= servalwrap.c - LOCAL_MODULE:= servald - LOCAL_CFLAGS += -fPIE - LOCAL_LDFLAGS += -fPIE -pie - include $(BUILD_EXECUTABLE) -endif - -# Build servald executable for use with gdb -ifdef SERVALD_SIMPLE - include $(CLEAR_VARS) - LOCAL_SRC_FILES:= $(SERVALD_SRC_FILES) version_servald.c - LOCAL_CFLAGS += $(SERVALD_LOCAL_CFLAGS) - LOCAL_LDLIBS := $(SERVALD_LOCAL_LDLIBS) - LOCAL_C_INCLUDES += $(SODIUM_INCLUDE) - LOCAL_STATIC_LIBRARIES := $(SERVALD_LOCAL_STATIC_LIBRARIES) - LOCAL_MODULE:= servaldsimple - LOCAL_CFLAGS += -fPIE - LOCAL_LDFLAGS += -fPIE -pie - include $(BUILD_EXECUTABLE) -endif +LOCAL_MODULE := servaldstatic +include $(BUILD_STATIC_LIBRARY)