1 # Makefile for the Linux CAN-bus driver.
2 # Written by Arnaud Westenberg email:arnaud@wanadoo.nl
3 # This software is released under the GPL-License.
4 # Version 0.7 6 Aug 2001
6 # This version is adapted from uLan Communication driver
7 # (C) Copyright 1999 by Pavel Pisa pisa@cmp.felk.cvut.cz
9 #*****************************************************************
11 # Where to look for kernel
12 # if not defined, sources of current running kernel are found
13 #KERNEL_LOCATION=/usr/src/linux
14 #KERNEL_LOCATION=/usr/src/linux-2.2.19
15 #KERNEL_LOCATION=/usr/src/linux-2.2.22
16 #KERNEL_LOCATION=/usr/src/linux-2.5.47
18 # Comment-out next two lines, if you do not build driver
19 # in the OCERA source tree
21 KERNEL_LOCATION=$(TOP)/kernel/linux
23 # Enable debugging messages
26 # You can comment out the hardware you don't need. This will result in a smaller
27 # driver. By default, all hardware is supported in the driver. See the README
28 # file for a description of the supported hardware.
29 # pccan Not to be confused with PCCCAN!!!
30 # pcccan Not to be confused with PCCAN!!!
32 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
33 pc_i03 pcm3680 aim104 m437 pcccan ssv \
34 bfadcan pikronisa template
36 ########## Don't change anything under this line ################
38 # currently running kernel
39 CURRENT=$(shell uname -r)
40 KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
41 then echo yes ; else echo no ; fi )
43 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
44 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
46 ifndef KERNEL_LOCATION
47 ifeq ($(KERNEL_NEW),yes)
48 KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
49 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
51 KERNEL_LOCATION=/usr/src/linux
52 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
56 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
57 $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
59 PROC_FS := $(shell awk -F\ '/PROC_FS/ {print $$3}' \
60 $(KERNEL_LOCATION)/include/linux/autoconf.h)
62 DEVFS_FS := $(shell awk -F\ '/DEVFS_FS/ {print $$3}' \
63 $(KERNEL_LOCATION)/include/linux/autoconf.h)
65 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
66 | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
69 EXTRA_CFLAGS += -DCAN_DEBUG
74 # EXTRA_CFLAGS += -DNOVER
76 # EXTRA_CFLAGS += -DMODVERSIONS
80 EXTRA_CFLAGS += -DWITH_DEVFS_FS
87 # Target object file if any
88 # this must be undefined for 2.5.xx kernels
89 ifndef KERNEL_MODULE_V26
92 # Regular object files
93 O_OBJS += $(SUPPORTED_CARDS:%=%.o)
94 O_OBJS += main.o modparms.o setup.o sja1000.o i82527.o close.o ioctl.o \
95 open.o write.o read.o sja1000p.o irq.o select.o
96 # Objects with exported symbols (-DEXPORT_SYMTAB)
100 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
102 # Kernel only objects
104 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
109 # Linux 2.4.2 build system needs next
110 can-objs := $(O_OBJS)
114 ########## Source/target independent buil of module #############
118 default : make_this_module
121 dep: make_this_module_dep
123 install : install_this_module
125 .supported_cards.h: Makefile
126 echo >.supported_cards.h
127 $(foreach card, $(SUPPORTED_CARDS), \
128 echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
130 make_this_module: .supported_cards.h
131 echo Linux kernel version $(KERNEL_VERSION)
132 echo Linux kernel sources $(KERNEL_LOCATION)
133 echo Module target $(obj-m)
134 echo Module objects $(can-objs)
135 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
136 for f in $(obj-m:%.o=%) ; do if [ -f $$f.ko ] ; then cp -u $$f.ko $$f.o ; fi ; done
138 make_this_module_dep:
139 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
141 install_this_module: make_this_module
142 su -c "mkdir -v -p $(MODULE_CHAR_LOC); cp -v $(obj-m) $(MODULE_CHAR_LOC)"
145 rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) $(obj-m:%.o=%.ko) \
146 .*.o.flags .*.o.cmd .depend .supported_cards.h *~
148 ifndef KERNEL_MODULE_V26
149 include $(KERNEL_LOCATION)/Rules.make