参数“-j“ 和”–jobs ”指定了同时编译的线程数量,通常是编译主机 CPU 支持的并发线程总数的 1 倍或 2 倍(如:在一个 4 核,每个核支持两个线程的 CPU 上,可以使用 make -j8 或 make -j16)。在调用 make 命令时,如果没有指定任何目标,则将编译默认目标“droid”(下面详解),然后将会编译出完整的 Android 系统镜像。
include $(BUILD_SYSTEM)/envsetup.mk #定义全局变量、用户特殊编译配置等 ,下详解 # Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE) # or under vendor/*/$(TARGET_DEVICE). Search in both places, but # make sure only one exists. # Real boards should always be associated with an OEM vendor. #在$(SRC_TARGET_DIR)/board/$(TARGET_DEVICE) 或vendor/*/$(TARGET_DEVICE)中搜索BoardConfig.mk文件,但两个路径中只能存在一个mk文件 board_config_mk := \ $(strip $(wildcard \ $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \ $(shell test -d device && find device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \ $(shell test -d vendor && find vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \ )) ifeq ($(board_config_mk),) $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE)) endif ifneq ($(words $(board_config_mk)),1) $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk)) endif include $(board_config_mk) ifeq ($(TARGET_ARCH),) $(error TARGET_ARCH not defined by board config: $(board_config_mk)) endif TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk))) board_config_mk :=
# The product defaults to generic on hardware # NOTE: This will be overridden in product_config.mk if make # was invoked with a PRODUCT-xxx-yyy goal. ifeq ($(TARGET_PRODUCT),) TARGET_PRODUCT := full endif
# the variant -- the set of files that are included for a build ifeq ($(strip $(TARGET_BUILD_VARIANT)),) TARGET_BUILD_VARIANT := eng endif ... # Read the product specs so we an get TARGET_DEVICE and other # variables that we need in order to locate the output files. include $(BUILD_SYSTEM)/product_config.mk ... # 指定编译文件输出路径 ifeq (,$(strip $(OUT_DIR))) ifeq (,$(strip $(OUT_DIR_COMMON_BASE))) OUT_DIR := $(TOPDIR)out else OUT_DIR := $(OUT_DIR_COMMON_BASE)/$(notdir $(PWD)) endif endif DEBUG_OUT_DIR := $(OUT_DIR)/debug PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE) TARGET_OUT_JAVA_LIBRARIES:= $(TARGET_OUT)/framework TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM) TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
# include $(BUILD_SYSTEM)/node_fns.mk include $(BUILD_SYSTEM)/product.mk include $(BUILD_SYSTEM)/device.mk ... # Import all product makefiles. $(call import-products, $(all_product_makefiles)) # 找到并导入所有Makefile # Import all or just the current product makefile $(call import-products, $(current_product_makefile)) # 找到并导入当前产品的Makefile $(check-all-products) # 完整性检查 ... # 调用resolve-short-product-name函数,返回TARGET_PRODUCT的配置文件目录 INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT)) ... # Find the device that this product maps to. TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE) # 获得目标设备名 #如:INTERNAL_PRODUCT = device\qcom\msm8916_32\msm8916_32.mk TARGET_DEVICE = msm8916_32