## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 12;
    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 doc 1

# 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.5.0
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
License:        LGPL-2.1-or-later AND 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 AND GPL-2.0-or-later WITH Autoconf-exception-generic
#     (and also derived from configure.ac, so presumably also 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
SourceLicense:  %{shrink:
                %{license} AND
                CECILL-B AND
                FSFAP AND
                FSFUL AND
                FSFULLR AND
                GPL-2.0-or-later AND
                GPL-2.0-or-later WITH Autoconf-exception-generic
                }
URL:            https://linbox-team.github.io/fflas-ffpack/
%global forgeurl https://github.com/linbox-team/fflas-ffpack
Source0:        %{forgeurl}/releases/download/v%{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 perf publisher
# https://github.com/linbox-team/fflas-ffpack/commit/833bb2fa4e87e51e3f7fa1d97f3b4372c1ee4200
#
# This is not only useful for perf/benchmarks; it fixes OpenMP detection in the
# configure script.
#
# Rebased on 2.5.0 (which lacks benchmarks/benchmark-sss.C).
Patch:          0001-fix-perf-publisher.patch

# Give cblas_ssyrk a return type
# https://github.com/linbox-team/fflas-ffpack/pull/384
Patch:          %{forgeurl}/pull/384.patch

# Fix a couple of apparent typos in config-blas.h
# https://github.com/linbox-team/fflas-ffpack/pull/385
Patch:          %{forgeurl}/pull/385.patch

# Do not use _mm_permute_ps for simd128_float as it requires AVX. Fix #378
# https://github.com/linbox-team/fflas-ffpack/pull/379
#
# Fixes:
#
# bad usage of AVX2 instruction without checking availability of the
# instruction set
# https://github.com/linbox-team/fflas-ffpack/issues/378
Patch:          %{forgeurl}/pull/379.patch

BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool

BuildRequires:  make
BuildRequires:  gcc-c++

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

%if %{with doc}
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.

%global common_description %{expand: \
The FFLAS-FFPACK library provides a set of basic routines for linear algebra
over a finite field or the ring of integers with dense and sparse matrices.}

%description
%{common_description}


%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
%{common_description}

This package provides the header files for developing applications that use
FFLAS-FFPACK.


%if %{with doc}
%package doc
Summary:        API documentation for fflas-ffpack

BuildArch:      noarch

%description doc
%{common_description}

This package provides API documentation for fflas-ffpack.
%endif


%prep
%autosetup -n fflas_ffpack-%{version} -p1
# 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

# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_shebang_lines
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}
# 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


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

# We define __FFLASFFPACK_HAVE_CBLAS to bypass CBLAS detection so that the
# configure script detects USER LAPACK. Ideally, this would be reported
# upstream, but it’s difficult to describe the problem precisely.
%configure \
  %{?with_doc:--enable-doc --docdir='%{_docdir}/fflas-ffpack'} \
  --disable-static \
  --enable-openmp \
  --without-archnative \
  --with-blas-cflags="$(pkgconf --cflags flexiblas) -D__FFLASFFPACK_HAVE_CBLAS=1" \
  --with-blas-libs="$(pkgconf --libs flexiblas)"
chmod -v a+x fflas-ffpack-config


%build
%make_build

%if %{with doc}
%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
# https://docs.fedoraproject.org/en-US/packaging-guidelines/BLAS_LAPACK/#_tests
export FLEXIBLAS=netlib
%make_build check


%files devel
%license COPYING COPYING.LESSER
%if %{without doc}
%doc AUTHORS ChangeLog README.md TODO
%endif

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

%{_includedir}/fflas-ffpack/

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


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


%changelog
## START: Generated by rpmautospec
* Thu Dec 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-12
- Add a SourceLicense field

* Fri Nov 01 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-11
- Invoke autoreconf and configure in %%conf rather than in %%build

* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.0-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Nov 17 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-7
- Bypass CBLAS detection so that configure detects USER LAPACK

* Tue Nov 14 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-6
- Fix use of AVX when it is unavailable

* Tue Nov 14 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-5
- Fix a couple of apparent typos in config-blas.h

* Tue Nov 14 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-4
- Give cblas_ssyrk a return type

* Tue Nov 14 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-3
- Don’t compile with ISA extensions (no -march=native)

* Tue Nov 14 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-2
- Fix OpenMP detection

* Tue Oct 17 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-1
- Update to 2.5.0 (close RHBZ#2032590)

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.3-32
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.4.3-31
- When PDF docs are disabled, omit the -doc subpackage

* Sat Jun 17 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.4.3-30
- Use new (rpm 4.17.1+) bcond style

* Sun Jan 22 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.4.3-28
- Revert "Work around missing dependency on texlive-wasy"

* Thu Jan 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.4.3-27
- Work around missing dependency on texlive-wasy

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.3-26
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* 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

## END: Generated by rpmautospec