#KERNEL = /usr/src/linux-2.2.10
#KERNEL = /usr/src/linux-2.2.16.SuSE
#KERNEL = /usr/src/linux-2.4.10.SuSE
KERNEL = /usr/src/linux

ARCH=$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sall0/arm/)

CFLAGS = -D__KERNEL__ -DMODULE -I$(KERNEL)/include
CFLAGS+= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing

all: cwkeyer_mod.o testmorse

# get configuration of kernel
include $(KERNEL)/.config

# modify CFLAGS with architecture specific flags
include $(KERNEL)/arch/$(ARCH)/Makefile

# enable the module versions, if configured in the kernel source tree
ifdef CONFIG_MODVERSIONS
CFLAGS+= -DMODVERSIONS -include $(KERNEL)/include/linux/modversions.h
endif

# enable SMP, if defined in the kernel source tree
ifdef CONFIG_SMP
CFLAGS+= -D__SMP__
endif
cwkeyer_mod.o:	cwkeyer.o
		$(LD) -r -o cwkeyer_mod.o cwkeyer.o

cwkeyer.o:	cwkeyer.c cwkeyer.h
		$(CC) $(CFLAGS) -c cwkeyer.c 

testmorse: testmorse.c cwkeyer.h
		$(CC) -O2 testmorse.c -o testmorse

clean:
		rm -f *.o *~ testmorse core
