]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/Makefile.std
Actual driver code for directly mapped SJA1000 into PCI mem region 0.
[lincan.git] / lincan / src / Makefile.std
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
5 #
6 # This Makefile version is adapted from uLan Communication driver
7 # (C) Copyright 1999 by Pavel Pisa pisa@cmp.felk.cvut.cz
8 #
9 #*****************************************************************
10
11 # Begin of OCERA framework header
12 ifdef SUBDIRS
13 SUBDIRS =
14 endif
15 ifneq ($(wildcard ../Standalone.mk),)
16 # Standalone make outside of OCERA framework
17
18 all : default
19
20 .PHONY: kernel-pass utils-pass
21
22 kernel-pass : default
23
24 else
25 # Build in structure of OCERA framework
26
27 ifneq ($(wildcard ../../../../../ocera.mk),)
28 ifndef TOPDIR
29 include ../../../../../ocera.mk
30 else
31 LINUX_DIR = ../../../../../kernel/linux/
32 endif
33 else
34 all: 
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"
38 endif
39 ifdef LINUX_DIR
40 KERNEL_LOCATION = $(LINUX_DIR)
41 endif
42 endif
43 # End of OCERA framework header
44
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
53
54
55 # Enable debugging messages
56 #DEBUG = y
57
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!!!
63
64 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
65                   pc_i03 pcm3680 aim104 m437 pcccan ssv \
66                   bfadcan gensja1000mm gensja1000io pcisja1000mm \
67                   kv_pcican msmcan virtual template \
68                   unican unican_cl2 ems_cpcpci adlink7841 oscar \
69                   pcan_pci esdpci200
70 #                 hms30c7202_can c_can c_can_irq tscan1
71 #                 pcan_dongle
72
73 #SUPPORTED_CARDS = pcm3680 bfadcan template
74
75 #SUPPORTED_CARDS = virtual
76
77 ########## Don't change anything under this line ################
78
79 # currently running kernel
80 CURRENT=$(shell uname -r)
81 KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
82                 then echo yes ; else echo no ; fi )
83
84 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
85 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
86
87 ifndef KERNEL_LOCATION
88 ifeq ($(KERNEL_NEW),yes)
89 KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
90 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
91 else
92 KERNEL_LOCATION=/usr/src/linux
93 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
94 endif
95 endif
96
97 TOPDIR = $(KERNEL_LOCATION)
98 CONFIG_SHELL = TOPDIR=$(TOPDIR)
99
100 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
101         $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
102
103 ifeq ($(KERNEL_VERSION),)
104 KERNEL_VERSION=$(shell grep UTS_RELEASE ${KERNEL_LOCATION}/include/linux/utsrelease.h | \
105                  sed 's/[^"]*"\(.*\)\{1\}"/\1/')
106 endif
107 ifeq ($(KERNEL_VERSION),)
108 KERNEL_VERSION=$(shell grep UTS_RELEASE ${KERNEL_LOCATION}/include/generated/utsrelease.h | \
109                  sed 's/[^"]*"\(.*\)\{1\}"/\1/')
110 endif
111
112 #$(warning KERNEL_VERSION = $(KERNEL_VERSION))
113
114 PROC_FS := $(shell awk -F\  '/PROC_FS/ {print $$3}' \
115         $(KERNEL_LOCATION)/include/linux/autoconf.h)
116
117 DEVFS_FS := $(shell awk -F\  '/DEVFS_FS/ {print $$3}' \
118         $(KERNEL_LOCATION)/include/linux/autoconf.h)
119
120 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
121         | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
122
123 ifdef DEBUG
124         EXTRA_CFLAGS += -DCAN_DEBUG
125         EXTRA_CFLAGS += -ggdb
126 endif
127
128 ifndef MODVERSIONS
129 #       EXTRA_CFLAGS += -DNOVER
130 #else
131 #       EXTRA_CFLAGS += -DMODVERSIONS
132 endif
133
134 ifdef DEVFS_FS
135         EXTRA_CFLAGS += -DWITH_DEVFS_FS
136 endif
137
138 ifdef PROC_FS
139         O_OBJS += proc.o
140 endif
141
142 ifdef SUBDIRS
143 EXTRA_CFLAGS += -I $(SUBDIRS)
144 else
145 EXTRA_CFLAGS += -I .
146 endif
147
148 # Target object file if any
149 # this must be undefined for 2.5.xx kernels
150 ifndef KERNEL_MODULE_V26
151 O_TARGET     = lincan.o
152 endif
153 # Regular object files
154 O_OBJS       += $(SUPPORTED_CARDS:%=%.o)
155 O_OBJS       += can_queue.o can_quekern.o devcommon.o main.o modparms.o \
156                 setup.o finish.o irq.o sysdep_lnx.o boardlist.o \
157                 sja1000p.o sja1000.o i82527.o  \
158                 open.o proc.o close.o write.o read.o \
159                 ioctl.o ioctl_query.o ioctl_remote.o select.o fasync.o
160 # Objects with exported symbols (-DEXPORT_SYMTAB)
161 OX_OBJS      = 
162 # Module objects 
163 M_OBJS       = $(O_TARGET)
164 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
165 MX_OBJS      = 
166 # Kernel only objects 
167 L_OBJS       =  
168 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
169 LX_OBJS      = 
170 # Additional CFLAGS
171 EXTRA_CFLAGS +=
172
173 # Linux 2.4.2 and newer build system needs next
174 lincan-objs = $(O_OBJS)
175 ifndef KERNEL_MODULE_V26
176 obj-y = $(O_OBJS)
177 endif
178 obj-m = lincan.o
179
180 ifndef KERNEL_MODULE_V26
181 FINAL_MODULE_OBJS=$(obj-m)
182 else
183 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
184 endif
185
186 ########## Source/target independent build of module #############
187
188 default : make_this_module
189         cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
190
191 dep: make_this_module_dep
192
193 install : install_this_module
194
195 lincan_config.h: Makefile
196         echo >lincan_config.h
197         $(foreach card, $(SUPPORTED_CARDS), \
198           echo \#define CONFIG_OC_LINCAN_CARD_$(card) 1 >>lincan_config.h ;)
199
200 make_this_module: lincan_config.h
201         echo Linux kernel version $(KERNEL_VERSION)
202         echo Linux kernel sources $(KERNEL_LOCATION)
203         echo Module target $(obj-m)
204         echo Module objects $(lincan-objs)
205         DIR=`pwd`; (cd $(KERNEL_LOCATION); make M=$$DIR SUBDIRS=$$DIR modules)
206
207 make_this_module_dep:
208         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
209
210 install_this_module: make_this_module
211         su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
212
213 clean:
214         rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
215               .*.o.flags .*.o.cmd .*.ko.cmd .depend lincan_config.h *~ \
216               $(obj-m:%.o=%.mod.o) $(obj-m:%.o=%.mod.c) \
217               $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
218
219 distclean: clean
220
221
222 ifndef KERNEL_MODULE_V26
223 include $(KERNEL_LOCATION)/Rules.make
224 endif
225