1
0

kernel-build.mk 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. include $(ADK_TOPDIR)/rules.mk
  4. include $(ADK_TOPDIR)/mk/kernel-ver.mk
  5. include $(ADK_TOPDIR)/mk/linux.mk
  6. include $(ADK_TOPDIR)/mk/kernel-vars.mk
  7. ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
  8. KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH))
  9. else
  10. KERNEL_MODULES_USED:=$(shell grep ^ADK_KERNEL $(ADK_TOPDIR)/.config|grep =m)
  11. endif
  12. KERNEL_FILE:=$(ADK_TARGET_KERNEL)
  13. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  14. ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
  15. KERNEL_FILE:=vmlinux
  16. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  17. endif
  18. ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
  19. KERNEL_FILE:=vmlinux
  20. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  21. endif
  22. ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
  23. KERNEL_FILE:=vmlinux
  24. KERNEL_TARGET:=all
  25. endif
  26. ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
  27. KERNEL_FILE:=vmlinux
  28. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  29. endif
  30. ifneq ($(KERNEL_MODULES_USED),)
  31. KERNEL_TARGET+=modules
  32. endif
  33. ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
  34. ADK_DEPMOD:=$(STAGING_HOST_DIR)/usr/bin/depmod
  35. else
  36. ADK_DEPMOD:=true
  37. endif
  38. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER)/.patched
  39. ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER) $(LINUX_DIR)
  40. mkdir -p $(LINUX_BUILD_DIR)/kmod-control
  41. touch $@
  42. ifeq ($(ADK_TARGET_KERNEL_USE_MINICONFIG),y)
  43. $(LINUX_DIR)/.config: $(BUILD_DIR)/.kernelconfig
  44. endif
  45. ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
  46. $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH):
  47. $(LINUX_DIR)/.config: $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH)
  48. endif
  49. $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared
  50. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-configure.. "
  51. echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
  52. ifeq ($(ADK_TARGET_KERNEL_USE_DEFCONFIG),y)
  53. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} $(ADK_TARGET_KERNEL_DEFCONFIG) $(MAKE_TRACE)
  54. else ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
  55. @if [ ! -f $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH) ];then \
  56. echo "no kernel configuration found in $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH)"; \
  57. exit 1; \
  58. fi
  59. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=$(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH) allnoconfig $(MAKE_TRACE)
  60. else
  61. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
  62. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
  63. endif
  64. $(CMD_TRACE) " done"
  65. $(END_TRACE)
  66. $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
  67. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-compile.. "
  68. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} $(KERNEL_TARGET) $(MAKE_TRACE)
  69. $(CMD_TRACE) " done"
  70. $(END_TRACE)
  71. prepare:
  72. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  73. install:
  74. ifneq ($(KERNEL_MODULES_USED),)
  75. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-install.. "
  76. rm -rf $(LINUX_BUILD_DIR)/modules
  77. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} \
  78. DEPMOD=$(ADK_DEPMOD) \
  79. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  80. modules_install $(MAKE_TRACE)
  81. $(CMD_TRACE) " done"
  82. $(END_TRACE)
  83. ifeq ($(ADK_RUNTIME_DEV_UDEV),)
  84. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-create-packages.. "
  85. rm -f ${PACKAGE_DIR}/kmod-*
  86. PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
  87. "${ADK_TARGET_CPU_ARCH}" \
  88. "${KERNEL_VERSION}" \
  89. "${LINUX_BUILD_DIR}" \
  90. "${PKG_BUILD}" \
  91. "${PACKAGE_DIR}"
  92. $(CMD_TRACE) " done"
  93. $(END_TRACE)
  94. endif
  95. $(START_TRACE) "target/${ADK_TARGET_ARCH}-kernel-modules-install-packages.. "
  96. for pkg in $(PACKAGE_DIR)/kmod-*; do \
  97. [[ -e "$$pkg" ]] && $(PKG_INSTALL) $$pkg; \
  98. done
  99. $(CMD_TRACE) " done"
  100. $(END_TRACE)
  101. endif
  102. clean:
  103. rm -rf $(LINUX_BUILD_DIR)
  104. rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)