diff --git a/kernel/Makefile b/kernel/Makefile index 5e532cff..6ff901f0 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -15,7 +15,13 @@ obj-y += selinux/ # .git is a text file while the module is imported by 'git submodule add'. ifeq ($(shell test -e $(srctree)/$(src)/../.git; echo $$?),0) KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count HEAD) -ccflags-y += -DKSU_GIT_VERSION=$(KSU_GIT_VERSION) +# ksu_version: major * 10000 + git version + 200 for historical reasons +$(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 200)) +$(info -- KernelSU version: $(KSU_VERSION)) +ccflags-y += -DKSU_VERSION=$(KSU_VERSION) +else # If there is no .git file, the default version will be passed. +$(warning "KSU_GIT_VERSION not defined! It is better to make KernelSU a git submodule!") +ccflags-y += -DKSU_VERSION=16 endif ifndef EXPECTED_SIZE diff --git a/kernel/ksu.h b/kernel/ksu.h index dae32738..cdffb5ae 100644 --- a/kernel/ksu.h +++ b/kernel/ksu.h @@ -4,16 +4,7 @@ #include "linux/types.h" #include "linux/workqueue.h" -#ifndef KSU_GIT_VERSION -#warning \ - "KSU_GIT_VERSION not defined! It is better to make KernelSU a git submodule!" -#define KERNEL_SU_VERSION (16) -#else -#define KERNEL_SU_VERSION \ - (10000 + KSU_GIT_VERSION + \ - 200) // major * 10000 + git version + 200 for historical reasons -#endif - +#define KERNEL_SU_VERSION KSU_VERSION #define KERNEL_SU_OPTION 0xDEADBEEF #define CMD_GRANT_ROOT 0