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 #*****************************************************************
15 ifneq ($(wildcard ../../../../../ocera.mk),)
17 include ../../../../../ocera.mk
19 LINUX_DIR = ../../../../../kernel/linux/
24 @echo -e "You should go to the ocera/ directory and do 'make' to generate the ocera.mk file first.\nThanks."
27 # Where to look for kernel
28 # if not defined, sources of current running kernel are found
29 #KERNEL_LOCATION=/usr/src/linux
30 #KERNEL_LOCATION=/usr/src/linux-2.2.19
31 #KERNEL_LOCATION=/usr/src/linux-2.2.22
32 #KERNEL_LOCATION=/usr/src/linux-2.6.0-test4
33 #KERNEL_LOCATION=/home/cvs/ocera/ocera-build/kernel/linux
36 KERNEL_LOCATION = $(LINUX_DIR)
39 # Enable debugging messages
42 # You can comment out the hardware you don't need. This will result in a smaller
43 # driver. By default, all hardware is supported in the driver. See the README
44 # file for a description of the supported hardware.
45 # pccan Not to be confused with PCCCAN!!!
46 # pcccan Not to be confused with PCCAN!!!
48 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
49 pc_i03 pcm3680 aim104 m437 pcccan ssv \
50 bfadcan pikronisa virtual template
52 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
54 #SUPPORTED_CARDS = pikronisa
56 ########## Don't change anything under this line ################
58 # currently running kernel
59 CURRENT=$(shell uname -r)
60 KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
61 then echo yes ; else echo no ; fi )
63 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
64 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
66 ifndef KERNEL_LOCATION
67 ifeq ($(KERNEL_NEW),yes)
68 KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
69 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
71 KERNEL_LOCATION=/usr/src/linux
72 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
76 TOPDIR = $(KERNEL_LOCATION)
77 CONFIG_SHELL = TOPDIR=$(TOPDIR)
79 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
80 $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
82 PROC_FS := $(shell awk -F\ '/PROC_FS/ {print $$3}' \
83 $(KERNEL_LOCATION)/include/linux/autoconf.h)
85 DEVFS_FS := $(shell awk -F\ '/DEVFS_FS/ {print $$3}' \
86 $(KERNEL_LOCATION)/include/linux/autoconf.h)
88 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
89 | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
92 EXTRA_CFLAGS += -DCAN_DEBUG
97 # EXTRA_CFLAGS += -DNOVER
99 # EXTRA_CFLAGS += -DMODVERSIONS
103 EXTRA_CFLAGS += -DWITH_DEVFS_FS
110 # Target object file if any
111 # this must be undefined for 2.5.xx kernels
112 ifndef KERNEL_MODULE_V26
115 # Regular object files
116 O_OBJS += $(SUPPORTED_CARDS:%=%.o)
117 O_OBJS += can_queue.o devcommon.o main.o modparms.o setup.o \
118 sja1000p.o sja1000.o i82527.o irq.o boardlist.o \
119 open.o proc.o close.o write.o read.o ioctl.o select.o
120 # Objects with exported symbols (-DEXPORT_SYMTAB)
124 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
126 # Kernel only objects
128 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
133 # Linux 2.4.2 build system needs next
138 ifndef KERNEL_MODULE_V26
139 FINAL_MODULE_OBJS=$(obj-m)
141 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
144 ########## Source/target independent buil of module #############
150 default : make_this_module
151 cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
153 dep: make_this_module_dep
155 install : install_this_module
157 .supported_cards.h: Makefile
158 echo >.supported_cards.h
159 $(foreach card, $(SUPPORTED_CARDS), \
160 echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
162 make_this_module: .supported_cards.h
163 echo Linux kernel version $(KERNEL_VERSION)
164 echo Linux kernel sources $(KERNEL_LOCATION)
165 echo Module target $(obj-m)
166 echo Module objects $(can-objs)
167 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
169 make_this_module_dep:
170 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
172 install_this_module: make_this_module
173 su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
175 ifndef KERNEL_MODULE_V26
176 include $(KERNEL_LOCATION)/Rules.make
178 rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
179 .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~ \
180 ../$(FINAL_MODULE_OBJS)
185 rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m:%.o=%.ko) \
186 $(obj-m:%.o=%.mod.o) .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~ \
187 ../$(FINAL_MODULE_OBJS)