%global pkgvers 0
%global scdate0 20250308
%global schash0 4722ef5b2894be5bc69ddf669232be6eba1b0cca
%global branch0 main
%global source0 https://github.com/gnuradio/gnuradio.git

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

Name:           gnuradio
Version:        %(curl -s https://raw.githubusercontent.com/gnuradio/gnuradio/%{schash0}/CMakeLists.txt | grep SET.*VERSION_ | sed 's|git|0|' | sed 's/[^[:digit:].-]//g' | sed ':a;N;$!ba;s/\n/./g')
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        Software defined radio framework
License:        GPLv3

URL:            https://www.gnuradio.org

BuildRequires:  cmake git libtool python3 alsa-lib-devel boost-devel codec2-devel
BuildRequires:  cppzmq-devel desktop-file-utils doxygen fftw-devel findutils gmp-devel
BuildRequires:  graphviz gsl-devel gsm-devel gtk3-devel jack-audio-connection-kit-devel pygccxml
BuildRequires:  portaudio-devel python3-devel python3-cairo python3-click-plugins python3-gobject
BuildRequires:  python3-numpy python3-pyyaml python3-lxml python3-mako python3-qt5-devel mathjax
BuildRequires:  python3-scipy python3-thrift qwt-qt5-devel tex(latex) SDL-devel thrift libunwind-devel
BuildRequires:  pybind11-devel uhd-devel xdg-utils xmlto zeromq-devel python3-gobject volk-devel
BuildRequires:  libsndfile-devel SoapySDR-devel spdlog-devel python3-packaging libiio-devel
BuildRequires:  python3-jsonschema libad9361-iio-devel thrift-devel python3-qt5 python3-pytest
%if 0%{?fedora}
BuildRequires:  python3-pyqtgraph
%endif
%if 0%{?rhel} == 8
%undefine _annotated_build
BuildRequires:  gcc-toolset-10-gcc-c++
%else
BuildRequires:  gcc-c++
%endif

Requires:       python3-%{name} = %{version}-%{release}
Requires:       gtk3 python3-numpy python3-thrift python3-pyyaml
Requires:       python3-gobject python3-mako python3-click-plugins
Requires:       python3-qt5 python3-scipy python3-jsonschema libunwind
%if 0%{?fedora}
Requires:       python3-pyopengl python3-pyqtgraph
%endif

Requires(pre):  shadow-utils

%undefine __cmake_in_source_build

%description
GNU Radio is a collection of software that when combined with minimal
hardware, allows the construction of radios where the actual waveforms
transmitted and received are defined by software. What this means is
that it turns the digital modulation schemes used in today's high
performance wireless devices into software problems.

%package -n     python3-%{name}
Summary:        GNU Radio Python 3 module

%description -n python3-%{name}
GNU Radio Python 3 module

%package        devel
Summary:        GNU Radio
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       cmake
Requires:       boost-devel%{?_isa}

%description    devel
GNU Radio Headers

%package        doc
Summary:        GNU Radio
Requires:       %{name} = %{version}-%{release}

%description    doc
GNU Radio Documentation

%package        examples
Summary:        GNU Radio
Requires:       %{name} = %{version}-%{release}

%description    examples
GNU Radio examples


%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 --no-pager log --format=fuller
%if 0%{?rhel}
find . -name '*.h' -exec sed -i 's|\[\[maybe_unused\]\]||g' {} +
find . -name '*.cc' -exec sed -i 's|\[\[maybe_unused\]\]||g' {} +
sed -i 's|FATAL_ERROR "Python bindings for|STATUS "Python bindings for|g' cmake/Modules/GrPybind.cmake
%endif
sed -i 's|GR_BOOST_MIN_VERSION "1.69"|GR_BOOST_MIN_VERSION "1.60"|' cmake/Modules/GrMinReq.cmake
sed -i 's|GR_NUMPY_MIN_VERSION "1.17.4"|GR_NUMPY_MIN_VERSION "1.10.0"|' cmake/Modules/GrMinReq.cmake
sed -i 's|GR_PYTHON_MIN_VERSION "3.6.5"|GR_PYTHON_MIN_VERSION "3.6.0"|' cmake/Modules/GrMinReq.cmake
sed -i 's|GR_MAKO_MIN_VERSION "1.1.0"|GR_MAKO_MIN_VERSION "1.0.0"|' cmake/Modules/GrMinReq.cmake
sed -i 's|GR_PYTHON_MIN_VERSION "3.7.2"|GR_PYTHON_MIN_VERSION "3.6.0"|' cmake/Modules/GrMinReq.cmake
sed -i '/target_precompile_headers(/,/)/d' gnuradio-runtime/lib/CMakeLists.txt
sed -i '1 i #include <mutex>' gnuradio-runtime/lib/thread/thread_group.cc
sed -i '1 i #include <cstddef>' gr-blocks/include/gnuradio/blocks/blockinterleaving.h
sed -i '1 i #include <vector>' gr-blocks/include/gnuradio/blocks/blockinterleaving.h
sed -i '1 i #include "stdint.h"' gr-fec/include/gnuradio/fec/alist.h


%build
%if 0%{?rhel} == 8
source scl_source enable gcc-toolset-10
%endif
%cmake -Wno-dev \
       -DCMAKE_SKIP_RPATH=ON \
       -DCMAKE_VERBOSE_MAKEFILE=OFF \
       -DCMAKE_BUILD_TYPE=RelWithDebInfo \
       -DENABLE_COMMON_PCH=OFF \
       -DSYSCONFDIR=%{_sysconfdir} \
%ifarch aarch64
       -Dhave_mfpu_neon=1 \
%endif
       -DGR_PKG_DOC_DIR=%{_docdir}/%{name} \
       -DGR_PYTHON_DIR=%{python3_sitearch} \
       -DPYTHON_EXECUTABLE=%{__python3}
%cmake_build


%install
%cmake_install
# desktop-file-validate %{buildroot}%{_datadir}/applications/gnuradio-grc.desktop
# Remove extraneous desktop/icon/mime files
# rm -r %{buildroot}%{_datadir}/%{name}/grc/freedesktop


%ldconfig_scriptlets


%files
%license COPYING
%{_bindir}/*
%{_libdir}/lib*.so.*
# % {_libexecdir}/*
%{_datadir}/gnuradio
# % {_datadir}/applications/gnuradio-grc.desktop
# % {_datadir}/mime/packages/gnuradio-grc.xml
# % {_datadir}/icons/hicolor/*/apps/gnuradio-grc.png
# % {_datadir}/metainfo/org.gnuradio.grc.metainfo.xml
%{_mandir}/man1/*
%config(noreplace) %{_sysconfdir}/gnuradio
%exclude %{_datadir}/gnuradio/examples
%exclude %{_docdir}/%{name}/html
%exclude %{_docdir}/%{name}/xml
%doc %{_docdir}/%{name}
%{_datadir}/bash-completion/completions/gr_modtool
%{_datadir}/fish/vendor_completions.d/gr_modtool.fish
%{_datadir}/zsh/site-functions/_gr_modtool

%files -n python3-%{name}
%{python3_sitearch}/%{name}/
%{python3_sitearch}/pmt/

%files devel
%{_includedir}/*
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc
%{_libdir}/cmake/gnuradio

%files doc
%doc %{_docdir}/%{name}/html
%doc %{_docdir}/%{name}/xml

%files examples
%{_datadir}/gnuradio/examples


%changelog
* Mon Mar 18 2019 Balint Cristian <cristian.balint@gmail.com>
- github update releases