File openmpi.spec of Package openmpi

#
# spec file for package openmpi
#
# Copyright (c) 2013 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/
#


# NOTE: openib may be switched on without UDAPL support, but dapl implies
#       openib

%define with_dapl   0
%define with_openib 0

Name:           openmpi
Version:        1.7.2
Release:        0
Summary:        A powerful implementaion of MPI
License:        BSD-3-Clause
Group:          Development/Libraries/Parallel
Url:            http://www.open-mpi.org/
Source0:        http://www.open-mpi.org/software/ompi/v1.7/downloads/%{name}-%{version}.tar.bz2
Source1:        mpivars.sh
Source2:        mpivars.csh
Source3:        baselibs.conf
# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch0:         remove-assembler-for-armv5.diff
Patch1:         openmpi-no_date_and_time.patch
BuildRequires:  Modules
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  libtool
BuildRequires:  mpi-selector
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{with_dapl}
BuildRequires:  compat-dapl-devel
%endif
%if %{with_openib} || %{with_dapl}
BuildRequires:  libibumad-devel
BuildRequires:  libibverbs-devel
%endif
# List loosely based on files available in openmpi-1.4.4/opal/asm/generated/
ExclusiveArch:  %alpha %arm aarch64 x86_64 %ix86 ia64 mips mips64 ppc ppc64 %sparc
%ifarch x86_64
BuildRequires:  numactl
%endif
Requires:       mpi-selector
Requires(preun): mpi-selector
%define mpi_prefix %{_libdir}/mpi/gcc/%{name}

%define mpi_bindir %{mpi_prefix}/bin
%define mpi_libdir %{mpi_prefix}/%{_lib}
%define mpi_datadir %{mpi_prefix}/share
%define mpi_includedir %{mpi_prefix}/include
%define mpi_mandir %{mpi_prefix}/share/man

%description
Open MPI is a project combining technologies and resources from several
other projects (FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) in order to
build the best MPI library available.

This RPM contains all the tools necessary to compile, link, and run
Open MPI jobs.

%package        devel
Summary:        SDK for openMPI
Group:          Development/Libraries/Parallel
Requires:       %{name} = %{version}
Requires:       libstdc++-devel
%if %{with_openib} || %{with_dapl}
Requires:       libibumad-devel
Requires:       libibverbs-devel
%endif

%description devel
Open MPI is a project combining technologies and resources from several
other projects (FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) in order to
build the best MPI library available.

This RPM contains all the tools necessary to compile, link, and run
Open MPI jobs.

%package        devel-static
Summary:        Static openMPI libraries
Group:          Development/Libraries/Parallel
Requires:       %{name}-devel = %{version}

%description devel-static
This RPM contains the static library files, which are packaged separately from
the dynamic library and headers.

%prep
%setup -q
%ifarch armv5el armv5tel aarch64
%patch0
%endif
%patch1

%build
./autogen.sh
%configure --prefix="%{mpi_prefix}" \
           --exec-prefix="%{mpi_prefix}" \
           --bindir="%{mpi_bindir}" \
           --datadir="%{mpi_datadir}" \
           --includedir="%{mpi_includedir}" \
           --libdir="%{mpi_libdir}" \
           --mandir="%{mpi_mandir}" \
           --disable-static  \
%if %{with_openib}
	   --with-verbs \
%endif
%if %{with_dapl}
           --with-udapl \
%endif
           --with-devel-headers
make %{?_smp_mflags} V=1

%install

%make_install
# make and install mpivars files
sed -e 's,prefix,%{mpi_prefix},g' -e 's,libdir,%{mpi_libdir},g' %{SOURCE1} \
    > %{buildroot}%{mpi_bindir}/mpivars.sh
sed -e 's,prefix,%{mpi_prefix},g' -e 's,libdir,%{mpi_libdir},g' %{SOURCE2} \
    > %{buildroot}%{mpi_bindir}/mpivars.csh
for input in `find %{buildroot}/%{mpi_mandir} -type f` ; do
	if test -f "$input.gz"; then
		#echo "Remove old file $input.gz"
		rm -f "$input.gz"
	fi
	if test -L "$input"; then
		link=`perl -e 'print readlink($ARGV[0]);' -- "$input"`
		test -d "$link" && continue
		test -d "%{buildroot}/$link" && continue
		rm -f "$input"
		ln -sf "$link.gz" "$input.gz"
	else
		gzip -nf9 "$input"
	fi
	ls -l "$input.gz"
done

mkdir -p %{buildroot}%{_datadir}/modules/gnu-openmpi
%fdupes %{buildroot}%{mpi_mandir} %{buildroot}%{mpi_datadir}

cat << EOF > %{buildroot}%{_datadir}/modules/gnu-openmpi/%{version}
#%Module
proc ModulesHelp { } {
        global dotversion
        puts stderr "\tLoads the gnu - openmpi %{version}  Environment"
}

module-whatis  "Loads the gnu openmpi %{version} Environment."
conflict gnu-openmpi
prepend-path PATH %{mpi_bindir}
prepend-path INCLUDE %{mpi_includedir}
prepend-path INCLUDE %{mpi_prefix}/lib64
prepend-path MANPATH %{mpi_mandir}
prepend-path LD_LIBRARY_PATH %{mpi_libdir}

EOF

cat << EOF > %{buildroot}%{_datadir}/modules/gnu-openmpi/.version
#%Module1.0
set ModulesVersion "%{version}"

EOF

%post
/sbin/ldconfig
/usr/bin/mpi-selector \
        --register %{name}-%{version} \
        --source-dir %{mpi_bindir} \
        --yes
/usr/bin/mpi-selector \
	--system \
	--set %{name}-%{version} \
	--yes

%preun
/usr/bin/mpi-selector --unregister %{name}-%{version} --yes
/usr/bin/mpi-selector --system --query
if [ ! -z "`/usr/bin/mpi-selector --system --query`" ]; then
    /usr/bin/mpi-selector --system --unset --yes %{name}-%{version}
fi

%postun -p /sbin/ldconfig

%files
%defattr(-, root, root)
%dir %{_libdir}/mpi
%dir %{_libdir}/mpi/gcc
%dir %{mpi_prefix}
%dir %{mpi_libdir}
%dir %{mpi_datadir}
%dir %{mpi_mandir}

%{mpi_bindir}/
%{mpi_mandir}/man1/
%{mpi_libdir}/*.so.*
%{mpi_libdir}/*.mod

%{mpi_datadir}/%{name}
%config %{_sysconfdir}/*
%{_datadir}/modules/gnu-openmpi/

%files devel
%defattr(-,root,root)
%doc %{mpi_datadir}/vampirtrace

%{mpi_includedir}
%{mpi_libdir}/*.so
%{mpi_libdir}/openmpi
%{mpi_libdir}/pkgconfig
%{mpi_mandir}/man3/
%{mpi_mandir}/man7/

%files devel-static
%defattr(-, root, root)
%{mpi_libdir}/*.la
%{mpi_libdir}/*.a

%changelog
openSUSE Build Service is sponsored by