#
#                         Copyright 1998 by KVASER AB            
#                   P.O Box 4076 SE-51104 KINNAHULT, SWEDEN
#             E-mail: staff@kvaser.se   WWW: http://www.kvaser.se
#
# This software is furnished under a license and may be used and copied
# only in accordance with the terms of such license.
#
# $Revision: 1.7 $ $Name:  $
# $Header: /home/cvs/beta/linuxcan_v2/lapcan/Makefile_24,v 1.7 2005/12/12 12:26:35 ga Exp $
#
# Description:
# Makefile for the LAPcan Linux kernel module.
#
include ../config.mak

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

endif


LAPCAN = lapcan_cs.o
CFLAGS += -Wall  -D__KERNEL__ -DMODULE -fomit-frame-pointer $(XTRA_CFLAGS)
CFLAGS += -DSPLIT=1 -I$(INCLUDES) -DLINUX=1 -D_LINUX=1 #qqq maybe remove later on

# Which kernel headers to use - Use the current kernel

# qqq we might want to change this later on to build for different
# kernels, also we may want to put the headers on servus
CPPFLAGS += -I/lib/modules/`uname -r`/build/include




SRCS := LapcanHWIf.c ../common/VCanOsIf.c 
SRCS += ../common/osif_functions_kernel.c
SRCS += ../common/osif_functions_pcmcia.c

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

# these rules are phony 
.PHONY:	sub all tarball rpm clean depend install clean 

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

sub: $(LAPCAN)

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

install:
	cp $(LAPCAN) $(FILESYSTEM)/lib/modules/`uname -r`/pcmcia/

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

depend: $(DEPS)

-include $(DEPS)
