File gromacs.spec of Package gromacs

#
# spec file for package gromacs
#
# Copyright (c) 2015-2017 Christoph Junghans <junghans@votca.org>
# Copyright (c) 2013,2014 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/
#

Name:           gromacs
Version:        2016.3
Release:        0
Summary:        Molecular Dynamics Package
License:        GPL-2.0+
Group:          Productivity/Scientific/Chemistry
Url:            http://www.gromacs.org
Source0:        ftp://ftp.gromacs.org/pub/gromacs/gromacs-%{version}.tar.gz
Source1:        ftp://ftp.gromacs.org/pub/manual/manual-%{version}.pdf
Source2:        http://gerrit.gromacs.org/download/regressiontests-%{version}.tar.gz

BuildRequires:  gcc-c++
BuildRequires:  cmake >= 2.8.8
BuildRequires:  fdupes
BuildRequires:  openmpi-devel
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(fftw3)
BuildRequires:  pkgconfig(tinyxml2)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
GROMACS is a versatile and extremely well optimized package to perform
molecular dynamics computer simulations and subsequent trajectory analysis.
It is developed for biomolecules like proteins, but the extremely high
performance means it is used also in several other field like polymer chemistry
and solid state physics.

%package devel
Summary:        Molecular dynamics package
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
GROMACS is a versatile and extremely well optimized package to perform
molecular dynamics computer simulations and subsequent trajectory analysis.
It is developed for biomolecules like proteins, but the extremely high
performance means it is used also in several other field like polymer chemistry
and solid state physics.

This package contains development libraries and header for GROMACS

%package -n libgromacs2
Summary:        Libraries for Gromacs
Group:          System/Libraries

%description -n libgromacs2
GROMACS is a versatile and extremely well optimized package to perform
molecular dynamics computer simulations and subsequent trajectory analysis.
It is developed for biomolecules like proteins, but the extremely high
performance means it is used also in several other field like polymer chemistry
and solid state physics.

This package contains libraries for Gromacs

%package bash
Summary:    Bash completion for Gromacs
Group:      Productivity/Other
Requires:   %{name} = %{version}-%{release}
Requires:   bash-completion
BuildArch:  noarch

%description bash
GROMACS is a versatile and extremely well optimized package to perform
molecular dynamics computer simulations and subsequent trajectory analysis.
It is developed for biomolecules like proteins, but the extremely high
performance means it is used also in several other field like polymer chemistry
and solid state physics.

This package contains bash completion support for gromacs.

%package doc
Summary:    Documentation for Gromacs
Group:      Productivity/Scientific/Chemistry
Requires:   %{name} = %{version}-%{release}
BuildArch:  noarch

%description doc
GROMACS is a versatile and extremely well optimized package to perform
molecular dynamics computer simulations and subsequent trajectory analysis.
It is developed for biomolecules like proteins, but the extremely high
performance means it is used also in several other field like polymer chemistry
and solid state physics.

This package contains documentation for gromacs.

%package openmpi
Summary:        Molecular dynamics package
Group:          Productivity/Scientific/Chemistry
Requires:       %{name} = %{version}

%description openmpi
GROMACS is a versatile and extremely well optimized package to perform
molecular dynamics computer simulations and subsequent trajectory analysis.
It is developed for biomolecules like proteins, but the extremely high
performance means it is used also in several other field like polymer chemistry
and solid state physics.

This package contains the openmpi version of GROMACS.

%prep
%setup -q
tar -xzf %{S:2}

%build
%ifarch i386 x86_64
#increse to SSE4.1, AVX_128_FMA, AVX_256 when possible
%define acce SSE2
%else
%define acce None
%endif
mkdir nompi
cd nompi
# note about rpath
# gromacs' cmake has too much rpath auto-magic, just
# force to skip it (CMAKE_SKIP_RPATH=1) and use 
# LD_LIBRARY_PATH for checks below
%{cmake} \
  -DCMAKE_INSTALL_PREFIX=%{_prefix} \
  -DCMAKE_VERBOSE_MAKEFILE=TRUE \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags} -fno-strict-aliasing" \
  -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \
  -DCMAKE_SKIP_RPATH=1 \
  -DGMX_SIMD=%{acce} \
  -DGMX_MPI=OFF \
  -DGMX_THREAD_MPI=ON \
  -DGMX_SYMLINK_OLD_BINARY_NAMES=OFF \
  -DGMX_OPENMP=ON \
  -DGMX_EXTERNAL_TINYXML2=ON \
  -DREGRESSIONTEST_PATH="$PWD/../../regressiontests-%{version}" \
  -DGMX_LIB_INSTALL_DIR=%{_lib} ../../
make %{?_smp_mflags}

cd ../..
mkdir openmpi
cd openmpi
%{cmake} \
  -DCMAKE_INSTALL_PREFIX=/usr \
  -DCMAKE_VERBOSE_MAKEFILE=TRUE \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags} -fno-strict-aliasing" \
  -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \
  -DCMAKE_SKIP_RPATH=1 \
  -DGMX_SIMD=%{acce} \
  -DGMX_BUILD_MDRUN_ONLY=ON \
  -DBUILD_SHARED_LIBS=OFF \
  -DGMX_MPI=ON \
  -DGMX_SYMLINK_OLD_BINARY_NAMES=OFF \
  -DGMX_OPENMP=ON \
  -DGMX_EXTERNAL_TINYXML2=ON \
  -DREGRESSIONTEST_PATH="$PWD/../../regressiontests-%{version}" \
  -DGMX_LIB_INSTALL_DIR=%{_lib} ../../
make %{?_smp_mflags}

%install
make -C nompi/build install DESTDIR=%{buildroot}
make -C openmpi/build install DESTDIR=%{buildroot}
%fdupes %{buildroot}%{_prefix}

#no need when installed in /usr
rm -f %{buildroot}%{_bindir}/GMXRC*
# Move bash completion file to correct location
mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d
#concatenate all gmx-completion*, starting with gmx-completion.bash (fct defs)
cat %{buildroot}%{_bindir}/gmx-completion{,?*}.bash > %{buildroot}%{_sysconfdir}/bash_completion.d/gromacs
rm -f %{buildroot}%{_bindir}/gmx-completion*

cp %{S:1} %{buildroot}%{_datadir}/gromacs

%check
#s390x is too slow for tests
%ifnarch s390x
LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make -C nompi/build %{?_smp_mflags} check
LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make -C openmpi/build %{?_smp_mflags} check
%endif

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

%files
%defattr(-,root,root,-)
%{_bindir}/gmx
%{_bindir}/*.pl
%dir %{_datadir}/gromacs
%{_datadir}/gromacs/top
%{_mandir}/man1/*

%files -n libgromacs2
%defattr(-,root,root,-)
%{_libdir}/lib*.so.*

%files doc
%defattr(-,root,root,-)
%doc %{_datadir}/gromacs/*.pdf
%doc %{_datadir}/gromacs/README*
%doc %{_datadir}/gromacs/COPYING

%files openmpi
%defattr(-,root,root,-)
%{_bindir}/*_mpi

%files devel
%defattr(-,root,root)
%{_datadir}/gromacs/template
%{_datadir}/cmake
%{_includedir}/gromacs/
%{_libdir}/*.so
%{_libdir}/pkgconfig/*

%files bash
%defattr(-,root,root,-)
%config %{_sysconfdir}/bash_completion.d/gromacs