In Layman's Android Makefile (1)--Preliminary discussion (reprint)

Source: Internet
Author: User

Reprint: http://nfer-zhuang.iteye.com/blog/1752368

  

I. Description
Android build system is a very large systems, to compile Android engineering, modify or add the Android module will need to have a certain understanding of this compilation system. But because it is too large, we often do not know where to cut into the Android compiler system for a systematic study.

Below we are trying to step through the Android build system from a small module to an in-depth analysis. The selected module is named ACP and the source code is located in the BUILD\TOOLS\ACP directory.

Subsequent compilation of many modules need to be used to the ACP, according to the compilation of the general will be compiled this module first. Of course it also needs to be dependent on other files, which we will elaborate when needed.

On the android.mk of ACP
The android.mk of the ACP is relatively simple, stripped of the useless code, as shown below:

Makefile Code

    Local_path:= $ (call my-dir)      include $ (clear_vars)            local_src_files:= acp.c            local_static_ LIBRARIES:= libhost      local_c_includes:= build/libs/host/include      local_module:= ACP      Local_acp_unavailable:true            include $ (build_host_executable)   

The above statement roughly means that using the ACP.C source code under the current path, the referenced include and linked libraries are host modules, and the final compilation generates an executable file that can be run on the current host, named ACP (Linux Environment).
Here we do not talk about the specific meaning and use of each variable, we will first look at a android.mk of the basic composition.

Iii. Basic composition of android.mk

    1. Local_path defines the relative path of the current module, which must appear before all the compiled modules
    2. Each compilation module starts with the include $ (clear_vars) and ends with the include $ (build_xxx)
    3. Include $ (clear_vars) is the beginning of a compilation module that empties all loca_xxx variables except Local_path
    4. Include $ (build_xxx) describes the compilation target
    5. local_src_files defines the source files used for compiling this module, using a relative path based on Local_path
    6. local_module defines the module name for this module

There are several optional variables required to compile the ACP:

    • Local_static_libraries represents a static library that needs to be linked when compiling this module
    • Local_c_includes represents the include file that this module needs to reference
    • Local_acp_unavailable indicates if ACP is supported, if ACP is supported, copy with ACP, otherwise use Linux CP Copy, this module compiles ACP, of course, ACP is not supported.

Iv. compilation target

Above we use the Include$ (clear_vars) and include $ (build_host_executable), then where are they defined? What other build_xxx goals are there besides build_host_executable? They are defined in the Build/core/config.mk file, and of course the Config.mk file defines a lot of compilation targets, here are a few common goals:
Compile target Description
Build_host_static_library Static libraries on the host
Build_host_shared_library Dynamic libraries on the host
Build_host_executable Executable files on the host
Build_static_library Static libraries on the target device
Build_shared_library Dynamic libraries on the target device
Build_executable Executable file on target device
Build_java_library Java Library
Build_static_java_library Static Java libraries
Build_host_java_library Java libraries on the host
Build_package APK program
Each of the specific goals, and so on when we meet, we will explain in detail.

In Layman's Android Makefile (1)--Preliminary discussion (reprint)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.