]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/Makefile
ae8bd4d4e0478e5afcc7832af771baa0f153f4cf
[lincan.git] / lincan / src / Makefile
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 else
21 # Build in structure of OCERA framework
22
23 ifneq ($(wildcard ../../../../../ocera.mk),)
24 ifndef TOPDIR
25 include ../../../../../ocera.mk
26 else
27 LINUX_DIR = ../../../../../kernel/linux/
28 endif
29 else
30 all: 
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"
34 endif
35 ifdef LINUX_DIR
36 KERNEL_LOCATION = $(LINUX_DIR)
37 endif
38 endif
39 # End of OCERA framework header
40
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
48
49
50 # Enable debugging messages
51 #DEBUG = y
52
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!!!
58
59 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
60                   pc_i03 pcm3680 aim104 m437 pcccan ssv \
61                   bfadcan pikronisa virtual template
62
63 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
64
65 #SUPPORTED_CARDS = virtual
66
67 ########## Don't change anything under this line ################
68
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 )
73
74 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
75 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
76
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
81 else
82 KERNEL_LOCATION=/usr/src/linux
83 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
84 endif
85 endif
86
87 TOPDIR = $(KERNEL_LOCATION)
88 CONFIG_SHELL = TOPDIR=$(TOPDIR)
89
90 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
91         $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
92
93 PROC_FS := $(shell awk -F\  '/PROC_FS/ {print $$3}' \
94         $(KERNEL_LOCATION)/include/linux/autoconf.h)
95
96 DEVFS_FS := $(shell awk -F\  '/DEVFS_FS/ {print $$3}' \
97         $(KERNEL_LOCATION)/include/linux/autoconf.h)
98
99 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
100         | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
101
102 ifdef DEBUG
103         EXTRA_CFLAGS += -DCAN_DEBUG
104         EXTRA_CFLAGS += -ggdb
105 endif
106
107 ifndef MODVERSIONS
108 #       EXTRA_CFLAGS += -DNOVER
109 #else
110 #       EXTRA_CFLAGS += -DMODVERSIONS
111 endif
112
113 ifdef DEVFS_FS
114         EXTRA_CFLAGS += -DWITH_DEVFS_FS
115 endif
116
117 ifdef PROC_FS
118         O_OBJS += proc.o
119 endif
120
121 # Target object file if any
122 # this must be undefined for 2.5.xx kernels
123 ifndef KERNEL_MODULE_V26
124 O_TARGET     = can.o
125 endif
126 # Regular object files
127 O_OBJS       += $(SUPPORTED_CARDS:%=%.o)
128 O_OBJS       += can_queue.o can_quekern.o devcommon.o main.o modparms.o \
129                 setup.o finish.o irq.o boardlist.o \
130                 sja1000p.o sja1000.o i82527.o  \
131                 open.o proc.o close.o write.o read.o \
132                 ioctl.o select.o fasync.o
133 # Objects with exported symbols (-DEXPORT_SYMTAB)
134 OX_OBJS      = 
135 # Module objects 
136 M_OBJS       = $(O_TARGET)
137 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
138 MX_OBJS      = 
139 # Kernel only objects 
140 L_OBJS       =  
141 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
142 LX_OBJS      = 
143 # Additional CFLAGS
144 EXTRA_CFLAGS +=
145
146 # Linux 2.4.2 and newer build system needs next
147 can-objs = $(O_OBJS)
148 obj-y = $(O_OBJS)
149 obj-m = can.o
150
151 ifndef KERNEL_MODULE_V26
152 FINAL_MODULE_OBJS=$(obj-m)
153 else
154 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
155 endif
156
157 ########## Source/target independent build of module #############
158
159 default : make_this_module
160         cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
161
162 dep: make_this_module_dep
163
164 install : install_this_module
165
166 .supported_cards.h: Makefile
167         echo >.supported_cards.h
168         $(foreach card, $(SUPPORTED_CARDS), \
169           echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
170         
171 make_this_module: .supported_cards.h
172         echo Linux kernel version $(KERNEL_VERSION)
173         echo Linux kernel sources $(KERNEL_LOCATION)
174         echo Module target $(obj-m)
175         echo Module objects $(can-objs)
176         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
177
178 make_this_module_dep:
179         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
180
181 install_this_module: make_this_module
182         su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
183
184 clean:
185         rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
186               .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~ \
187               $(obj-m:%.o=%.mod.o) $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
188
189 distclean: clean
190
191
192 ifndef KERNEL_MODULE_V26
193 include $(KERNEL_LOCATION)/Rules.make
194 endif
195