Compile Android Kernel from sources
This commit is contained in:
parent
eaa7bca11e
commit
8ae21df51e
3 changed files with 126 additions and 9 deletions
|
@ -1 +1,3 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(LOCAL_PATH)/AndroidKernel.mk
|
||||
|
|
121
tulip-chiphd/AndroidKernel.mk
Normal file
121
tulip-chiphd/AndroidKernel.mk
Normal file
|
@ -0,0 +1,121 @@
|
|||
ifeq ($(TARGET_KERNEL_BUILT_FROM_SOURCE),true)
|
||||
|
||||
# Force using bash as a shell, otherwise, on Ubuntu, dash will break some
|
||||
# dependency due to its bad handling of echo \1
|
||||
MAKE += SHELL=/bin/bash
|
||||
|
||||
ifeq ($(KERNEL_CFG_NAME),)
|
||||
$(error cannot build kernel, config not specified)
|
||||
endif
|
||||
|
||||
KERNEL_MODULES_TO_ROOT := nand.ko sunxi_tr.ko disp.ko hdmi.ko sw-device.ko gslX680new.ko
|
||||
|
||||
KERNEL_TOOLCHAIN_ARCH := $(TARGET_KERNEL_ARCH)
|
||||
KERNEL_EXTRA_FLAGS := ANDROID_TOOLCHAIN_FLAGS="-mno-android -Werror"
|
||||
KERNEL_CROSS_COMP := $(notdir $(TARGET_TOOLS_PREFIX))
|
||||
|
||||
KERNEL_CCACHE :=$(firstword $(TARGET_CC))
|
||||
KERNEL_PATH := $(ANDROID_BUILD_TOP)/vendor/pine64/support
|
||||
ifeq ($(notdir $(KERNEL_CCACHE)),ccache)
|
||||
KERNEL_CROSS_COMP := "ccache $(KERNEL_CROSS_COMP)"
|
||||
KERNEL_PATH := $(KERNEL_PATH):$(ANDROID_BUILD_TOP)/$(dir $(KERNEL_CCACHE))
|
||||
endif
|
||||
|
||||
#remove time_macros from ccache options, it breaks signing process
|
||||
KERNEL_CCSLOP := $(filter-out time_macros,$(subst $(comma), ,$(CCACHE_SLOPPINESS)))
|
||||
KERNEL_CCSLOP := $(subst $(space),$(comma),$(KERNEL_CCSLOP))
|
||||
|
||||
KERNEL_OUT_DIR := $(ANDROID_BUILD_TOP)/$(PRODUCT_OUT)/linux/kernel
|
||||
KERNEL_MODINSTALL := modules_install
|
||||
KERNEL_OUT_MODINSTALL := $(KERNEL_OUT_DIR)/$(KERNEL_MODINSTALL)
|
||||
KERNEL_MODULES_ROOT := $(PRODUCT_OUT)/root
|
||||
KERNEL_MODULES_VENDOR := $(PRODUCT_OUT)/system/vendor/modules
|
||||
KERNEL_CONFIG := $(KERNEL_OUT_DIR)/.config
|
||||
KERNEL_SAVE_DEFCONFIG := $(KERNEL_OUT_DIR)/defconfig
|
||||
KERNEL_BLD_FLAGS := \
|
||||
ARCH=$(TARGET_KERNEL_ARCH) \
|
||||
INSTALL_MOD_PATH=$(KERNEL_MODINSTALL) \
|
||||
$(KERNEL_EXTRA_FLAGS)
|
||||
|
||||
KERNEL_BLD_FLAGS :=$(KERNEL_BLD_FLAGS) \
|
||||
O=$(KERNEL_OUT_DIR) \
|
||||
|
||||
KERNEL_BLD_ENV := CROSS_COMPILE=$(KERNEL_CROSS_COMP) \
|
||||
PATH=$(KERNEL_PATH):$(PATH) \
|
||||
CCACHE_SLOPPINESS=$(KERNEL_CCSLOP)
|
||||
KERNEL_FAKE_DEPMOD := $(KERNEL_OUT_DIR)/fakedepmod/lib/modules
|
||||
|
||||
KERNEL_DEFCONFIG ?= $(KERNEL_SRC_DIR)/arch/$(TARGET_KERNEL_ARCH)/configs/$(KERNEL_CFG_NAME)_defconfig
|
||||
KERNEL_VERSION_FILE := $(KERNEL_OUT_DIR)/include/config/kernel.release
|
||||
KERNEL_BZIMAGE := $(PRODUCT_OUT)/kernel
|
||||
|
||||
$(KERNEL_CONFIG): $(KERNEL_DEFCONFIG)
|
||||
$(hide) echo Regenerating kernel config $(KERNEL_OUT_DIR)
|
||||
$(hide) mkdir -p $(KERNEL_OUT_DIR)
|
||||
$(hide) $(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS) $(notdir $(KERNEL_DEFCONFIG))
|
||||
|
||||
ifeq (,$(filter build_kernel-nodeps,$(MAKECMDGOALS)))
|
||||
$(KERNEL_BZIMAGE): $(MINIGZIP)
|
||||
endif
|
||||
|
||||
$(KERNEL_BZIMAGE): $(KERNEL_CONFIG)
|
||||
$(hide) $(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS)
|
||||
$(hide) cp -f $(KERNEL_OUT_DIR)/arch/arm64/boot/Image $@
|
||||
|
||||
$(KERNEL_OUT_MODINSTALL): $(KERNEL_CONFIG)
|
||||
@mkdir -p $(KERNEL_OUT_MODINSTALL)
|
||||
@$(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS) modules_install
|
||||
@touch $@
|
||||
|
||||
mrproper_kernel:
|
||||
$(hide) $(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS) mrproper
|
||||
|
||||
clean_kernel:
|
||||
$(hide) $(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS) clean
|
||||
$(hide) rm -rf $(KERNEL_OUT_MODINSTALL)
|
||||
|
||||
menuconfig xconfig gconfig: $(KERNEL_CONFIG)
|
||||
$(hide) $(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS) $@
|
||||
$(hide) $(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS) savedefconfig
|
||||
$(hide) cp -f $(KERNEL_SAVE_DEFCONFIG) $(KERNEL_DEFCONFIG)
|
||||
$(hide) echo ===========
|
||||
$(hide) echo $(KERNEL_DEFCONFIG) has been modified !
|
||||
$(hide) echo ===========
|
||||
|
||||
build_kernel: $(KERNEL_BZIMAGE)
|
||||
|
||||
modules_install: $(KERNEL_OUT_MODINSTALL)
|
||||
|
||||
copy_modules_to_root: modules_install
|
||||
@for module in $(KERNEL_MODULES_TO_ROOT); do \
|
||||
find $(KERNEL_OUT_MODINSTALL)/lib/modules/`cat $(KERNEL_VERSION_FILE)` -name "$${module}" \
|
||||
-exec cp -f {} $(KERNEL_MODULES_ROOT)/ \; ; \
|
||||
done
|
||||
|
||||
copy_modules_to_system: modules_install
|
||||
@rm -rf $(KERNEL_MODULES_VENDOR)
|
||||
@mkdir -p $(KERNEL_MODULES_VENDOR)
|
||||
@for module in $$(find $(KERNEL_OUT_MODINSTALL)/lib/modules/`cat $(KERNEL_VERSION_FILE)` -name "*.ko"); do \
|
||||
cp -f "$${module}" $(KERNEL_MODULES_VENDOR)/ ; \
|
||||
done
|
||||
|
||||
TAGS_files := TAGS
|
||||
tags_files := tags
|
||||
gtags_files := GTAGS GPATH GRTAGS GSYMS
|
||||
cscope_files := $(addprefix cscope.,files out out.in out.po)
|
||||
|
||||
TAGS tags gtags cscope: $(KERNEL_CONFIG)
|
||||
$(hide) $(KERNEL_BLD_ENV) $(MAKE) -C $(KERNEL_SRC_DIR) $(KERNEL_BLD_FLAGS) $@
|
||||
$(hide) rm -f $(KERNEL_SRC_DIR)/$($@_files)
|
||||
$(hide) cp -fs $(addprefix `pwd`/$(KERNEL_OUT_DIR)/,$($@_files)) $(KERNEL_SRC_DIR)/
|
||||
|
||||
.PHONY: menuconfig xconfig gconfig
|
||||
.PHONY: build_kernel build_kernel-nodeps copy_modules_to_root copy_modules_to_system
|
||||
|
||||
$(PRODUCT_OUT)/boot.img: build_kernel
|
||||
|
||||
$(PRODUCT_OUT)/ramdisk.img: copy_modules_to_root
|
||||
|
||||
$(PRODUCT_OUT)/system.img: copy_modules_to_system
|
||||
|
||||
endif #TARGET_KERNEL_BUILT_FROM_SOURCE
|
|
@ -1,6 +1,5 @@
|
|||
$(call inherit-product, device/softwinner/tulip-common/tulip_64_bit.mk)
|
||||
$(call inherit-product, device/softwinner/tulip-common/tulip-common.mk)
|
||||
$(call inherit-product-if-exists, device/softwinner/tulip-chiphd/modules/modules.mk)
|
||||
$(call inherit-product, frameworks/native/build/tablet-7in-xhdpi-2048-dalvik-heap.mk)
|
||||
$(call inherit-product, hardware/realtek/bluetooth/firmware/rtlbtfw_cfg.mk)
|
||||
|
||||
|
@ -22,6 +21,7 @@ ifeq ($(TARGET_PREBUILT_KERNEL),)
|
|||
LOCAL_KERNEL := device/softwinner/tulip-chiphd/kernel
|
||||
else
|
||||
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
|
||||
PRODUCT_COPY_FILES += $(TARGET_PREBUILT_KERNEL_MODULES)
|
||||
endif
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
|
@ -42,13 +42,7 @@ PRODUCT_COPY_FILES += \
|
|||
device/softwinner/tulip-chiphd/init.sun50iw1p1.rc:root/init.sun50iw1p1.rc \
|
||||
device/softwinner/tulip-chiphd/init.recovery.sun50iw1p1.rc:root/init.recovery.sun50iw1p1.rc \
|
||||
device/softwinner/tulip-chiphd/ueventd.sun50iw1p1.rc:root/ueventd.sun50iw1p1.rc \
|
||||
device/softwinner/tulip-chiphd/recovery.fstab:recovery.fstab \
|
||||
device/softwinner/tulip-chiphd/modules/modules/nand.ko:root/nand.ko \
|
||||
device/softwinner/tulip-chiphd/modules/modules/sunxi_tr.ko:root/sunxi_tr.ko \
|
||||
device/softwinner/tulip-chiphd/modules/modules/disp.ko:root/disp.ko \
|
||||
device/softwinner/tulip-chiphd/modules/modules/hdmi.ko:root/hdmi.ko \
|
||||
device/softwinner/tulip-chiphd/modules/modules/sw-device.ko:obj/sw-device.ko \
|
||||
device/softwinner/tulip-chiphd/modules/modules/gslX680new.ko:obj/gslX680new.ko
|
||||
device/softwinner/tulip-chiphd/recovery.fstab:recovery.fstab
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/softwinner/tulip-chiphd/twrp.fstab:recovery/root/etc/twrp.fstab
|
||||
|
|
Loading…
Reference in a new issue