package/network/utils/iptables: fix PKG_CPE_ID
[openwrt/openwrt.git] / include / kernel-version.mk
1
2 # Use the default kernel version if the Makefile doesn't override it
3 LINUX_RELEASE?=1
4
5 ifdef CONFIG_TESTING_KERNEL
6 KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
7 endif
8
9 KERNEL_DETAILS_FILE=$(INCLUDE_DIR)/kernel-$(KERNEL_PATCHVER)
10 ifeq ($(wildcard $(KERNEL_DETAILS_FILE)),)
11 $(error Missing kernel version/hash file for $(KERNEL_PATCHVER). Please create $(KERNEL_DETAILS_FILE))
12 endif
13
14 include $(KERNEL_DETAILS_FILE)
15
16 ifdef 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)
23 endif
24
25 remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
26 sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
27
28 ifneq ($(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))
34 else
35 ifdef KERNEL_PATCHVER
36 LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))
37 endif
38 ifdef KERNEL_TESTING_PATCHVER
39 LINUX_TESTING_VERSION:=$(KERNEL_TESTING_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_TESTING_PATCHVER)))
40 endif
41 endif
42
43 split_version=$(subst ., ,$(1))
44 merge_version=$(subst $(space),.,$(1))
45 KERNEL_BASE=$(firstword $(subst -, ,$(LINUX_VERSION)))
46 KERNEL=$(call merge_version,$(wordlist 1,2,$(call split_version,$(KERNEL_BASE))))
47 KERNEL_PATCHVER ?= $(KERNEL)
48
49 # disable the md5sum check for unknown kernel versions
50 LINUX_KERNEL_HASH:=$(LINUX_KERNEL_HASH-$(strip $(LINUX_VERSION)))
51 LINUX_KERNEL_HASH?=x