kernel-build.mk 2.5 KB

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