0.build-android
#!/bin/bash
if [ ! -e "./jdk1.6.0_23" ]; then
tar xzf jdk1.6.0_23.tar.gz
fi
export PATH=$PWD/jdk1.6.0_23/bin:$PATH
. setenv
#make -j$CPU_JOB_NUM || exit 1
make || exit 0
if [ ! -e "./jdk1.6.0_23" ]; then
tar xzf jdk1.6.0_23.tar.gz
fi
export PATH=$PWD/jdk1.6.0_23/bin:$PATH
. setenv
#make -j$CPU_JOB_NUM || exit 1
make || exit 0
1.主makefile
include build/core/main.mk
2.build/core/main.mk
subdir_makefiles := \
$(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
ifeq ($(SDK_ONLY),true)
# ----- SDK for Windows ------
# These configure the build targets that are available for the SDK under Windows.
# The first section defines all the C/C++ tools that can be compiled in C/C++,
# the second section defines all the Java ones (assuming javac is available.)
subdirs := \
prebuilt \
build/libs/host \
build/tools/zipalign \
dalvik/dexdump \
dalvik/libdex \
dalvik/tools/dmtracedump \
dalvik/tools/hprof-conv \
development/tools/line_endings \
development/tools/etc1tool \
sdk/emulator/mksdcard \
sdk/sdklauncher \
development/host \
external/expat \
external/libpng \
external/qemu \
external/sqlite/dist \
external/zlib \
frameworks/base \
system/core/adb \
system/core/fastboot \
system/core/libcutils \
system/core/liblog \
system/core/libzipfile
# The following can only be built if "javac" is available.
# This check is used when building parts of the SDK under Cygwin.
ifneq (,$(shell which javac 2>/dev/null))
subdirs += \
build/tools/signapk \
dalvik/dx \
libcore \
sdk/archquery \
sdk/androidprefs \
sdk/apkbuilder \
sdk/jarutils \
sdk/layoutlib_api \
sdk/layoutlib_utils \
sdk/ninepatch \
sdk/sdkstats \
sdk/sdkmanager \
sdk/layoutopt \
development/apps \
development/tools/mkstubs \
packages
else
$(warning SDK_ONLY: javac not available.)
endif
# Exclude tools/acp when cross-compiling windows under linux
ifeq ($(findstring Linux,$(UNAME)),)
subdirs += build/tools/acp
endif
else # !SDK_ONLY
ifeq ($(BUILD_TINY_ANDROID), true)
# TINY_ANDROID is a super-minimal build configuration, handy for board
# bringup and very low level debugging
subdirs := \
bionic \
system/core \
system/extras/ext4_utils \
system/extras/su \
build/libs \
build/target \
build/tools/acp \
build/tools/apriori \
build/tools/kcm \
build/tools/soslim \
external/elfcopy \
external/elfutils \
external/yaffs2 \
external/zlib
else # !BUILD_TINY_ANDROID
#
# Typical build; include any Android.mk files we can find.
#
subdirs := $(TOP)
FULL_BUILD := true
endif # !BUILD_TINY_ANDROID
endif # !SDK_ONLY
其中几个定义:
TOP := .
TOPDIR :=
BUILD_SYSTEM := $(TOPDIR)build/core
$(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
ifeq ($(SDK_ONLY),true)
# ----- SDK for Windows ------
# These configure the build targets that are available for the SDK under Windows.
# The first section defines all the C/C++ tools that can be compiled in C/C++,
# the second section defines all the Java ones (assuming javac is available.)
subdirs := \
prebuilt \
build/libs/host \
build/tools/zipalign \
dalvik/dexdump \
dalvik/libdex \
dalvik/tools/dmtracedump \
dalvik/tools/hprof-conv \
development/tools/line_endings \
development/tools/etc1tool \
sdk/emulator/mksdcard \
sdk/sdklauncher \
development/host \
external/expat \
external/libpng \
external/qemu \
external/sqlite/dist \
external/zlib \
frameworks/base \
system/core/adb \
system/core/fastboot \
system/core/libcutils \
system/core/liblog \
system/core/libzipfile
# The following can only be built if "javac" is available.
# This check is used when building parts of the SDK under Cygwin.
ifneq (,$(shell which javac 2>/dev/null))
subdirs += \
build/tools/signapk \
dalvik/dx \
libcore \
sdk/archquery \
sdk/androidprefs \
sdk/apkbuilder \
sdk/jarutils \
sdk/layoutlib_api \
sdk/layoutlib_utils \
sdk/ninepatch \
sdk/sdkstats \
sdk/sdkmanager \
sdk/layoutopt \
development/apps \
development/tools/mkstubs \
packages
else
$(warning SDK_ONLY: javac not available.)
endif
# Exclude tools/acp when cross-compiling windows under linux
ifeq ($(findstring Linux,$(UNAME)),)
subdirs += build/tools/acp
endif
else # !SDK_ONLY
ifeq ($(BUILD_TINY_ANDROID), true)
# TINY_ANDROID is a super-minimal build configuration, handy for board
# bringup and very low level debugging
subdirs := \
bionic \
system/core \
system/extras/ext4_utils \
system/extras/su \
build/libs \
build/target \
build/tools/acp \
build/tools/apriori \
build/tools/kcm \
build/tools/soslim \
external/elfcopy \
external/elfutils \
external/yaffs2 \
external/zlib
else # !BUILD_TINY_ANDROID
#
# Typical build; include any Android.mk files we can find.
#
subdirs := $(TOP)
FULL_BUILD := true
endif # !BUILD_TINY_ANDROID
endif # !SDK_ONLY
其中几个定义:
TOP := .
TOPDIR :=
BUILD_SYSTEM := $(TOPDIR)build/core
我们取 非SDK_ONLY来分析
3.build/tools/findleaves.py
中调用os.walk遍历工程目录
http://www.2cto.com/kf/201108/101784.html
4.include其他文件的顺序:
# Set up various standard variables based on configuration
# and host information.
include $(BUILD_SYSTEM)/config.mk
# This allows us to force a clean build - included after the config.make
# environment setup is done, but before we generate any dependencies. This
# file does the rm -rf inline so the deps which are all done below will
# be generated correctly
include $(BUILD_SYSTEM)/cleanbuild.mk
VERSION_CHECK_SEQUENCE_NUMBER := 2
-include $(OUT_DIR)/versions_checked.mk
ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
$(info Checking build tools versions...)
# Bring in standard build system definitions.
include $(BUILD_SYSTEM)/definitions.mk
# Bring in dex_preopt.mk
include $(BUILD_SYSTEM)/dex_preopt.mk
# Can't use first-makefiles-under here because
# --mindepth=2 makes the prunes not work.
subdir_makefiles := \
$(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
include $(subdir_makefiles)
# -------------------------------------------------------------------
# Include any makefiles that must happen after the module makefiles
# have been included.
# TODO: have these files register themselves via a global var rather
# than hard-coding the list here.
ifdef FULL_BUILD
# Only include this during a full build, otherwise we can't be
# guaranteed that any policies were included.
-include frameworks/policies/base/PolicyConfig.mk
endif
include $(BUILD_SYSTEM)/Makefile
# and host information.
include $(BUILD_SYSTEM)/config.mk
# This allows us to force a clean build - included after the config.make
# environment setup is done, but before we generate any dependencies. This
# file does the rm -rf inline so the deps which are all done below will
# be generated correctly
include $(BUILD_SYSTEM)/cleanbuild.mk
VERSION_CHECK_SEQUENCE_NUMBER := 2
-include $(OUT_DIR)/versions_checked.mk
ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
$(info Checking build tools versions...)
# Bring in standard build system definitions.
include $(BUILD_SYSTEM)/definitions.mk
# Bring in dex_preopt.mk
include $(BUILD_SYSTEM)/dex_preopt.mk
# Can't use first-makefiles-under here because
# --mindepth=2 makes the prunes not work.
subdir_makefiles := \
$(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
include $(subdir_makefiles)
# -------------------------------------------------------------------
# Include any makefiles that must happen after the module makefiles
# have been included.
# TODO: have these files register themselves via a global var rather
# than hard-coding the list here.
ifdef FULL_BUILD
# Only include this during a full build, otherwise we can't be
# guaranteed that any policies were included.
-include frameworks/policies/base/PolicyConfig.mk
endif
include $(BUILD_SYSTEM)/Makefile
(待续)