I. Introduction to Android:
The 1.android.mk file first needs to specify the Local_path variable, which is used to locate the source file. Since android.mk and the source files that need to be compiled are in the same directory, they are defined in the following form:
local_path:=$ (call my-dir)
The above statement means that the Local_path variable defines the directory path where the cost file is located.
2. Android.mk can define multiple compilation modules, each of which starts with the include $ (clear_vars) and ends with the include $ (build_xxx).
Include $ (clear_vars)
Clear_vars is provided by the build system, specifying that the GNU makefile for you to clear all local_xxx variables except Local_path, such as Local_module, Local_src_files, Local_shared_ LIBRARIES, local_static_libraries, etc.
The include $ (build_static_library) means that compiling into a static library include $ (build_shared_library) means compiling into a dynamic library. Include $ (build_executable) to compile into executable program
3. Examples are as follows (FRAMEWORKS/BASE/LIBS/AUDIOFLINGER/ANDROID.MK)
(1).
Local_path:= $ (Call my-dir) include $ (clear_vars) ifeq ($ (audio_policy_test),true) Enable_audio_dump:=trueEndiflocal_src_files:=audiohardwaregeneric.CPPaudiohardwarestub.CPPAudiohardwareinterface.CPPifeq ($ (enable_audio_dump),true) Local_src_files+ = Audiodumpinterface.CPPLocal_cflags+= -denable_audio_dumpendiflocal_shared_libraries:=libcutils libutils libbinder libmedia libhardware_legacyifeq ($ (Strip $ (board_uses_generic_audio) ),true) Local_cflags+= -Dgeneric_audioendiflocal_module:=Libaudiointerfaceifeq ($ (board_have_bluetooth),true) Local_src_files+ = A2dpaudiointerface.CPPlocal_shared_libraries+=LIBA2DP local_cflags+ =-dwith_bluetooth-DWITH_A2DP local_c_includes+ = $ (call include-path- for, BlueZ) Endifinclude $ (build_static_library) module compiled into a static library
(2)
include $ (clear_vars) Local_src_files:=audiopolicymanagerbase.CPPlocal_shared_libraries:=libcutils libutils libmediaifeq ($ (target_simulator),true) Local_ldlibs+= -LDLElselocal_shared_libraries+=Libdlendiflocal_module:=Libaudiopolicybaseifeq ($ (board_have_bluetooth),true) Local_cflags+= -Dwith_a2dpendififeq ($ (audio_policy_test),true) Local_cflags+= -Daudio_policy_testendifinclude $ (build_static_library) module two compiled into a static library
(3)
include $ (clear_vars) Local_src_files:=Audioflinger.CPPaudiomixer.CPP. Arm Audioresampler.CPP. Arm Audioresamplersinc.CPP. Arm audioresamplercubic.CPP. Arm Audiopolicyservice.CPPlocal_shared_libraries:=libcutils libutils libbinder libmedia libhardware_legacyifeq ($ (Strip $ (board_uses_generic_audio )),true) Local_static_libraries+=libaudiointerface libaudiopolicybase local_cflags+= -Dgeneric_audioElselocal_shared_libraries+=Libaudio libaudiopolicyendififeq ($ (target_simulator),true) Local_ldlibs+= -LDLElselocal_shared_libraries+=Libdlendiflocal_module:=Libaudioflingerifeq ($ (board_have_bluetooth),true) Local_cflags+ =-dwith_bluetooth-DWITH_A2DP local_shared_libraries+=Liba2dpendififeq ($ (audio_policy_test),true) Local_cflags+= -Daudio_policy_testendififeq ($ (target_simulator),true) ifeq ($ (host_os), Linux) Local_ldlibs+ =-LRT-Lpthread endifendififeq ($ (BOARD_USE_LVMX),true) Local_cflags+= -dlvmx local_c_includes+ = vendor/NXP Local_static_libraries+=Liblifevibes local_shared_libraries+=liblvmxservice# local_shared_libraries+=Liblvmxipcendifinclude $ (build_shared_library) module three compiled into a dynamic library
For more android.mk use see : http://blog.csdn.net/fengbingchun/article/details/38705519
two. Compilation Summary:
1. Compile a simple apk (localpackageapk)
Local_path: = $ (call my-dir in the java subdirectorylocal_src_files:= $ (call all-subdir-java-files) # Name of the APK to Buildlocal_package_name:= localpackage# Tell it to build an Apkin Clude $ (build_package)
2. Compiling an apk(localpackage. apk) that relies on static (static-library. jar) files
Local_path: = $ (call my-dir) include $ (clear_vars) in the package Local_ Static_java_libraries:= static-library in the JAVA subdirectory local_src_ FILES:= $ (call all-subdir-java-files) # Name of the APK to build local_package_name:= L Ocalpackage # Tell it to build an APK include $ (build_package)
Note:local_static_java_libraries should be followed by the jar file name of the JAVA library required by your APK program.
3. Compile an apk (localpackage. apk) that requires platform key signature
Local_path: = $ (call my-dir) include $ (clear_vars) in the Java subdirectory local_src_files:= $ (call all-subdir-java-FILES) # Name of the APK to build Local_package_ NAME:= localpackage local_certificate:= Platform # Tell it to build an APK Include $ (build_package)
Note:local_certificate should be followed by the file name of the signature files
4. Compile aAPK (localpackage. apk) that requires special vendor key signature
Local_path: = $ (call my-dir) include $ (clear_vars) in the Java subdirectory local_src_files:= $ (call all-subdir-java-FILES) # Name of the APK to build local_package_name := localpackage local_certificate:= vendor/example/certs/app # Tell it to build an APK include $ (build_package)
5. Load anormal third-party apk (localmodulenameapk)
Local_path: = $ (call my-dir) include $ (clear_vars) # Module name should match apk name to be Installe D. Local_module:= localmodulename local_src_files:= $ (local_module). apk Local_module_ CLASS:= APPS local_module_suffix:= $ (common_android_package_suffix) Local_ CERTIFICATE:= Platform
6. Load the third-party apk that requires. So (Dynamic library)
Local_path: = $ (my-dir) include $ (clear_vars) Local_module:=Baiduinput_android_v1.1_1000elocal_src_files:=$ (local_module). Apklocal_module_class:=Appslocal_module_suffix:=$ (common_android_package_suffix) Local_certificate:=Platforminclude $ (build_prebuilt) ######################################################################## Copy the library to/system/Lib ######################################################################################### #include $ ( Clear_vars) Local_module:=Libinputcore.solocal_module_class:=Shared_librarieslocal_module_path:=$ (target_out_shared_libraries) Local_src_files:= lib/$ (local_module) Override_build_module_path:=$ (target_out_intermediate_libraries) include $ (build_prebuilt)
7. Compiling a static Java library
Local_path: = $ (call my-dir) include $ (clear_vars) in the Java subdirectory local_src_files:= $ (call all-subdir-java-FILES) # Any libraries the This library depends on Local_java_libraries:= android.test.runner file to create local_module: = Sample file. Include $ (build_static_java_library)
Note:local_java_libraries represents the jar file name of the generated JAVA library.
How to compile Android.mk