]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/src/Makefile
The first enhanced version of Linux CAN-bus driver for OCERA project
[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 0.7  6 Aug 2001
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.5.47
17
18 # Comment-out next two lines, if you do not build driver 
19 # in the OCERA source tree
20 TOP=../../../../..
21 KERNEL_LOCATION=$(TOP)/kernel/linux
22
23 # Enable debugging messages
24 DEBUG = y
25
26 # You can comment out the hardware you don't need. This will result in a smaller
27 # driver. By default, all hardware is supported in the driver. See the README 
28 # file for a description of the supported hardware.
29 #   pccan       Not to be confused with PCCCAN!!!
30 #   pcccan      Not to be confused with PCCAN!!!
31
32 SUPPORTED_CARDS = pip pccan smartcan nsi cc_can104 \
33                   pc_i03 pcm3680 aim104 m437 pcccan ssv \
34                   bfadcan pikronisa template
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       += main.o modparms.o setup.o sja1000.o i82527.o close.o ioctl.o \
95                 open.o write.o read.o sja1000p.o irq.o select.o
96 # Objects with exported symbols (-DEXPORT_SYMTAB)
97 OX_OBJS      = 
98 # Module objects 
99 M_OBJS       = $(O_TARGET)
100 # Module only objects with exported symbols (-DEXPORT_SYMTAB)
101 MX_OBJS      = 
102 # Kernel only objects 
103 L_OBJS       =  
104 # Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
105 LX_OBJS      = 
106 # Additional CFLAGS
107 EXTRA_CFLAGS +=
108
109 # Linux 2.4.2 build system needs next
110 can-objs := $(O_OBJS)
111 obj-y := $(O_OBJS)
112 obj-m := can.o
113
114 ########## Source/target independent buil of module #############
115
116 all : default
117
118 default : make_this_module
119         cp can.o ../can.o
120
121 dep: make_this_module_dep
122
123 install : install_this_module
124
125 .supported_cards.h: Makefile
126         echo >.supported_cards.h
127         $(foreach card, $(SUPPORTED_CARDS), \
128           echo \#define ENABLE_CARD_$(card) 1 >>.supported_cards.h ;)
129         
130 make_this_module: .supported_cards.h
131         echo Linux kernel version $(KERNEL_VERSION)
132         echo Linux kernel sources $(KERNEL_LOCATION)
133         echo Module target $(obj-m)
134         echo Module objects $(can-objs)
135         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
136         for f in $(obj-m:%.o=%) ; do if [ -f $$f.ko ] ; then cp -u $$f.ko $$f.o ; fi ; done
137
138 make_this_module_dep:
139         DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR dep)
140
141 install_this_module: make_this_module
142         su -c "mkdir -v -p $(MODULE_CHAR_LOC); cp -v $(obj-m) $(MODULE_CHAR_LOC)"
143
144 clean:
145         rm -f $(M_OBJS) $(MX_OBJS) $(O_OBJS) $(OX_OBJS) $(obj-m) $(obj-m:%.o=%.ko) \
146                         .*.o.flags .*.o.cmd .depend .supported_cards.h *~
147
148 ifndef KERNEL_MODULE_V26
149 include $(KERNEL_LOCATION)/Rules.make
150 endif