  CC=gcc
KERNELVER :=	$(shell uname -r)
KERNSRCTREE :=	/usr/src/linux-$(KERNELVER)
MODULEPATH :=	/lib/modules/$(KERNELVER)
MODCFLAGS :=	-Wall -DMODULE -DWITH_TCP_UNIQUE -D__SMP__ -D__KERNEL__ -DLINUX -I$(KERNSRCTREE)/include

all:		ipdsend ipdrecv
debug:		debugall
debugall:	debugsend debugrecv
clean:		cleanall
cleanall:	cleansend cleanrecv
debugsend:	ipdsend.c $(KERNSRCTREE)/include/linux/version.h
		$(CC) $(MODCFLAGS) -DDEBUG -c ipdsend.c
		@echo insmod ipdsend.o to turn it on
		@echo rmmod ipdsend to turn if off
		@echo
		@echo X and kernel programming do not mix.
		@echo Do the insmod and rmmod from outside X.

ipdsend:	ipdsend.c $(KERNSRCTREE)/include/linux/version.h
		$(CC) $(MODCFLAGS) -c ipdsend.c
		@echo insmod ipdsend.o to turn it on
		@echo rmmod ipdsend to turn if off
		@echo
		@echo X and kernel programming do not mix.
		@echo Do the insmod and rmmod from outside X.
cleansend:
		rm -f ipdsend.o

ipdrecv:	ipdrecv.c $(KERNSRCTREE)/include/linux/version.h
		$(CC) $(MODCFLAGS) -c ipdrecv.c
		@echo insmod ipdrecv.o to turn it on
		@echo rmmod ipdrecv to turn if off
		@echo
		@echo X and kernel programming do not mix.
		@echo Do the insmod and rmmod from outside X.

debugrecv:	ipdrecv.c $(KERNSRCTREE)/include/linux/version.h
		$(CC) $(MODCFLAGS) -DDEBUG -c ipdrecv.c
		@echo insmod ipdrecv.o to turn it on
		@echo rmmod ipdrecv to turn if off
		@echo
		@echo X and kernel programming do not mix.
		@echo Do the insmod and rmmod from outside X.

cleanrecv:
		rm -f ipdrecv.o

install:	installsend installrecv
installsend:	makemodulepath
		cp ipdsend.o $(MODULEPATH)/ipd
installrecv:	makemodulepath
		cp ipdrecv.o $(MODULEPATH)/ipd
makemodulepath:
		mkdir -p $(MODULEPATH)/ipd

patch:
		cp ipdpatch $(KERNSRCTREE)/
		-(cd $(KERNSRCTREE); patch -p 1 -Nui ipdpatch)


