Subversion Repositories f9daq

Rev

Rev 43 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9 f9daq 1
#****************************************************************************
2
# Copyright (C) 2000-2004  ARW Elektronik Germany
3
#
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
#
19
# Maintainer(s): Klaus Hitschler (klaus.hitschler@gmx.de)
20
#****************************************************************************
21
 
22
#****************************************************************************
23
#
24
# Makefile - makefile for ARW Elektronik PCI to VME interfaces driver
25
#
26
# $Log: Makefile,v $
27
# Revision 1.2  2004/08/13 19:23:26  klaus
28
# conversion to kernel-version 2.6, released version 3.0
29
#
30
# Revision 1.1.1.2  2002/10/18 22:14:29  klaus
31
# *** empty log message ***
32
#
33
# Revision 1.1.1.1  2002/10/09 19:36:30  klaus
34
# initial import
35
#
36
#
37
#****************************************************************************
38
 
39
#****************************************************************************
40
# please modify only here if your kernel path is elsewhere located
41
#
42
KERNEL_LOCATION =/usr/src/linux-headers-$(shell uname -r)
43
 
43 f9daq 44
EXTRA_CFLAGS := -I.
9 f9daq 45
#****************************************************************************
46
# removed old kernel source path retrival for support of kernels < 2.2.18!
47
# old KERNSRC = /lib/modules/$(VERSION)/build
48
#
49
KERNSRC := $(KERNEL_LOCATION)
50
 
51
#****************************************************************************
52
# whole makefile is based on availability of version.h file
53
# do a forced stop if it is not available
54
#
55
HASVERSION_H := $(shell if test -f /usr/include/linux/version.h ; then echo yes ; else echo no; fi )
56
 
57
ifeq ($(HASVERSION_H),no)
58
$(error "Can't find $(KERNEL_LOCATION)/include/linux/version.h !")
59
else
60
 
61
#****************************************************************************
62
# removed old version retrival for better cross compile support
63
# old VERSION := $(shell uname -r)
64
#
65
 
66
 
67
VERSION := $(shell cpp -dM -I$(KERNEL_LOCATION)/include $(KERNEL_LOCATION)/include/generated/utsrelease.h \
68
            | grep UTS_RELEASE | sed -e 's;[^"]*"\(.*\)";\1;g')
69
 
70
 
71
#****************************************************************************
72
# where the driver should be installed - change here for cross install - currently not functional
73
#
74
 
11 f9daq 75
INSTALL_LOCATION = /lib/modules/$(shell uname -r)/kernel/drivers/misc/
76
 
9 f9daq 77
#****************************************************************************
78
# get extracted kernel VERSION and PATCHLEVEL for comparison
79
# decide to use KBUILD for kernels greater 2.6.0
80
#
81
KVERSION    := $(shell echo $(VERSION) | sed -e 's;\([1-9]\)\..*;\1;g' )
82
KPATCHLEVEL := $(shell echo $(VERSION) | sed -e 's;[1-9]\.\([0-9]\{0,3\}\)\..*;\1;g' )
83
USEKBUILD   := yes
84
#****************************************************************************
85
# some common switches and defines
86
#
44 f9daq 87
#DBG     = __NO_DEBUG__  # or __DEBUG__ to debug the driver
88
DBG     = __DEBUG__
9 f9daq 89
SRC     = .
90
 
91
 
92
#****************************************************************************
93
# preparation what to build or what to KBUILD
94
#
95
pcivme-objs :=  $(SRC)/main.o $(SRC)/askpci.o $(SRC)/plxbug.o $(SRC)/fops.o
96
 
97
 
98
ifeq ($(USEKBUILD),yes) # <<<<< USEKBUILD >>>>>>
99
 
100
#****************************************************************************
101
# what's the target
102
#
103
TARGET = pcivme.ko
104
obj-m := pcivme.o
105
 
106
#****************************************************************************
107
# add flags to standard flags
108
#
109
CPPFLAGS += -I$(PWD) -D$(DBG)
110
 
111
#****************************************************************************
112
# do it
113
#
43 f9daq 114
KBUILD_CPPFLAGS +=  -D$(DBG)
115
KBUILD_CPPFLAGS += -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast
11 f9daq 116
 
9 f9daq 117
all : message
11 f9daq 118
	$(MAKE) -C $(KERNSRC) M=$(PWD) V=$(VERBOSE)  $(filter-out all, $(MAKECMDGOLAS)) modules
9 f9daq 119
 
120
else # <<<<< USEKBUILD >>>>>>
121
 
122
#****************************************************************************
123
# additional common switches and defines
124
#
125
CC      = gcc
126
LD      = ld
127
INC     = $(KERNSRC)/include
128
DEP     = .depend
129
 
130
#****************************************************************************
131
# what's the target
132
#
133
TARGET = pcivme.o
134
 
135
#****************************************************************************
136
# compile flags
137
#
138
CFLAGS = -O2 -D__KERNEL__ -DMODULE -Wall $(INCLUDE) -D$(DBG)
139
 
140
#****************************************************************************
141
# do it
142
#
143
all: message $(TARGET)
144
 
145
$(TARGET)  : $(pcivme-objs)
146
	$(LD) -r $^ -o $@
147
 
148
#********** catch include file depencies ************************************
149
ifeq ($(DEP),$(wildcard $(DEP)))
150
 
151
depend:
152
	makedepend -f$(DEP) -- $(CFLAGS) -- $(addsuffix .c, $(basename $(pcivme-objs))) -I$(INC)
153
 
154
include $(DEP)
155
 
156
else
157
 
158
depend:
159
	touch $(DEP)
160
	makedepend -f$(DEP) -- $(CFLAGS) -- $(addsuffix .c, $(basename $(pcivme-objs))) -I$(INC)
161
endif
162
 
163
endif # <<<<< USEKBUILD >>>>>>
164
 
165
#********** clean all for a rebuild *****************************************
166
clean:
167
	rm -f *~ $(TARGET) $(pcivme-objs)
168
 
169
#********** clean all for a rebuild *****************************************
170
fresh:
171
	touch *.c
172
	make all
173
 
174
#********** informations during build of driver *****************************
175
.PHONY : message
176
message:
177
	@ echo "***"
178
	@ echo "*** Host machine kernel version=$(shell uname -r), Driver kernel version=$(VERSION), Path to kernel sources=$(KERNSRC), use KBUILD=$(USEKBUILD)"
179
	@ echo "***"
180
 
181
#********** root installation only ******************************************
11 f9daq 182
install:
44 f9daq 183
	@echo "** Removing existing module pcivme from kernel"
11 f9daq 184
	-rmmod  pcivme
44 f9daq 185
	@echo "** Installing new module into the module directory"
11 f9daq 186
	-cp -r pcivme.ko $(INSTALL_LOCATION)
44 f9daq 187
	@echo "** Loading new module with ./pcivme_load 1"
9 f9daq 188
	./pcivme_load 1
189
 
190
endif  # <<<<< HASVERSION_H >>>>>>
191
 
192
# DO NOT DELETE
193