(1) The android.mk file first needs to specify the Local_path variable to find the source file. As a general case
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 is defined as the directory path of the cost file.
(2) Multiple compilation modules can be defined in Android.mk, and each compilation module starts with include $ (clear_vars)
Ends with include $ (build_xxx).
Include $ (clear_vars)
Clear_vars is provided by the compilation system, specifying that the GNU makefile clear all local_xxx variables except local_path for you,
such as local_module,local_src_files,local_shared_libraries,local_static_libraries and so on.
Include $ (build_static_library) for compiling into a static library
Include $ (build_shared_library) represents compilation into a dynamic library.
Include $ (build_executable) to represent a compiled executable program
(3) When Android compiles, it iterates through the android.mk of all directories, and once found, it stops looking for subdirectories. Need to include subdirectories in the upper Android.mk andriod.mk
Include $ (base_path)/..../android.mk
(4) Examples are as follows (FRAMEWORKS/BASE/LIBS/AUDIOFLINGER/ANDROID.MK):
Local_path:= $ (call My-dir)
Include $ (clear_vars) module A
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 one 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 II compiled into a 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 dynamic library
(5) compiling an application (APK)
Local_path: = $ (call My-dir)
include $ (clear_vars)
# Build all Java files in the Java subdirectory--> literal translation (all Java documents built in a Java subdirectory)
Local_src_files: = $ ( Call all-subdir-java-files)
# Name of the APK to build--> literal translation (create APK name)
LOCA L_package_name: = LocalPackage
Tell it to build a apk--> literal translation (tells it to create a APK)
Include $ (build_package)
(6) Compiling an application that relies on a static Java library (Static.jar)
Local_path: = $ (call My-dir)
include $ (clear_vars)
& NBSP; &NBSP
# 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_FI LES: = $ (call all-subdir-java-files)
# Name of the ' APK to ' build
Local_package _name: = LocalPackage
# Tell it to build a APK
include $ (build_package)
(7) compiling an application that needs to be signed with a platform key
Local_path: = $ (call My-dir)
include $ (clear_vars)
& nbsp
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 a APK
include $ (build_package)
(8) 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)
(9) Adding a precompiled application
Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Module name should match apk name to is installed.
Local_module: = Localmodulename
Local_src_files: = $ (local_module). apk
Local_module_class: = APPS
Local_module_suffix: = $ (Common_android_package_suffix)
Include $ (build_prebuilt)
(10) 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)
(11) In the middle of the Android.mk compilation module, you can define the relevant compilation content, which is to 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 sets this variable when compiling an application (Build_package) in a android.mk file, representing a resource file.
is usually defined as Local_asset_files + = $ (call find-subdir-assets)
Local_built_module_stem
Local_c_includes the additional C + + + + Compilation header file path, using 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 Specifies the C compiler
Local_certificate Signature Certification
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
The header files that need to be replicated when Local_copy_headers install applications must be defined at the same time local_copy_headers_to
Local_copy_headers_to the destination of a header file when install an application
Local_cpp_extension if your C + + file is not in CPP as a 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 passes additional flags to the C + + compiler, such as: Local_cppflags + +-ffriend-injection
LOCAL_CXX Specifies the C + + compiler
Local_dx_flags
Local_export_package_resources
Local_force_static_executable if the compiled executable program is to be statically linked (does not depend on any dynamic libraries at execution time), set the Local_force_static_executable:=true
Currently, only the LIBC has a static library form, which is only used by applications in the/sbin directory in the file system, and the applications under this directory are usually
Other parts of the file system have not yet been loaded, so static links 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
Local_java_libraries Java applications and libraries are compiled by specifying the included Java class Library, which currently has two kinds of 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 APK (the system is automatically added)
Local_java_resource_dirs
Local_java_resource_files
Local_jni_shared_libraries
Local_ldflags Pass additional parameters to the connector (be sure to note the order of the parameters)
LOCAL_LDLIBS specifies additional libraries for executables or library compilation, specifying libraries in "-LXXX" format, for example:
Local_ldlibs + +-lcurses-lpthread
Local_ldlibs + +-wl,-z,origin
Local_module the name of the module generated (note that the application name is Local_package_name instead of Local_module)
Path to the Local_module_path build module
Local_module_stem
Local_module_tags the markup for the build module
Local_no_default_compiler_flags
Local_no_emma_compile
Local_no_emma_instrument
Local_no_standard_libraries
Local_overrides_packages
Name of the Local_package_name apk application
Local_post_process_command
Local_prebuilt_executables to precompile including $ (build_prebuilt) or $ (build_host_prebuilt), specify the executable files that need to be replicated
Local_prebuilt_java_libraries
Local_prebuilt_libs to precompile including $ (build_prebuilt) or $ (build_host_prebuilt), specify the libraries that need to be replicated.
Local_prebuilt_obj_files
Local_prebuilt_static_java_libraries
Local_prelink_module whether pre-join processing is required (default required for dynamic library optimization)
Local_required_modules specifies the module on which the module is to run (the modules it relies on will be installed synchronously when the module is installed)
Local_resource_dir
Local_sdk_version
Local_shared_libraries can link dynamic libraries
Local_src_files Compiling source files
Local_static_java_libraries
Local_static_libraries links to Static libraries
Local_uninstallable_module
The
Local_unstripped_path
local_whole_static_libraries (full link) specifies the complete static library that the module needs to load ( These static libraries do not allow the linker to delete unwanted code in the link:
local_yaccflags
Override_built_module_path