kernel-build.mk 2.6 KB

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