%global pkgvers 0
%global scdate0 20240228
%global schash0 d3d04f9edfd067744c7b02221f3ba3e5267aad7b
%global branch0 master
%global source0 https://gerrit.osmocom.org/libosmo-abis.git

%global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}}

Name:           libosmo-abis
Version:        1.5.1
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        A-bis interface between BTS and BSC
License:        AGPLv3

URL:            https://osmocom.org/projects/libosmo-abis/wiki/Libosmo-abis

BuildRequires:  git gcc autoconf automake libtool doxygen
BuildRequires:  libosmocore-devel ortp-devel dahdi-tools-devel openssl-devel

%undefine _hardened_build
%undefine _annotated_build

%description
A-bis interface between BTS and BSC. It implements
drivers for mISDN and DAHDI based E1 cards, as well
as some A-bis/IP dialects.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name} = %{version}-%{release}

%description    devel
Development files for %{name}.


%prep
%setup -T -c -n %{name}
git clone --depth 1 -n -b %{branch0} %{source0} .
git fetch --depth 1 origin %{schash0}
git reset --hard %{schash0}
git log --format=fuller
# new ortp
sed -i '/ortp_set_memory_functions/d' src/trau/osmo_ortp.c
sed -i '/OrtpMemoryFunctions/,/\}\;/d' src/trau/osmo_ortp.c


%build
%global optflags %(echo %optflags | sed 's|-Wp,-D_GLIBCXX_ASSERTIONS||g')
autoreconf -fi
%configure --enable-shared \
           --disable-static

# Fix unused direct shlib dependency
sed -i -e 's! -shared ! -Wl,--as-needed\0!g' libtool

make %{?_smp_mflags} VERBOSE=0


%install
make install DESTDIR=%{buildroot}
# Remove libtool archives
find %{buildroot} -name '*.la' -exec rm -f {} \;
sed -i -e 's|UNKNOWN|%{version}|g' %{buildroot}/%{_libdir}/pkgconfig/*.pc


%check
make check || true


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


%files
%doc README.md
%license COPYING
%{_libdir}/*.so.*

%files devel
%{_includedir}/osmocom/*
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc


%changelog
* Sun Aug 26 2018 Cristian Balint <cristian.balint@gmail.com>
- github update releases