File libatlas3.spec of Package libatlas3

#
# spec file for package libatlas3
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define enable_native_atlas 0

Name:           libatlas3
Version:        3.10.2
Release:        0
Summary:        Automatically Tuned Linear Algebra Software
License:        BSD-3-Clause and GPL-2.0
Group:          Development/Libraries/C and C++
Url:            http://math-atlas.sourceforge.net/

Source:         atlas%{version}.tar.bz2
Source2:        README.SuSE
Source3:        POWER332.tar.bz2
Source4:        POWER764LEVSX.tar.bz2
Source5:        %name-rpmlintrc
Patch0:         atlas-suse-shared.patch
Patch1:         atlas-hack.patch
# for ppc64 ppc64le
# https://bugzilla.redhat.com/show_bug.cgi?id=1080073#c40
Patch10:        getdoublearr.stripwhite.patch
#atch11:        issue_64.patch
Patch12:        initialize_malloc_memory.invtrsm.wms.oct23.patch
Patch13:        atlas.3.10.2-ppc64le_abiv2.patch
Patch14:        atlas-new_archdef_for_ppc64le.patch
Patch15:        atlas.3.10.2-add_power8_cpu.patch
# for ppc64le tempo patch
Patch16:        atlas.3.10.2-ppc64le_do_not_use_files_with_lvx.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  gcc-fortran
BuildRequires:  lapack-devel
BuildRequires:  update-alternatives
PreReq:         update-alternatives

%description
The ATLAS (Automatically Tuned Linear Algebra Software) project is an
ongoing research effort focusing on applying empirical techniques in
order to provide portable performance. At present, it provides C and
Fortran77 interfaces to a portably efficient BLAS implementation, as
well as a few routines from LAPACK.

The performance improvements in ATLAS are obtained largely via
compile-time optimizations and tend to be specific to a given hardware
configuration. In order to package ATLAS for openSUSE some compromises
are necessary so that good performance can be obtained on a variety
of hardware. This set of ATLAS binary packages is therefore not
necessarily optimal for any specific hardware configuration.  However,
the source package can be used to compile customized ATLAS packages;
see the documentation for information.

%package devel
Summary:        Development libraries for ATLAS
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
This package contains the static libraries and headers for development
with ATLAS (Automatically Tuned Linear Algebra Software).

%define types base

%if "%{?enable_native_atlas}" == "0"
############## Subpackages for architecture extensions #################
#
# Because a set of ATLAS libraries is a ~5 MB package, separate packages
# are created for SSE, SSE2, and SSE3 extensions to ix86.

%ifarch i586
%define types sse sse2 sse3

%package sse
Summary:        ATLAS libraries for SSE extensions
License:        BSD-3-Clause
Group:          System/Libraries
Obsoletes:      %{name}-3dnow < 3.9
Provides:       %{name} = %{version}-%{release}
Provides:       %{name}-3dnow = %{version}-%{release}
Obsoletes:      %{name} < %{version}-%{release}
PreReq:         update-alternatives

%description sse
This package contains the ATLAS (Automatically Tuned Linear Algebra
Software) libraries compiled with optimizations for the SSE(1) extensions
to the ix86 architecture. openSUSE also produces ATLAS build with SSE2 and SSE3
extensions.

%package sse-devel
Summary:        Development libraries for ATLAS with SSE extensions
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
Requires:       %{name}-sse = %{version}-%{release}
Requires:       %{name}-sse-common-devel = %{version}-%{release}
Obsoletes:      %{name}-3dnow-devel < 3.9
Provides:       %{name}-3dnow-devel = %{version}-%{release}

%description sse-devel
This package contains headers and static versions of the ATLAS
(Automatically Tuned Linear Algebra Software) libraries compiled with
optimizations for the SSE(1) extensions to the ix86 architecture.

%package sse2
Summary:        ATLAS libraries for SSE2 extensions
License:        BSD-3-Clause
Group:          System/Libraries
Obsoletes:      %{name} < 3.9
Provides:       %{name} = %{version}-%{release}
Provides:       %{name} = %{version}-%{release}
Obsoletes:      %{name} < %{version}-%{release}
PreReq:         update-alternatives

%description sse2
This package contains the ATLAS (Automatically Tuned Linear Algebra
Software) libraries compiled with optimizations for the SSE2
extensions to the ix86 architecture. openSUSE also produces ATLAS build with
SSE(1) and SSE3 extensions.

%package sse2-devel
Summary:        Development libraries for ATLAS with SSE2 extensions
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
Requires:       %{name}-sse-common-devel = %{version}-%{release}
Requires:       %{name}-sse2 = %{version}-%{release}
Obsoletes:      %{name}-devel < 3.9
Provides:       %{name}-devel = %{version}-%{release}

