# Comment/uncomment the following line to disable/enable debugging
# DEBUG = y

# Change it here or specify it on the "make" commandline
INCLUDEDIR = /lib/modules/2.4.20-4GB/build/include

ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DCIF_DEBUG # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif

CFLAGS = -D__KERNEL__ -DMODULE -Wall $(DEBFLAGS)
CFLAGS += -I.. -I$(INCLUDEDIR)

# Extract version number from headers.
VER = $(shell awk -F\" '/REL/ {print $$2}' $(INCLUDEDIR)/linux/version.h)

TARGET = cif
TARGETDIR = ../drv
OBJS = $(TARGETDIR)/$(TARGET).o
SRC = cif_main.c cif_irq.c cif_dev.c cif_ioctl.c

all: .depend $(TARGETDIR)/$(TARGET).o


$(TARGETDIR)/$(TARGET).o: $(SRC:.c=.o)
	$(LD) -r $^ -o $@

install:
	mkdir -p /lib/modules/$(VER)/misc /lib/modules/misc
	install -c $(TARGETDIR)/$(TARGET).o /lib/modules/$(VER)/misc
	install -c $(TARGETDIR)/$(TARGET).o /lib/modules/misc


clean:
	rm -f *.o log .depend dep *~

depend .depend dep:
	$(CC) $(CFLAGS) -M *.c > $@

ifeq (.depend,$(wildcard .depend))
include .depend
endif
