96 lines
3.4 KiB
Makefile
96 lines
3.4 KiB
Makefile
kernelsu-objs := ksu.o
|
|
kernelsu-objs += allowlist.o
|
|
kernelsu-objs += apk_sign.o
|
|
kernelsu-objs += sucompat.o
|
|
kernelsu-objs += throne_tracker.o
|
|
kernelsu-objs += core_hook.o
|
|
kernelsu-objs += ksud.o
|
|
kernelsu-objs += embed_ksud.o
|
|
kernelsu-objs += kernel_compat.o
|
|
|
|
kernelsu-objs += selinux/
|
|
|
|
obj-$(CONFIG_KPM) += kpm/
|
|
|
|
obj-$(CONFIG_KSU) += kernelsu.o
|
|
|
|
obj-y += check/
|
|
|
|
# Do checks before compile
|
|
ifneq ($(shell grep -q "int path_umount" $(srctree)/fs/namespace.c; echo $$?),0)
|
|
$(error -- Backporting path_umount is mandatory !! Read: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#how-to-backport-path-umount)
|
|
endif
|
|
|
|
# https://github.com/tiann/KernelSU/pull/2102/files#diff-3a325663233178293ee38b8161f3be511a466af7e0156b9d03d5aed0497564bfR19
|
|
IS_GKI := $(strip $(shell \
|
|
if [ "$(VERSION)" -ge "5" -a "$(PATCHLEVEL)" -ge "10" ]; then \
|
|
echo TRUE; \
|
|
else \
|
|
echo FALSE; \
|
|
fi \
|
|
))
|
|
|
|
ifeq ($(IS_GKI),TRUE)
|
|
$(info -- KernelSU: Kernel version is GKI.)
|
|
# GKI manual hook checks
|
|
# https://github.com/Pzqqt/android_kernel_xiaomi_marble/commit/5b8596b5604bcd0e6e12697a01136a0bb9eb0257
|
|
ifeq ($(strip $(CONFIG_KSU_MANUAL_HOOK)),y)
|
|
$(info -- KernelSU: Hooks with Manual hook!)
|
|
ifeq ($(strip $(CONFIG_KSU)),m)
|
|
$(error CONFIG_KSU_MANUAL_HOOK cannot be enabled when compiling KernelSU as LKM!)
|
|
endif
|
|
else
|
|
ccflags-y += -DKSU_HOOK_WITH_KPROBES
|
|
endif
|
|
endif
|
|
|
|
# .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)
|
|
KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count main)
|
|
# ksu_version: major * 10000 + git version + 606 for historical reasons
|
|
$(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 606))
|
|
$(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
|
|
|
|
ifndef KSU_EXPECTED_SIZE
|
|
KSU_EXPECTED_SIZE := 0x35c
|
|
endif
|
|
|
|
ifndef KSU_EXPECTED_HASH
|
|
KSU_EXPECTED_HASH := 947ae944f3de4ed4c21a7e4f7953ecf351bfa2b36239da37a34111ad29993eef
|
|
endif
|
|
|
|
ifdef KSU_MANAGER_PACKAGE
|
|
ccflags-y += -DKSU_MANAGER_PACKAGE=\"$(KSU_MANAGER_PACKAGE)\"
|
|
$(info -- KernelSU Manager package name: $(KSU_MANAGER_PACKAGE))
|
|
endif
|
|
|
|
$(info -- KernelSU Manager signature size: $(KSU_EXPECTED_SIZE))
|
|
$(info -- KernelSU Manager signature hash: $(KSU_EXPECTED_HASH))
|
|
$(info -- Supported Unofficial Manager: 5ec1cff (GKI) rsuntk (Non-GKI) ShirkNeko udochina (GKI and non-GKI and KPM))
|
|
KERNEL_VERSION := $(VERSION).$(PATCHLEVEL)
|
|
$(info -- KERNEL_VERSION: $(KERNEL_VERSION))
|
|
ifeq ($(CONFIG_KPM),y)
|
|
$(info -- KPM is enabled)
|
|
else
|
|
$(info -- KPM is disabled)
|
|
endif
|
|
|
|
ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE)
|
|
ccflags-y += -DEXPECTED_HASH=\"$(KSU_EXPECTED_HASH)\"
|
|
|
|
## For susfs stuff ##
|
|
ifeq ($(shell test -e $(srctree)/fs/susfs.c; echo $$?),0)
|
|
$(eval SUSFS_VERSION=$(shell cat $(srctree)/include/linux/susfs.h | grep -E '^#define SUSFS_VERSION' | cut -d' ' -f3 | sed 's/"//g'))
|
|
$(info )
|
|
$(info -- SUSFS_VERSION: $(SUSFS_VERSION))
|
|
else
|
|
$(info -- You have not integrate susfs in your kernel.)
|
|
$(info -- Read: https://gitlab.com/simonpunk/susfs4ksu)
|
|
endif
|
|
# Keep a new line here!! Because someone may append config
|