%description sse2-devel
This package contains headers and static versions of the ATLAS
(Automatically Tuned Linear Algebra Software) libraries compiled with
optimizations for the SSE2 extensions to the ix86 architecture.

%package sse3
Summary:        ATLAS libraries for SSE3 extensions
License:        BSD-3-Clause
Group:          System/Libraries
Provides:       %{name} = %{version}-%{release}
Obsoletes:      %{name} < %{version}-%{release}
PreReq:         update-alternatives

%description sse3
This package contains the ATLAS (Automatically Tuned Linear Algebra
Software) libraries compiled with optimizations for the SSE3.
openSUSE also produces ATLAS build with SSE(1) and SSE2 extensions.

%package sse3-devel
Summary:        Development libraries for ATLAS with SSE3 extensions
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
Requires:       %{name}-sse-common-devel = %{version}-%{release}
Requires:       %{name}-sse3 = %{version}-%{release}

%description sse3-devel
This package contains headers and static versions of the ATLAS
(Automatically Tuned Linear Algebra Software) libraries compiled with
optimizations for the sse3 extensions to the ix86 architecture.

%package sse-common-devel
Summary:        Headers files for ATLAS
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description sse-common-devel
This package contains the headers for development
with ATLAS (Automatically Tuned Linear Algebra Software).


%endif
%endif

%ifarch x86_64 ppc64 ppc64le
%define mode 64
%else
%define mode 32
%endif

%prep
%setup -q -n ATLAS
%patch0 -p1
%ifarch x86_64 i586
%patch1
%endif
%ifarch ppc64le ppc64
%patch10 -p1
#patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%endif
%ifarch ppc64le
%patch16 -p1
%endif
cp %{SOURCE2} doc

cp %{SOURCE3} %{SOURCE4} CONFIG/ARCHS/

# if Power8 archdef do not exist yet
# then use the Power7 one that may be the same.
# do that for BE and LE:
%ifarch ppc64 ppc64le
P8archdef='POWER864VSX.tar.bz2'
P7archdef='POWER764VSX.tar.bz2'
if [  ! -e CONFIG/ARCHS/${P8archdef} ]; then
    cp  CONFIG/ARCHS/${P7archdef} /tmp/
    pushd /tmp
    tar -xjf ${P7archdef}
    rm -rf POWER864VSX
    mv POWER764VSX POWER864VSX
    tar -cjf ${P8archdef} POWER864VSX
    popd
    mv /tmp/${P8archdef}  CONFIG/ARCHS/
fi
P8archdef='POWER864LEVSX.tar.bz2'
P7archdef='POWER764LEVSX.tar.bz2'
if [  ! -e CONFIG/ARCHS/${P8archdef} ]; then
    cp  CONFIG/ARCHS/${P7archdef} /tmp/
    pushd /tmp
    tar -xjf ${P7archdef}
    rm -rf POWER864LEVSX
    mv POWER764LEVSX POWER864LEVSX
    tar -cjf ${P8archdef} POWER864LEVSX
    popd
    mv /tmp/${P8archdef}  CONFIG/ARCHS/
fi
%endif

%build
for type in %{types}; do
	if [ "$type" = "base" ]; then
		libname=atlas
	else
		libname=atlas-${type}
	fi
	mkdir -p %{_arch}_${type}
	pushd %{_arch}_${type}
	export CFLAGS="-g -w %{optflags}"  
	export CXXFLAGS="-g -w %{optflags}"  
	../configure -b %mode --shared \
	--prefix=%{buildroot}%{_prefix}			\
	--incdir=%{buildroot}%{_includedir}		\
	--libdir=%{buildroot}%{_libdir}/${libname}

	if [ "$type" = "sse" ]; then
		sed -i 's#ARCH =.*#ARCH = PIII32SSE1#' Make.inc
		sed -i 's#-DATL_SSE3 -DATL_SSE2##' Make.inc 
	elif [ "$type" = "sse2" ]; then
		sed -i 's#ARCH =.*#ARCH = P432SSE2#' Make.inc
		sed -i 's#-DATL_SSE3##' Make.inc 
	elif [ "$type" = "sse3" ]; then
		sed -i 's#ARCH =.*#ARCH = P4E32SSE3#' Make.inc
	fi
%ifarch ppc
	sed -i 's#ARCH =.*#ARCH = POWER332#' Make.inc
	sed -i 's#-DATL_ARCH_POWER7#-DATL_ARCH_POWER3#g' Make.inc
	sed -i 's#power7#power3#g' Make.inc
	sed -i 's#-DATL_VSX##g' Make.inc
	sed -i 's#-mvsx##g' Make.inc
	sed -i 's#-DATL_AltiVec##g' Make.inc
	sed -i 's#-m64#-m32#g' Make.inc
