(1) The android.mk file first needs to specify the Local_path variable, which is used to locate the source file. As a general rule
The android.mk and the source files that need to be compiled are in the same directory, so they are defined as follows:
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) Multiple compilation modules can be defined in Android.mk, with each compiled module starting with the include $ (clear_vars)
End with 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 and so on.
Include $ (build_static_library) to compile into a static library
The include $ (build_shared_library) represents the compilation into a dynamic library.
Include $ (build_executable) to compile into executable program
(3) Examples are as follows (FRAMEWORKS/BASE/LIBS/AUDIOFLINGER/ANDROID.MK):
Local_path:= $ (call My-dir)
Include $ (clear_vars) module one
Ifeq ($ (audio_policy_test), true)
Enable_audio_dump: = True
endif
local_src_files:= \
AudioHardwareGeneric.cpp \
AudioHardwareStub.cpp \
AudioHardwareInterface.cpp
Ifeq ($ (enable_audio_dump), true)
Local_src_files + = AudioDumpInterface.cpp
Local_cflags + =-denable_audio_dump
endif
Local_shared_libraries: = \
Libcutils \
Libutils \
Libbinder \
Libmedia \
Libhardware_legacy
Ifeq ($ (Strip $ (Board_uses_generic_audio)), true)
Local_cflags + =-dgeneric_audio
endif
local_module:= Libaudiointerface
Ifeq ($ (Board_have_bluetooth), true)
Local_src_files + = A2dpAudioInterface.cpp
Local_shared_libraries + = LIBA2DP
Local_cflags + =-DWITH_BLUETOOTH-DWITH_A2DP
Local_c_includes + = $ (call include-path-for, BlueZ)
endif
Include $ (build_static_library) module compiled into a static library
Include $ (clear_vars) module two
local_src_files:= \
AudioPolicyManagerBase.cpp
Local_shared_libraries: = \
Libcutils \
Libutils \
Libmedia
Ifeq ($ (target_simulator), true)
Local_ldlibs + =-ldl
Else
Local_shared_libraries + = LIBDL
endif
local_module:= Libaudiopolicybase
Ifeq ($ (Board_have_bluetooth), true)
Local_cflags + =-DWITH_A2DP
endif
Ifeq ($ (audio_policy_test), true)
Local_cflags + =-daudio_policy_test
endif
Include $ (build_static_library) module two compiled into static library
Include $ (clear_vars) module three
local_src_files:= \
AudioFlinger.cpp \
AudioMixer.cpp.arm \
AudioResampler.cpp.arm \
AudioResamplerSinc.cpp.arm \
AudioResamplerCubic.cpp.arm \
AudioPolicyService.cpp
Local_shared_libraries: = \
Libcutils \
Libutils \
Libbinder \
Libmedia \
Libhardware_legacy
Ifeq ($ (Strip $ (Board_uses_generic_audio)), true)
Local_static_libraries + = Libaudiointerface libaudiopolicybase
Local_cflags + =-dgeneric_audio
Else
Local_shared_libraries + = Libaudio libaudiopolicy
endif
Ifeq ($ (target_simulator), true)
Local_ldlibs + =-ldl
Else
Local_shared_libraries + = LIBDL
endif
local_module:= Libaudioflinger
Ifeq ($ (Board_have_bluetooth), true)
Local_cflags + =-DWITH_BLUETOOTH-DWITH_A2DP
Local_shared_libraries + = LIBA2DP
endif
Ifeq ($ (audio_policy_test), true)
Local_cflags + =-daudio_policy_test
endif
Ifeq ($ (target_simulator), true)
Ifeq ($ (host_os), Linux)
Local_ldlibs + =-lrt-lpthread
endif
endif
Ifeq ($ (BOARD_USE_LVMX), true)
Local_cflags + =-dlvmx
Local_c_includes + = Vendor/nxp
Local_static_libraries + = Liblifevibes
Local_shared_libraries + = Liblvmxservice
# Local_shared_libraries + = LIBLVMXIPC
endif
Include $ (build_shared_library) module three compiled into a dynamic library
(4) compiling an application (APK)
Local_path: = $ (call My-dir)
include $ (clear_vars)
# Build All Java files in the Java subdirectory--> literal translation ( build java file)
Local_src_files: = $ (call all-subdir-java-files)
# Name of the APK to build--> literal translation (name of the apk created)
Local_ Package_name: = LocalPackage
# Tell it to build a apk--> literal translation ( tell it to create a Span title= "Click to show other translations" >apk)
include $ (build_package)
(5) Compiling an application that relies on a static Java library (Static.jar)
Local_path: = $ (call My-dir)
include $ (clear_vars)
# List of static libraries to include in the package
Local_static_java_libraries: = Static-library
# Build All Java files in the Java subdirectory
Local_src_files : = $ (call all-subdir-java-files)
# Name of the APK to build
Local_package_name : = LocalPackage
# Tell it to build an APK
include $ (build_package)
(6) Compile an application that requires a platform key signature
Local_path: = $ (call My-dir)
include $ (clear_vars)
# Build All Java files in the Java subdirectory
Local_src_files: = $ (Call All-subdir-java-files
# Name of the APK to build
local_package_name: = LocalPackage
 &NBSP
Local_certificate: = Platform
# Tell it to build an APK
Include $ (build_package)
(7) Compiling an application that needs to be preceded by a specific key
Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Build All Java files 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)
(8) Add a precompiled application
Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Module name should match apk name to be installed.
Local_module: = Localmodulename
Local_src_files: = $ (local_module). apk
Local_module_class: = APPS
Local_module_suffix: = $ (Common_android_package_suffix)
Include $ (build_prebuilt)
(9) Add a static Java library
Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Build All Java files 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
# The name of the jar file to create
Local_module: = sample
# Build a static jar file.
Include $ (build_static_java_library)
(10) In the middle of the android.mk compile module, you can define the relevant compilation content, that is, specify the relevant variables as follows:
Local_aapt_flags
Local_acp_unavailable
Local_additional_java_dir
Local_aidl_includes
Local_allow_undefined_symbols
Local_arm_mode
Local_asflags
Local_asset_dir
Local_asset_files set this variable when compiling the application (build_package) in the Android.mk file, representing the resource file,
Typically defined as Local_asset_files + = $ (call find-subdir-assets)
Local_built_module_stem
Local_c_includes an additional C + + compiler header file path with Local_path to indicate the directory in which this file resides
Examples are as follows:
Local_c_includes + = extlibs/zlib-1.2.3
Local_c_includes + = $ (local_path)/src
LOCAL_CC specifying the C compiler
Local_certificate Signature Authentication
Local_cflags defines additional flags (such as macro definitions) for the C + + compiler, for example: Local_cflags + =-dlibutils_native=1
Local_classpath
Local_compress_module_symbols
Local_copy_headers the header file that needs to be copied when you install the application, you must also define Local_copy_headers_to
Local_copy_headers_to the destination path of the header file when the install application is installed
Local_cpp_extension if your C + + file does not have CPP as the file suffix, you can specify the C + + file suffix name by local_cpp_extension
such as: local_cpp_extension: =. cc
Note the C + + file suffixes in the Unified module must be consistent.
Local_cppflags Pass additional flags to the C + + compiler, such as: Local_cppflags + =-ffriend-injection
Local_cxx specifying the C + + compiler
Local_dx_flags
Local_export_package_resources
Local_force_static_executable if the compiled executable is to be statically linked (execution is not dependent on any dynamic libraries), the local_force_static_executable:=true is set
Currently only LIBC has a static library form, which is only used by applications under the/sbin directory in the file system, and the applications in this directory are usually run
Other parts of the filesystem have not yet been loaded, so a static link must be made.
Local_generated_sources
Local_instrumentation_for
Local_instrumentation_for_package_name
Local_intermediate_sources
Local_intermediate_targets
Local_is_host_module
Local_jar_manifest
Local_jarjar_rules
When compiling Java applications and libraries, local_java_libraries specifies the included Java class Library, which currently has two core and framework
In most cases it is defined as: local_java_libraries: = Core Framework
Note that local_java_libraries is not required and is not allowed to be defined when compiling the APK (the system will automatically add)
Local_java_resource_dirs
Local_java_resource_files
Local_jni_shared_libraries
Local_ldflags passing additional parameters to the connector (be sure to note the order of the parameters)
LOCAL_LDLIBS specifies an additional library for the compilation of an executable or library, specifying that the library is in "-lxxx" format, for example:
Local_ldlibs + =-lcurses-lpthread
Local_ldlibs + =-wl,-z,origin
Local_module the name of the generated module (note that the application name is Local_package_name instead of Local_module)
Local_module_path path of the build module
Local_module_stem
Local_module_tags markup for generating modules
Local_no_default_compiler_flags
Local_no_emma_compile
Local_no_emma_instrument
Local_no_standard_libraries
Local_overrides_packages
Local_package_name apk app Name
Local_post_process_command
Local_prebuilt_executables precompiled including $ (build_prebuilt) or $ (build_host_prebuilt), specify the executables that need to be copied
Local_prebuilt_java_libraries
Local_prebuilt_libs precompiled including $ (build_prebuilt) or $ (build_host_prebuilt), specify the libraries that need to be copied.
Local_prebuilt_obj_files
Local_prebuilt_static_java_libraries
Local_prelink_module whether pre-connection processing is required (default, used for dynamic library optimization)
Local_required_modules specifies the module on which the module is to be run (the module on which it depends will be installed synchronously during module installation)
Local_resource_dir
Local_sdk_version
Local_shared_libraries can link dynamic library
Local_src_files Compiling source files
Local_static_java_libraries
Local_static_libraries can link static library
Local_uninstallable_module
Local_unstripped_path
local_whole_static_libraries Specifies the full static library that the module needs to load (these masters are not allowed to delete the useless code in the link)
Local_yaccflags
Override_built_module_path
The makefile file of the Android compilation system android.mk the following notation