1
0

kernel-build.mk 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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/$(ADK_TARGET_OS)-ver.mk
  5. include $(ADK_TOPDIR)/mk/$(ADK_TARGET_OS).mk
  6. include $(ADK_TOPDIR)/mk/kernel-vars.mk
  7. ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
  8. KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH))
  9. else
  10. KERNEL_MODULES_USED:=$(shell grep ^ADK_$(ADK_TARGET_OS)_KERNEL $(ADK_TOPDIR)/.config|grep =m)
  11. endif
  12. KERNEL_FILE:=$(ADK_TARGET_KERNEL)
  13. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  14. ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
  15. KERNEL_FILE:=vmlinux
  16. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  17. endif
  18. ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
  19. KERNEL_FILE:=vmlinux
  20. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  21. endif
  22. ifeq ($(ADK_TARGET_KERNEL_VMLINUX_BOOTP),y)
  23. KERNEL_FILE:=bootpfile
  24. KERNEL_TARGET:=bootpfile
  25. endif
  26. ifeq ($(ADK_TARGET_KERNEL_VMLINUX_GZ),y)
  27. KERNEL_FILE:=vmlinux
  28. KERNEL_TARGET:=all
  29. endif
  30. ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
  31. KERNEL_FILE:=vmlinux
  32. KERNEL_TARGET:=all
  33. endif
  34. ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
  35. KERNEL_FILE:=vmlinux
  36. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  37. endif
  38. ifneq ($(KERNEL_MODULES_USED),)
  39. KERNEL_TARGET+=modules
  40. endif
  41. ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
  42. ADK_DEPMOD:=$(STAGING_HOST_DIR)/usr/bin/depmod
  43. else
  44. ADK_DEPMOD:=true
  45. endif
  46. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(ADK_TARGET_OS)-$(KERNEL_FILE_VER)/.patched
  47. ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(ADK_TARGET_OS)-$(KERNEL_FILE_VER) $(LINUX_DIR)
  48. mkdir -p $(LINUX_BUILD_DIR)/kmod-control
  49. touch $@
  50. ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_MINICONFIG)$(ADK_TARGET_WALDUX_KERNEL_USE_MINICONFIG),y)
  51. $(LINUX_DIR)/.config: $(BUILD_DIR)/.kernelconfig
  52. endif
  53. ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
  54. $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH):
  55. $(LINUX_DIR)/.config: $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH)
  56. endif
  57. ifeq ($(ADK_TARGET_WALDUX_KERNEL_USE_CUSTOMCONFIG),y)
  58. $(ADK_TOPDIR)/$(ADK_TARGET_WALDUX_KERNEL_CUSTOMCONFIG_PATH):
  59. $(LINUX_DIR)/.config: $(ADK_TOPDIR)/$(ADK_TARGET_WALDUX_KERNEL_CUSTOMCONFIG_PATH)
  60. endif
  61. $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared
  62. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-configure.. "
  63. echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
  64. ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_DEFCONFIG)$(ADK_TARGET_WALDUX_KERNEL_USE_DEFCONFIG),y)
  65. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} $(ADK_TARGET_KERNEL_DEFCONFIG) $(MAKE_TRACE)
  66. else ifeq ($(ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG),y)
  67. @if [ ! -f $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH) ];then \
  68. echo "no kernel configuration found in $(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH)"; \
  69. exit 1; \
  70. fi
  71. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=$(ADK_TOPDIR)/$(ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH) allnoconfig $(MAKE_TRACE)
  72. else ifeq ($(ADK_TARGET_WALDUX_KERNEL_USE_CUSTOMCONFIG),y)
  73. @if [ ! -f $(ADK_TOPDIR)/$(ADK_TARGET_WALDUX_KERNEL_CUSTOMCONFIG_PATH) ];then \
  74. echo "no kernel configuration found in $(ADK_TOPDIR)/$(ADK_TARGET_WALDUX_KERNEL_CUSTOMCONFIG_PATH)"; \
  75. exit 1; \
  76. fi
  77. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=$(ADK_TOPDIR)/$(ADK_TARGET_WALDUX_KERNEL_CUSTOMCONFIG_PATH) allnoconfig $(MAKE_TRACE)
  78. else
  79. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
  80. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
  81. endif
  82. $(CMD_TRACE) " done"
  83. $(END_TRACE)
  84. $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
  85. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-compile.. "
  86. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} $(KERNEL_TARGET) $(MAKE_TRACE)
  87. $(CMD_TRACE) " done"
  88. $(END_TRACE)
  89. prepare:
  90. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  91. install:
  92. ifneq ($(KERNEL_MODULES_USED),)
  93. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-install.. "
  94. rm -rf $(LINUX_BUILD_DIR)/modules
  95. ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} \
  96. DEPMOD=$(ADK_DEPMOD) \
  97. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  98. modules_install $(MAKE_TRACE)
  99. $(CMD_TRACE) " done"
  100. $(END_TRACE)
  101. ifeq ($(ADK_RUNTIME_DEV_UDEV),)
  102. $(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-modules-create-packages.. "
  103. rm -f ${PACKAGE_DIR}/kmod-*
  104. PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/make-module-ipkgs.sh \
  105. "${ADK_TARGET_CPU_ARCH}" \
  106. "${KERNEL_VERSION}" \
  107. "${LINUX_BUILD_DIR}" \
  108. "${PKG_BUILD}" \
  109. "${PACKAGE_DIR}"
  110. $(CMD_TRACE) " done"
  111. $(END_TRACE)
  112. endif
  113. $(START_TRACE) "target/${ADK_TARGET_ARCH}-kernel-modules-install-packages.. "
  114. for pkg in $(PACKAGE_DIR)/kmod-*; do \
  115. [[ -e "$$pkg" ]] && $(PKG_INSTALL) $$pkg; \
  116. done
  117. $(CMD_TRACE) " done"
  118. $(END_TRACE)
  119. endif
  120. clean:
  121. rm -rf $(LINUX_BUILD_DIR)
  122. rm -f $(wildcard ${PACKAGE_DIR}/kmod-*) $(wildcard ${PACKAGE_DIR}/kernel_*)