Android. mk developed by NDK to write samples
1. jni contains multiple source files and multiple files are compiled into different so files.
(1) jni/Android. mk:
Include $ (call all-subdir-makefiles) (contains Android. mk in all subdirectories)
Note: When writing an Android. mk file,
Call all-subdir-makefiles and call all-makefiles-under, $ (LOCAL_PATH) are different.
The former indicates "no files need to be compiled in the current directory. Please go deep into the subdirectory ",
It is a required way to tell the compiler to continue recursion to the depths of the directory.
The latter can be understood literally in the same way.
However, consider the following situation: if a file in the current directory needs to be compiled,
In addition, there are subdirectories in the current directory, and files in the subdirectories also need to be compiled,
In this case, the Android. mk file in the current directory must contain statements for compiling files in the current directory,
After the compiler has compiled the files in the current directory,
Continue to the sub-directory statements. There is a problem here,
How can I write the following statement? Is call all-subdir-makefiles,
Or call all-makefiles-under, $ (LOCAL_PATH?
After my experiment, writing the former won't work,
The compiler does not compile sub-directories after compiling the files in the current directory.
The latter can meet our expectations.
(2) jni/app_jni/Android. mk
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE_TAGS: = optional
LOCAL_MODULE: = libcallApp_jni
LOCAL_SRC_FILES: = callApp_jni.cpp
LOCAL_LDLIBS + =-L $ (SYSROOT)/usr/lib-llog
LOCAL_SHARED_LIBRARIES: = libdl \
Liblog \
LibAppUpgrade \
LibAppArea
Include $ (BUILD_SHARED_LIBRARY)
(3) jni/app_area/Android. mk
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_SRC_FILES: = \
AppArea. c Encrypt. c
LOCAL_MODULE: = libAppArea
Include $ (BUILD_SHARED_LIBRARY)
(4) jni/app_upgrade/Android. mk
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE_TAGS: = optional
LOCAL_LDLIBS + =-L $ (SYSROOT)/usr/lib-llog
LOCAL_SHARED_LIBRARIES: = liblog libAppArea
LOCAL_SRC_FILES: = \
AppUpgrade. c
LOCAL_MODULE: = libAppUpgrade
Include $ (BUILD_SHARED_LIBRARY)
2. jni contains multiple so files, excluding source files.
(1) jni/Android. mk:
Include $ (call all-subdir-makefiles) (contains Android. mk in all subdirectories)
(2) jni/app_jni/Android. mk
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE_TAGS: = optional
LOCAL_MODULE: = libcallApp_jni
LOCAL_SRC_FILES: = callApp_jni.cpp
LOCAL_LDLIBS + =-L $ (SYSROOT)/usr/lib-llog
LOCAL_SHARED_LIBRARIES: = libdl \
Liblog \
Libpre_AppUpgrade \
Libpre_AppArea
Include $ (BUILD_SHARED_LIBRARY)
(3) jni/app_area/Android. mk
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE: = pre_AppArea
LOCAL_SRC_FILES: = libAppArea. so
Include $ (PREBUILT_SHARED_LIBRARY)
(4) jni/app_upgrade/Android. mk
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE: = pre_AppUpgrade
LOCAL_SRC_FILES: = libAppUpgrade. so
Include $ (PREBUILT_SHARED_LIBRARY)