kernel-build.mk 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. KERNEL_MODULES_USED:=$(shell grep ^ADK_KERNEL $(ADK_TOPDIR)/.config|grep =m)
  8. KERNEL_FILE:=$(ADK_TARGET_KERNEL)
  9. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  10. ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
  11. KERNEL_FILE:=vmlinux
  12. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  13. endif
  14. ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
  15. KERNEL_FILE:=vmlinux
  16. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  17. endif
  18. ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
  19. KERNEL_FILE:=vmlinux
  20. KERNEL_TARGET:=all
  21. endif
  22. ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
  23. KERNEL_FILE:=vmlinux
  24. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  25. endif
  26. ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
  27. ADK_DEPMOD:=$(STAGING_HOST_DIR)/usr/bin/depmod
  28. else
  29. ADK_DEPMOD:=true
  30. endif
  31. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER)/.patched
  32. $(TRACE) target/kernel-prepare
  33. ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER) $(LINUX_DIR)
  34. mkdir -p $(LINUX_BUILD_DIR)/kmod-control
  35. touch $@
  36. $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared $(BUILD_DIR)/.kernelconfig
  37. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-configure
  38. -for f in $(TARGETS);do if [ -f $$f ];then rm $$f;fi;done
  39. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
  40. echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
  41. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
  42. touch -c $(LINUX_DIR)/.config
  43. $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
  44. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-compile
  45. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} LOCALVERSION="" $(KERNEL_TARGET) $(MAKE_TRACE)
  46. touch -c $(LINUX_DIR)/$(KERNEL_FILE)
  47. $(LINUX_BUILD_DIR)/modules: $(LINUX_DIR)/$(KERNEL_FILE)
  48. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-modules-compile
  49. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} LOCALVERSION="" modules $(MAKE_TRACE)
  50. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-modules-install
  51. rm -rf $(LINUX_BUILD_DIR)/modules
  52. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} \
  53. DEPMOD=$(ADK_DEPMOD) \
  54. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  55. LOCALVERSION="" \
  56. modules_install $(MAKE_TRACE)
  57. $(TRACE) target/$(ADK_TARGET_ARCH)-create-packages
  58. @mkdir -p ${PACKAGE_DIR}
  59. ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
  60. "${ADK_TARGET_CPU_ARCH}" \
  61. "${KERNEL_VERSION}" \
  62. "${LINUX_BUILD_DIR}" \
  63. "${PKG_BUILD}" \
  64. "${PACKAGE_DIR}"
  65. prepare:
  66. ifneq ($(KERNEL_MODULES_USED),)
  67. compile: $(LINUX_BUILD_DIR)/modules
  68. else
  69. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  70. endif
  71. install: compile
  72. $(TRACE) target/${ADK_TARGET_ARCH}-modules-install
  73. ifeq ($(ADK_TARGET_PACKAGE_IPKG)$(ADK_TARGET_PACKAGE_OPKG),y)
  74. $(PKG_INSTALL) $(wildcard ${PACKAGE_DIR}/kmod-*) $(MAKE_TRACE)
  75. else
  76. $(foreach pkg,$(wildcard ${PACKAGE_DIR}/kmod-*),$(shell $(PKG_INSTALL) $(pkg)))
  77. endif
  78. clean:
  79. rm -rf $(LINUX_BUILD_DIR)
  80. rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)