bzr branch
http://suren.me/webbzr/alps/pcitool
358
by Suren A. Chilingaryan
Support emulation mode without real hardware |
1 |
CONFIG_MODULE_SIG=n |
1
by Suren A. Chilingaryan
Initial import |
2 |
|
3 |
obj-m := pciDriver.o |
|
365
by Suren A. Chilingaryan
Restructure driver headers |
4 |
pciDriver-objs := base.o dev.o int.o umem.o kmem.o sysfs.o ioctl.o pcibus.o rdma.o |
1
by Suren A. Chilingaryan
Initial import |
5 |
|
370
by Suren A. Chilingaryan
RPM generation |
6 |
KERNELVER ?= $(shell uname -r) |
7 |
KERNELDIR ?= /lib/modules/$(KERNELVER)/build |
|
8 |
INSTALLDIR ?= /lib/modules/$(KERNELVER)/extra |
|
9 |
MAININSTALLDIR ?= /lib/modules/$(KERNELVER)/kernel/extra |
|
402
by Suren A. Chilingaryan
Fix driver installation on Ubuntu |
10 |
ifneq ("$(wildcard /lib/modules/$(KERNELVER)/build/include/linux)","")
|
11 |
HEADERDIR ?= /lib/modules/$(KERNELVER)/build/include |
|
12 |
else ifneq ("$(wildcard /lib/modules/$(KERNELVER)/source/include/linux)","")
|
|
370
by Suren A. Chilingaryan
RPM generation |
13 |
HEADERDIR ?= /lib/modules/$(KERNELVER)/source/include |
402
by Suren A. Chilingaryan
Fix driver installation on Ubuntu |
14 |
else
|
15 |
HEADERDIR ?= "" |
|
16 |
endif
|
|
17 |
||
1
by Suren A. Chilingaryan
Initial import |
18 |
PWD := $(shell pwd) |
19 |
||
400
by Suren A. Chilingaryan
Further fixes for out-of-source compilation |
20 |
EXTRA_CFLAGS += -I$(M)/.. ${PCILIB_DYNAMIC_HEADERS_INC} |
45
by root
North West Logick DMA implementation |
21 |
|
358
by Suren A. Chilingaryan
Support emulation mode without real hardware |
22 |
ifdef DUMMY_DEVICE
|
23 |
ifneq ($(DUMMY_DEVICE), 0)
|
|
24 |
EXTRA_CFLAGS += -DPCIDRIVER_DUMMY_DEVICE |
|
25 |
endif
|
|
26 |
endif
|
|
27 |
||
400
by Suren A. Chilingaryan
Further fixes for out-of-source compilation |
28 |
# Grepping in '../pcilib/build.h' is correct as we will always have this file in the releases...
|
1
by Suren A. Chilingaryan
Initial import |
29 |
default: |
158
by Suren A. Chilingaryan
Verify gcc version |
30 |
@KERNEL_GCC_VERSION=`cat /proc/version | head -n1 | cut -d " " -f 7` ;\ |
225
by Suren A. Chilingaryan
Fix detection of gcc version on Ubuntu (by Uros) |
31 |
GCC_VERSION=`$(CC) --version | head -n 1 | tr ' ' '\n' | grep -e "[0-9]\+\.[0-9]" | tail -n 1` ;\ |
158
by Suren A. Chilingaryan
Verify gcc version |
32 |
if [ $$KERNEL_GCC_VERSION != $$GCC_VERSION ]; then \
|
33 |
echo "Kernel is compiled with gcc $$KERNEL_GCC_VERSION, but you are now using $$GCC_VERSION" ;\
|
|
34 |
GCC_MAJOR=`echo $$KERNEL_GCC_VERSION | cut -d "." -f 1-2` ;\
|
|
381
by Suren A. Chilingaryan
Improve search routing looking up gcc suitable to compile kernel |
35 |
newCC=gcc-$$KERNEL_GCC_VERSION ;\
|
158
by Suren A. Chilingaryan
Verify gcc version |
36 |
CC=`which $$newCC 2>/dev/null` ;\
|
37 |
if [ $$? -ne 0 ]; then \
|
|
381
by Suren A. Chilingaryan
Improve search routing looking up gcc suitable to compile kernel |
38 |
newCC=gcc-$$GCC_MAJOR ;\
|
39 |
CC=`which $$newCC 2>/dev/null` ;\
|
|
40 |
if [ $$? -ne 0 ]; then \
|
|
41 |
newCC=`compgen -ac | grep -E ^gcc-4.6 | head -n 1` ;\
|
|
42 |
CC=`which $$newCC 2>/dev/null` ;\
|
|
43 |
if [ $$? -ne 0 ]; then \
|
|
44 |
echo "No compiler of $$GCC_MAJOR series is installed" ;\
|
|
45 |
exit 1 ;\
|
|
46 |
fi ; \
|
|
47 |
fi ;\
|
|
158
by Suren A. Chilingaryan
Verify gcc version |
48 |
fi ;\
|
349
by Suren A. Chilingaryan
Improve gcc detection for module compilation |
49 |
GCC_VERSION=`$$CC --version | head -n 1 | tr ' ' '\n' | grep -e "[0-9]\+\.[0-9]" | tail -n 1` ;\
|
50 |
if [ $$KERNEL_GCC_VERSION != $$GCC_VERSION -a -z "$$RELAXED_GCC_CHECK" ]; then \
|
|
158
by Suren A. Chilingaryan
Verify gcc version |
51 |
echo "The $$GCC_VERSION of $$GCC_MAJOR series is installed" ;\
|
52 |
exit 1 ;\
|
|
53 |
fi ;\
|
|
54 |
echo "Setting CC to $$newCC" ;\
|
|
55 |
else \
|
|
56 |
CC=$(CC) ;\
|
|
57 |
fi ;\
|
|
350
by Suren A. Chilingaryan
Report information about driver revision and build |
58 |
build_path=`pwd` ;\
|
59 |
build_lastmod=`find . -type f -name '*.[ch]' -printf '%TY/%Tm/%Td %TH:%TM:%TS %p\n' | grep -E -v 'build.h|mod.c' | sort -n | tail -n 1 | cut -d ' ' -f 1-2 | cut -d '.' -f 1` ;\
|
|
60 |
build_user=`whoami` ;\
|
|
61 |
build_date=`date "+%Y/%m/%d %H:%M:%S"` ;\
|
|
62 |
build="Built at $$build_date by $$build_user" ;\
|
|
394
by Suren A. Chilingaryan
Fix driver compilation when bazaar is missing in the system |
63 |
bzr=`which bzr 2>/dev/null` ;\
|
64 |
if [ $$? -eq 0 -a -d ../.bzr ]; then \
|
|
376
by Suren A. Chilingaryan
Support compiling without bzr in the driver |
65 |
build_revision=`bzr revno` ;\
|
66 |
build_author=`bzr log -r$$build_revision | grep committer | cut -c 12-` ;\
|
|
67 |
build_branch=`bzr nick` ;\
|
|
68 |
build_changes=`bzr status -SV | cut -c 5- | tr \\\n " "` ;\
|
|
69 |
revision="Revision $$build_revision from $$build_branch by $$build_author at $$build_path, last modification from $$build_lastmod" ;\
|
|
70 |
/bin/echo -e "#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES \"$$build_changes\"\\n" > build.h ;\
|
|
71 |
else \
|
|
401
by Suren A. Chilingaryan
Fix driver compilation on Ubuntu 14.04 |
72 |
if [ -f ../pcilib/build.h ]; then \
|
73 |
grep "#define PCILIB_RELEASE" ../pcilib/build.h &> /dev/null ;\
|
|
74 |
res=$$? ;\
|
|
75 |
else \
|
|
76 |
res=-1 ;\
|
|
77 |
fi ;\
|
|
78 |
if [ $$res -eq 0 ]; then \
|
|
398
by Suren A. Chilingaryan
Fix also building of driver for bazaar-exported zip archives |
79 |
revision="Release \" PCILIB_RELEASE \" (r\" PCILIB_REVISION \") from \" PCILIB_REVISION_BRANCH \" by \" PCILIB_REVISION_AUTHOR \" at $$build_path, last modification from $$build_lastmod" ;\
|
400
by Suren A. Chilingaryan
Further fixes for out-of-source compilation |
80 |
/bin/echo -e "#include \"pcilib/build.h\"\\n#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES PCILIB_REVISION_MODIFICATIONS\n" > build.h ;\
|
398
by Suren A. Chilingaryan
Fix also building of driver for bazaar-exported zip archives |
81 |
else \
|
82 |
revision="Revision r\" PCILIB_REVISION \" from \" PCILIB_REVISION_BRANCH \" by \" PCILIB_REVISION_AUTHOR \" at $$build_path, last modification from $$build_lastmod" ;\
|
|
400
by Suren A. Chilingaryan
Further fixes for out-of-source compilation |
83 |
/bin/echo -e "#include \"pcilib/build.h\"\\n#define PCIDRIVER_BUILD \"$$build\"\\n#define PCIDRIVER_REVISION \"$$revision\"\\n#define PCIDRIVER_CHANGES PCILIB_REVISION_MODIFICATIONS\n" > build.h ;\
|
398
by Suren A. Chilingaryan
Fix also building of driver for bazaar-exported zip archives |
84 |
fi ;\
|
376
by Suren A. Chilingaryan
Support compiling without bzr in the driver |
85 |
fi ;\
|
158
by Suren A. Chilingaryan
Verify gcc version |
86 |
$(MAKE) $(CFLAGS) -C $(KERNELDIR) M=$(PWD) CC=$$CC modules
|
1
by Suren A. Chilingaryan
Initial import |
87 |
|
88 |
install: |
|
89 |
@mkdir -p $(INSTALLDIR) |
|
90 |
@echo "INSTALL $(INSTALLDIR)/pciDriver.ko" |
|
91 |
@install -m 755 pciDriver.ko $(INSTALLDIR) |
|
363
by Suren A. Chilingaryan
Resolution of the user-space BAR addresses |
92 |
@echo "INSTALL $(INSTALLDIR)/pciDriver.symvers" |
93 |
@install -m 644 Module.symvers $(INSTALLDIR)/pciDriver.symvers |
|
402
by Suren A. Chilingaryan
Fix driver installation on Ubuntu |
94 |
@if [ "$(HEADERDIR)" != "" ]; then \ |
95 |
echo "INSTALL $(HEADERDIR)/linux/pcidriver.h" ;\ |
|
96 |
install -m 644 pcidriver.h $(HEADERDIR)/linux/ ;\ |
|
97 |
fi
|
|
365
by Suren A. Chilingaryan
Restructure driver headers |
98 |
@echo "INSTALL /usr/include/linux/pcidriver.h"
|
99 |
@mkdir -p /usr/include/linux |
|
100 |
@install -m 644 ioctl.h /usr/include/linux/pcidriver.h
|
|
1
by Suren A. Chilingaryan
Initial import |
101 |
|
370
by Suren A. Chilingaryan
RPM generation |
102 |
install_symvers: |
103 |
@mkdir -p $(INSTALLDIR) |
|
104 |
@echo "INSTALL $(INSTALLDIR)/pciDriver.symvers" |
|
105 |
@install -m 644 Module.symvers $(INSTALLDIR)/pciDriver.symvers |
|
106 |
@echo "INSTALL $(HEADERDIR)/linux/pcidriver.h" |
|
107 |
@install -m 644 pcidriver.h $(HEADERDIR)/linux/ |
|
108 |
||
109 |
||
1
by Suren A. Chilingaryan
Initial import |
110 |
uninstall: |
402
by Suren A. Chilingaryan
Fix driver installation on Ubuntu |
111 |
@if [ -f $(INSTALLDIR)/pciDriver.ko ]; then \ |
112 |
echo "UNINSTALL $(INSTALLDIR)/pciDriver.ko" ;\ |
|
113 |
rm -f $(INSTALLDIR)/pciDriver.ko ;\ |
|
114 |
fi
|
|
115 |
@if [ -f $(MAININSTALLDIR)/pciDriver.ko ]; then \ |
|
116 |
echo "UNINSTALL $(MAININSTALLDIR)/pciDriver.ko" ;\ |
|
117 |
rm -f $(MAININSTALLDIR)/pciDriver.ko ;\ |
|
118 |
fi
|
|
119 |
@if [ -f $(INSTALLDIR)/pciDriver.symvers ]; then \ |
|
120 |
echo "UNINSTALL $(INSTALLDIR)/pciDriver.symvers" ;\ |
|
121 |
rm -f $(INSTALLDIR)/pciDriver.symvers ;\ |
|
122 |
fi
|
|
123 |
@if [ -f $(MAININSTALLDIR)/pciDriver.symvers ]; then \ |
|
124 |
echo "UNINSTALL $(MAININSTALLDIR)/pciDriver.symvers" ;\ |
|
125 |
rm -f $(MAININSTALLDIR)/pciDriver.symvers ;\ |
|
126 |
fi
|
|
127 |
@if [ -f /usr/include/linux/pcidriver.h ]; then \ |
|
128 |
echo "UNINSTALL /usr/include/linux/pcidriver.h" ;\ |
|
129 |
rm -rf /usr/include/linux/pcidriver.h ;\ |
|
130 |
fi
|
|
131 |
@if [ -d /usr/include/pciDriver/ ]; then \ |
|
132 |
echo "UNINSTALL /usr/include/pciDriver/" ;\ |
|
133 |
rm -rf /usr/include/pciDriver/ ;\ |
|
134 |
fi
|
|
135 |
@if [ "$(HEADERDIR)" != "" -a -f $(HEADERDIR)/linux/pcidriver.h ]; then \ |
|
136 |
echo "UNINSTALL $(HEADERDIR)/linux/pcidriver.h" ;\ |
|
137 |
rm -rf $(HEADERDIR)/linux/pcidriver.h ;\ |
|
138 |
fi
|
|
1
by Suren A. Chilingaryan
Initial import |
139 |
|
140 |
clean: |
|
141 |
rm -rf *.o *.ko *.mod.c .*.o.cmd .*.o.tmp .*.ko.cmd .*.o *.symvers modules.order .tmp_versions |