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=/usr/src/linux-2.6.18-rc4/_build/arm
52 #KERNEL_LOCATION=/home/cvs/ocera/ocera-build/kernel/linux
55 # Enable debugging messages
58 # You can comment out the hardware you don't need. This will result in a smaller
59 # driver. By default, all hardware is supported in the driver. See the README
60 # file for a description of the supported hardware.
61 # pccan Not to be confused with PCCCAN!!!
62 # pcccan Not to be confused with PCCAN!!!
64 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
65 pc_i03 pcm3680 aim104 m437 pcccan ssv \
66 bfadcan pikronisa kv_pcican msmcan virtual template \
67 unican unican_cl2 ems_cpcpci adlink7841 oscar
68 # hms30c7202_can c_can c_can_irq tscan1
71 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
73 #SUPPORTED_CARDS = virtual
75 ########## Don't change anything under this line ################
77 # currently running kernel
78 CURRENT=$(shell uname -r)
79 KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
80 then echo yes ; else echo no ; fi )
82 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
83 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
85 ifndef KERNEL_LOCATION
86 ifeq ($(KERNEL_NEW),yes)
87 KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
88 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
90 KERNEL_LOCATION=/usr/src/linux
91 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
95 TOPDIR = $(KERNEL_LOCATION)
96 CONFIG_SHELL = TOPDIR=$(TOPDIR)
98 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
99 $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
101 ifeq ($(KERNEL_VERSION),)
102 KERNEL_VERSION=$(shell grep UTS_RELEASE ${KERNEL_LOCATION}/include/linux/utsrelease.h | \
103 sed 's/[^"]*"\(.*\)\{1\}"/\1/')
106 #$(warning KERNEL_VERSION = $(KERNEL_VERSION))
108 PROC_FS := $(shell awk -F\ '/PROC_FS/ {print $$3}' \
109 $(KERNEL_LOCATION)/include/linux/autoconf.h)
111 DEVFS_FS := $(shell awk -F\ '/DEVFS_FS/ {print $$3}' \
112 $(KERNEL_LOCATION)/include/linux/autoconf.h)
114 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
115 | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
118 EXTRA_CFLAGS += -DCAN_DEBUG
119 EXTRA_CFLAGS += -ggdb
123 # EXTRA_CFLAGS += -DNOVER
125 # EXTRA_CFLAGS += -DMODVERSIONS
129 EXTRA_CFLAGS += -DWITH_DEVFS_FS
137 EXTRA_CFLAGS += -I $(SUBDIRS)
142 # Target object file if any
143 # this must be undefined for 2.5.xx kernels
144 ifndef KERNEL_MODULE_V26
147 # Regular object files
148 O_OBJS += $(SUPPORTED_CARDS:%=%.o)
149 O_OBJS += can_queue.o can_quekern.o devcommon.o main.o modparms.o \
150 setup.o finish.o irq.o sysdep_lnx.o boardlist.o \
151 sja1000p.o sja1000.o i82527.o \
152 open.o proc.o close.o write.o read.o \
153 ioctl.o ioctl_query.o ioctl_remote.o select.o fasync.o
154 # Objects with exported symbols (-DEXPORT_SYMTAB)
158 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
160 # Kernel only objects
162 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
167 # Linux 2.4.2 and newer build system needs next
172 ifndef KERNEL_MODULE_V26
173 FINAL_MODULE_OBJS=$(obj-m)
175 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
178 ########## Source/target independent build of module #############
180 default : make_this_module
181 cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
183 dep: make_this_module_dep
185 install : install_this_module
187 lincan_config.h: Makefile
188 echo >lincan_config.h
189 $(foreach card, $(SUPPORTED_CARDS), \
190 echo \#define CONFIG_OC_LINCAN_CARD_$(card) 1 >>lincan_config.h ;)
192 make_this_module: lincan_config.h
193 echo Linux kernel version $(KERNEL_VERSION)
194 echo Linux kernel sources $(KERNEL_LOCATION)
195 echo Module target $(obj-m)
196 echo Module objects $(can-objs)
197 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
199 make_this_module_dep:
200 DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
202 install_this_module: make_this_module
203 su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
206 rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
207 .*.o.flags .*.o.cmd .*.ko.cmd .depend lincan_config.h *~ \
208 $(obj-m:%.o=%.mod.o) $(obj-m:%.o=%.mod.c) \
209 $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
214 ifndef KERNEL_MODULE_V26
215 include $(KERNEL_LOCATION)/Rules.make