File dahdi-linux.spec of Package dahdi-linux

#
# spec file for package dahdi-linux
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2019-2020 LISA GmbH, Bingen, Germany.
#
# 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/
#

Name:           dahdi-linux
Summary:        Digium Asterisk Hardware Device Interface driver
Version:        3.1.0+git20240501
Release:        0
Url:            https://asterisk.org/
License:        GPL-2.0
Group:          Productivity/Telephony/Utilities
#Git-Clone:     https://gitea.osmocom.org/retronetworking/dahdi-linux/ (osmocom fork)
Source:         %{name}-%{version}.tar.xz
Source3:        %name-preamble
Source4:        firmware-20200416.tar.xz
Patch8:         dahdi-warn-on-once.diff
Patch9:         dahdi-oslec.diff
Patch10:        dahdi-slab.diff
Patch11:        dahdi-fix-kernel-6.11.patch
Patch90:        dahdi-fix-leap-15.1.diff
Patch91:        dahdi-disable-xpp.patch
BuildRequires:  fdupes
BuildRequires:  kernel-syms >= 2.6.17
BuildRequires:  modutils
BuildRequires:  udev
BuildRequires:  xz
BuildRequires:  zlib-devel
BuildRequires:  %kernel_module_package_buildreqs

Provides:       dahdi = %version-%release
Obsoletes:      dahdi < %version-%release

# EC2 and UM have no PCI, but DAHDI is all about PCI device drivers
%kernel_module_package -p %name-preamble -x ec2 um

%description
This package contains configuration files, header files, and setup
tools needed for the zapata telephony interface drivers.

See %_datadir/doc/packages/dahdi/README for a list of supported
hardware.

%package KMP
Summary:        Digium Asterisk Hardware Device Interface driver
Group:          System/Kernel

%description KMP
This package contains the kernel modules of the Zapata Telephony
Interface. For details see the dahdi package.

%package devel
Summary:        Development files for the Digium Asterisk Hardware Device Interface
Group:          Development/Libraries/Other
License:        GPL-2.0 and LGPL-2.1
Requires:       %name = %version-%release
Provides:       dahdi-devel = %version-%release
Provides:       dahdi-linux-syms = %version-%release

%description devel
This package contains the header files and libraries necessary for
developing applications which use zaptel.

Install dahdi-devel if you want to develop applications which depend on
asterisk.

%prep
%setup -qa4 -n%name-%version
%patch -p1 -P 8 -P 9 -P 10 -P 11
%if 0%{?sle_version} == 150100 && 0%{?is_opensuse}
%patch -p1 -P 90
%endif
%if %__isa_bits == 32
%patch -p1 -P 91
%endif
pushd drivers/dahdi/firmware/
for i in *.tar*; do
	tar -xf "$i"
done
popd
# kernel 5.3.18 of 15.3 behaves like a 5.4 kernel in this regard
%if 0%{?sle_version} == 150300 && 0%{?is_opensuse}
sed -i 's|KERNEL_VERSION(5, 4, 0)|KERNEL_VERSION(5, 3, 0)|' include/dahdi/kernel.h
%endif

%build
export CFLAGS="%optflags -Wincompatible-pointer-types"
export MODULES_EXTRA="dahdi_dummy"
mkdir -p ../obj
for flavor in %flavors_to_build; do
	cp -a . "../obj/$flavor"
	pushd "../obj/$flavor"
	%make_build KSRC="/usr/src/linux-obj/%_target_cpu/$flavor"
	popd
done

%install
export MODULES_EXTRA="dahdi_dummy"
b="%buildroot"
for flavor in %flavors_to_build; do
	pushd "../obj/$flavor"
	%make_install INSTALL_MOD_PATH="$b" \
		KSRC="/usr/src/linux-obj/%_target_cpu/$flavor"

	# wanpipe-kmp wants this
	dahdi_dir="%_includedir/dahdi/obj/%_target_cpu/$flavor"
	mkdir -p "$b/$dahdi_dir"
	cp -a include "$b/$dahdi_dir/"
	ln -s "%_includedir/dahdi" "$b/$dahdi_dir/include/dahdi"
	mkdir -p "$b/$dahdi_dir/drivers/dahdi"
	cp -a drivers/dahdi/Module*.symvers "$b/$dahdi_dir/drivers/dahdi"

	# wanted by voicesync/wanpipe-voicetime
	cp -a drivers/dahdi/ecdis.h "$b/$dahdi_dir/drivers/dahdi"
	cp -a drivers/dahdi/biquad.h "$b/$dahdi_dir/drivers/dahdi"
	echo "%version" >"$b/$dahdi_dir/.version"

	popd
done

# remove pointless double copy
rm -Rv "$b/usr/lib/hotplug"
%fdupes %buildroot/%_prefix

%files
%license LICENSE*
%doc README
/lib/firmware/*
/lib/firmware/.dahdi*
%_datadir/dahdi/

%files devel
%_includedir/dahdi/

%changelog
openSUSE Build Service is sponsored by