编译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.mk3 ### 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/bash10 endif
对shell类型有严格的限制,只能用 “$(ANDROID_BUILD_SHELL)” 或 “bash”,这样可以避免一些兼容性问题。
build/core/main.mk
1 # this turns off the suffix rules built into make2 .SUFFIXES:3 4 # this turns off the RCS / SCCS implicit rules of GNU Make5 % : RCS/%,v6 % : RCS/%7 % : %,v8 % : 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 endif10 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: droid3 DEFAULT_GOAL := droid4 $(DEFAULT_GOAL):5 6 # Used to force goals to build. Only use for conditionally defined goals.7 .PHONY: FORCE8 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 @echo11 @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: out24 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 configuration2 # and host information.3 include $(BUILD_SYSTEM)/config.mk
更多相关文章
- android Intent练习
- 关于使用InputStreamReader读取GBK编码文件乱码的问题
- 第75章、再识Intent-调用发送Email程序(从零开始学Android)
- Android(安卓)studio升级3.0.1遇到的坑及Android(安卓)Studio 3.
- Android之NDK开发 Android(安卓)studio 篇
- mac 平台下编译android版本 ffmpeg+h264
- CyanogenMod源码下载及在模拟器上刷机
- is 32-bit instead of 64-bit动态库错误分析
- Android项目清单文件