Blob Blame History Raw
# Copyright (c) 2014  Dave Love, University of Liverpool
# MIT licence, per Fedora policy

%if 0%{?el6}
%ifarch ppc64
%bcond_with mpich
%else
%bcond_without mpich
%endif
%else
%bcond_without mpich
%endif

%ifarch s390 s390x
%bcond_with openmpi
%else
%bcond_without openmpi
%endif

%ifarch %{ix86} x86_64 armv7hl ppc64le
%global use_openblas 1
%else
%global use_openblas 0
%endif

Name:           hypre
Version:        2.11.1
Release:        6%{?dist}
Summary:        High performance matrix preconditioners
# FEI_mv/ml/src/Include/ml_vampir.h has a GPL notice, but it doesn't
# look copyright-significant.
License:        LGPLv2
URL:            http://www.llnl.gov/casc/hypre/
Source:         https://github.com/LLNL/hypre/archive/v%version.tar.gz#/%{name}-%{version}.tar.gz
# Make library .so.0.0, not -<version>.so
Patch1:         hypre-soname.patch
# Don't use hostname for tests and use two MPI processes
Patch2:         hypre-test.patch

BuildRequires:  gcc-c++ gcc-gfortran automake libtool libtool-ltdl-devel
BuildRequires:  SuperLU-devel
%if %{with openmpi}
BuildRequires:  openmpi-devel
%endif
%if %{with mpich}
BuildRequires:  mpich-devel
%endif
%if %use_openblas
BuildRequires:  openblas-devel%{?_isa}
%else
BuildRequires:  atlas-devel
%endif

%global __requires_exclude libHYPRE.*
%{?filter_setup:
%filter_from_requires /libHYPRE/d
%filter_setup
}

%global desc \
Hypre is a set of matrix preconditioning libraries to aid in the\
solution of large systems of linear equations.

%description
%desc

%package devel
Summary:        Development files for %name
Requires:       %{?name}%{?_isa} = %{version}-%{release}
Requires:       SuperLU-devel%{?_isa} 
%if %use_openblas
Requires:       openblas-devel%{?_isa}
%else
Requires:       atlas-devel
%endif

%description devel
Development files for %name

%if %{with openmpi}
%package openmpi
Summary:        High performance matrix preconditioners - openmpi
Requires:       openmpi%{?_isa}

%description openmpi
%desc

This is the openmpi version.

%package openmpi-devel
Summary:        Development files for %name-openmpi
Requires:       %{name}-openmpi%{?_isa} = %{version}-%{release}
Requires:       openmpi-devel%{?_isa} SuperLU-devel%{?_isa}
%if %use_openblas
Requires:       openblas-devel%{?_isa}
%else
Requires:       atlas-devel%{?_isa}
%endif

%description openmpi-devel
Development files for %name-openmpi
%endif

%if %{with mpich}
%package mpich
Summary:        High performance matrix preconditioners - mpich
Requires:       mpich%{?_isa}

%description mpich
%desc

This is the mpich version.

%package mpich-devel
Summary:        Development files for %name-mpich
Requires:       %{name}-mpich%{?_isa} = %{version}-%{release}
%if 0%{?el7}
# https://bugzilla.redhat.com/show_bug.cgi?id=1397192
Requires:       mpich-devel
%else
Requires:       mpich-devel%{?_isa}
%endif
Requires:       SuperLU-devel%{?_isa}
%if %use_openblas
Requires:       openblas-devel%{?_isa}
%else
Requires:       atlas-devel%{?_isa}
%endif

%description mpich-devel
Development files for %name-mpich
%endif

%package doc
Summary:        Documentation for hypre
BuildArch:      noarch

%description doc
Documentation for hypre


%prep
%setup -q -n %name-%version

%patch1 -p1
%patch2 -p1

find \( -name \*.[ch] -o -name \*.cxx \) -perm /=x -exec chmod 0644 {} \;

%if %{with openmpi}
cp -a src openmpi
%endif
%if %{with mpich}
cp -a src mpich
%endif

%build
%if %use_openblas
%global lalibs --with-blas-libs=openblas --with-lapack-libs=openblas --with-blas-lib-dirs=%_libdir --with-lapack-lib-dirs=%_libdir
%else
%if 0%{?el6}
%global lalibs --with-blas-libs=f77blas --with-lapack-libs=lapack --with-blas-lib-dirs=%_libdir/atlas --with-lapack-lib-dirs=%_libdir/atlas
%else
%global lalibs --with-blas-libs=satlas --with-lapack-libs=satlas --with-blas-lib-dirs=%_libdir/atlas --with-lapack-lib-dirs=%_libdir/atlas
%endif
%endif

pushd src
# Note that --without-superlu refers to the bundled version.
# -Dhypre_dgesvd fixes a build error which should probably be patched,
# but I haven't tracked it down.
# -O3 seems like a good idea for vectorization, at least.
%configure --without-MPI --with-timing \
           %lalibs \
           --with-lapack --enable-shared --without-superlu \
           LDFLAGS="$LDFLAGS -Wl,--as-needed -lsuperlu" \
           CFLAGS="$CFLAGS -O3 -Dhypre_dgesvd=dgesvd_"
make %{?_smp_mflags}
popd

%global do_mpi_build \
%configure --prefix=$MPI_HOME --with-MPI --with-MPI-include=$MPI_INCLUDE \\\
           --with-MPI-lib-dirs=$MPI_LIB --with-timing --without-openmp \\\
           %lalibs \\\
           --enable-shared --without-superlu \\\
           LDFLAGS="$LDFLAGS -Wl,--as-needed -lsuperlu" \\\
           CFLAGS="$CFLAGS -O3 -Dhypre_dgesvd=dgesvd_" \
  make %{?_smp_mflags}

