Android.mk 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Copyright (C) 2017 MediaTek Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License version 2 as
  5. # published by the Free Software Foundation.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # See http://www.gnu.org/licenses/gpl-2.0.html for more details.
  11. LOCAL_PATH := $(call my-dir)
  12. ifeq ($(notdir $(LOCAL_PATH)),$(strip $(LINUX_KERNEL_VERSION)))
  13. ifneq ($(strip $(TARGET_NO_KERNEL)),true)
  14. include $(LOCAL_PATH)/kenv.mk
  15. ifeq ($(wildcard $(TARGET_PREBUILT_KERNEL)),)
  16. KERNEL_MAKE_DEPENDENCIES := $(shell find $(KERNEL_DIR) -name .git -prune -o -type f | sort)
  17. KERNEL_MAKE_DEPENDENCIES := $(filter-out %/.git %/.gitignore %/.gitattributes,$(KERNEL_MAKE_DEPENDENCIES))
  18. $(TARGET_KERNEL_CONFIG): PRIVATE_DIR := $(KERNEL_DIR)
  19. $(TARGET_KERNEL_CONFIG): $(KERNEL_CONFIG_FILE) $(LOCAL_PATH)/Android.mk
  20. $(TARGET_KERNEL_CONFIG): $(KERNEL_MAKE_DEPENDENCIES)
  21. $(hide) mkdir -p $(dir $@)
  22. $(PREBUILT_MAKE_PREFIX)$(MAKE) -C $(PRIVATE_DIR) $(KERNEL_MAKE_OPTION) $(KERNEL_DEFCONFIG)
  23. $(BUILT_DTB_OVERLAY_TARGET): $(KERNEL_ZIMAGE_OUT)
  24. .KATI_RESTAT: $(KERNEL_ZIMAGE_OUT)
  25. $(KERNEL_ZIMAGE_OUT): PRIVATE_DIR := $(KERNEL_DIR)
  26. $(KERNEL_ZIMAGE_OUT): $(TARGET_KERNEL_CONFIG) $(KERNEL_MAKE_DEPENDENCIES)
  27. $(hide) mkdir -p $(dir $@)
  28. $(PREBUILT_MAKE_PREFIX)$(MAKE) -C $(PRIVATE_DIR) $(KERNEL_MAKE_OPTION)
  29. $(hide) $(call fixup-kernel-cmd-file,$(KERNEL_OUT)/arch/$(KERNEL_TARGET_ARCH)/boot/compressed/.piggy.xzkern.cmd)
  30. # check the kernel image size
  31. python device/mediatek/build/build/tools/check_kernel_size.py $(KERNEL_OUT) $(KERNEL_DIR) $(PROJECT_DTB_NAMES)
  32. ifeq ($(strip $(MTK_HEADER_SUPPORT)), yes)
  33. $(BUILT_KERNEL_TARGET): $(KERNEL_ZIMAGE_OUT) $(TARGET_KERNEL_CONFIG) $(LOCAL_PATH)/Android.mk | $(HOST_OUT_EXECUTABLES)/mkimage$(HOST_EXECUTABLE_SUFFIX)
  34. $(hide) $(HOST_OUT_EXECUTABLES)/mkimage$(HOST_EXECUTABLE_SUFFIX) $< KERNEL 0xffffffff > $@
  35. else
  36. $(BUILT_KERNEL_TARGET): $(KERNEL_ZIMAGE_OUT) $(TARGET_KERNEL_CONFIG) $(LOCAL_PATH)/Android.mk | $(ACP)
  37. $(copy-file-to-target)
  38. endif
  39. $(TARGET_PREBUILT_KERNEL): $(BUILT_KERNEL_TARGET) $(LOCAL_PATH)/Android.mk | $(ACP)
  40. $(copy-file-to-new-target)
  41. endif#TARGET_PREBUILT_KERNEL is empty
  42. $(INSTALLED_KERNEL_TARGET): $(BUILT_KERNEL_TARGET) $(LOCAL_PATH)/Android.mk | $(ACP)
  43. $(copy-file-to-target)
  44. .PHONY: kernel save-kernel kernel-savedefconfig kernel-menuconfig menuconfig-kernel savedefconfig-kernel clean-kernel
  45. kernel: $(INSTALLED_KERNEL_TARGET)
  46. save-kernel: $(TARGET_PREBUILT_KERNEL)
  47. kernel-savedefconfig: $(TARGET_KERNEL_CONFIG)
  48. cp $(TARGET_KERNEL_CONFIG) $(KERNEL_CONFIG_FILE)
  49. kernel-menuconfig:
  50. $(hide) mkdir -p $(KERNEL_OUT)
  51. $(MAKE) -C $(KERNEL_DIR) $(KERNEL_MAKE_OPTION) menuconfig
  52. menuconfig-kernel savedefconfig-kernel:
  53. $(hide) mkdir -p $(KERNEL_OUT)
  54. $(MAKE) -C $(KERNEL_DIR) $(KERNEL_MAKE_OPTION) $(patsubst %config-kernel,%config,$@)
  55. clean-kernel:
  56. $(hide) rm -rf $(KERNEL_OUT) $(KERNEL_MODULES_OUT) $(INSTALLED_KERNEL_TARGET)
  57. $(hide) rm -f $(INSTALLED_DTB_OVERLAY_TARGET)
  58. ### DTB build template
  59. MTK_DTBIMAGE_DTS := $(addsuffix .dts,$(addprefix $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/,$(PLATFORM_DTB_NAME)))
  60. include device/mediatek/build/core/build_dtbimage.mk
  61. MTK_DTBOIMAGE_DTS := $(addsuffix .dts,$(addprefix $(KERNEL_DIR)/arch/$(KERNEL_TARGET_ARCH)/boot/dts/,$(PROJECT_DTB_NAMES)))
  62. include device/mediatek/build/core/build_dtboimage.mk
  63. endif#TARGET_NO_KERNEL
  64. endif#LINUX_KERNEL_VERSION