kernel-build.mk 5.2 KB

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