%if %{with openmpi}
pushd openmpi
%_openmpi_load
%do_mpi_build
%_openmpi_unload
popd
%endif

%if %{with mpich}
pushd mpich
%_mpich_load
%do_mpi_build
%_mpich_unload
popd
%endif


%check
%if %{with openmpi}
export LD_LIBRARY_PATH=$(pwd)/openmpi/hypre/lib
export OMPI_MCA_orte_allocation_required=0
%_openmpi_load
pushd openmpi/test
make %{?_smp_mflags}
# A random selection to check, rather than all possibilities.  (The
# relevant binaries aren't built for all the TEST_...s.)
./runtest.sh TEST_ij/*sh
popd
%endif


%install
make -C src install HYPRE_INSTALL_DIR=%{buildroot}%{_prefix} \
     HYPRE_LIB_INSTALL=%{buildroot}%{_libdir} \
     HYPRE_INC_INSTALL=%{buildroot}%{_includedir}/%{name}

%if %{with openmpi}
%_openmpi_load
make -C openmpi install HYPRE_INSTALL_DIR=%{buildroot}$MPI_HOME \
     HYPRE_LIB_INSTALL=%{buildroot}$MPI_LIB \
     HYPRE_INC_INSTALL=%{buildroot}$MPI_INCLUDE/%{name}
%_openmpi_unload
%endif

%if %{with mpich}
%_mpich_load
make -C mpich install HYPRE_INSTALL_DIR=%{buildroot}$MPI_HOME \
     HYPRE_LIB_INSTALL=%{buildroot}$MPI_LIB \
     HYPRE_INC_INSTALL=%{buildroot}$MPI_INCLUDE/%{name}
%_mpich_unload
%endif

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


%{!?_licensedir:%global license %doc}

%files
%doc CHANGELOG
%license COPYING.LESSER COPYRIGHT src/docs/copyright.txt
%{_libdir}/libHYPRE.so.*

%files devel
%{_libdir}/libHYPRE.so
%{_includedir}/%{name}

%if %{with openmpi}
%files openmpi
%doc CHANGELOG
%license COPYING.LESSER COPYRIGHT src/docs/copyright.txt
%{_libdir}/openmpi/lib/libHYPRE.so.*

%files openmpi-devel
%{_libdir}/openmpi/lib/libHYPRE.so
%{_includedir}/openmpi-%_arch/%{name}
%endif

%if %{with mpich}
%files mpich
%doc CHANGELOG
%license COPYING.LESSER COPYRIGHT src/docs/copyright.txt
%{_libdir}/mpich/lib/libHYPRE.so.*

%files mpich-devel
%{_libdir}/mpich/lib/libHYPRE.so
%{_includedir}/mpich-%_arch/%{name}
%endif

%files doc
%doc CHANGELOG
%license COPYING.LESSER COPYRIGHT src/docs/copyright.txt
%doc docs/*.pdf

%changelog
* Thu Dec  1 2016 Dave Love <loveshack@fedoraproject.org> - 2.11.1-6
- Conditionalize mpich-devel%%{?_isa}

* Fri Oct 21 2016 Orion Poplawski <orion@cora.nwra.com> - 2.11.1-5
- Rebuild for openmpi 2.0

* Fri Jul 22 2016 Dave Love <loveshack@fedoraproject.org> - 2.11.1-4
- Ship manuals correctly

* Wed Jul 20 2016 Dave Love <loveshack@fedoraproject.org> - 2.11.1-3
- Avoid openmpi on s390
- Patch to not call hostname in test.sh and use two procs

* Mon Jul 11 2016 Dave Love <loveshack@fedoraproject.org> - 2.11.1-2
- Fix openblas conditionals

* Mon Jul 11 2016 Dave Love <loveshack@fedoraproject.org> - 2.11.1-1
- New version
- Update URL
- Drop previous patches -- make single library with new soversion
- Adjust configure/build
- Run tests
- Compile with -O3

* Fri Apr  1 2016 Dave Love <loveshack@fedoraproject.org> - 2.11.0-1
- New version
- Adjust hypre-shlibs-interlink.patch and %%lalibs

* Mon Dec 14 2015 Dave Love <loveshack@fedoraproject.org> - 2.10.1-2
- Fix use of %%license for -mpich package

* Tue Dec  1 2015 Dave Love <loveshack@fedoraproject.org> - 2.10.1-1
- New version
- Remove -Wl,-z,defs from configure to avoid link error (patch5)
- Fix use of atlas on non-x86
- Fix %%license conditional

* Sun Jul  5 2015 Dave Love <d.love@liverpool.ac.uk> - 2.9.1a-1
- New version, without babel stuff
- Modify patches
- Use %%license

* Fri Feb 20 2015 Dave Love <d.love@liverpool.ac.uk> - 2.8.0b-16
- Conditionalize out mpich on ppc64 el6
- Use -f with libtoolize (for f22)
- Fix some missing _isa in requires
- Drop unnecessary configure patch
- Run tests
- Small simplifications

* Wed Feb  4 2015 Dave Love <d.love@liverpool.ac.uk> - 2.8.0b-15
- Fix requires

* Mon Dec 29 2014 Dave Love <d.love@liverpool.ac.uk> - 2.8.0b-15
- Build without internal superlu

* Thu Dec 11 2014 Dave Love <d.love@liverpool.ac.uk> - 2.8.0b-14
- mpich version

* Fri Nov 28 2014 Dave Love <d.love@liverpool.ac.uk> - 2.8.0b-13
- Initial packaging, following Debian, including patches
  High release number to avoid clash with old SuSE-based version