# Kvaser CAN driver USBcan hardware specific parts                    
# Makefile for the USBcan 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


USBCAN = usbcanII.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 := usbcanHWIf.c  ../common/VCanOsIf.c
#SRCS += ../common/osif_functions_kernel.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:	#$(USBCAN)
	@echo "*********************************************************"
	@echo "USBcanII driver currently only available for kernel 2.6.x"
	@echo "*********************************************************"

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

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

$(USBCAN): $(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) $(USBCAN) Makefile *~

depend: $(DEPS)

