]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/Makefile
The first enhanced version of Linux CAN-bus driver for OCERA project
[lincan.git] / lincan / src / Makefile
diff --git a/lincan/src/Makefile b/lincan/src/Makefile
new file mode 100644 (file)
index 0000000..b83aa6d
--- /dev/null
@@ -0,0 +1,150 @@
+# Makefile for the Linux CAN-bus driver.
+# Written by Arnaud Westenberg email:arnaud@wanadoo.nl
+# This software is released under the GPL-License.
+# Version 0.7  6 Aug 2001
+#
+# This version is adapted from uLan Communication driver
+# (C) Copyright 1999 by Pavel Pisa pisa@cmp.felk.cvut.cz
+#
+#*****************************************************************
+
+# Where to look for kernel
+# if not defined, sources of current running kernel are found
+#KERNEL_LOCATION=/usr/src/linux
+#KERNEL_LOCATION=/usr/src/linux-2.2.19
+#KERNEL_LOCATION=/usr/src/linux-2.2.22
+#KERNEL_LOCATION=/usr/src/linux-2.5.47
+
+# Comment-out next two lines, if you do not build driver 
+# in the OCERA source tree
+TOP=../../../../..
+KERNEL_LOCATION=$(TOP)/kernel/linux
+
+# Enable debugging messages
+DEBUG = y
+
+# You can comment out the hardware you don't need. This will result in a smaller
+# driver. By default, all hardware is supported in the driver. See the README 
+# file for a description of the supported hardware.
+#   pccan      Not to be confused with PCCCAN!!!
+#   pcccan     Not to be confused with PCCAN!!!
+
+SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
+                 pc_i03 pcm3680 aim104 m437 pcccan ssv \
+                 bfadcan pikronisa template
+
+########## Don't change anything under this line ################
+
+# currently running kernel
+CURRENT=$(shell uname -r)
+KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
+               then echo yes ; else echo no ; fi )
+
+#KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
+#KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
+
+ifndef KERNEL_LOCATION
+ifeq ($(KERNEL_NEW),yes)
+KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
+MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
+else
+KERNEL_LOCATION=/usr/src/linux
+MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
+endif
+endif
+
+KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
+       $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
+
+PROC_FS := $(shell awk -F\  '/PROC_FS/ {print $$3}' \
+       $(KERNEL_LOCATION)/include/linux/autoconf.h)
+
+DEVFS_FS := $(shell awk -F\  '/DEVFS_FS/ {print $$3}' \
+       $(KERNEL_LOCATION)/include/linux/autoconf.h)
+
+KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
+       | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
+
+ifdef DEBUG
+       EXTRA_CFLAGS += -DCAN_DEBUG
+       EXTRA_CFLAGS += -ggdb
+endif
+
+ifndef MODVERSIONS
+#      EXTRA_CFLAGS += -DNOVER
+#else
+#      EXTRA_CFLAGS += -DMODVERSIONS
+endif
+
+ifdef DEVFS_FS
+       EXTRA_CFLAGS += -DWITH_DEVFS_FS
+endif
+
+ifdef PROC_FS
+       O_OBJS += proc.o
+endif
+
+# Target object file if any
+# this must be undefined for 2.5.xx kernels
+ifndef KERNEL_MODULE_V26
+O_TARGET     = can.o
+endif
+# Regular object files
+O_OBJS      += $(SUPPORTED_CARDS:%=%.o)
+O_OBJS       += main.o modparms.o setup.o sja1000.o i82527.o close.o ioctl.o \
+               open.o write.o read.o sja1000p.o irq.o select.o
+# Objects with exported symbols (-DEXPORT_SYMTAB)
+OX_OBJS      = 
+# Module objects 
+M_OBJS       = $(O_TARGET)
+# Module only objects with exported symbols (-DEXPORT_SYMTAB)
+MX_OBJS      = 
+# Kernel only objects 
+L_OBJS       = 
+# Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
+LX_OBJS      = 
+# Additional CFLAGS
+EXTRA_CFLAGS +=
+
+# Linux 2.4.2 build system needs next
+can-objs := $(O_OBJS)
+obj-y := $(O_OBJS)
+obj-m := can.o
+
+########## Source/target independent buil of module #############
+
+all : default
+
+default : make_this_module
+       cp can.o ../can.o
+
+dep: make_this_module_dep
+
+install : install_this_module
+
+.supported_cards.h: Makefile
+       echo >.supported_cards.h
+       $(foreach card, $(SUPPORTED_CARDS), \
+         echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
+       
+make_this_module: .supported_cards.h
+       echo Linux kernel version $(KERNEL_VERSION)
+       echo Linux kernel sources $(KERNEL_LOCATION)
+       echo Module target $(obj-m)
+       echo Module objects $(can-objs)
+       DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
+       for f in $(obj-m:%.o=%) ; do if [ -f $$f.ko ] ; then cp -u $$f.ko $$f.o ; fi ; done
+
+make_this_module_dep:
+       DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
+
+install_this_module: make_this_module
+       su -c "mkdir -v -p $(MODULE_CHAR_LOC); cp -v $(obj-m) $(MODULE_CHAR_LOC)"
+
+clean:
+       rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) $(obj-m:%.o=%.ko) \
+                       .*.o.flags .*.o.cmd .depend .supported_cards.h *~
+
+ifndef KERNEL_MODULE_V26
+include $(KERNEL_LOCATION)/Rules.make
+endif