obj-m += sehcio.o

KDIR := /home/anhnv/robotnet/kernels/linux-6.12.39
KBUILD_EXTRA_SYMBOLS := /home/anhnv/robotnet/ethercat/Module.symvers
ccflags-y := -I/home/anhnv/robotnet/ethercat/include

SIGN_SCRIPT := $(KDIR)/scripts/sign-file
SIGN_KEY := $(KDIR)/certs/signing_key.pem
SIGN_CERT := $(KDIR)/certs/signing_key.x509

all:
	make -C $(KDIR) M=$(PWD) modules
	@if [ -f $(SIGN_SCRIPT) ] && [ -f $(SIGN_KEY) ] && [ -f $(SIGN_CERT) ]; then \
		echo "Signing module sehcio.ko..."; \
		$(SIGN_SCRIPT) sha256 $(SIGN_KEY) $(SIGN_CERT) sehcio.ko; \
	else \
		echo "Warning: Module signing files not found, skipping signing"; \
	fi

clean:
	make -C $(KDIR) M=$(PWD) clean
