]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/Makefile.std
The first chunk to support for PEAK's LPT dongle adapter
[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=/home/cvs/ocera/ocera-build/kernel/linux
52
53
54 # Enable debugging messages
55 #DEBUG = y
56
57 # You can comment out the hardware you don't need. This will result in a smaller
58 # driver. By default, all hardware is supported in the driver. See the README 
59 # file for a description of the supported hardware.
60 #   pccan       Not to be confused with PCCCAN!!!
61 #   pcccan      Not to be confused with PCCAN!!!
62
63 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
64                   pc_i03 pcm3680 aim104 m437 pcccan ssv \
65                   bfadcan pikronisa kv_pcican msmcan virtual template \
66                   unican unican_cl2
67 #                 ems_cpcpci # compiles only for 2.6 kernels now
68 #                 hms30c7202_can c_can c_can_irq
69 #                 pcan_dongle
70
71 #SUPPORTED_CARDS = pcm3680 bfadcan pikronisa template
72
73 #SUPPORTED_CARDS = virtual
74
75 ########## Don't change anything under this line ################
76
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 )
81
82 #KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
83 #KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
84
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
89 else
90 KERNEL_LOCATION=/usr/src/linux
91 MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
92 endif
93 endif
94
95 TOPDIR = $(KERNEL_LOCATION)
96 CONFIG_SHELL = TOPDIR=$(TOPDIR)
97
98 KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
99         $(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
100
101 PROC_FS := $(shell awk -F\  '/PROC_FS/ {print $$3}' \
102         $(KERNEL_LOCATION)/include/linux/autoconf.h)
103
104 DEVFS_FS := $(shell awk -F\  '/DEVFS_FS/ {print $$3}' \
105         $(KERNEL_LOCATION)/include/linux/autoconf.h)
106
107 KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
108         | sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
109
110 ifdef DEBUG
111         EXTRA_CFLAGS += -DCAN_DEBUG
112         EXTRA_CFLAGS += -ggdb
113 endif
114
115 ifndef MODVERSIONS
116 #       EXTRA_CFLAGS += -DNOVER
117 #else
118 #       EXTRA_CFLAGS += -DMODVERSIONS
119 endif
120
121 ifdef DEVFS_FS
122         EXTRA_CFLAGS += -DWITH_DEVFS_FS
123 endif
124
125 ifdef PROC_FS
126         O_OBJS += proc.o
127 endif
128
129 ifdef SUBDIRS
130 EXTRA_CFLAGS += -I $(SUBDIRS)
131 else
132 EXTRA_CFLAGS += -I .
133 endif
134
135 # Target object file if any
136 # this must be undefined for 2.5.xx kernels
137 ifndef KERNEL_MODULE_V26
138 O_TARGET     = can.o
139 endif
140 # Regular object files
141 O_OBJS       += $(SUPPORTED_CARDS:%=%.o)
142 O_OBJS       += can_queue.o can_quekern.o devcommon.o main.o modparms.o \
143                 setup.o finish.o irq.o boardlist.o \
144                 sja1000p.o sja1000.o i82527.o  \
145                 open.o proc.o close.o write.o read.o \
146                 ioctl.o ioctl_query.o select.o fasync.o
147 # Objects with exported symbols (-DEXPORT_SYMTAB)
148 OX_OBJS      = 
149 # Module objects 
150 M_OBJS       = $(O_TARGET)
151 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
152 MX_OBJS      = 
153 # Kernel only objects 
154 L_OBJS       =  
155 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
156 LX_OBJS      = 
157 # Additional CFLAGS
158 EXTRA_CFLAGS +=
159
160 # Linux 2.4.2 and newer build system needs next
161 can-objs = $(O_OBJS)
162 obj-y = $(O_OBJS)
163 obj-m = can.o
164
165 ifndef KERNEL_MODULE_V26
166 FINAL_MODULE_OBJS=$(obj-m)
167 else
168 FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
169 endif
170
171 ########## Source/target independent build of module #############
172
173 default : make_this_module
174         cp $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
175
176 dep: make_this_module_dep
177
178 install : install_this_module
179
180 lincan_config.h: Makefile
181         echo >lincan_config.h
182         $(foreach card, $(SUPPORTED_CARDS), \
183           echo \#define CONFIG_OC_LINCAN_CARD_$(card) 1 >>lincan_config.h ;)
184
185 make_this_module: lincan_config.h
186         echo Linux kernel version $(KERNEL_VERSION)
187         echo Linux kernel sources $(KERNEL_LOCATION)
188         echo Module target $(obj-m)
189         echo Module objects $(can-objs)
190         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
191
192 make_this_module_dep:
193         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
194
195 install_this_module: make_this_module
196         su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
197
198 clean:
199         rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) \
200               .*.o.flags .*.o.cmd .*.ko.cmd .depend lincan_config.h *~ \
201               $(obj-m:%.o=%.mod.o) $(obj-m:%.o=%.mod.c) \
202               $(FINAL_MODULE_OBJS) ../$(FINAL_MODULE_OBJS)
203
204 distclean: clean
205
206
207 ifndef KERNEL_MODULE_V26
208 include $(KERNEL_LOCATION)/Rules.make
209 endif
210