## Makefile for the Linux kernel module.

# Overwrite the variables of "TARGET、FILE..." 
#	in "./.Kbuild.cfg" according to your needs.
#
# example:
# 	TARGET := module_name
# 	FILES := source1.c source2.c source3.c
#	ccflags-y := -DDEBUG
#	CFLAGS_<source1>.o := -DDEBUG
####################################################
-include $(PWD)/.Kbuild.cfg

# # module name
# TARGET ?= $(notdir $(PWD))
# # source files
# FILES ?= $(notdir $(wildcard $(PWD)/*.c))

ifdef KERNELRELEASE

# ccflags-y := -DDEBUG
# CFLAGS_<file>.o := -DDEBUG

# obj-m += $(TARGET).o
# $(TARGET)-y := $(FILES:%.c=%.o)

obj-m += attackmod.o hello01.o
attackmod-y := attackmod-ko.o entry.o
hello01-y := hello01-ko.o entry.o
# $(warning pwd="$(PWD)" obj-m="$(obj-m)" $(TARGET)-y="$($(TARGET)-y)" )

else

KDIR ?= /lib/modules/$(shell uname -r)/build
INSTALLDIR ?= /lib/modules/$(shell uname -r)/updates

build:
	make -C $(KDIR) M=$(shell pwd) modules

clean:
	make -C $(KDIR) M=$(shell pwd) clean

# test:
# 	insmod $(TARGET).ko dyndbg="+p"
# 	rmmod $(TARGET)

# install:
# 	install -d $(DESTDIR)$(INSTALLDIR)
# 	install -m 644 $(TARGET).ko $(DESTDIR)$(INSTALLDIR)

endif
