From 03933c30ab11cab781cc74fe826b18deba4930fe Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Sun, 6 Apr 2025 13:33:57 +0800 Subject: [PATCH] Update Makefile --- kernel/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index 8f855e0c..7682cbb7 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -47,14 +47,17 @@ endif obj-$(CONFIG_KSU) += kernelsu.o +# .git is a text file while the module is imported by 'git submodule add'. ifeq ($(shell test -e $(srctree)/$(src)/../.git; echo $$?),0) $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin [ -f ../.git/shallow ] && git fetch --unshallow) -# Get the number of commits on the main branch KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count main) -# Calculate KSU_VERSION +# ksu_version: major * 10000 + git version + 606 for historical reasons $(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 606)) -$(info -- KernelSU version (main): $(KSU_VERSION)) +$(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=12500 endif # SELinux drivers check