linux-backports.mk 4.8 KB

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