kernel-build.mk 4.3 KB

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