Android编译系统主要有三种方式:
1.编译整个Android系统
cd /YOUR_Android_Root/ -->进入android工程目录
source build/envsetup.sh -->设置编译环境
make bigfish -j2 -->完整编译
2.编译子系统
mm -->当前目录下要有Android.mk文件
mmm subsystem/ -->subsystem文件夹下要有Android.mk文件
make libbz
3.编译sdk
make sdk
Android.mk文件分析:
packages/apps/Music/Android.mk
LOCAL_PATH:= $(call my-dir) #宏函数’my-dir’, 由编译系统提供,用于返回当前路径(即包含Android.mk file文件的目录)
include $(CLEAR_VARS) #CLEAR_VARS由编译系统提供,指定让GNU MAKEFILE为你清除许多LOCAL_XXX变量(例如 LOCAL_MODULE, LOCAL_SRC_FILES, LOCAL_STATIC_LIBRARIES, 等等...),除了LOCAL_PATH。
LOCAL_MODULE_TAGS := optional #指定当前子项目所属的标签,user eng userdebug optional
ifdef DOLBY_DAP #宏是否定义
LOCAL_JAVA_LIBRARIES += framework_ext
else
LOCAL_STATIC_JAVA_LIBRARIES := libmds
endif #DOLBY_DAP
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
src/com/android/music/IMediaPlaybackService.aidl #编译所需源文件
LOCAL_PACKAGE_NAME := Music #编译APK文件的文件名
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE) #编译成APK文件
ifndef DOLBY_DAP
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libmds:ds.jar #添加预编译所需java静态库
include $(BUILD_MULTI_PREBUILT)
endif
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH)) #调用子目录下的makefile文件即Android.mk
Android补充说明http://www.ibm.com/developerworks/cn/opensource/os-cn-android-build/
build/core/config.mk中定义include $(BUILD_***)
CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk
BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk