Linux-Kernel-Internals - Linux Kernel Internals: https://ankitkdev.com/blog/ - Char Driver: https://ankitkdev.com/blog/linux-kernel/device-driver/char-driver/ - Ioctl Interface: https://ankitkdev.com/blog/linux-kernel/device-driver/ioctl/ - Proc-Interface: https://ankitkdev.com/blog/linux-kernel/device-driver/proc/ - Completion-Variable: https://ankitkdev.com/blog/linux-kernel/concurrency/completion-variable/ - container_of(): https://ankitkdev.com/blog/linux-kernel/macros/container_of/ - Module Parameters: https://ankitkdev.com/blog/linux-kernel/macros/kernel-module/ - pr_fmt(): https://ankitkdev.com/blog/linux-kernel/macros/pr-family/ - Stringification: https://ankitkdev.com/blog/linux-kernel/macros/string/ - Debugging Macros: https://ankitkdev.com/blog/linux-kernel/macros/debug/ - Error Handling with Pointers: https://ankitkdev.com/blog/kernal-internals/error-handling/ - Kbuild Makefile: https://ankitkdev.com/blog/kernal-internals/kbuild/ - SLUB debug: https://ankitkdev.com/blog/kernel-debugging/debug-slub-memory/ - unsigned :\ 0 Bit-Fields in c: https://ankitkdev.com/blog/c/zero-width-bit-field/ - do { ... } while (0): https://ankitkdev.com/blog/c/do-while-loop/ - Error Handling: https://ankitkdev.com/blog/c/error-handling/ - C Memory Layout: https://ankitkdev.com/blog/c/c-memory-layout/ - Forward Declarations: https://ankitkdev.com/blog/c/forward-declaration-in-c/ - Return value by Macro: https://ankitkdev.com/blog/c/return-by-macro/ - Variadic Macro: https://ankitkdev.com/blog/c/variadic-macro/ - programming concepts: https://ankitkdev.com/blog/theory/ - Build & Install Linux Kernel for BBB: https://ankitkdev.com/blog/misc/build-linux-kernel-BBB/ - Configure U-boot for BBB: https://ankitkdev.com/blog/misc/configure-uboot-bbb/ - Install Ubuntu Server on Qemu: https://ankitkdev.com/blog/misc/install-ubuntu-server-on-qemu/ - Linux Kernel Mentorship Program: https://ankitkdev.com/blog/misc/linux-kernel-mentorship-program/ ## Kbuild Makefile > These aren't plain GNU Make, Kbuild (the kernel's build system) reads them with special meaning when you run `make -C /lib/modules/$(uname -r)/build M=$(pwd) modules`. ```makefile CFLAGS_main.o := -DDEBUG ccflags-y := -std=gnu99 -DENABLE_DEBUG proc_fs_basic-objs := main.o obj-m := proc_fs_basic.o ``` - **`CFLAGS_main.o`** - per-object compiler flags. Only `main.o` gets `-DDEBUG`; if you had `main.o` and `helper.o`, only the first sees the macro. Useful for debug-gating one file without recompiling the whole module noisily. - **`ccflags-y`** - flags applied to _every_ `.o` in this Makefile (the module-wide equivalent of `CFLAGS`). Here it forces `gnu99` and defines `ENABLE_DEBUG` globally. - **`proc_fs_basic-objs`** - when a module is built from more than one source file, this lists what gets linked into the final `.ko`. Pattern is `-objs := a.o b.o c.o` (Kbuild also accepts `-y` instead of `-objs` in newer trees). - **`obj-m`** - the actual build trigger. `obj-m` = build as a loadable module → `proc_fs_basic.ko`. Swap it for `obj-y` and it'd get compiled directly into the kernel image instead. > Order of resolution: `obj-m` → Kbuild sees `proc_fs_basic.o` is wanted → checks for `proc_fs_basic-objs` → pulls in `main.o` → applies `CFLAGS_main.o` + `ccflags-y` while compiling it.