File linux-gpib.spec of Package linux-gpib

#
# spec file for package linux-gpib
#
# Copyright (c) 2009-2013 acurana GmbH
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.acurana.com/
#
# norootforbuild

#%%trace

%define         vmajor  3
%define         vmiddle 2

%if 0%{?sles_version} >= 12 || 0%{?suse_version} >= 1200
%define         vminor  17
%else
%define         vminor  14
%endif

%define         tclpkg  libgpib_tcl-%{vmajor}_%{vmiddle}_%{vminor}

Name:        linux-gpib
Summary:     A GPIB kernel driver and user-space library
Version:     %{vmajor}.%{vmiddle}.%{vminor}
Release:     1
Requires:    %{name}-kmp
URL:         http://linux-gpib.sourceforge.net/
Source0:     %name-%{version}.tar.gz
Source1:     preamble-tnt4882
Source2:     tnt4882.files
Source3:     nec7210.files
Source4:     preamble-nec7210
%if 0%{?sles_version} >= 12 || 0%{?suse_version} >= 1200
Patch0:      linux-gpib-3.2.17-change-email.patch
Patch1:      linux-gpib-3.2.17-destdir.patch
Patch2:      linux-gpib-3.2.17-disable_drivers_build.patch
Patch3:      linux-gpib-3.2.17-fix-includes-modules.patch
Patch4:      linux-gpib-3.2.17-fix-incl-files.patch
Patch5:      fix_devinitdata.patch
%else
Patch0:      fix_kmod_stuff.patch
%endif
License:     GPL-2.0
Group:       System/Libraries
BuildRoot:   %{_tmppath}/%{name}-%{version}-build

# SuSE > 11.1
%if 0%{?sles_version} == 11 || 0%{?suse_version} > 1110
BuildRequires:  %kernel_module_package_buildreqs python-devel tcl-devel
%kernel_module_package -n %{name} -f %_sourcedir/kmpfiles -p %_sourcedir/preamble -x xen -x xenpae
%else
# RHEL based, no Supplements: tag, CentOS doesn't know kernel_module_package_buildreqs
%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?fedora}
BuildRequires:  redhat-rpm-config kernel-devel python-devel tcl-devel
%kernel_module_package -n %{name} -f %_sourcedir/kmpfiles
%else
# remaining SuSE distros
BuildRequires:  kernel-syms module-init-tools python-devel tcl-devel
%suse_kernel_module_package -n %{name} -f %_sourcedir/kmpfiles -p %_sourcedir/preamble kdump um xen xenpae
%endif
%endif

# needed for RedHat to avoid problems with build requirements generated by kmodtool
%undefine kmodtool_generate_buildreqs


%description
The Linux GPIB Package is a support package for GPIB (IEEE 488) hardware. The package contains kernel driver modules, and a C user-space library with Guile, Perl, PHP, Python and TCL bindings. The API of the C library is intended to be compatible with National Instrument's GPIB library.


Authors:
--------
    Frank Mori Hess et. al.
    See http://linux-gpib.sourceforge.net/AUTHORS
    spec file by Christopher Lang <christopher.lang@acurana.de>
    

%package devel
Summary:     Development files for the linux-gpib library
Group:       Development/Libraries/C and C++
Requires:    %{name}
%description devel
Files needed for the development for the linux-gpib library.


%package doc
Summary:     Documentation for the linux-gpib library
Group:       Documentation/Other
%description doc
Documentation files for the linux-gpib library.


%package python
Summary:     Python bindings for the linux-gpib library
Group:       Development/Libraries/Python
Requires:    %{name}
%description python
Python language bindings for the linux-gpib library.


%package -n %{tclpkg}
Summary:     Tcl bindings for the linux-gpib library
Group:       Development/Libraries/Tcl
Requires:    %{name}
%description -n %{tclpkg}
Tcl language bindings for the linux-gpib library.


%package test
Summary:     Test programs for the linux-gpib library
Group:       Hardware/Other
Requires:    %{name}
%description test
Hardware test programs for the linux-gpib library.


