Reputation: 577
I'm trying to configure Android.mk to cross compile native code to support different chipset namely armeabi, mips, and x86. I know I can configure Application.mk in the following way to compile the source code for different chip set:
APP_ABI := all
This will trigger Android-NDK's build script to compile the source code for all the chipsets. However, I want to dynamically tell Android.mk to look for different static library dependencies compiled with different chip set.
# Get the architecture info
ARCH := ????
include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)
Is this possible to do? If so, can anyone advice how to do so?
Update: I tried something like this in Application.mk:
APP_ABI := armeabi armeabi-v7a mips x64
with Android.mk:
# Get the architecture info ARCH := $(APP_ABI) include $(CLEAR_VARS) LOCAL_MODULE:= mylib LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) include $(PREBUILT_STATIC_LIBRARY)
but it errors with the following:
The LOCAL_SRC_FILES for a prebuilt static library should only contain one item
which makes sense. I want to pass APP_ABI := all in Application.mk and be able to dynamically reference it. Any ideas?
Upvotes: 36
Views: 31406
Reputation: 25386
There is TARGET_ARCH
variable that holds the value of the current ABI being built. You can use it the following way:
ifeq ($(TARGET_ARCH),x86)
LOCAL_CFLAGS := $(COMMON_FLAGS_LIST)
else
LOCAL_CFLAGS := -mfpu=vfp -mfloat-abi=softfp $(COMMON_FLAGS_LIST)
endif
If you specify APP_ABI := armeabi-v7a armeabi mips x86
or APP_ABI := all
in your Application.mk
you will get each and every separate ABI value.
Upvotes: 29
Reputation: 179392
Check TARGET_ARCH_ABI
:
ifeq($(TARGET_ARCH_ABI), armeabi-v7a)
# v7a-specific stuff
endif
Upvotes: 36