kernel-build.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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/$(ADK_TARGET_OS)-ver.mk
  5. include $(ADK_TOPDIR)/mk/$(ADK_TARGET_OS).mk
  6. include $(ADK_TOPDIR)/mk/kernel-vars.mk
  7. ifeq ($(ADK_TARGET_OS_LINUX),y)
  8. KERNEL_MODULES_USED:=$(shell grep ^ADK_LINUX_KERNEL $(ADK_TOPDIR)/.config|grep =m)
  9. endif
  10. ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
  11. KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH))
  12. endif
  13. KERNEL_FILE:=$(ADK_TARGET_KERNEL)
  14. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  15. ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
  16. KERNEL_FILE:=vmlinux
  17. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  18. endif
  19. ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
  20. KERNEL_FILE:=vmlinux
  21. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  22. endif
  23. ifeq ($(ADK_TARGET_KERNEL_VMLINUX_BOOTP),y)
  24. KERNEL_FILE:=bootpfile
  25. KERNEL_TARGET:=bootpfile
  26. endif
  27. ifeq ($(ADK_TARGET_KERNEL_VMLINUX_EFI),y)
  28. KERNEL_FILE:=vmlinux.efi
  29. KERNEL_TARGET:=all
  30. endif
  31. ifeq ($(ADK_TARGET_KERNEL_VMLINUX_GZ),y)
  32. KERNEL_FILE:=vmlinux
  33. KERNEL_TARGET:=all
  34. endif
  35. ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
  36. KERNEL_FILE:=vmlinux
  37. KERNEL_TARGET:=all
  38. endif
  39. ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
  40. KERNEL_FILE:=vmlinux
  41. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  42. endif
  43. ifeq ($(ADK_TARGET_KERNEL_SIMPLEIMAGE),y)
  44. KERNEL_FILE:=vmlinux.bin
  45. KERNEL_TARGET:=simpleImage.milkymist_one
  46. endif
  47. ifneq ($(KERNEL_MODULES_USED),)
  48. KERNEL_TARGET+=modules
  49. endif
  50. ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
  51. ADK_DEPMOD:=$(STAGING_HOST_DIR)/usr/bin/depmod
  52. else
  53. ADK_DEPMOD:=true
  54. endif
  55. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(ADK_TARGET_OS)-$(KERNEL_FILE_VER)/.patched
  56. ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(ADK_TARGET_OS)-$(KERNEL_FILE_VER) $(LINUX_DIR)
  57. mkdir -p $(LINUX_BUILD_DIR)/kmod-control
  58. touch $@
  59. ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_MINICONFIG),y)
  60. $(LINUX_DIR)/.config: $(BUILD_DIR)/.kernelconfig
  61. endif
  62. ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
  63. $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH):
  64. $(LINUX_DIR)/.config: $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH)
  65. endif
  66. $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared
  67. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-configure.. "
  68. echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
  69. ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_DEFCONFIG),y)
  70. ${KERNEL_MAKE} $(ADK_TARGET_LINUX_KERNEL_DEFCONFIG) $(MAKE_TRACE)
  71. else ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
  72. @if [ ! -f $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH) ];then \
  73. echo "no kernel configuration found in $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH)"; \
  74. exit 1; \
  75. fi
  76. ${KERNEL_MAKE} KCONFIG_ALLCONFIG=$(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH) allnoconfig $(MAKE_TRACE)
  77. else
  78. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
  79. ${KERNEL_MAKE} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
  80. endif
  81. $(CMD_TRACE) " done"
  82. $(END_TRACE)
  83. $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
  84. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-compile.. "
  85. ifneq ($(ADK_TARGET_KERNEL_APPEND_DTB),)
  86. ${KERNEL_MAKE} zImage dtbs $(MAKE_TRACE)
  87. (cd $(LINUX_DIR)/arch/$(ADK_TARGET_ARCH)/boot && \
  88. cat dts/${ADK_TARGET_KERNEL_APPEND_DTB}.dtb >> zImage)
  89. endif
  90. ${KERNEL_MAKE} $(KERNEL_TARGET) $(MAKE_TRACE)
  91. $(CMD_TRACE) " done"
  92. $(END_TRACE)
  93. prepare:
  94. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  95. install:
  96. ifneq ($(KERNEL_MODULES_USED),)
  97. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-install.. "
  98. rm -rf $(LINUX_BUILD_DIR)/modules
  99. ${KERNEL_MAKE} DEPMOD=$(ADK_DEPMOD) \
  100. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  101. modules_install $(MAKE_TRACE)
  102. $(CMD_TRACE) " done"
  103. $(END_TRACE)
  104. ifeq ($(ADK_RUNTIME_DEV_UDEV),)
  105. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-create-packages.. "
  106. rm -f ${PACKAGE_DIR}/kmod-*
  107. PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
  108. "${ADK_TARGET_CPU_ARCH}" \
  109. "${KERNEL_VERSION}" \
  110. "${LINUX_BUILD_DIR}" \
  111. "${PKG_BUILD}" \
  112. "${PACKAGE_DIR}"
  113. $(CMD_TRACE) " done"
  114. $(END_TRACE)
  115. endif
  116. $(START_TRACE) "target/${ADK_TARGET_ARCH}-kernel-modules-install-packages.. "
  117. for pkg in $(PACKAGE_DIR)/kmod-*; do \
  118. [[ -e "$$pkg" ]] && $(PKG_INSTALL) $$pkg; \
  119. done
  120. $(CMD_TRACE) " done"
  121. $(END_TRACE)
  122. endif
  123. clean:
  124. rm -rf $(LINUX_BUILD_DIR)
  125. rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)