# Kvaser CAN driver PCIcan II hardware specific parts                    
# Makefile for the PCIcan II kernel module.                              
# Copyright (C) 2003 Kvaser AB - support@kvaser.com - www.kvaser.com

include ../config.mak

#if debug
ifeq ($(KV_DEBUG_ON),1)
	CFLAGS+=$(KV_DEBUGFLAGS)
else

endif


PCICANII = kvpcicanII.o
CFLAGS += -Wall  -D__KERNEL__ -DMODULE -fomit-frame-pointer $(XTRA_CFLAGS)
CFLAGS += -DSPLIT -I$(INCLUDES) -DLINUX=1 -D_LINUX=1
# Which kernel headers to use - Use the current kernel
CPPFLAGS += -I/lib/modules/`uname -r`/build/include

SRCS := PciCanIIHwIf.c ../common/VCanOsIf.c
SRCS += ../common/osif_functions_kernel.c
SRCS += memQ.c

OBJS := $(patsubst %.c,%.o,$(SRCS))
DEPS := $(patsubst %.o,%.d,$(OBJS))

.PHONY:	sub all tarball rpm clean depend


all:
	@echo "Run make from the parent directory"
	@echo OBJS

sub:	$(PCICANII)

sub_debug: CFLAGS += $(DEBUGFLAGS) -g
sub_debug: sub

install: sub
	cp $(PCICANII) $(FILESYSTEM)/lib/modules/`uname -r`/kernel/drivers/char/

$(PCICANII): $(OBJS)
	$(LD) -r $^ -o $@


# Specify that the dependency files depend on the C source files.
%.d: %.c
	$(CC) -M $(CPPFLAGS) -I$(INCLUDES) -DLINUX=1 -D_LINUX=1 $< > $@
	$(CC) -M $(CPPFLAGS) -I$(INCLUDES) -DLINUX=1 -D_LINUX=1 $< | sed s/\\.o/.d/ >> $@

clean:
	rm -f $(OBJS) $(EXECUTABLE) $(DEPS) $(OTHERS) $(TARBALL) $(PCICANII) Makefile *~

depend: $(DEPS)

-include $(DEPS)