kernel-build.mk 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 $(TOPDIR)/rules.mk
  4. include $(TOPDIR)/mk/linux.mk
  5. include ${TOPDIR}/mk/kernel-vars.mk
  6. KERNEL_FILE:=$(ADK_TARGET_KERNEL)
  7. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  8. ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
  9. KERNEL_FILE:=vmlinux
  10. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  11. endif
  12. ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
  13. KERNEL_FILE:=vmlinux
  14. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  15. endif
  16. ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
  17. KERNEL_FILE:=vmlinux
  18. KERNEL_TARGET:=all
  19. endif
  20. $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION)/.patched:
  21. $(TRACE) target/kernel-patch
  22. $(PATCH) $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION) \
  23. ../linux/patches/$(KERNEL_VERSION) *.patch $(MAKE_TRACE)
  24. $(PATCH) $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION) \
  25. ../$(ARCH)/$(ADK_TARGET_SYSTEM)/patches/$(KERNEL_VERSION) *.patch $(MAKE_TRACE)
  26. touch $@
  27. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION)/.patched
  28. $(TRACE) target/kernel-prepare
  29. ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION) $(LINUX_DIR)
  30. mkdir -p $(LINUX_BUILD_DIR)/kmod-control
  31. touch $@
  32. $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared $(BUILD_DIR)/.kernelconfig $(TOPDIR)/mk/modules.mk
  33. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-configure
  34. -for f in $(TARGETS);do if [ -f $$f ];then rm $$f;fi;done
  35. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
  36. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
  37. touch -c $(LINUX_DIR)/.config
  38. $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
  39. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-compile
  40. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} LOCALVERSION="" $(KERNEL_TARGET) modules $(MAKE_TRACE)
  41. touch -c $(LINUX_DIR)/$(KERNEL_FILE)
  42. $(LINUX_BUILD_DIR)/modules: $(LINUX_DIR)/$(KERNEL_FILE)
  43. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-modules-install
  44. rm -rf $(LINUX_BUILD_DIR)/modules
  45. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} DEPMOD=true \
  46. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  47. LOCALVERSION="" \
  48. modules_install $(MAKE_TRACE)
  49. $(TRACE) target/$(ADK_TARGET_ARCH)-create-packages
  50. @mkdir -p ${PACKAGE_DIR}
  51. ifneq ($(strip $(TARGETS)),)
  52. $(MAKE) $(TARGETS)
  53. endif
  54. $(INSTALL_TARGETS): $(LINUX_BUILD_DIR)/modules
  55. prepare:
  56. compile: $(LINUX_BUILD_DIR)/modules
  57. install: compile $(INSTALL_TARGETS)
  58. ifneq ($(strip $(INSTALL_TARGETS)),)
  59. $(TRACE) target/${ADK_TARGET_ARCH}-modules-install
  60. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  61. $(PKG_INSTALL) $(INSTALL_TARGETS) $(MAKE_TRACE)
  62. else
  63. $(foreach pkg,$(INSTALL_TARGETS),$(shell $(PKG_INSTALL) $(pkg)))
  64. endif
  65. endif
  66. clean:
  67. rm -rf $(LINUX_BUILD_DIR)
  68. rm -f $(TARGETS)