## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 25;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Doxygen HTML help is not suitable for packaging due to a minified JavaScript
# bundle inserted by Doxygen itself. See discussion at
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555.
#
# We can enable the Doxygen PDF documentation as a substitute.
%bcond_without doc_pdf

# This package is arch-specific, because it computes properties of the system
# (such as endianness) and stores them in generated header files. Hence, the
# files DO vary by platform. However, there is no actual compiled code, so turn
# off debuginfo generation.
%global debug_package %{nil}

Name:           fflas-ffpack
Version:        2.4.3
Release:        %autorelease
Summary:        Finite field linear algebra subroutines

# The entire source is LGPL-2.1-or-later, except:
#   - fflas-ffpack/fflas-ffpack-config.h is LGPL-2.0-or-later
#
# Certain build system files that do not contribute to the license of the
# binary RPMs are also distributed under other licenses:
#   - INSTALL and macros/ax_cxx_compile_stdcxx_11.m4 are FSFAP
#   - aclocal.m4 and macros/libtool.m4 are (FSFULLR AND GPL-2.0-or-later)
#   - configure is FSFUL, or, more likely (FSFUL AND LGPL-2.1-or-later)
#   - build-aux/compile, build-aux/depcomp, build-aux/ltmain.sh,
#     build-aux/missing, and build-aux/test-driver are GPL-2.0-or-later
#   - macros/instr_set.m4 is CECILL-B
#   - macros/ltoptions.m4, macros/ltsugar.m4, macros/ltversion.m4, and
#     macros/lt~obsolete.m4 are FSFULLR
License:        LGPL-2.1-or-later AND LGPL-2.0-or-later
URL:            https://linbox-team.github.io/fflas-ffpack/
Source0:        https://github.com/linbox-team/fflas-ffpack/releases/download/%{version}/fflas_ffpack-%{version}.tar.bz2
# Man page written for Fedora in groff_man(7) format based on --help output
Source1:        fflas-ffpack-config.1

# Fix memory leaks
# https://github.com/linbox-team/fflas-ffpack/pull/276
Patch0:         fflas-ffpack-mem-leak.patch

BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool

BuildRequires:  make
BuildRequires:  gcc-c++

BuildRequires:  pkgconfig(flexiblas)
BuildRequires:  pkgconfig(givaro)
BuildRequires:  gmp-devel

%if %{with doc_pdf}
BuildRequires:  doxygen
BuildRequires:  doxygen-latex
BuildRequires:  make
BuildRequires:  tex(stmaryrd.sty)
# Default font for graphviz/dot
BuildRequires:  font(freesans)
%endif

# Although there are references to linbox-devel files in this package,
# linbox-devel Requires fflas-ffpack-devel, not the other way around.

%description
The FFLAS-FFPACK library provides functionality for dense linear algebra
over word size prime finite fields.


%package devel
Summary:        Header files for developing with fflas-ffpack

Requires:       givaro-devel%{?_isa}
Requires:       gmp-devel%{?_isa}
Requires:       flexiblas-devel%{?_isa}

Provides:       fflas-ffpack-static = %{version}-%{release}

%description devel
The FFLAS-FFPACK library provides functionality for dense linear algebra
over word size prime finite fields.  This package provides the header
files for developing applications that use FFLAS-FFPACK.


%package doc
Summary:        API documentation for fflas-ffpack

BuildArch:      noarch

%description doc
API documentation for fflas-ffpack.


%prep
%autosetup -p0 -n fflas_ffpack-%{version}
# Skip test-echelon for now due to failures.
# See https://github.com/linbox-team/fflas-ffpack/issues/282
sed -i '/^[[:blank:]]*test-echelon/d' tests/Makefile.am

# Do not use env
sed -i 's,%{_bindir}/env bash,%{_bindir}/bash,' fflas-ffpack-config.in

