Android.mk compiled files are used to describe your c,c++ source code files to the Android NDK, and today check out some common syntax.
An overview: A android.mk file is used to describe your source code to the compilation system.
Specifically: This file is a small part of the GNU Makefile, and will be compiled by the system to parse one or more times of the build system.
You can define one or more modules in each of the android.mk files.
You can also use the same source code file in several modules.
Two Syntax 1 You must define the content first by looking at what must be defined:
Local_path: = $ (call My-dir) include $ (clear_vars) Local_module: = xxxlocal_files: = XXX.cpp ... Include $ (build_xxx)
The specific meanings are as follows:
Local_path: = $ (call My-dir)
Each android.mk file must start with a definition of local_path. It is used to find source files in the development tree.
My-dir is a macro function that is provided by the compilation system and returns the current path, which is the file directory containing the ANDROID.MK.
Include $ (clear_vars)
The Clear_vars variable is provided by the compiler and points to a GNU Makefile, which is responsible for cleaning up the local_xxx variable (not clearing local_path).
Because all compiled control files are parsed and executed by the same GNU make, their variables are global, so they are cleaned up to avoid interaction.
Local_module: = XXX
Local_module is the module name and must be defined before include $ (build_xxxxx), unique and without spaces.
Local_src_files: = XXX.cpp
A list of source files that must contain the C + + source code that will be packaged as modules.
You do not have to list header files, and the compilation system automatically finds the dependent header files.
The default C + + source extension is. cpp. can also be modified by local_cpp_extension.
Include $ (XXX)
Responsible for collecting all local_xxx information since the last call to include $ (clear_vars). and decide what to compile.
Only two commonly used ones are introduced:
Build_static_library: Compile as a static library and generate a file named lib$ (Local_module). So.
Build_shared_library: Compile as a dynamic library and generate a file named lib$ (Local_module). A.
2 Common optional content local_module_filename: = XXX
Typically defined after local_module: = xxx, used to overwrite Local_module and redefine the final generated target file name.
Local_cpp_extension: =. CXX
Indicates the C + + extension. For example: local_cpp_extension: =. cxx. CPP. cc.
Local_c_includes: = XXX
Specify the include path, which will be appended to the compile-time directory.
For example:
Local_c_includes: = $ (Local_path)/. /.. /classes \
$ (Local_path)/.. /.. /classes/sdkcontroller \
$ (Local_path)/.. /.. /classes/sdkcontroller/android \
$ (Local_path)/.. /.. /classes/sharecontroller \
$ (Local_path)/.. /.. /.. /.. /.. /cocos2dx/platform/android/jni
Local_cflags: = xxx, local_cppflags: = xxx
Used to add compilation options when compiling a C + +.
For example:
Local_cflags: = \
-wno-multichar \
-dandroid \
-dlibdir= "C" \
-dbuilding_libiconv \
-din_library
Local_whole_static_libraries: = XXX
Static library full link, the compiler will complete the static library link without pruning optimization.
Unlike Local_static_libraries, it is similar to using--whole-archive.
For example:
Local_whole_static_libraries: = cocos2dx_static
Local_whole_static_libraries + = Cocosdenshion_static
Local_whole_static_libraries + = Cocos_lua_static
Import-module:
Allow to find and import other modules into this android.mk. It will look for the specified module name from Ndk_module_path.
$ (call import-module,<name>)
For example:
$ (call IMPORT-MODULE,COCOS2DX)
$ (call import-module,cocosdenshion/android)
$ (call import-module,scripting/lua/proj.android)
Appendix: Reference Blog
Http://www.cnblogs.com/wainiwann/p/3837936.html
Http://www.cnblogs.com/leaven/archive/2011/01/25/1944688.html
Common syntax in android.mk