File pds.spec of Package pds

#
# spec file for package pds
#
# Copyright (c) 2021, Martin Hauke <mardnh@gmx.de>
#
# 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.opensuse.org/
#

%bcond_without pds
# FIXME: hdlc_tun and hdlc_cisco_eth are not ported to modern kernels yet
%if 0%{?suse_version} >= 1550
%bcond_with hdlc_tun
%bcond_with hdlc_cisco_eth
%else
%bcond_without hdlc_tun
%bcond_without hdlc_cisco_eth
%endif
#
Name:           pds
Version:        0~git20210920
Release:        0
Summary:        PDS Linux Kernel Device Driver for E1 Devices
License:        GPL-2.0-or-later
Group:          System/Kernel
#Git-Clone:     https://github.com/ikle/ds.git
URL:            https://github.com/ikle/ds
Source:         %{name}-%{version}.tar.xz
Source1:        %{name}-kmp-preamble
Patch0:         fix-build.patch
BuildRequires:  %{kernel_module_package_buildreqs}
BuildRequires:  dahdi-linux-devel
%kernel_module_package -p pds-kmp-preamble

%description
PDS Linux Kernel Device Driver is a driver for E1 devices connected via
Ethernet. Currently, it is assumed that only one E1 device is connected
to one Ethernet port: the driver sends messages via broadcast. (Adding
the ability to work via unicast is not difficult, just no one needs it
at the moment.)

The driver allows you to work in the so-called fake mode, in which it
still returns a positive status without receiving a response from the
device. (In configuration mode, data transmission is stateless.) In this
mode, the PDS can be used as a virtual E1 tunnel: for example, it is
useful for automated testing of E1/DAHDI configuration system.

As an add-on, there is also a simple implementation of the Cisco HDLC
Ethernet encapsulation module. Keepalive messages are not supported.

%package tools
Summary:        Tools for the PDS Linux Kernel Device Driver
Group:          Productivity/Telephony/Utilities

%description tools
Tools for the PDS Linux Kernel Device Driver.
Currently there only on tool:
 * pds-emu

%prep
%setup -q
%patch0 -p1

set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
# kernel modules
for flavor in %{flavors_to_build}; do
    cp -r source obj/$flavor
    %make_build \
        V=1 -C %{kernel_source $flavor} \
        M=$PWD/obj/$flavor/linux \
        DAHDI=%{_includedir}/dahdi/obj/%{_target_cpu}/$flavor \
        KBUILD_EXTRA_SYMBOLS=%{_includedir}/dahdi/obj/%{_target_cpu}/$flavor/drivers/dahdi/Module.symvers \
%if 0%{with hdlc_cisco_eth}
        HDLC_CISCO_ETH=m \
%endif
%if 0%{with hdlc_tun}
        HDLC_TUN=m \
%endif
%if 0%{with pds}
        PDS=m \
%endif
        %{?_smp_mflags}
done

# tools
%make_build -C source/tools

%install
# kernel modules
for flavor in %{flavors_to_build}; do
    make -C %{kernel_source $flavor} M=$PWD/obj/$flavor/linux INSTALL_MOD_PATH=%{buildroot} modules_install
done

# tools
make -C source/tools DESTDIR=%{buildroot} PREFIX=%{_prefix} install

%files tools
%license source/LICENCE
%doc source/README.md source/doc/pds-notes.md
%{_bindir}/pds-emu

%changelog
openSUSE Build Service is sponsored by