1
0

kernel-build.mk 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. ifeq ($(ADK_TARGET_KERNEL_USE_DEFCONFIG),y)
  40. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} $(ADK_TARGET_KERNEL_DEFCONFIG) $(MAKE_TRACE)
  41. else
  42. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
  43. echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
  44. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
  45. endif
  46. touch -c $(LINUX_DIR)/.config
  47. $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
  48. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-compile
  49. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} $(KERNEL_TARGET) $(MAKE_TRACE)
  50. touch -c $(LINUX_DIR)/$(KERNEL_FILE)
  51. $(LINUX_BUILD_DIR)/modules: $(LINUX_DIR)/$(KERNEL_FILE)
  52. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-modules-compile
  53. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} modules $(MAKE_TRACE)
  54. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-modules-install
  55. rm -rf $(LINUX_BUILD_DIR)/modules
  56. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} \
  57. DEPMOD=$(ADK_DEPMOD) \
  58. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  59. modules_install $(MAKE_TRACE)
  60. ifneq ($(ADK_RUNTIME_DEV_UDEV),y)
  61. $(TRACE) target/$(ADK_TARGET_ARCH)-create-packages
  62. @mkdir -p ${PACKAGE_DIR}
  63. PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
  64. "${ADK_TARGET_CPU_ARCH}" \
  65. "${KERNEL_VERSION}" \
  66. "${LINUX_BUILD_DIR}" \
  67. "${PKG_BUILD}" \
  68. "${PACKAGE_DIR}"
  69. endif
  70. prepare:
  71. ifneq ($(KERNEL_MODULES_USED),)
  72. compile: $(LINUX_BUILD_DIR)/modules
  73. else
  74. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  75. endif
  76. install: compile
  77. $(TRACE) target/${ADK_TARGET_ARCH}-modules-install
  78. ifeq ($(ADK_TARGET_PACKAGE_IPKG)$(ADK_TARGET_PACKAGE_OPKG),y)
  79. $(PKG_INSTALL) $(wildcard ${PACKAGE_DIR}/kmod-*) $(MAKE_TRACE)
  80. else
  81. $(foreach pkg,$(wildcard ${PACKAGE_DIR}/kmod-*),$(shell $(PKG_INSTALL) $(pkg)))
  82. endif
  83. clean:
  84. rm -rf $(LINUX_BUILD_DIR)
  85. rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)