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 Makefile version is adapted from uLan Communication driver
7 # (C) Copyright 1999 by Pavel Pisa pisa@cmp.felk.cvut.cz
9 #*****************************************************************
11 # Begin of OCERA framework header
15 ifneq ($(wildcard ../Standalone.mk),)
16 # Standalone make outside of OCERA framework
20 .PHONY: kernel-pass utils-pass
25 # Build in structure of OCERA framework
27 ifneq ($(wildcard ../../../../../ocera.mk),)
29 include ../../../../../ocera.mk
31 LINUX_DIR = ../../../../../kernel/linux/
35 @echo -e "\nTo build LinCAN driver for OCERA framework, ocera.mk file have"
36 @echo -e "to be generated first. Go to ocera/ directory and do 'make', please."
37 @echo -e "If standalone build is required, mark lincan/ by 'touch ../Standalone.mk'.\n"
40 KERNEL_LOCATION = $(LINUX_DIR)
43 # End of OCERA framework header
45 # Where to look for kernel
46 # if not defined, sources of current running kernel are found
47 #KERNEL_LOCATION=/usr/src/linux
48 #KERNEL_LOCATION=/usr/src/linux-2.2.19
49 #KERNEL_LOCATION=/usr/src/linux-2.2.22
50 #KERNEL_LOCATION=/usr/src/linux-2.6.0
51 #KERNEL_LOCATION=/home/cvs/ocera/ocera-build/kernel/linux
54 # Enable debugging messages
57 # You can comment out the hardware you don't need. This will result in a smaller
58 # driver. By default, all hardware is supported in the driver. See the README
59 # file for a description of the supported hardware.
60 # pccan Not to be confused with PCCCAN!!!
61 # pcccan Not to be confused with PCCAN!!!
63 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
64 pc_i03 pcm3680 aim104 m437 pcccan ssv \
65 bfadcan pikronisa kv_pcican virtual template
67 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
69 #SUPPORTED_CARDS = virtual
71 ########## Don't change anything under this line ################
73 # currently running kernel
74 CURRENT=$(shell uname -r)
75 KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
76 then echo yes ; else echo no ; fi )
78 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
79 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
81 ifndef KERNEL_LOCATION
82 ifeq ($(KERNEL_NEW),yes)
83 KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
84 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
86 KERNEL_LOCATION=/usr/src/linux
87 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
91 TOPDIR = $(KERNEL_LOCATION)
92 CONFIG_SHELL = TOPDIR=$(TOPDIR)
94 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
95 $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
97 PROC_FS := $(shell awk -F\ '/PROC_FS/ {print $$3}' \
98 $(KERNEL_LOCATION)/include/linux/autoconf.h)
100 DEVFS_FS := $(shell awk -F\ '/DEVFS_FS/ {print $$3}' \
101 $(KERNEL_LOCATION)/include/linux/autoconf.h)
103 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
104 | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
107 EXTRA_CFLAGS += -DCAN_DEBUG
108 EXTRA_CFLAGS += -ggdb
112 # EXTRA_CFLAGS += -DNOVER
114 # EXTRA_CFLAGS += -DMODVERSIONS
118 EXTRA_CFLAGS += -DWITH_DEVFS_FS
125 # Target object file if any
126 # this must be undefined for 2.5.xx kernels
127 ifndef KERNEL_MODULE_V26
130 # Regular object files
131 O_OBJS += $(SUPPORTED_CARDS:%=%.o)
132 O_OBJS += can_queue.o can_quekern.o devcommon.o main.o modparms.o \
133 setup.o finish.o irq.o boardlist.o \
134 sja1000p.o sja1000.o i82527.o \
135 open.o proc.o close.o write.o read.o \
136 ioctl.o select.o fasync.o
137 # Objects with exported symbols (-DEXPORT_SYMTAB)
141 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
143 # Kernel only objects
145 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
150 # Linux 2.4.2 and newer build system needs next
155 ifndef KERNEL_MODULE_V26
156 FINAL_MODULE_OBJS=$(obj-m)
158 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
161 ########## Source/target independent build of module #############
163 default : make_this_module
164 cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
166 dep: make_this_module_dep
168 install : install_this_module
170 .supported_cards.h: Makefile
171 echo >.supported_cards.h
172 $(foreach card, $(SUPPORTED_CARDS), \
173 echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
175 make_this_module: .supported_cards.h
176 echo Linux kernel version $(KERNEL_VERSION)
177 echo Linux kernel sources $(KERNEL_LOCATION)
178 echo Module target $(obj-m)
179 echo Module objects $(can-objs)
180 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
182 make_this_module_dep:
183 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
185 install_this_module: make_this_module
186 su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
189 rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
190 .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~ \
191 $(obj-m:%.o=%.mod.o) $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
196 ifndef KERNEL_MODULE_V26
197 include $(KERNEL_LOCATION)/Rules.make