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