vpnhide/kmod/Makefile
okhsunrog e35cf1a6b9 refactor: overhaul kmod build system, fix kernel module bugs
Build system:
- Replace hardcoded paths in Makefile with env vars (KERNEL_SRC, CLANG_DIR)
- Add .env.example and .envrc for direnv-based config
- Simplify build-zip.sh to delegate to make instead of duplicating build command
- Rewrite BUILDING.md: 5-step happy path with direnv, standalone prep as appendix
- Remove redundant quick-reference script and step 7 (manual module.lds hack)

Kernel module (vpnhide_kmod.c):
- Fix fib_route_seq_show hook: save seq_file pointer and buffer position in entry
  handler instead of reading regs->regs[0] in return handler (which holds the
  return value on arm64, not the original argument). Rewrite buffer scanning as
  clean forward iteration with memmove compaction.
- Remove dead SIOCGIFCONF case from dev_ioctl hook (confirmed in kernel source:
  SIOCGIFCONF goes through sock_ioctl -> dev_ifconf, not dev_ioctl on GKI 6.1)
- Fix header comment: remove false tcp4_seq_show claim, correct rtnl symbol name

Test app:
- Auto-run checks on launch (LaunchedEffect) for easier adb-driven testing
2026-04-11 18:50:18 +03:00

35 lines
963 B
Makefile

obj-m += vpnhide_kmod.o
ifeq ($(KERNELRELEASE),)
# KERNEL_SRC and CLANG_DIR come from the environment (set via .env + direnv).
ifndef KERNEL_SRC
$(error KERNEL_SRC is not setcopy .env.example to .env and fill in paths)
endif
ifndef CLANG_DIR
$(error CLANG_DIR is not setcopy .env.example to .env and fill in paths)
endif
ARCH := arm64
CROSS_COMPILE := aarch64-linux-gnu-
CC := $(CLANG_DIR)/clang
LD := $(CLANG_DIR)/ld.lld
AR := $(CLANG_DIR)/llvm-ar
NM := $(CLANG_DIR)/llvm-nm
OBJCOPY := $(CLANG_DIR)/llvm-objcopy
OBJDUMP := $(CLANG_DIR)/llvm-objdump
STRIP := $(CLANG_DIR)/llvm-strip
MAKE_ARGS := -C $(KERNEL_SRC) M=$(CURDIR) \
ARCH=$(ARCH) LLVM=1 LLVM_IAS=1 \
CROSS_COMPILE=$(CROSS_COMPILE) \
CC=$(CC) LD=$(LD) AR=$(AR) NM=$(NM) \
OBJCOPY=$(OBJCOPY) OBJDUMP=$(OBJDUMP) STRIP=$(STRIP)
all:
$(MAKE) $(MAKE_ARGS) modules
clean:
$(MAKE) $(MAKE_ARGS) clean
endif