转载:http://home.lupaworld.com/home-space-uid-131820-do-blog-id-149451.html
Android 的核心 Makefile 为 build/core/main.mk (有关该Makefile的分析请见 http://heaven.branda.to/~thinker/GinGin_CGI.py/show_id_doc/393 ),其中编译的内核的target为 INSTALLED_BOOTIMAGE_TARGET 即 out/target/product/dream-open/boot.img
boot.img的生成在下面的Makefile中
build/core/Makefile: 293
$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
$(call pretty,"Target boot image: $@")
$(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
上面的语句翻译下来为:
out/target/product/dream-open/boot.img: out/host/linux-x86/bin/genext2fs out/target/product/dream-open/kernel out/target/product/dream-open/ramdisk.img
$(call pretty,"Target boot image: out/target/product/dream-open/boot.img")
$(hide) external/genext2fs/mkbootimg_ext2.sh --kernel out/target/product/dream-open/kernel --ramdisk out/target/product/dream-open/ramdisk.img --cmdline "no_console_suspend=1 console=null" --output out/target/product/dream-open/boot.img
可见boot.img 是由 kernel 和 ramdisk.img 通过脚本mkbootimg_ext2.sh生成的。
那个out/target/product/dream-open/kernel 从哪里来的呢?请看下面的Makefile
vendor/htc/dream-open/AndroidBoard.mk:3
ifeq ($(TARGET_PREBUILT_KERNEL),)
TARGET_PREBUILT_KERNEL := $(LOCAL_PATH)/kernel
endif
file := $(INSTALLED_KERNEL_TARGET)
ALL_PREBUILT += $(file)
$(file): $(TARGET_PREBUILT_KERNEL) | $(ACP)
$(transform-prebuilt-to-target)
可见内核在 vendor/htc/dream-open/kernel,该文件是预编译好的,从android的版本库上直接下载下来的。