Android makefile (android. mk) analysis (sequence)

Source: Internet
Author: User

 

Android has been sought after by many people since its open source. Of course, one person is pursuing it because it was developed by Google. For a programmer, the value of a system is not worth mentioning. I am not going to analyze the android code here, but the android makefile. I want to tell you how to write the makefile by analyzing the andorid makefile.

For new programmers, good IDE is the target of their pursuit. However, when there is more code, he will gradually find that the IDE is not enough, because there are a lot of things that IDE is not good at, such as automatic compilation, testing, version control, compilation customization. This is a bit like a political saying: capitalism started to promote productivity development, but later it became a factor hindering productivity development. If a program cannot get rid of IDE restrictions (not unnecessary, but selective), it will be difficult to improve. You must know that IDE and makefile represent two different ideas: IDE emphasizes simplifying the interaction between computers and users, while makefile reflects automation.

Makefile may be easier to learn for a person who has been familiar with linux since the very beginning (practice makes perfect). For a person who has been familiar with Windows since the very beginning, makefile is hard to learn, this is mainly because Visual Studio is often used unconsciously (Visual Studio is a good thing, especially its debugging ). I don't know whether it feels like shouting: if a person first contacts c and then java, it will be easier; if a person first contacts java and then c, it will be more disgusted with c.

Here are some of the makefile descriptions provided by Baidu Encyclopedia:

The source files in a project are not counted. They are stored in several directories by type, function, and module. makefile defines a series of rules to specify which files need to be compiled first, which files need post-compilation, which need to be re-compiled, or even perform more complex functional operations, because makefile is like a Shell script and can also execute operating system commands.

The benefit of makefile is "automatic compilation". Once written, only one make command is required, and the entire project is fully automatically compiled, which greatly improves the efficiency of software development. Make is a command tool that explains commands in makefile. Generally, most ides use this command, such as make in Delphi and nmake in Visual C ++, GNU make in Linux. It can be seen that makefile is a compilation method in Engineering.

The most important and basic function of the Make tool is to use the makefile file to describe the relationship between source programs and automatically maintain the compilation work. The makefile file needs to be compiled according to a certain syntax. The file must describe how to compile each source file and generate an executable file, and define the dependency between the source files. Makefile is a common method for many compilers-including compilers in Windows NT-to maintain compilation information. It is only possible for users to modify makefile files on a friendly interface in the integrated development environment.

For android, android uses GNU make, so its makefile format is also the GNU makefile format. The best makefile document on the network is "write makefile With Me" by Chen Hao. This document provides a detailed introduction to makefile, therefore, we recommend that you read this document first (the electronic version can be used in the workshop ).

The top-level directory structure of android is as follows:

.
| -- Makefile (Global Makefile)
| -- Bionic)
| -- Bootloader)
| -- Build (the content in the build directory is not the code used by the target, but the scripts and tools required for compilation and configuration)
| -- Dalvik (Java Virtual Machine)
| -- Development (templates and tools required for Program development)
| -- External (some libraries used by the target machine)
| -- Frameworks (framework layer of the Application)
| -- Hardware (hardware-related Library)
| -- Kernel (source code of Linux2.6)
| -- Packages (various Android applications)
| -- Prebuilt (preset scripts compiled by Android on various platforms)
| -- Recovery (related to the recovery function of the target)
'-- System (some underlying libraries of Android)

This article will analyze makefile and shell files under the build directory. The android code is version 1.5.

The main directory structure is as follows:

1. Get started with makefile

1.1 makefile helloworld

1.2 use makefile to build a cross-compiling environment

1.3 techniques in makefile

2. android makefile Analysis

2.1 android shell Analysis

2.2 makefile Analysis in android build

3. android. mk Analysis in other android Directories

As graduate students are about to graduate and have to look for a job, the analysis may take a day or two. I hope you will understand.

As the final part of the sequence, let's take a look at the makefile of andoroid through some articles on the network.

1. Android build system

2. Android Building System Analysis

3. Android Build System (Introduction)

4. http://source.android.com/porting/build_cookbook.html

Reprint android makefile (android. mk) analysis (sequence)-Xu Fan's blog-CSDN blog

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.