Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | #Android makefile to build kernel as a part of Android Build |
| 2 | |
| 3 | ifeq ($(TARGET_PREBUILT_KERNEL),) |
| 4 | |
| 5 | KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
| 6 | KERNEL_CONFIG := $(KERNEL_OUT)/.config |
| 7 | TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/arm/boot/zImage |
| 8 | KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr |
| 9 | KERNEL_MODULES_INSTALL := system |
| 10 | KERNEL_MODULES_OUT := $(TARGET_OUT)/lib/modules |
| 11 | |
| 12 | ifeq ($(TARGET_USES_UNCOMPRESSED_KERNEL),true) |
| 13 | $(info Using uncompressed kernel) |
| 14 | TARGET_PREBUILT_KERNEL := $(KERNEL_OUT)/piggy |
| 15 | else |
| 16 | TARGET_PREBUILT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL) |
| 17 | endif |
| 18 | |
| 19 | define mv-modules |
| 20 | mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.dep`;\ |
| 21 | if [ "$$mdpath" != "" ];then\ |
| 22 | mpath=`dirname $$mdpath`;\ |
| 23 | ko=`find $$mpath/kernel -type f -name *.ko`;\ |
| 24 | for i in $$ko; do mv $$i $(KERNEL_MODULES_OUT)/; done;\ |
| 25 | fi |
| 26 | endef |
| 27 | |
| 28 | define clean-module-folder |
| 29 | mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.dep`;\ |
| 30 | if [ "$$mdpath" != "" ];then\ |
| 31 | mpath=`dirname $$mdpath`; rm -rf $$mpath;\ |
| 32 | fi |
| 33 | endef |
| 34 | |
| 35 | $(KERNEL_OUT): |
| 36 | mkdir -p $(KERNEL_OUT) |
| 37 | |
| 38 | $(KERNEL_CONFIG): $(KERNEL_OUT) |
| 39 | $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- $(KERNEL_DEFCONFIG) |
| 40 | |
| 41 | $(KERNEL_OUT)/piggy : $(TARGET_PREBUILT_INT_KERNEL) |
| 42 | $(hide) gunzip -c $(KERNEL_OUT)/arch/arm/boot/compressed/piggy.gzip > $(KERNEL_OUT)/piggy |
| 43 | |
| 44 | $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_OUT) $(KERNEL_CONFIG) $(KERNEL_HEADERS_INSTALL) |
| 45 | $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- |
| 46 | $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- modules |
| 47 | $(MAKE) -C kernel O=../$(KERNEL_OUT) INSTALL_MOD_PATH=../../$(KERNEL_MODULES_INSTALL) ARCH=arm CROSS_COMPILE=arm-eabi- modules_install |
| 48 | $(mv-modules) |
| 49 | $(clean-module-folder) |
| 50 | |
| 51 | $(KERNEL_HEADERS_INSTALL): $(KERNEL_OUT) $(KERNEL_CONFIG) |
| 52 | $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- headers_install |
| 53 | |
| 54 | kerneltags: $(KERNEL_OUT) $(KERNEL_CONFIG) |
| 55 | $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- tags |
| 56 | |
| 57 | kernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG) |
| 58 | env KCONFIG_NOTIMESTAMP=true \ |
| 59 | $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- menuconfig |
| 60 | env KCONFIG_NOTIMESTAMP=true \ |
| 61 | $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- savedefconfig |
| 62 | cp $(KERNEL_OUT)/defconfig kernel/arch/arm/configs/$(KERNEL_DEFCONFIG) |
| 63 | |
| 64 | endif |