132 lines
4.7 KiB
Makefile
132 lines
4.7 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/selinux.o
|
|
kernelsu-objs += selinux/sepolicy.o
|
|
kernelsu-objs += selinux/rules.o
|
|
ccflags-y += -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include
|
|
ccflags-y += -I$(objtree)/security/selinux -include $(srctree)/include/uapi/asm-generic/errno.h
|
|
|
|
obj-$(CONFIG_KSU) += kernelsu.o
|
|
|
|
obj-$(CONFIG_KPM) += kpm/
|
|
|
|
|
|
# .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 -- SukiSU 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 SukiSU a git submodule!")
|
|
ccflags-y += -DKSU_VERSION=12800
|
|
endif
|
|
|
|
# Checks hooks state
|
|
ifeq ($(strip $(CONFIG_KSU_MANUAL_HOOK)),y)
|
|
$(info -- KernelSU: Manually-patched hook.)
|
|
else
|
|
$(info -- KernelSU: Kernel-probe hook.)
|
|
ccflags-y += -DCONFIG_KSU_KPROBES_HOOK
|
|
endif
|
|
|
|
# SELinux drivers check
|
|
ifeq ($(shell grep -q "current_sid(void)" $(srctree)/security/selinux/include/objsec.h; echo $$?),0)
|
|
ccflags-y += -DKSU_COMPAT_HAS_CURRENT_SID
|
|
endif
|
|
ifeq ($(shell grep -q "struct selinux_state " $(srctree)/security/selinux/include/security.h; echo $$?),0)
|
|
ccflags-y += -DKSU_COMPAT_HAS_SELINUX_STATE
|
|
endif
|
|
|
|
# This feature was introduced in linux 5.0-rc1
|
|
ifeq ($(shell grep -q "get_cred_rcu" $(srctree)/include/linux/cred.h; echo $$?),0)
|
|
ccflags-y += -DKSU_COMPAT_HAS_GET_CRED_RCU
|
|
else
|
|
ifeq ($(shell grep -q "atomic_long_t\s\+usage" $(srctree)/include/linux/cred.h; echo $$?),0)
|
|
ccflags-y += -DKSU_COMPAT_ATOMIC_LONG
|
|
endif
|
|
ifeq ($(shell grep -q "int\s\+non_rcu" $(srctree)/include/linux/cred.h; echo $$?),0)
|
|
ccflags-y += -DKSU_COMPAT_HAS_NONCONST_CRED
|
|
endif
|
|
endif
|
|
|
|
# Handle optional backports
|
|
ifeq ($(shell grep -q "strncpy_from_user_nofault" $(srctree)/include/linux/uaccess.h; echo $$?),0)
|
|
ccflags-y += -DKSU_OPTIONAL_STRNCPY
|
|
endif
|
|
ifeq ($(shell grep -q "ssize_t kernel_read" $(srctree)/fs/read_write.c; echo $$?),0)
|
|
ccflags-y += -DKSU_OPTIONAL_KERNEL_READ
|
|
endif
|
|
ifeq ($(shell grep "ssize_t kernel_write" $(srctree)/fs/read_write.c | grep -q "const void" ; echo $$?),0)
|
|
ccflags-y += -DKSU_OPTIONAL_KERNEL_WRITE
|
|
endif
|
|
ifeq ($(shell grep -q "int\s\+path_umount" $(srctree)/fs/namespace.c; echo $$?),0)
|
|
ccflags-y += -DKSU_HAS_PATH_UMOUNT
|
|
endif
|
|
|
|
# Checks Samsung UH drivers
|
|
ifeq ($(shell grep -q "CONFIG_KDP_CRED" $(srctree)/kernel/cred.c; echo $$?),0)
|
|
ccflags-y += -DSAMSUNG_UH_DRIVER_EXIST
|
|
endif
|
|
|
|
# Samsung SELinux Porting
|
|
ifeq ($(shell grep -q "SEC_SELINUX_PORTING_COMMON" $(srctree)/security/selinux/avc.c; echo $$?),0)
|
|
ccflags-y += -DSAMSUNG_SELINUX_PORTING
|
|
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 -- SukiSU Manager package name: $(KSU_MANAGER_PACKAGE))
|
|
endif
|
|
|
|
$(info -- SukiSU Manager signature size: $(KSU_EXPECTED_SIZE))
|
|
$(info -- SukiSU Manager signature hash: $(KSU_EXPECTED_HASH))
|
|
$(info -- Supported Unofficial Manager: 5ec1cff (GKI) ShirkNeko udochina (GKI and KPM))
|
|
KERNEL_VERSION := $(VERSION).$(PATCHLEVEL)
|
|
KERNEL_TYPE := Non-GKI
|
|
# Check for GKI 2.0 (5.10+ or 6.x+)
|
|
ifneq ($(shell test \( $(VERSION) -ge 5 -a $(PATCHLEVEL) -ge 10 \) -o $(VERSION) -ge 6; echo $$?),0)
|
|
# Check for GKI 1.0 (5.4)
|
|
ifeq ($(shell test $(VERSION)-$(PATCHLEVEL) = 5-4; echo $$?),0)
|
|
KERNEL_TYPE := GKI 1.0
|
|
endif
|
|
else
|
|
KERNEL_TYPE := GKI 2.0
|
|
endif
|
|
$(info -- KERNEL_VERSION: $(KERNEL_VERSION))
|
|
$(info -- KERNEL_TYPE: $(KERNEL_TYPE))
|
|
|
|
$(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)\"
|
|
|
|
ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat
|
|
ccflags-y += -Wno-declaration-after-statement -Wno-unused-function
|
|
|
|
# Keep a new line here!! Because someone may append config
|