summaryrefslogtreecommitdiffstats
path: root/pcitool.spec.in
blob: a8b1d9bc15f6be82c2c8c0df0c22d51c8718da17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
%define	modname pciDriver

%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

Summary: Universal PCI driver
Name: pcitool
Version: ${CPACK_PACKAGE_VERSION}
Release: csa
License: GPL-3.0
Group: Development/Libraries
Source: ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-root
URL: http://darksoft.org
Prefix: %{_prefix}
Docdir: %{_docdir}
BuildRequires: libfastwriter-devel libxml2-devel uthash
BuildRequires: python python-devel swig 
BuildRequires: kernel-devel dkms
BuildRequires: doxygen
BuildRequires: pkg-config libtool cmake
Vendor: Institute for Data Processing and Electronics, KIT
Packager: Suren A. Chilingaryan <csa@suren.me>

%description 
pcitool is a command line tool to manipulate PCI hardware. It provides ability
to get/set registers, read/write data using DMA engine, and debug hardware 
operation. 

%package -n libpcilib${PCILIB_ABI_VERSION}
Summary: User-space PCI library
Group: Development/Libraries
Requires: pcilib-python >= %{version}
Requires: pcilib-dkms >= %{version}

%description -n libpcilib${PCILIB_ABI_VERSION}
pcilib is a user-space library providing structured access to the PCI hardware.
API exposes 4 API layers.
 - PCI memory access - allows to map PCI bar memory into the address space of 
 user application and manipulate it directly.
 - Register access - allows to read and write device registers. The register
 model is defined using XML. Besides the direct hardware access, the register
 values can be filtered using Python scripts. This allows to convert hardware
 reading to standard units, make consistency checking, and create meta registers
 setting multiple registers from a single parameter.
 - DMA engine - allows high-speed reading and writting using DMA. The DMA 
 engines are implemented in user-space as plugins.
 - Event engine - allows polling for hardware events and grabbing the data
 associated with the event in multiple supported formats. The event engines
 are implemented as plugins and are not part of this package.
 
%package -n libpcilib-devel
Summary: Development files for pcilib
Group: Development/Libraries 
Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}

%description -n libpcilib-devel
Development files for user-space PCI library

%package -n pcilib-test
Summary: Testing files for pcilib
Group: Development/Libraries 
Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}

%description -n pcilib-test
Sample XML register model and a few applications for testing pcilib

%package -n pcilib-python
Summary: Python wrapper for pcilib
Group: Development/Libraries 
Requires: libpcilib${PCILIB_ABI_VERSION} = %{version}

%description -n pcilib-python
Python wrapper for pcilib. The python wrapper is used 
 - By register scripts which are used to convert hardware reading to standard
 units, make consistency checking, and create meta registers setting multiple 
 registers from a single parameter.
 - pcilib web api which used to provide register and dma access from remote
 applications.

%package -n pcilib-dkms
Summary: Kernel module providing low-level PCI access
Group: Development/Libraries 
Requires: dkms bash gcc make

%description -n pcilib-dkms
Minimalistic driver used by pcilib to 
 - Handle interrupts
 - Map PCI regions into the user space
 - Allocate persistent page-locked memory for DMA operations
 and map it into the user-space
 - Ensure access syncrhonization between multiple applications
 
%package -n pcilib-server
Summary: Pcilib Web API
Group: Development/Libraries 
Requires: pcilib-python = %{version}
Requires: python

%description -n pcilib-server
Pcilib Web API and small demo web server.

%prep
%setup -q -n pcitool-%{version}

%build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \
	-DPCILIB_PLUGIN_DIR=%{_libdir}/pcilib${PCILIB_ABI_VERSION}/ -DPCILIB_DATA_DIR=%{_datadir}/pcilib${PCILIB_ABI_VERSION}/ \
	-DLIB_INSTALL_DIR=%{_libdir} -DBIN_INSTALL_DIR=%{_bindir} -DDATA_INSTALL_DIR=%{_datadir} -DINCLUDE_INSTALL_DIR=%{_includedir} -DPYTHON_INSTALL_DIR=%{python2_sitearch} .
make
make docs

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/pcilib${PCILIB_ABI_VERSION}/

# scripts
install -m 755 tests/reload.sh $RPM_BUILD_ROOT/%{_bindir}/pci-reload

# udev
mkdir -p $RPM_BUILD_ROOT/usr/lib/udev/rules.d
install -m 644 misc/50-pcidriver.rules $RPM_BUILD_ROOT/%{_udevrulesdir}

# DKMS
mkdir -p $RPM_BUILD_ROOT/%{_includedir}/linux/
install -m 644 driver/ioctl.h $RPM_BUILD_ROOT/%{_includedir}/linux/pcidriver.h
mkdir -p $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/pcilib/
install -m 644 misc/dkms.conf $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/
install -m 644 pcilib/*.h $RPM_BUILD_ROOT/%{_prefix}/src/%{modname}-%{version}/pcilib/
cp -r driver $RPM_BUILD_ROOT/usr/src/%{modname}-%{version}/

# Sample model
cp -r xml/test $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/

# Servers
cp -r pyserver $RPM_BUILD_ROOT/%{_datadir}/pcilib${PCILIB_ABI_VERSION}/

%clean
rm -rf $RPM_BUILD_ROOT

%post -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig

%postun -n libpcilib${PCILIB_ABI_VERSION} -p /sbin/ldconfig

%post -n pcilib-dkms
if [ -z "`dkms status -m %{modname} -v %{version}`" ]; then
	echo "Add module source to dkms"
	dkms add -m %{modname} -v %{version} --rpm_safe_upgrade

	echo "Build module with dkms"
	dkms build -m %{modname} -v %{version}
	dkms install -m %{modname} -v %{version}
fi
exit 0

%preun -n pcilib-dkms
/usr/sbin/dkms remove -m %{modname} -v %{version} --all --rpm_safe_upgrade
exit 0

%files
%defattr(-, root, root)
%{_bindir}/pci
%{_bindir}/pci-reload

%files -n libpcilib${PCILIB_ABI_VERSION}
%defattr(-, root, root)
%doc docs/README 
%doc docs/HARDWARE
%dir %{_libdir}/pcilib${PCILIB_ABI_VERSION}/
%dir %{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/
%{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/*.xsd
%{_libdir}/libpcilib.so.*

%files -n libpcilib-devel
%defattr(-, root, root)  
%doc docs/html
%{_includedir}/linux/pcidriver.h
%{_includedir}/pcilib.h
%{_includedir}/pcilib/
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc

%files -n pcilib-test
%defattr(-, root, root)  
%{_datadir}/pcilib${PCILIB_ABI_VERSION}/models/test

%files -n pcilib-dkms
%defattr(-, root, root)  
%{_udevrulesdir}
%{_prefix}/src/%{modname}-%{version}/

%files -n pcilib-python
%defattr(-, root, root)
%{python2_sitearch}/*

%files -n pcilib-server
%defattr(-, root, root)  
%{_datadir}/pcilib${PCILIB_ABI_VERSION}/pyserver

%changelog
* Fri Mar  4 2016 Suren A. Chilingaryan <csa@suren.me> - ${CPACK_PACKAGE_VERSION}
- Added spec file to the sources