zoukankan      html  css  js  c++  java
  • 编译cubieboard android 源码过程详解之(五):make

    前期准备终于做完了,设置好了环境变量,提供了所需的函数,相关文件也已经到位,所有这一且都是为了最终的make。

    首先是Makefile的包含关系:

    Makefile

    build/core/main.mk

    build/core/help.mk

    build/core/config.mk

    build/core/pathmap.mk

    buildspec.mk

    device/softwinner/apollo-cubieboard/BoardConfig.mk

    device/softwinner/crane-common/BoardConfigCommon.mk

    build/core/combo/select.mk

    build/core/combo/HOST_linux-x86.mk

    build/core/combo/TARGET_linux-arm.mk

    build/core/combo/javac.mk

    build/core/dumpvar.mk

    build/core/cleanbuild.mk

    很多和 clean 相关的 Makefile,这里不再列出

     

    out/versions_checked.mk

     

    发现我错了,这简直是个无底洞啊,后面分析的时候有些Makefile就不展开了或是只局部分析。想到用脚本来打印这个列表的,但是发现include Makefile时,有些路径包含变量,不得不放弃了。 其实我更关心的是和硬件相关的Makefile。

     

    make命令是在 “android” 目录下执行的,依照make的用法,在该目录下找到 Makefile 文件:

    Makefile

    1 ### DO NOT EDIT THIS FILE ###
    2 include build/core/main.mk
    3 ### DO NOT EDIT THIS FILE ###

    只有一行有效语句,就是包含了 “build/core/main.mk” 文件,顺藤摸瓜:

    build/core/main.mk

     1 # Only use ANDROID_BUILD_SHELL to wrap around bash.
     2 # DO NOT use other shells such as zsh.
     3 ifdef ANDROID_BUILD_SHELL
     4 SHELL := $(ANDROID_BUILD_SHELL)
     5 else
     6 # Use bash, not whatever shell somebody has installed as /bin/sh
     7 # This is repeated in config.mk, since envsetup.sh runs that file
     8 # directly.
     9 SHELL := /bin/bash
    10 endif

    对shell类型有严格的限制,只能用 “$(ANDROID_BUILD_SHELL)” 或 “bash”,这样可以避免一些兼容性问题。

    build/core/main.mk

    1 # this turns off the suffix rules built into make
    2 .SUFFIXES:
    3 
    4 # this turns off the RCS / SCCS implicit rules of GNU Make
    5 % : RCS/%,v
    6 % : RCS/%
    7 % : %,v
    8 % : s.%
    9 % : SCCS/s.%

    见注释,关闭一些规则,但现在还没弄懂(TODO)。

    build/core/main.mk

    1 # If a rule fails, delete $@.
    2 .DELETE_ON_ERROR:

    如果规则的命令执行错误,将删除已经被修改的目标文件。

    build/core/main.mk

     1 # check for broken versions of make
     2 ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9.].*//") = 3.81)) #只能使用make 3.81
     3 $(warning ********************************************************************************)
     4 $(warning *  You are using version $(MAKE_VERSION) of make.)
     5 $(warning *  Android can only be built by version 3.81.)
     6 $(warning *  see http://source.android.com/source/download.html)
     7 $(warning ********************************************************************************)
     8 $(error stopping)
     9 endif
    10 
    11 TOP := .
    12 TOPDIR :=
    13 
    14 BUILD_SYSTEM := $(TOPDIR)build/core

    build/core/main.mk

    1 # This is the default target.  It must be the first declared target.
    2 .PHONY: droid
    3 DEFAULT_GOAL := droid
    4 $(DEFAULT_GOAL):
    5 
    6 # Used to force goals to build.  Only use for conditionally defined goals.
    7 .PHONY: FORCE
    8 FORCE:

    默认目标为 “droid”,没有什么依赖,直接执行下面的命令。

    build/core/main.mk

    1 # Targets that provide quick help on the build system.
    2 include $(BUILD_SYSTEM)/help.mk

    build/core/help.mk

     1 ifeq ($(MAKECMDGOALS),help)
     2 dont_bother := true
     3 endif
     4 ifeq ($(MAKECMDGOALS),out)
     5 dont_bother := true
     6 endif
     7 
     8 .PHONY: help
     9 help:
    10     @echo
    11     @echo "Common make targets:"
    12     @echo "----------------------------------------------------------------------------------"
    13     @echo "droid                   Default target"
    14     @echo "clean                   (aka clobber) equivalent to rm -rf out/"
    15     @echo "snod                    Quickly rebuild the system image from built packages"
    16     @echo "offline-sdk-docs        Generate the HTML for the developer SDK docs"
    17     @echo "doc-comment-check-docs  Check HTML doc links & validity, without generating HTML"
    18     @echo "libandroid_runtime      All the JNI framework stuff"
    19     @echo "framework               All the java framework stuff"
    20     @echo "services                The system server (Java) and friends"
    21     @echo "help                    You're reading it right now"
    22 
    23 .PHONY: out
    24 out:
    25     @echo "I'm sure you're nice and all, but no thanks."

    提供一些帮助。当然这个目标不手动调用是不会执行的,这里不做分析。

    build/core/main.mk

    1 # Set up various standard variables based on configuration
    2 # and host information.
    3 include $(BUILD_SYSTEM)/config.mk
  • 相关阅读:
    237. Delete Node in a Linked List
    430. Flatten a Multilevel Doubly Linked List
    707. Design Linked List
    83. Remove Duplicates from Sorted List
    160. Intersection of Two Linked Lists
    426. Convert Binary Search Tree to Sorted Doubly Linked List
    142. Linked List Cycle II
    类之间的关系
    初始化块
    明确类和对象
  • 原文地址:https://www.cnblogs.com/JonnyLulu/p/3573547.html
Copyright © 2011-2022 走看看