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