What about using ifeq
and TARGET_ARCH
?
LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/
ifeq ($(TARGET_ARCH),arm)
LOCAL_LDLIBS += -lcrypto_v7a -lssl_v7a
else
ifeq ($(TARGET_ARCH),x86)
LOCAL_LDLIBS += -lcrypto_x86 -lssl_x86
endif
endif
Question
My Application.mk is set to build arm as well as x86 shared libraries:
APP_ABI :- armeabi-v7a x86
I have prebuilt openssl static libraries:
libcrypto_v7a.a
libcrypto_x86.a
libssl_v7a.a
libssl_x86.a
These files have been copied to jni/inc directory:
Would appreciate your help in setting up Android.mk such that it picks up proper library to link with:
LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ -lcrypto_v7a -lssl_v7a
or
LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ -lcrypto_x86 -lssl_x86
Perhaps there is a $(ARCH) kind of variable defined that I could use to my advantage:
LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ -lcrypto_$(ARCH) -lssl_$(ARCH)
Solution
What about using ifeq
and TARGET_ARCH
?
LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/
ifeq ($(TARGET_ARCH),arm)
LOCAL_LDLIBS += -lcrypto_v7a -lssl_v7a
else
ifeq ($(TARGET_ARCH),x86)
LOCAL_LDLIBS += -lcrypto_x86 -lssl_x86
endif
endif
OTHER TIPS
Another alternative is:
MY_LDLIBS_arm := -lcrypto_v7a -lssl_v7a
MY_LDLIBS_x86 := -lcrypto_x86 -lssl_x86
MY_LDLIBS_mips := ...
LOCAL_LDLIBS += $(MY_LDLIBS_$(TARGET_ARCH))
Which is easier to read and write.