linux-backports.mk 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ################################################################################
  2. #
  3. # linux-backports
  4. #
  5. ################################################################################
  6. ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_5_10_X),y)
  7. LINUX_BACKPORTS_VERSION_MAJOR = 5.10.110
  8. LINUX_BACKPORTS_MINIMAL_KVER_MAJOR = 3
  9. LINUX_BACKPORTS_MINIMAL_KVER_MINOR = 10
  10. else
  11. # use default the latest version as default
  12. LINUX_BACKPORTS_VERSION_MAJOR = 5.15.58
  13. LINUX_BACKPORTS_MINIMAL_KVER_MAJOR = 4
  14. LINUX_BACKPORTS_MINIMAL_KVER_MINOR = 4
  15. endif
  16. LINUX_BACKPORTS_VERSION = $(LINUX_BACKPORTS_VERSION_MAJOR)-1
  17. LINUX_BACKPORTS_SOURCE = backports-$(LINUX_BACKPORTS_VERSION).tar.xz
  18. LINUX_BACKPORTS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/projects/backports/stable/v$(LINUX_BACKPORTS_VERSION_MAJOR)
  19. LINUX_BACKPORTS_LICENSE = GPL-2.0
  20. LINUX_BACKPORTS_LICENSE_FILES = \
  21. COPYING \
  22. LICENSES/exceptions/Linux-syscall-note \
  23. LICENSES/preferred/GPL-2.0
  24. # flex and bison are needed to generate kconfig parser. We use the
  25. # same logic as the linux kernel (we add host dependencies only if
  26. # host does not have them). See linux/linux.mk and
  27. # support/dependencies/check-host-bison-flex.mk.
  28. LINUX_BACKPORTS_DEPENDENCIES = \
  29. $(BR2_BISON_HOST_DEPENDENCY) \
  30. $(BR2_FLEX_HOST_DEPENDENCY)
  31. ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_DEFCONFIG),y)
  32. LINUX_BACKPORTS_KCONFIG_FILE = $(LINUX_BACKPORTS_DIR)/defconfigs/$(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG))
  33. else ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_CUSTOM_CONFIG),y)
  34. LINUX_BACKPORTS_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_CUSTOM_CONFIG_FILE))
  35. endif
  36. LINUX_BACKPORTS_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_CONFIG_FRAGMENT_FILES))
  37. LINUX_BACKPORTS_KCONFIG_OPTS = $(LINUX_BACKPORTS_MAKE_OPTS)
  38. # linux-backports' build system expects the config options to be present
  39. # in the environment, and it is so when using their custom buildsystem,
  40. # because they are set in the main Makefile, which then calls a second
  41. # Makefile.
  42. #
  43. # In our case, we do not use that first Makefile. So, we parse the
  44. # .config file, filter-out comment lines and put the rest as command
  45. # line variables.
  46. #
  47. # LINUX_BACKPORTS_MAKE_OPTS is used by the kconfig-package infra, while
  48. # LINUX_BACKPORTS_MODULE_MAKE_OPTS is used by the kernel-module infra.
  49. #
  50. LINUX_BACKPORTS_MAKE_OPTS = \
  51. LEX=flex \
  52. YACC=bison \
  53. BACKPORT_DIR=$(@D) \
  54. KLIB_BUILD=$(LINUX_DIR) \
  55. KLIB=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
  56. INSTALL_MOD_DIR=backports \
  57. `sed -r -e '/^\#/d;' $(@D)/.config`
  58. LINUX_BACKPORTS_MODULE_MAKE_OPTS = $(LINUX_BACKPORTS_MAKE_OPTS)
  59. # This file is not automatically generated by 'oldconfig' that we use in
  60. # the kconfig-package infrastructure. In the linux buildsystem, it is
  61. # generated by running silentoldconfig, but that's not the case for
  62. # linux-backports: it uses a hand-crafted rule to generate that file.
  63. define LINUX_BACKPORTS_KCONFIG_FIXUP_CMDS
  64. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(LINUX_BACKPORTS_MAKE_OPTS) backport-include/backport/autoconf.h
  65. endef
  66. # Checks to give errors that the user can understand
  67. ifeq ($(BR_BUILDING),y)
  68. ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_DEFCONFIG),y)
  69. ifeq ($(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG)),)
  70. $(error No linux-backports defconfig name specified, check your BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG setting)
  71. endif
  72. endif
  73. ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_CUSTOM_CONFIG),y)
  74. ifeq ($(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_CUSTOM_CONFIG_FILE)),)
  75. $(error No linux-backports configuration file specified, check your BR2_PACKAGE_LINUX_BACKPORTS_CUSTOM_CONFIG_FILE setting)
  76. endif
  77. endif
  78. endif # BR_BUILDING
  79. $(eval $(kernel-module))
  80. $(eval $(kconfig-package))
  81. # linux-backports' own .config file needs options from the kernel's own
  82. # .config file. The dependencies handling in the infrastructure does not
  83. # allow to express this kind of dependencies. Besides, linux.mk might
  84. # not have been parsed yet, so the Linux build dir LINUX_DIR is not yet
  85. # known. Thus, we use a "secondary expansion" so the rule is re-evaluated
  86. # after all Makefiles are parsed, and thus at that time we will have the
  87. # LINUX_DIR variable set to the proper value. Moreover, since linux-4.19,
  88. # the kernel's build system internally touches its .config file, so we
  89. # can't use it as a stamp file. We use the LINUX_KCONFIG_STAMP_DOTCONFIG
  90. # instead.
  91. #
  92. # Furthermore, we want to check the kernel version is compatible with
  93. # linux-backports. To avoid overriding linux-backports'
  94. # KCONFIG_STAMP_DOTCONFIG rule defined in the kconfig-package infra, we
  95. # use an intermediate stamp-file.
  96. #
  97. # Finally, it must also come after the call to kconfig-package, so we get
  98. # LINUX_BACKPORTS_DIR properly defined (because the target part of the
  99. # rule is not re-evaluated).
  100. #
  101. $(LINUX_BACKPORTS_DIR)/$(LINUX_BACKPORTS_KCONFIG_STAMP_DOTCONFIG): $(LINUX_BACKPORTS_DIR)/.stamp_check_kernel_version
  102. .SECONDEXPANSION:
  103. $(LINUX_BACKPORTS_DIR)/.stamp_check_kernel_version: $$(LINUX_DIR)/$$(LINUX_KCONFIG_STAMP_DOTCONFIG)
  104. $(Q)KVER=$(LINUX_VERSION_PROBED); \
  105. MIN_KVER_MAJOR=$(LINUX_BACKPORTS_MINIMAL_KVER_MAJOR); \
  106. MIN_KVER_MINOR=$(LINUX_BACKPORTS_MINIMAL_KVER_MINOR); \
  107. KVER_MAJOR=`echo $${KVER} | sed 's/^\([0-9]*\)\..*/\1/'`; \
  108. KVER_MINOR=`echo $${KVER} | sed 's/^[0-9]*\.\([0-9]*\).*/\1/'`; \
  109. if [ $${KVER_MAJOR} -lt $(LINUX_BACKPORTS_MINIMAL_KVER_MAJOR) \
  110. -o \( $${KVER_MAJOR} -eq $(LINUX_BACKPORTS_MINIMAL_KVER_MAJOR) \
  111. -a $${KVER_MINOR} -lt $(LINUX_BACKPORTS_MINIMAL_KVER_MINOR) \
  112. \) ]; then \
  113. printf "Linux version '%s' is too old for linux-backports (needs %s.%s or later)\n" \
  114. "$${KVER}" \
  115. "$(LINUX_BACKPORTS_MINIMAL_KVER_MAJOR)" \
  116. "$(LINUX_BACKPORTS_MINIMAL_KVER_MINOR)"; \
  117. exit 1; \
  118. fi
  119. $(Q)touch $(@)