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