package/rpcbind: fix musl build
[buildroot-gz.git] / package / linux-backports / linux-backports.mk
blob58cd50f2c430458ac56cd45838af83d7e49fdbcf
1 ################################################################################
3 # linux-backports
5 ################################################################################
7 LINUX_BACKPORTS_VERSION_MAJOR = 4.4.2
8 LINUX_BACKPORTS_VERSION = $(LINUX_BACKPORTS_VERSION_MAJOR)-1
9 LINUX_BACKPORTS_SOURCE = backports-$(LINUX_BACKPORTS_VERSION).tar.xz
10 LINUX_BACKPORTS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/projects/backports/stable/v$(LINUX_BACKPORTS_VERSION_MAJOR)
11 LINUX_BACKPORTS_LICENSE = GPLv2
12 LINUX_BACKPORTS_LICENSE_FILES = COPYING
14 ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_DEFCONFIG),y)
15 LINUX_BACKPORTS_KCONFIG_FILE = $(LINUX_BACKPORTS_DIR)/defconfigs/$(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG))
16 else ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_CUSTOM_CONFIG),y)
17 LINUX_BACKPORTS_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_CUSTOM_CONFIG_FILE))
18 endif
20 LINUX_BACKPORTS_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_CONFIG_FRAGMENT_FILES))
21 LINUX_BACKPORTS_KCONFIG_OPTS = $(LINUX_BACKPORTS_MAKE_OPTS)
23 # linux-backports' build system expects the config options to be present
24 # in the environment, and it is so when using their custom buildsystem,
25 # because they are set in the main Makefile, which then calls a second
26 # Makefile.
28 # In our case, we do not use that first Makefile. So, we parse the
29 # .config file, filter-out comment lines and put the rest as command
30 # line variables.
32 # LINUX_BACKPORTS_MAKE_OPTS is used by the kconfig-package infra, while
33 # LINUX_BACKPORTS_MODULE_MAKE_OPTS is used by the kernel-module infra.
35 LINUX_BACKPORTS_MAKE_OPTS = \
36 BACKPORT_DIR=$(@D) \
37 KLIB_BUILD=$(LINUX_DIR) \
38 KLIB=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
39 INSTALL_MOD_DIR=backports \
40 `sed -r -e '/^\#/d;' $(@D)/.config`
42 LINUX_BACKPORTS_MODULE_MAKE_OPTS = $(LINUX_BACKPORTS_MAKE_OPTS)
44 # This file is not automatically generated by 'oldconfig' that we use in
45 # the kconfig-package infrastructure. In the linux buildsystem, it is
46 # generated by running silentoldconfig, but that's not the case for
47 # linux-backports: it uses a hand-crafted rule to generate that file.
48 define LINUX_BACKPORTS_KCONFIG_FIXUP_CMDS
49 $(MAKE) -C $(@D) $(LINUX_BACKPORTS_MAKE_OPTS) backport-include/backport/autoconf.h
50 endef
52 # Checks to give errors that the user can understand
53 ifeq ($(BR_BUILDING),y)
55 ifeq ($(BR2_PACKAGE_LINUX_BACKPORTS_USE_DEFCONFIG),y)
56 ifeq ($(call qstrip,$(BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG)),)
57 $(error No linux-backports defconfig name specified, check your BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG setting)
58 endif
59 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
67 endif # BR_BUILDING
69 $(eval $(kernel-module))
70 $(eval $(kconfig-package))
72 # linux-backports' own .config file needs options from the kernel's own
73 # .config file. The dependencies handling in the infrastructure does not
74 # allow to express this kind of dependencies. Besides, linux.mk might
75 # not have been parsed yet, so the Linux build dir LINUX_DIR is not yet
76 # known. Thus, we use a "secondary expansion" so the rule is re-evaluated
77 # after all Makefiles are parsed, and thus at that time we will have the
78 # LINUX_DIR variable set to the proper value.
80 # Furthermore, we want to check the kernel version, since linux-backports
81 # only supports kernels >= 3.0. To avoid overriding linux-backports'
82 # .config rule defined in the kconfig-package infra, we use an
83 # intermediate stamp-file.
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).
89 $(LINUX_BACKPORTS_DIR)/.config: $(LINUX_BACKPORTS_DIR)/.stamp_check_kernel_version
91 .SECONDEXPANSION:
92 $(LINUX_BACKPORTS_DIR)/.stamp_check_kernel_version: $$(LINUX_DIR)/.config
93 $(Q)LINUX_VERSION_PROBED=$(LINUX_VERSION_PROBED); \
94 if [ $${LINUX_VERSION_PROBED%%.*} -lt 3 ]; then \
95 printf "Linux version '%s' is too old for linux-backports (needs 3.0 or later)\n" \
96 "$${LINUX_VERSION_PROBED}"; \
97 exit 1; \
99 $(Q)touch $(@)