]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/Makefile
First integration step:
[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 version is adapted from uLan Communication driver
7 # (C) Copyright 1999 by Pavel Pisa pisa@cmp.felk.cvut.cz
8 #
9 #*****************************************************************
10
11 ifdef SUBDIRS
12 SUBDIRS =
13 endif
14
15 ifneq ($(wildcard ../../../../../ocera.mk),)
16 ifndef TOPDIR
17 include ../../../../../ocera.mk
18 else
19 LINUX_DIR = ../../../../../kernel/linux/
20 endif
21 else
22 OCERA_NOTDEF = 1
23 all: 
24         @echo -e "You should go to the ocera/ directory and do 'make' to generate the ocera.mk file first.\nThanks."
25 endif
26
27 # Where to look for kernel
28 # if not defined, sources of current running kernel are found
29 #KERNEL_LOCATION=/usr/src/linux
30 #KERNEL_LOCATION=/usr/src/linux-2.2.19
31 #KERNEL_LOCATION=/usr/src/linux-2.2.22
32 #KERNEL_LOCATION=/usr/src/linux-2.6.0-test4
33 #KERNEL_LOCATION=/home/cvs/ocera/ocera-build/kernel/linux
34
35 ifdef LINUX_DIR
36 KERNEL_LOCATION = $(LINUX_DIR)
37 endif
38
39 # Enable debugging messages
40 #DEBUG = y
41
42 # You can comment out the hardware you don't need. This will result in a smaller
43 # driver. By default, all hardware is supported in the driver. See the README 
44 # file for a description of the supported hardware.
45 #   pccan       Not to be confused with PCCCAN!!!
46 #   pcccan      Not to be confused with PCCAN!!!
47
48 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
49                   pc_i03 pcm3680 aim104 m437 pcccan ssv \
50                   bfadcan pikronisa virtual template
51
52 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
53
54 #SUPPORTED_CARDS = pikronisa
55
56 ########## Don't change anything under this line ################
57
58 # currently running kernel
59 CURRENT=$(shell uname -r)
60 KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
61                 then echo yes ; else echo no ; fi )
62
63 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
64 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
65
66 ifndef KERNEL_LOCATION
67 ifeq ($(KERNEL_NEW),yes)
68 KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
69 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
70 else
71 KERNEL_LOCATION=/usr/src/linux
72 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
73 endif
74 endif
75
76 TOPDIR = $(KERNEL_LOCATION)
77 CONFIG_SHELL = TOPDIR=$(TOPDIR)
78
79 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
80         $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
81
82 PROC_FS := $(shell awk -F\  '/PROC_FS/ {print $$3}' \
83         $(KERNEL_LOCATION)/include/linux/autoconf.h)
84
85 DEVFS_FS := $(shell awk -F\  '/DEVFS_FS/ {print $$3}' \
86         $(KERNEL_LOCATION)/include/linux/autoconf.h)
87
88 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
89         | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
90
91 ifdef DEBUG
92         EXTRA_CFLAGS += -DCAN_DEBUG
93         EXTRA_CFLAGS += -ggdb
94 endif
95
96 ifndef MODVERSIONS
97 #       EXTRA_CFLAGS += -DNOVER
98 #else
99 #       EXTRA_CFLAGS += -DMODVERSIONS
100 endif
101
102 ifdef DEVFS_FS
103         EXTRA_CFLAGS += -DWITH_DEVFS_FS
104 endif
105
106 ifdef PROC_FS
107         O_OBJS += proc.o
108 endif
109
110 # Target object file if any
111 # this must be undefined for 2.5.xx kernels
112 ifndef KERNEL_MODULE_V26
113 O_TARGET     = can.o
114 endif
115 # Regular object files
116 O_OBJS       += $(SUPPORTED_CARDS:%=%.o)
117 O_OBJS       += can_queue.o devcommon.o main.o modparms.o setup.o \
118                 sja1000p.o sja1000.o i82527.o irq.o boardlist.o \
119                 open.o proc.o close.o write.o read.o ioctl.o select.o
120 # Objects with exported symbols (-DEXPORT_SYMTAB)
121 OX_OBJS      = 
122 # Module objects 
123 M_OBJS       = $(O_TARGET)
124 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
125 MX_OBJS      = 
126 # Kernel only objects 
127 L_OBJS       =  
128 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
129 LX_OBJS      = 
130 # Additional CFLAGS
131 EXTRA_CFLAGS +=
132
133 # Linux 2.4.2 build system needs next
134 can-objs = $(O_OBJS)
135 obj-y = $(O_OBJS)
136 obj-m = can.o
137
138 ifndef KERNEL_MODULE_V26
139 FINAL_MODULE_OBJS=$(obj-m)
140 else
141 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
142 endif
143
144 ########## Source/target independent buil of module #############
145
146 #ifndef OCERA_NOTDEF
147 all : default
148 #endif
149
150 default : make_this_module
151         cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
152
153 dep: make_this_module_dep
154
155 install : install_this_module
156
157 .supported_cards.h: Makefile
158         echo >.supported_cards.h
159         $(foreach card, $(SUPPORTED_CARDS), \
160           echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
161         
162 make_this_module: .supported_cards.h
163         echo Linux kernel version $(KERNEL_VERSION)
164         echo Linux kernel sources $(KERNEL_LOCATION)
165         echo Module target $(obj-m)
166         echo Module objects $(can-objs)
167         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
168
169 make_this_module_dep:
170         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
171
172 install_this_module: make_this_module
173         su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
174
175 ifndef KERNEL_MODULE_V26
176 include $(KERNEL_LOCATION)/Rules.make
177 clean:
178         rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
179               .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~ \
180               ../$(FINAL_MODULE_OBJS)
181
182 distclean: clean
183 else
184 clean:
185         rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m:%.o=%.ko) \
186               $(obj-m:%.o=%.mod.o) .*.o.flags .*.o.cmd .*.ko.cmd .depend .supported_cards.h *~ \
187               ../$(FINAL_MODULE_OBJS)
188
189 distclean: clean
190 endif
191