kernel-build.mk 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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} $(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} 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. modules_install $(MAKE_TRACE)
  56. $(TRACE) target/$(ADK_TARGET_ARCH)-create-packages
  57. @mkdir -p ${PACKAGE_DIR}
  58. PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
  59. "${ADK_TARGET_CPU_ARCH}" \
  60. "${KERNEL_VERSION}" \
  61. "${LINUX_BUILD_DIR}" \
  62. "${PKG_BUILD}" \
  63. "${PACKAGE_DIR}"
  64. prepare:
  65. ifneq ($(KERNEL_MODULES_USED),)
  66. compile: $(LINUX_BUILD_DIR)/modules
  67. else
  68. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  69. endif
  70. install: compile
  71. $(TRACE) target/${ADK_TARGET_ARCH}-modules-install
  72. ifeq ($(ADK_TARGET_PACKAGE_IPKG)$(ADK_TARGET_PACKAGE_OPKG),y)
  73. $(PKG_INSTALL) $(wildcard ${PACKAGE_DIR}/kmod-*) $(MAKE_TRACE)
  74. else
  75. $(foreach pkg,$(wildcard ${PACKAGE_DIR}/kmod-*),$(shell $(PKG_INSTALL) $(pkg)))
  76. endif
  77. clean:
  78. rm -rf $(LINUX_BUILD_DIR)
  79. rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)