forked from azaleski9/kernel-omap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AndroidKernel.mk
95 lines (77 loc) · 3.26 KB
/
AndroidKernel.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#Android makefile to build kernel as a part of Android Build
ifneq ($(BUILD_KERNEL),)
KERNEL_SRCDIR := kernel/omap-moto-cw
KERNEL_OUT := $(ANDROID_PRODUCT_OUT)/obj/KERNEL_OBJ
KERNEL_CONFIG := $(KERNEL_OUT)/.config
TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/arm/boot/zImage-dtb
KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr
KERNEL_MODULES_INSTALL := system
KERNEL_MODULES_OUT := $(TARGET_OUT)/lib/modules
KERNEL_IMG=$(KERNEL_OUT)/arch/arm/boot/Image
# relative path from KERNEL_OUT to kernel source directory
KERNEL_SOURCE_RELATIVE_PATH := ../../../../../../$(KERNEL_SRCDIR)
PRODUCT_PREBUILT_KERNEL := $(TARGET_PREBUILT_KERNEL)
# Add 4.8 arm-eabi to PATH if gcc can't be found
GCC_FOUND := $(shell (which $(KERNEL_CROSS_COMPILE)gcc)2>&1 ; echo $$?)
ifneq ($(strip $(GCC_FOUND)),0)
ifneq ($(HOST_OS),)
PATH := $(PATH):$(ANDROID_BUILD_TOP)/prebuilts/gcc/$(HOST_OS)-x86/arm/arm-eabi-4.8/bin/
endif
endif
ifeq ($(TARGET_USES_UNCOMPRESSED_KERNEL),true)
$(error TARGET_USES_UNCOMPRESSED_KERNEL is not supported)
else
TARGET_PREBUILT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL)
endif
# use eng_ defconfig for engineering Android variants
ifeq ($(TARGET_BUILD_VARIANT), eng)
KERNEL_DEFCONFIG := eng_${KERNEL_DEFCONFIG}
endif
SOURCE_DEFCONFIG := $(KERNEL_SRCDIR)/arch/arm/configs/$(KERNEL_DEFCONFIG)
define mv-modules
mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.order`;\
if [ "$$mdpath" != "" ];then\
mpath=`dirname $$mdpath`;\
ko=`find $$mpath/kernel -type f -name *.ko`;\
for i in $$ko; do mv $$i $(KERNEL_MODULES_OUT)/; done;\
fi
endef
define clean-module-folder
mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.order`;\
if [ "$$mdpath" != "" ];then\
mpath=`dirname $$mdpath`; rm -rf $$mpath;\
fi
endef
define update-prebuilts
if [ -f $(TARGET_PREBUILT_INT_KERNEL) -a\
-f $(PRODUCT_PREBUILT_KERNEL) ]; then\
cp -f $(TARGET_PREBUILT_INT_KERNEL) $(PRODUCT_PREBUILT_KERNEL);\
fi;
endef
define do-kernel-config
( cp $(3) $(2) && $(7) -C $(4) O=$(1) ARCH=$(5) CROSS_COMPILE=$(6) oldconfig ) || ( rm -f $(2) && false )
endef
GIT_HOOKS_DIR := $(KERNEL_SRCDIR)/.git/hooks
inst_hook: $(GIT_HOOKS_DIR)/pre-commit $(GIT_HOOKS_DIR)/checkpatch.pl
$(GIT_HOOKS_DIR)/pre-commit: $(KERNEL_SRCDIR)/scripts/pre-commit
@-cp -f $< $@
@-chmod ugo+x $@
$(GIT_HOOKS_DIR)/checkpatch.pl: $(KERNEL_SRCDIR)/scripts/checkpatch.pl
@-cp -f $< $@
@-chmod ugo+x $@
$(KERNEL_OUT):
mkdir -p $(KERNEL_OUT)
$(KERNEL_CONFIG): $(KERNEL_OUT) $(SOURCE_DEFCONFIG) inst_hook
$(call do-kernel-config,$(KERNEL_OUT),$@,$(SOURCE_DEFCONFIG),$(KERNEL_SRCDIR),arm,arm-eabi-,$(MAKE))
$(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_OUT) $(KERNEL_CONFIG) $(KERNEL_HEADERS_INSTALL) $(TARGET_PREBUILT_INT_DTB)
$(MAKE) -C $(KERNEL_SRCDIR) KBUILD_RELSRC=$(KERNEL_SOURCE_RELATIVE_PATH) O=$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi-
$(update-prebuilts)
$(KERNEL_HEADERS_INSTALL): $(KERNEL_OUT) $(KERNEL_CONFIG)
$(MAKE) -C $(KERNEL_SRCDIR) O=$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- headers_install
kerneltags: $(KERNEL_OUT) $(KERNEL_CONFIG)
$(MAKE) -C $(KERNEL_SRCDIR) O=$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- tags
kernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG)
env KCONFIG_NOTIMESTAMP=true \
$(MAKE) -C $(KERNEL_SRCDIR) O=$(KERNEL_OUT) ARCH=arm CROSS_COMPILE=arm-eabi- menuconfig
cp $(KERNEL_OUT)/.config $(SOURCE_DEFCONFIG)
endif