kernel-build.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} $(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_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} 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_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} 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. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} $(KERNEL_TARGET) $(MAKE_TRACE)
  82. $(CMD_TRACE) " done"
  83. $(END_TRACE)
  84. prepare:
  85. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  86. install:
  87. ifneq ($(KERNEL_MODULES_USED),)
  88. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-install.. "
  89. rm -rf $(LINUX_BUILD_DIR)/modules
  90. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} \
  91. DEPMOD=$(ADK_DEPMOD) \
  92. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  93. modules_install $(MAKE_TRACE)
  94. $(CMD_TRACE) " done"
  95. $(END_TRACE)
  96. ifeq ($(ADK_RUNTIME_DEV_UDEV),)
  97. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-create-packages.. "
  98. rm -f ${PACKAGE_DIR}/kmod-*
  99. PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
  100. "${ADK_TARGET_CPU_ARCH}" \
  101. "${KERNEL_VERSION}" \
  102. "${LINUX_BUILD_DIR}" \
  103. "${PKG_BUILD}" \
  104. "${PACKAGE_DIR}"
  105. $(CMD_TRACE) " done"
  106. $(END_TRACE)
  107. endif
  108. $(START_TRACE) "target/${ADK_TARGET_ARCH}-kernel-modules-install-packages.. "
  109. for pkg in $(PACKAGE_DIR)/kmod-*; do \
  110. [[ -e "$$pkg" ]] && $(PKG_INSTALL) $$pkg; \
  111. done
  112. $(CMD_TRACE) " done"
  113. $(END_TRACE)
  114. endif
  115. clean:
  116. rm -rf $(LINUX_BUILD_DIR)
  117. rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)