blob: 958ed9be0c0b80d82e4dab4aa95f83fd08a0ee87 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001
2# Use the default kernel version if the Makefile doesn't override it
3LINUX_RELEASE?=1
4
5ifdef CONFIG_TESTING_KERNEL
6 KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
7endif
8
9KERNEL_DETAILS_FILE=$(INCLUDE_DIR)/kernel-$(KERNEL_PATCHVER)
10ifeq ($(wildcard $(KERNEL_DETAILS_FILE)),)
11 $(error Missing kernel version/hash file for $(KERNEL_PATCHVER). Please create $(KERNEL_DETAILS_FILE))
12endif
13
14include $(KERNEL_DETAILS_FILE)
15
16ifdef KERNEL_TESTING_PATCHVER
17 KERNEL_TESTING_DETAILS_FILE=$(INCLUDE_DIR)/kernel-$(KERNEL_TESTING_PATCHVER)
18 ifeq ($(wildcard $(KERNEL_TESTING_DETAILS_FILE)),)
19 $(error Missing kernel version/hash file for $(KERNEL_TESTING_PATCHVER). Please create $(KERNEL_TESTING_DETAILS_FILE))
20 endif
21
22 include $(KERNEL_TESTING_DETAILS_FILE)
23endif
24
25remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
26sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
27
28ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
29 LINUX_VERSION:=$(call sanitize_uri,$(call remove_uri_prefix,$(CONFIG_KERNEL_GIT_CLONE_URI)))
30 ifeq ($(call qstrip,$(CONFIG_KERNEL_GIT_REF)),)
31 CONFIG_KERNEL_GIT_REF:=HEAD
32 endif
33 LINUX_VERSION:=$(LINUX_VERSION)-$(call sanitize_uri,$(CONFIG_KERNEL_GIT_REF))
34else
35ifdef KERNEL_PATCHVER
36 LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))
37endif
38ifdef KERNEL_TESTING_PATCHVER
39 LINUX_TESTING_VERSION:=$(KERNEL_TESTING_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_TESTING_PATCHVER)))
40endif
41endif
42
43split_version=$(subst ., ,$(1))
44merge_version=$(subst $(space),.,$(1))
45KERNEL_BASE=$(firstword $(subst -, ,$(LINUX_VERSION)))
46KERNEL=$(call merge_version,$(wordlist 1,2,$(call split_version,$(KERNEL_BASE))))
47KERNEL_PATCHVER ?= $(KERNEL)
48
49# disable the md5sum check for unknown kernel versions
50LINUX_KERNEL_HASH:=$(LINUX_KERNEL_HASH-$(strip $(LINUX_VERSION)))
51LINUX_KERNEL_HASH?=x