blob: dcb81d72d6588252e7c77fb82cf5aaf42f9233a7 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001#Android makefile to build kernel as a part of Android Build
2
3ifeq ($(TARGET_PREBUILT_KERNEL),)
4
5KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
6KERNEL_CONFIG := $(KERNEL_OUT)/.config
7TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/arm/boot/zImage
8KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr
9KERNEL_MODULES_INSTALL := system
10KERNEL_MODULES_OUT := $(TARGET_OUT)/lib/modules
11
12ifeq ($(TARGET_USES_UNCOMPRESSED_KERNEL),true)
13$(info Using uncompressed kernel)
14TARGET_PREBUILT_KERNEL := $(KERNEL_OUT)/piggy
15else
16TARGET_PREBUILT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL)
17endif
18
19define mv-modules
20mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.dep`;\
21if [ "$$mdpath" != "" ];then\
22mpath=`dirname $$mdpath`;\
23ko=`find $$mpath/kernel -type f -name *.ko`;\
24for i in $$ko; do mv $$i $(KERNEL_MODULES_OUT)/; done;\
25fi
26endef
27
28define clean-module-folder
29mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.dep`;\
30if [ "$$mdpath" != "" ];then\
31mpath=`dirname $$mdpath`; rm -rf $$mpath;\
32fi
33endef
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
54kerneltags: $(KERNEL_OUT) $(KERNEL_CONFIG)
55 $(MAKE) -C kernel O=../$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- tags
56
57kernelconfig: $(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
64endif