Package clapack: Specfile

%global _unpackaged_files_terminate_build 1

%define sover 0
%def_enable compat_lapack
# full xblas implementation requires fortran support,
# reduced C-only implementation will yield some symbols undefined
%def_enable fortran

Name: clapack
Version: 3.2.1
Release: alt2.E2K.3
Summary: C version of LAPACK
License: BSD
Group: Sciences/Mathematics
Url: http://www.netlib.org/clapack/
Packager: Eugeny A. Rostovtsev (REAL) <real at altlinux.org>

Source: %name-%version.tar
Source1: make.inc
Source2: lapack.pc

BuildPreReq: libopenblas-devel %{?_enable_fortran:libxblas-devel}
BuildRequires: libf2c-ng-devel

%description
The CLAPACK library was built using a Fortran to C conversion utility
called f2c.  The entire Fortran 77 LAPACK library is run through f2c to
obtain C code, and then modified to improve readability.  CLAPACK's goal
is to provide LAPACK for someone who does not have access to a Fortran
compiler.

%package -n lib%name
Summary: Shared library of CLAPACK
Group: System/Libraries

%description -n lib%name
The CLAPACK library was built using a Fortran to C conversion utility
called f2c.  The entire Fortran 77 LAPACK library is run through f2c to
obtain C code, and then modified to improve readability.  CLAPACK's goal
is to provide LAPACK for someone who does not have access to a Fortran
compiler.

This package contains shared library of CLAPACK.

%package -n lib%name-devel
Summary: Development files of CLAPACK
Group: Development/C
Requires: lib%name = %version-%release

%description -n lib%name-devel
The CLAPACK library was built using a Fortran to C conversion utility
called f2c.  The entire Fortran 77 LAPACK library is run through f2c to
obtain C code, and then modified to improve readability.  CLAPACK's goal
is to provide LAPACK for someone who does not have access to a Fortran
compiler.

This package contains development files of CLAPACK.

%package -n liblapack-devel
Summary: Provide system LAPACK interface using CLAPACK
Group: Development/Other
Requires: lib%name-devel = %version-%release
Epoch: 2

%description -n liblapack-devel
Install files necessary to use CLAPACK as system-wide liblapack replacement.

%prep
%setup
install -p -m644 %SOURCE1 .

%build
%if_disabled fortran
sed -i 's/^USEXBLAS/#USEXBLAS/' make.inc
%endif
# Use system f2c-ng
sed -i 's|../../F2CLIBS|%_libdir|' make.inc

%make_build -C INSTALL
%make_build -C SRC

gcc -shared -Wl,--whole-archive lib%name.a -Wl,--no-whole-archive \
	-Wl,-soname,lib%name.so.%sover -o lib%name.so.%sover \
	-lf2c -lf2c-dm -lopenblas %{?_enable_fortran:-lxblas} -lm

%install
install -d %buildroot%_includedir
install -p -m644 INCLUDE/* BLAS/WRAP/*.h %buildroot%_includedir
rm %buildroot%_includedir/f2c.h

install -d %buildroot%_libdir
install -m644 lib%name.so.%sover %buildroot%_libdir
ln -s lib%name.so.%sover %buildroot%_libdir/lib%name.so

%if_enabled compat_lapack
install -D -m644 -t %buildroot%_pkgconfigdir/ %{SOURCE2}

ln -sT libclapack.so %buildroot%_libdir/liblapack.so
%endif

%files -n lib%name
%doc COPYING
%_libdir/*.so.*

%files -n lib%name-devel
%_includedir/*
%_libdir/libclapack.so

%if_enabled compat_lapack
%files -n liblapack-devel
%_libdir/liblapack.so
%_pkgconfigdir/*.pc
%endif

%changelog
* Sat Jun 11 2022 Andrew Savchenko <bircoph@altlinux.org> 3.2.1-alt2.E2K.3
- Use system libf2c-ng

* Mon Jun 06 2022 Andrew Savchenko <bircoph@altlinux.org> 3.2.1-alt2.E2K.2
- Disable xblas if Fortran is disabled: reduced xblas C-only
  implementation is not sufficient for clapack.

* Fri Jun 03 2022 Andrew Savchenko <bircoph@altlinux.org> 3.2.1-alt2.E2K.1
- Provide liblapack-devel subsitute.

* Sat Aug 11 2012 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.2.1-alt2
- Built with OpenBLAS instead of GotoBLAS2

* Wed Dec 21 2011 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.2.1-alt1
- Initial build for Sisyphus