# Remove parts of the configure script that select non-default architectures
# and ABIs. On x86_64, we could rely on up to SSE2, but there are no explicit
# SIMD routines below SSE4.1 in the library, so it is not worth worrying about.
sed -i '/INSTR_SET/,/fabi-version/d' configure.ac

%if %{with doc_pdf}
# We enable the Doxygen PDF documentation as a substitute. We must enable
# GENERATE_LATEX and LATEX_BATCHMODE; the rest are precautionary and should
# already be set as we like them. We also disable GENERATE_HTML, since we will
# not use it.
sed -r -i \
    -e "s/^([[:blank:]]*(GENERATE_LATEX|LATEX_BATCHMODE|USE_PDFLATEX|\
PDF_HYPERLINKS)[[:blank:]]*=[[:blank:]]*)NO[[:blank:]]*/\1YES/" \
    -e "s/^([[:blank:]]*(LATEX_TIMESTAMP|GENERATE_HTML)\
[[:blank:]]*=[[:blank:]]*)YES[[:blank:]]*/\1NO/" \
    doc/Doxyfile doc/DoxyfileDev
%endif


%build
# Regenerate configure after monkeying with configure.ac
autoreconf --force --install --verbose

%configure \
  %{?with_doc_pdf:--enable-doc --docdir='%{_docdir}/fflas-ffpack'} \
  --disable-static \
  --enable-openmp \
  --disable-simd \
  --with-blas-cflags="$(pkgconf --cflags flexiblas)" \
  --with-blas-libs="$(pkgconf --libs flexiblas)"
chmod -v a+x fflas-ffpack-config
%make_build

%if %{with doc_pdf}
%make_build -C doc/latex
mv -v doc/latex/refman.pdf doc/fflas-ffpack.pdf
# Build the developer documentation, too.
rm -rf doc/latex
%make_build -C doc docs_dev
%make_build -C doc/latex
mv -v doc/latex/refman.pdf doc/fflas-ffpack-dev.pdf
%endif


%install
%make_install
rm -vrf '%{buildroot}%{_prefix}/docs'
install -t '%{buildroot}%{_mandir}/man1' -D -m 0644 -p '%{SOURCE1}'


%check
export FLEXIBLAS=netlib
%make_build check


%files devel
%license COPYING COPYING.LESSER
%doc README.md

%{_bindir}/fflas-ffpack-config
%{_mandir}/man1/fflas-ffpack-config.1*

%{_includedir}/fflas-ffpack/

%{_libdir}/pkgconfig/fflas-ffpack.pc


%files doc
%license COPYING COPYING.LESSER
%doc AUTHORS
%doc ChangeLog
%doc README.md
%doc TODO
%if %{with doc_pdf}
%doc doc/fflas-ffpack.pdf
%doc doc/fflas-ffpack-dev.pdf
%endif


%changelog
* Mon Aug 01 2022 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-25
- Update License field to SPDX

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> 2.4.3-24
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed Apr 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-23
- Install the man page directly

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> 2.4.3-22
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-21
- Explicitly BR autoconf/automake, not just libtool

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-20
- Add a man page for the “config” script

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-19
- Add comment about SIMD to spec file

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-18
- Remove a stray newline

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-17
- Express givaro BR with pkgconfig(…)

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-16
- Use pkgconf to set up flexiblas

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-15
- Let autoreconf be considered a build step

* Fri Dec 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-14
- Build Doxygen documentation as PDF

* Thu Dec 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-13
- Remove accommodations for F32 and older

* Thu Dec 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-12
- Minor style changes according to personal preference

* Thu Dec 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-11
- Reduce macro indirection in the spec file

* Thu Dec 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> 2.4.3-10
- Switch URL from HTTP to HTTPS

* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.3-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Thu Aug 13 2020 Iñaki Úcar <iucar@fedoraproject.org> - 2.4.3-4
- https://fedoraproject.org/wiki/Changes/FlexiBLAS_as_BLAS/LAPACK_manager

* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Fri Nov  1 2019 Jerry James <loganjerry@gmail.com> - 2.4.3-1
- New upstream release
- Drop upstreamed -const-void patch
- Add -mem-leak patch
- Switch from libopenblaso to libopenblasp due to test failures

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Wed Oct 10 2018 Jerry James <loganjerry@gmail.com> - 2.3.2-3
- Try again to switch from atlas to openblas
- Add -const-void patch from the sagemath developers

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Sat Jun  2 2018 Jerry James <loganjerry@gmail.com> - 2.3.2-1
- New upstream release, fixes FTBFS (bz 1585225)
- Drop all patches
- Drop workarounds in the check script

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Wed Sep 27 2017 Jerry James <loganjerry@gmail.com> - 2.2.2-8
- Rebuild after failed attempt to switch to openblas (s390x failures)

* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Wed Apr  5 2017 Jerry James <loganjerry@gmail.com> - 2.2.2-5
- Remove dependency on /usr/bin/env

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Fri Jan  6 2017 Jerry James <loganjerry@gmail.com> - 2.2.2-3
- Fix build on big endian platforms
- Disable ppc64 tests that fail due to an ATLAS bug (bz 1410633)

* Thu Oct 20 2016 Jerry James <loganjerry@gmail.com> - 2.2.2-2
- Fix build on non-x86 platforms (bz 1373305)

* Fri Aug 12 2016 Jerry James <loganjerry@gmail.com> - 2.2.2-1
- New upstream release

* Tue Apr 12 2016 Jerry James <loganjerry@gmail.com> - 2.2.1-1
- New upstream release

* Fri Feb 26 2016 Jerry James <loganjerry@gmail.com> - 2.2.0-1
- New upstream release

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.0-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Mon Feb 16 2015 Jerry James <loganjerry@gmail.com> - 1.6.0-10
- Note bundled jquery

* Tue Oct 28 2014 Jerry James <loganjerry@gmail.com> - 1.6.0-9
- Rebuild for givaro 3.8.0
- Fix license handling

* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Mon Sep 23 2013 Jerry James <loganjerry@gmail.com> - 1.6.0-6
- Rebuild for atlas 3.10.1

* Tue Jul 30 2013 Jerry James <loganjerry@gmail.com> - 1.6.0-5
- Adapt to Rawhide versionless _docdir change

* Wed Mar 27 2013 Jerry James <loganjerry@gmail.com> - 1.6.0-4
- Support building on aarch64 (bz 925336)
- Add more tex BRs due to TeXLive 2012 reorganization
- Ensure that __int64 is defined

* Fri Feb  8 2013 Jerry James <loganjerry@gmail.com> - 1.6.0-3
- Rebuild for givaro 3.7.2

* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Tue Jul 3 2012 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.6.0-1
- Update to latest upstream release.
- Remove gcc 4.7 patch already applied to upstream tarball.
- Rediff fflas-ffpack-debug patch.
- Remove fflas-ffpack-inline patch already applied to upstream tarball.
- Remove fflas-ffpack-64bit patch already applied to upstream tarball.

* Thu May  3 2012 Jerry James <loganjerry@gmail.com> - 1.4.3-3
- Add debug, inline, and 64bit patches

* Mon Jan  9 2012 Jerry James <loganjerry@gmail.com> - 1.4.3-2
- Rebuild for GCC 4.7

* Tue Nov  1 2011 Jerry James <loganjerry@gmail.com> - 1.4.3-1
- New upstream version
- Tests have been fixed; restore %%check script

* Mon Aug 29 2011 Jerry James <loganjerry@gmail.com> - 1.4.2-1
- New upstream version
- Tests are hopelessly broken; disable for now

* Thu May 26 2011 Jerry James <loganjerry@gmail.com> - 1.4.1-2
- Issues found on review:
- Fix license tag (fflasffpack-config is CeCILL-B)
- Add -doc subpackage
- More bad FSF addresses

* Tue May 24 2011 Jerry James <loganjerry@gmail.com> - 1.4.1-1
- Initial RPM