kernel: Move kernel part build rules from Makefile to Kbuild#3003
kernel: Move kernel part build rules from Makefile to Kbuild#3003Ylarod merged 5 commits intotiann:mainfrom
Conversation
This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. Signed-off-by: dabao1955 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR refactors the KernelSU build system by moving kernel module build definitions from kernel/Makefile to kernel/Kbuild, following Linux kernel out-of-tree module conventions. The Makefile now serves only as a user-facing entry point that invokes the kernel build system.
Key Changes:
- Relocated all object file declarations (
kernelsu-objs), compiler flags (ccflags-y), and versioning logic from Makefile to Kbuild - Simplified Makefile to contain only build invocation targets (all, compdb, clean)
- Maintained all functional definitions including git version detection, manager signature configuration, and warning suppressions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| kernel/Makefile | Simplified to contain only PHONY targets that invoke the kernel build system via make -C $(KDIR) M=$(MDIR) modules |
| kernel/Kbuild | New file containing all kernel module build rules, object file lists, compiler flags, versioning logic, and security macros previously in Makefile |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Co-authored-by: Copilot <[email protected]>
This reverts commit 1d64c82.
|
missing kernel/selinux/Makefile |
kernel/selinux objects already defined in Kbuild. CC [M] /__w/KernelSU/KernelSU/kernel/selinux/selinux.o
CC [M] /__w/KernelSU/KernelSU/kernel/selinux/sepolicy.o
CC [M] /__w/KernelSU/KernelSU/kernel/selinux/rules.o
LD [M] /__w/KernelSU/KernelSU/kernel/kernelsu.o |
|
so remove it, since it's not needed |
selinux objects already defined on Kbuild.
Deleted. |
|
CC @Ylarod please review |
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
) This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in `kernel/Makefile`—into a dedicated `kernel/Kbuild` file, in strict accordance with the Linux kernel's out-of-tree module conventions. The `Kbuild` file is the standard and only appropriate location for declaring: - Object file lists (`kernelsu-objs`), - Compiler flags (`ccflags-y`), - Conditional logic for versioning (Git revision count), - Security-related macros (e.g., `KSU_VERSION`, `EXPECTED_HASH`, `KSU_MANAGER_PACKAGE`), - Header include paths and warning suppressions. The top-level `kernel/Makefile` is now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system via `make -C $(KDIR) M=$(MDIR) modules`. This separation ensures compatibility with the kernel’s build infrastructure (including `O=` out-of-source builds, LLVM builds, and modpost) and adheres to guidelines in `Documentation/kbuild/modules.rst`. No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices. --------- Signed-off-by: dabao1955 <[email protected]> Co-authored-by: Copilot <[email protected]>
This commit reorganizes the KernelSU build system by relocating all kernel-specific build definitions—previously embedded in
kernel/Makefile—into a dedicatedkernel/Kbuildfile, in strict accordance with the Linux kernel's out-of-tree module conventions.The
Kbuildfile is the standard and only appropriate location for declaring:kernelsu-objs),ccflags-y),KSU_VERSION,EXPECTED_HASH,KSU_MANAGER_PACKAGE),The top-level
kernel/Makefileis now reduced to its intended role: a minimal user-facing entry point that invokes the kernel’s build system viamake -C $(KDIR) M=$(MDIR) modules. This separation ensures compatibility with the kernel’s build infrastructure (includingO=out-of-source builds, LLVM builds, and modpost) and adheres to guidelines inDocumentation/kbuild/modules.rst.No functional or behavioral changes are introduced—this is a pure build-system refactor to improve correctness, maintainability, and alignment with upstream practices.