%endif

	make build %{?_smp_mflags}
	cd lib
	make shared %{?_smp_mflags}
	make ptshared %{?_smp_mflags}
	popd
done

%install
for type in %{types}; do
	pushd %{_arch}_${type}
	%makeinstall
	if [ "$type" = "base" ]; then
                cp -pr lib/*.so* %{buildroot}%{_libdir}/atlas/
	else
		cp -pr lib/*.so* %{buildroot}%{_libdir}/atlas-${type}/
	fi
	popd
done

mv %{buildroot}%{_includedir}/*.h %{buildroot}%{_includedir}/atlas/

mkdir -p %{buildroot}/etc/ld.so.conf.d
echo "%{_libdir}/atlas"	> %{buildroot}/etc/ld.so.conf.d/atlas-%{_arch}.conf

%ifarch i586 && %if "%{?enable_native_atlas}" == "0"
mkdir -p %{buildroot}%{_libdir}/atlas
%endif

%ifnarch i586 || %if "%{?enable_native_atlas}" == "1"

%post
"%_sbindir/update-alternatives" --install \
   %{_libdir}/libblas.so.3 libblas.so.3     %{_libdir}/atlas/libsatlas.so.3  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/libblas.so.3 libblas.so.3     %{_libdir}/atlas/libtatlas.so.3  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/atlas/libtatlas.so.3  20
/sbin/ldconfig

%preun
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libtatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libtatlas.so.3
fi

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc doc/README.SuSE
%dir %{_libdir}/atlas
%{_libdir}/atlas/*.so.*
%config(noreplace) /etc/ld.so.conf.d/atlas-%{_arch}.conf

%files devel
%defattr(-,root,root,-)
%doc doc
%{_libdir}/atlas/*.so
%{_libdir}/atlas/*.a
%{_includedir}/atlas/

%else

%post   -n libatlas3-sse
"%_sbindir/update-alternatives" --install \
   %{_libdir}/atlas/libsatlas.so.3 libsatlas.so.3 %{_libdir}/atlas-sse/libsatlas.so.3.0  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/atlas/libtatlas.so.3 libtatlas.so.3 %{_libdir}/atlas-sse/libtatlas.so.3.0  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/libblas.so.3 libblas.so.3     %{_libdir}/atlas/libsatlas.so.3  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3  20
/sbin/ldconfig

%preun   -n libatlas3-sse
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove libsatlas.so.3 %{_libdir}/atlas-sse/libsatlas.so.3.0
   "%_sbindir/update-alternatives" --remove libtatlas.so.3 %{_libdir}/atlas-sse/libtatlas.so.3.0
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libtatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libtatlas.so.3
fi

%postun -n libatlas3-sse -p /sbin/ldconfig

%post    -n libatlas3-sse2
"%_sbindir/update-alternatives" --install \
   %{_libdir}/atlas/libsatlas.so.3 libsatlas.so.3 %{_libdir}/atlas-sse2/libsatlas.so.3.0  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/atlas/libtatlas.so.3 libtatlas.so.3 %{_libdir}/atlas-sse2/libtatlas.so.3.0  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/libblas.so.3 libblas.so.3     %{_libdir}/atlas/libsatlas.so.3  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3  20
/sbin/ldconfig

%preun   -n libatlas3-sse2
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove libsatlas.so.3 %{_libdir}/atlas-sse2/libsatlas.so.3.0
   "%_sbindir/update-alternatives" --remove libtatlas.so.3 %{_libdir}/atlas-sse2/libtatlas.so.3.0
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libtatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libtatlas.so.3
fi

%postun -n libatlas3-sse2 -p /sbin/ldconfig

%post   -n libatlas3-sse3
"%_sbindir/update-alternatives" --install \
   %{_libdir}/atlas/libsatlas.so.3 libsatlas.so.3 %{_libdir}/atlas-sse3/libsatlas.so.3.0  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/atlas/libtatlas.so.3 libtatlas.so.3 %{_libdir}/atlas-sse3/libtatlas.so.3.0  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/libblas.so.3 libblas.so.3     %{_libdir}/atlas/libsatlas.so.3  20
"%_sbindir/update-alternatives" --install \
   %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3  20
/sbin/ldconfig

%preun   -n libatlas3-sse3
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove libsatlas.so.3 %{_libdir}/atlas-sse3/libsatlas.so.3.0
   "%_sbindir/update-alternatives" --remove libtatlas.so.3 %{_libdir}/atlas-sse3/libtatlas.so.3.0
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libsatlas.so.3
   "%_sbindir/update-alternatives" --remove libblas.so.3   %{_libdir}/atlas/libtatlas.so.3
   "%_sbindir/update-alternatives" --remove liblapack.so.3 %{_libdir}/atlas/libtatlas.so.3
fi

%postun -n libatlas3-sse3 -p /sbin/ldconfig

%post   -n libatlas3-sse-devel
"%_sbindir/update-alternatives" \
    --install %{_libdir}/atlas/libatlas.a   libatlas.a     %{_libdir}/atlas-sse/libatlas.a  20 \
    --slave %{_libdir}/atlas/libptf77blas.a libptf77blas.a %{_libdir}/atlas-sse/libptf77blas.a \
    --slave %{_libdir}/atlas/libptcblas.a   libptcblas.a   %{_libdir}/atlas-sse/libptcblas.a \
    --slave %{_libdir}/atlas/libf77blas.a   libf77blas.a   %{_libdir}/atlas-sse/libf77blas.a \
    --slave %{_libdir}/atlas/libcblas.a     libcblas.a     %{_libdir}/atlas-sse/libcblas.a \
    --slave %{_libdir}/atlas/liblapack.a    liblapack.a    %{_libdir}/atlas-sse/liblapack.a

%preun   -n libatlas3-sse-devel
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove libatlas.a %{_libdir}/atlas-sse/libatlas.a
fi

%post   -n libatlas3-sse2-devel
"%_sbindir/update-alternatives" \
    --install %{_libdir}/atlas/libatlas.a   libatlas.a     %{_libdir}/atlas-sse2/libatlas.a  20 \
    --slave %{_libdir}/atlas/libptf77blas.a libptf77blas.a %{_libdir}/atlas-sse2/libptf77blas.a \
    --slave %{_libdir}/atlas/libptcblas.a   libptcblas.a   %{_libdir}/atlas-sse2/libptcblas.a \
    --slave %{_libdir}/atlas/libf77blas.a   libf77blas.a   %{_libdir}/atlas-sse2/libf77blas.a \
    --slave %{_libdir}/atlas/libcblas.a     libcblas.a     %{_libdir}/atlas-sse2/libcblas.a \
    --slave %{_libdir}/atlas/liblapack.a    liblapack.a    %{_libdir}/atlas-sse2/liblapack.a

%preun   -n libatlas3-sse2-devel
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove libatlas.a %{_libdir}/atlas-sse2/libatlas.a
fi

%post   -n libatlas3-sse3-devel
"%_sbindir/update-alternatives" \
    --install %{_libdir}/atlas/libatlas.a   libatlas.a     %{_libdir}/atlas-sse3/libatlas.a  20 \
    --slave %{_libdir}/atlas/libptf77blas.a libptf77blas.a %{_libdir}/atlas-sse3/libptf77blas.a \
    --slave %{_libdir}/atlas/libptcblas.a   libptcblas.a   %{_libdir}/atlas-sse3/libptcblas.a \
    --slave %{_libdir}/atlas/libf77blas.a   libf77blas.a   %{_libdir}/atlas-sse3/libf77blas.a \
    --slave %{_libdir}/atlas/libcblas.a     libcblas.a     %{_libdir}/atlas-sse3/libcblas.a \
    --slave %{_libdir}/atlas/liblapack.a    liblapack.a    %{_libdir}/atlas-sse3/liblapack.a

%preun   -n libatlas3-sse3-devel
if [ "$1" = 0 ] ; then
   "%_sbindir/update-alternatives" --remove libatlas.a %{_libdir}/atlas-sse3/libatlas.a
fi

%files sse
%defattr(-,root,root,-)
%doc doc/README.SuSE
%dir %{_libdir}/atlas-sse
%dir %{_libdir}/atlas
%{_libdir}/atlas-sse/lib*.so.*

%files sse-devel
%defattr(-,root,root,-)
%doc doc
%{_libdir}/atlas-sse/lib*.so
%{_libdir}/atlas-sse/lib*.a

%files sse2
%defattr(-,root,root,-)
%doc doc/README.SuSE
%dir %{_libdir}/atlas-sse2
%dir %{_libdir}/atlas
%{_libdir}/atlas-sse2/lib*.so.*

%files sse2-devel
%defattr(-,root,root,-)
%doc doc
%{_libdir}/atlas-sse2/lib*.so
%{_libdir}/atlas-sse2/lib*.a

%files sse3
%defattr(-,root,root,-)
%doc doc/README.SuSE
%dir %{_libdir}/atlas-sse3
%dir %{_libdir}/atlas
%{_libdir}/atlas-sse3/lib*.so.*

%files sse3-devel
%defattr(-,root,root,-)
%doc doc
%{_libdir}/atlas-sse3/lib*.so
%{_libdir}/atlas-sse3/lib*.a

%files sse-common-devel
%defattr(-,root,root,-)
%{_includedir}/atlas/
%config(noreplace) /etc/ld.so.conf.d/atlas-%{_arch}.conf

%endif

%changelog
openSUSE Build Service is sponsored by