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 lincan-0.2 9 Aug 2003
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.6.0-test4
17 #KERNEL_LOCATION=/home/cvs/ocera/ocera-build/kernel/linux
19 # Enable debugging messages
22 # You can comment out the hardware you don't need. This will result in a smaller
23 # driver. By default, all hardware is supported in the driver. See the README
24 # file for a description of the supported hardware.
25 # pccan Not to be confused with PCCCAN!!!
26 # pcccan Not to be confused with PCCAN!!!
28 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
29 pc_i03 pcm3680 aim104 m437 pcccan ssv \
30 bfadcan pikronisa template
32 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
34 #SUPPORTED_CARDS = pikronisa
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 += can_queue.o devcommon.o main.o modparms.o setup.o \
95 sja1000.o i82527.o close.o ioctl.o \
96 open.o write.o read.o sja1000p.o irq.o select.o
97 # Objects with exported symbols (-DEXPORT_SYMTAB)
101 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
103 # Kernel only objects
105 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
110 # Linux 2.4.2 build system needs next
111 can-objs := $(O_OBJS)
115 ifndef KERNEL_MODULE_V26
116 FINAL_MODULE_OBJS=$(obj-m)
118 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
121 ########## Source/target independent buil of module #############
125 default : make_this_module
126 cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
128 dep: make_this_module_dep
130 install : install_this_module
132 .supported_cards.h: Makefile
133 echo >.supported_cards.h
134 $(foreach card, $(SUPPORTED_CARDS), \
135 echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
137 make_this_module: .supported_cards.h
138 echo Linux kernel version $(KERNEL_VERSION)
139 echo Linux kernel sources $(KERNEL_LOCATION)
140 echo Module target $(obj-m)
141 echo Module objects $(can-objs)
142 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
144 make_this_module_dep:
145 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
147 install_this_module: make_this_module
148 su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
151 rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) $(obj-m:%.o=%.ko) \
152 $(obj-m:%.o=%.mod.o) .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~
154 ifndef KERNEL_MODULE_V26
155 include $(KERNEL_LOCATION)/Rules.make