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
21 # Build in structure of OCERA framework
23 ifneq ($(wildcard ../../../../../ocera.mk),)
25 include ../../../../../ocera.mk
27 LINUX_DIR = ../../../../../kernel/linux/
31 @echo -e "\nTo build LinCAN driver for OCERA framework, ocera.mk file have"
32 @echo -e "to be generated first. Go to ocera/ directory and do 'make', please."
33 @echo -e "If standalone build is required, mark lincan/ by 'touch ../Standalone.mk'.\n"
36 KERNEL_LOCATION = $(LINUX_DIR)
39 # End of OCERA framework header
41 # Where to look for kernel
42 # if not defined, sources of current running kernel are found
43 #KERNEL_LOCATION=/usr/src/linux
44 #KERNEL_LOCATION=/usr/src/linux-2.2.19
45 #KERNEL_LOCATION=/usr/src/linux-2.2.22
46 #KERNEL_LOCATION=/usr/src/linux-2.6.0-test4
47 #KERNEL_LOCATION=/home/cvs/ocera/ocera-build/kernel/linux
50 # Enable debugging messages
53 # You can comment out the hardware you don't need. This will result in a smaller
54 # driver. By default, all hardware is supported in the driver. See the README
55 # file for a description of the supported hardware.
56 # pccan Not to be confused with PCCCAN!!!
57 # pcccan Not to be confused with PCCAN!!!
59 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
60 pc_i03 pcm3680 aim104 m437 pcccan ssv \
61 bfadcan pikronisa virtual template
63 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
65 #SUPPORTED_CARDS = virtual
67 ########## Don't change anything under this line ################
69 # currently running kernel
70 CURRENT=$(shell uname -r)
71 KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
72 then echo yes ; else echo no ; fi )
74 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
75 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
77 ifndef KERNEL_LOCATION
78 ifeq ($(KERNEL_NEW),yes)
79 KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
80 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
82 KERNEL_LOCATION=/usr/src/linux
83 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
87 TOPDIR = $(KERNEL_LOCATION)
88 CONFIG_SHELL = TOPDIR=$(TOPDIR)
90 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
91 $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
93 PROC_FS := $(shell awk -F\ '/PROC_FS/ {print $$3}' \
94 $(KERNEL_LOCATION)/include/linux/autoconf.h)
96 DEVFS_FS := $(shell awk -F\ '/DEVFS_FS/ {print $$3}' \
97 $(KERNEL_LOCATION)/include/linux/autoconf.h)
99 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
100 | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
103 EXTRA_CFLAGS += -DCAN_DEBUG
104 EXTRA_CFLAGS += -ggdb
108 # EXTRA_CFLAGS += -DNOVER
110 # EXTRA_CFLAGS += -DMODVERSIONS
114 EXTRA_CFLAGS += -DWITH_DEVFS_FS
121 # Target object file if any
122 # this must be undefined for 2.5.xx kernels
123 ifndef KERNEL_MODULE_V26
126 # Regular object files
127 O_OBJS += $(SUPPORTED_CARDS:%=%.o)
128 O_OBJS += can_queue.o devcommon.o main.o modparms.o setup.o \
129 sja1000p.o sja1000.o i82527.o irq.o boardlist.o \
130 open.o proc.o close.o write.o read.o ioctl.o select.o
131 # Objects with exported symbols (-DEXPORT_SYMTAB)
135 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
137 # Kernel only objects
139 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
144 # Linux 2.4.2 and newer build system needs next
149 ifndef KERNEL_MODULE_V26
150 FINAL_MODULE_OBJS=$(obj-m)
152 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
155 ########## Source/target independent build of module #############
157 default : make_this_module
158 cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
160 dep: make_this_module_dep
162 install : install_this_module
164 .supported_cards.h: Makefile
165 echo >.supported_cards.h
166 $(foreach card, $(SUPPORTED_CARDS), \
167 echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
169 make_this_module: .supported_cards.h
170 echo Linux kernel version $(KERNEL_VERSION)
171 echo Linux kernel sources $(KERNEL_LOCATION)
172 echo Module target $(obj-m)
173 echo Module objects $(can-objs)
174 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
176 make_this_module_dep:
177 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
179 install_this_module: make_this_module
180 su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
183 rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
184 .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~ \
185 $(obj-m:%.o=%.mod.o) $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
190 ifndef KERNEL_MODULE_V26
191 include $(KERNEL_LOCATION)/Rules.make