Name:           SuperLU
Version:        6.0.1
Release:        1
Summary:        Library for the direct solution of large, sparse, nonsymmetric systems of linear equations
License:        BSD and GPLv2+
URL:            http://crd-legacy.lbl.gov/~xiaoye/SuperLU/
Source0:        https://github.com/xiaoyeli/superlu/archive/v%{version}/superlu-%{version}.tar.gz
BuildRequires:  openblas-devel openblas-srpm-macros cmake3 gcc-gfortran csh
Patch0001:      superlu-removemc64.patch

%description
The library is written in C and is callable from either C or Fortran program. It uses MPI, OpenMP and
CUDA to support various forms of parallelism. It supports both real and complex datatypes, both single
and double precision, and 64-bit integer indexing. The library routines performs an LU decomposition
with partial pivoting and triangular system solves through forward and back substitution.

%package        devel
Summary:        Files for SuperLU development
Requires:       SuperLU = %{version}-%{release}

%description    devel
The package contains the header files and libraries for SuperLU development.

%package        help
Summary:        Documentation for SuperLU
Provides:       SuperLU-doc = %{version}-%{release}
Obsoletes:      SuperLU-doc < %{version}-%{release}
Requires:       SuperLU = %{version}-%{release}

%description    help
The package contains all the help documentation along with C and FORTRAN examples.

%prep
%autosetup -n superlu-%{version} -p1
rm -fr SRC/mc64ad.f.bak
find . -type f | sed -e "/TESTING/d" | xargs chmod a-x
find EXAMPLE -type f | while read file; do [ "$(file $file | awk '{print $2}')" = ELF ] && rm $file || : ; done
sed -i.bak '/NOOPTS/d' make.inc.in
sed -e 's|-O0|-O2|g' -i SRC/CMakeLists.txt

%build
mkdir -p build && cd build
%cmake3 -Denable_blaslib:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release ..
%make_build

%install
%make_install -C build

%check
cd build
ctest3 -V %{?_smp_mflags}
cd -

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

%files
%doc License.txt
%{_libdir}/libsuperlu.so.6*

%files devel
%{_includedir}/*
%{_libdir}/libsuperlu.so
%{_libdir}/cmake/superlu/
%{_libdir}/pkgconfig/superlu.pc

%files help
%doc DOC EXAMPLE FORTRAN

%changelog
* Tue Sep 26 2023 xu_ping <707078654@qq.com> - 6.0.1-1
- Upgrade version to 6.0.1

* Thu Mar 5 2020 Ling Yang <lingyang2@huawei.com> - 5.2.1-6
- Package Init

* Tue Aug 10 2021 Senlin Xia <xiasenlin1@huawei.com> - 5.2.1-7
- remove useless buildrequire: atlas-devel