# todo: need to add more drivers and corresponding makefile patches
# the "drivers" directories to build modules in
%define drivers tnt4882 sys nec7210 tms9914 agilent_82350b


%prep
%setup -q
%if 0%{?sles_version} >= 12 || 0%{?suse_version} >= 1200
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%else
%patch0 -p1
%endif
set -- *
%__mkdir source
%__cp -r "drivers/" source/
for driver in %drivers ; do
    %__mkdir -p obj/$driver
done


%build
%configure --docdir=%{_datadir}/doc/packages/%{name} --libdir="%_libdir"
%__make

# RedHat debug
ls -la /usr/src/kernels/ || true
ls -la /lib/modules/ || true

for flavor in %flavors_to_build ; do
    for driver in %drivers ; do
        %__rm -rf obj/$driver/$flavor
        %__cp -r source/drivers/gpib/$driver obj/$driver/$flavor
%if 0%{?fedora}
        %__make -C /usr/src/kernels/%kverrel.$([ $flavor = default ] || echo "$flavor.")%_target_cpu" \
            V=1 modules M=$PWD/obj/$driver/$flavor
%else
        %__make -C %{kernel_source $flavor} V=1 modules M=$PWD/obj/$driver/$flavor
%endif
    done
done


%install
%__make DESTDIR=%{buildroot} install

install -d -m 755 %{buildroot}%_bindir/
install -m 755 examples/.libs/* %{buildroot}%_bindir/
install -m 755 test/.libs/* %{buildroot}%_bindir/
install -m 644 include/gpib_user.h %{buildroot}%_includedir/gpib

%__rm %{buildroot}%_libdir/python*/site-packages/Gpib.pyc

export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=extra/%{name}
for flavor in %flavors_to_build ; do
    for driver in %drivers ; do
%if 0%{?fedora}
        %__make -C /usr/src/kernels/%kverrel.$([ $flavor = default ] || echo "$flavor.")%_target_cpu" \
            V=1 modules_install M=$PWD/obj/$driver/$flavor
%else
        %__make -C %{kernel_source $flavor} V=1 modules_install M=$PWD/obj/$driver/$flavor
%endif
    done
done


%clean
#


%post -p /sbin/ldconfig


%postun -p /sbin/ldconfig


%post python -p /sbin/ldconfig
%postun python -p /sbin/ldconfig


%post -n %{tclpkg} -p /sbin/ldconfig
%postun -n %{tclpkg} -p /sbin/ldconfig


%files
%defattr(-,root,root)
%_sbindir/*
%{_libdir}/libgpib.so.*
%{_libdir}/libgpib.so
%_sysconfdir/*
%{_datadir}/usb*


%files devel
%defattr(-, root, root, -)
%{_includedir}/gpib
%{_libdir}/libgpib.la


%files python
%defattr(-,root,root)
%{_libdir}/python*


%files -n %{tclpkg}
%defattr(-,root,root)
%{_libdir}/*tcl*


%files test
%defattr(-,root,root)
%{_bindir}/*


%files doc
%defattr(-,root,root)
#%%doc {_datadir}/doc/packages/{name}/*
%doc AUTHORS COPYING ChangeLog README TODO


%changelog -n linux-gpib
* Wed Jul 17 2013 - Christopher Lang <christopher.lang@acurana.de> 3.2.17
- fixed removal of __devinitdata macro from kernel sources

* Sat Jan 19 2013 - Christopher Lang <christopher.lang@acurana.de> 3.2.17
- updated for OBS

* Fri Nov 20 2009 - christopher.lang@acurana.de
- started more or less from scratch to get it cleand up

* Mon Nov 16 2009 - christopher.lang@acurana.de
- fixed suse versions > 1120

* Sat Nov 14 2009 - christopher.lang@acurana.de
- spec file working
- added python and tcl packages

* Tue Nov 09 2009 - christopher.lang@acurana.de
- initial spec file for version 3.2.14

openSUSE Build Service is sponsored by