You are right, this does not apply to the import module. The way you reference the avihi library from your own code will still be LOCAL_SHARED_LIBRARIES (see the NDK module-exports example). But in your jni/Android.mk file, you can use the include command for another file. This command is very similar to the #include statement in C. This file should not be inside your project tree. Taking the same sample, here is how it can work:
Original Android.mk from samples / module-exports / jni :
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := foo LOCAL_SRC_FILES := foo/foo.c LOCAL_CFLAGS := -DFOO=2 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo LOCAL_EXPORT_CFLAGS := -DFOO=1 LOCAL_EXPORT_LDLIBS := -llog include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := bar LOCAL_SRC_FILES := bar/bar.c LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/bar LOCAL_STATIC_LIBRARIES := foo include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := zoo LOCAL_SRC_FILES := zoo/zoo.c LOCAL_SHARED_LIBRARIES := bar include $(BUILD_SHARED_LIBRARY)
The modified file will look like this:
ZOO_LOCAL_PATH := $(call my-dir) include ~/projects/bar/jni/Android.mk LOCAL_PATH := $(ZOO_LOCAL_PATH) include $(CLEAR_VARS) LOCAL_MODULE := zoo LOCAL_SRC_FILES := zoo/zoo.c LOCAL_SHARED_LIBRARIES := bar include $(BUILD_SHARED_LIBRARY)
And the external bar /jni/Android.mk:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := foo LOCAL_SRC_FILES := foo/foo.c LOCAL_CFLAGS := -DFOO=2 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo LOCAL_EXPORT_CFLAGS := -DFOO=1 LOCAL_EXPORT_LDLIBS := -llog include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := bar LOCAL_SRC_FILES := bar/bar.c LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/bar LOCAL_STATIC_LIBRARIES := foo include $(BUILD_SHARED_LIBRARY)
Now both bar.c and foo.c files can be stored outside the tree of the zoo project!
Alex cohn
source share