kernel-version.mk 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Use the default kernel version if the Makefile doesn't override it
  2. LINUX_RELEASE?=1
  3. ifdef CONFIG_TESTING_KERNEL
  4. KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
  5. endif
  6. KERNEL_DETAILS_FILE=$(INCLUDE_DIR)/kernel-$(KERNEL_PATCHVER)
  7. ifeq ($(wildcard $(KERNEL_DETAILS_FILE)),)
  8. $(error Missing kernel version/hash file for $(KERNEL_PATCHVER). Please create $(KERNEL_DETAILS_FILE))
  9. endif
  10. include $(KERNEL_DETAILS_FILE)
  11. remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
  12. sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
  13. ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
  14. LINUX_VERSION:=$(call sanitize_uri,$(call remove_uri_prefix,$(CONFIG_KERNEL_GIT_CLONE_URI)))
  15. ifeq ($(call qstrip,$(CONFIG_KERNEL_GIT_REF)),)
  16. CONFIG_KERNEL_GIT_REF:=HEAD
  17. endif
  18. LINUX_VERSION:=$(LINUX_VERSION)-$(call sanitize_uri,$(CONFIG_KERNEL_GIT_REF))
  19. else
  20. ifdef KERNEL_PATCHVER
  21. LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))
  22. endif
  23. ifdef KERNEL_TESTING_PATCHVER
  24. LINUX_TESTING_VERSION:=$(KERNEL_TESTING_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_TESTING_PATCHVER)))
  25. endif
  26. endif
  27. split_version=$(subst ., ,$(1))
  28. merge_version=$(subst $(space),.,$(1))
  29. KERNEL_BASE=$(firstword $(subst -, ,$(LINUX_VERSION)))
  30. KERNEL=$(call merge_version,$(wordlist 1,2,$(call split_version,$(KERNEL_BASE))))
  31. KERNEL_PATCHVER ?= $(KERNEL)
  32. # disable the md5sum check for unknown kernel versions
  33. LINUX_KERNEL_HASH:=$(LINUX_KERNEL_HASH-$(strip $(LINUX_VERSION)))
  34. LINUX_KERNEL_HASH?=x