File hdf5.spec of Package hdf5

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


%define hdf5_libver 8
%define libname libhdf5

%if 0%{?sles_version}
%define _mvapich2 1
%endif
%if 0%{?suse_version}
%define _openmpi 1
%endif

%define _mpi %{?_openmpi:openmpi} %{?_mvapich2:mvapich2}

# rpm may not like this original version number
%define xversion 1.8.12

Name:           hdf5
Version:        1.8.12
Release:        0
Summary:        A general purpose library and file format for storing scientific data
License:        BSD-3-Clause
Group:          Development/Libraries/Other
Url:            http://www.hdfgroup.org/HDF5/
Source0:        http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-%{xversion}/src/hdf5-%{xversion}.tar.bz2
Patch0:         hdf5-LD_LIBRARY_PATH.patch
Patch1:         hdf5-non_void_return.patch
# not really needed but we want to get noticed if hdf5 doesn' t know our host
Patch2:         hdf5-1.8.11-abort_unknown_host_config.patch
%ifarch %arm
Patch4:         hdf5-1.8.10-tests-arm.patch
%endif
Patch5:         hdf5-configure-long-double.patch
Patch6:         hdf5-ldouble-ppc64le.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  gcc-c++
%if 0%{?suse_version} > 1140
BuildRequires:  gcc-fortran
%endif
BuildRequires:  krb5-devel
BuildRequires:  openssl-devel
BuildRequires:  zlib-devel
%if 0%{?suse_version} >= 1110
BuildRequires:  fdupes
%endif
%if 0%{?_openmpi}
BuildRequires:  openmpi-devel
%endif
%if 0%{?_mvapich2}
BuildRequires:  mvapich2-devel
%endif

%description
HDF5 is a general purpose library and file format for storing scientific data.
HDF5 can store two primary objects: datasets and groups. A dataset is
essentially a multidimensional array of data elements, and a group is a
structure for organizing objects in an HDF5 file. Using these two basic
objects, one can create and store almost any kind of scientific data
structure, such as images, arrays of vectors, and structured and unstructured
grids. You can also mix and match them in HDF5 files according to your needs.

%package -n %{libname}-%{hdf5_libver}
Summary:        HDF 5 runtime libraries
Group:          System/Libraries

%description -n %{libname}-%{hdf5_libver}
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains the HDF 5 runtime libraries.

%package -n %{libname}_hl%{hdf5_libver}
Summary:        HDF 5 runtimelibraries
Group:          System/Libraries

%description -n %{libname}_hl%{hdf5_libver}
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains the HDF 5 runtime libraries.

%package devel
Summary:        Hierarchical Data File Format Version 5
Group:          Development/Libraries/Parallel
Requires:       %{name} = %{version}
# Required by Fortran programs?
Requires:       %{libname}-%{hdf5_libver} = %{version}
Requires:       %{libname}_hl%{hdf5_libver} = %{version}

%description devel
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains all files needed to create projects that use
hdf5.

%package  devel-static
Summary:        Hierarchical Data File Format Version 5 - static libraries
Group:          Development/Libraries/C and C++
Requires:       hdf5-devel

%description devel-static
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package provides the static libraries.

%package examples
Summary:        Examples for HDF5
Group:          Development/Libraries/Parallel
Requires:       %{libname}-%{hdf5_libver} = %{version}
Requires:       %{libname}_hl%{hdf5_libver} = %{version}

%description examples
Examples of HDF5 library use.


%if 0%{?_openmpi}
%package -n %{name}-openmpi
Summary:        A general purpose library and file format for storing scientific data
Group:          Development/Libraries/Other

%description -n %{name}-openmpi
HDF5 is a general purpose library and file format for storing scientific data.
HDF5 can store two primary objects: datasets and groups. A dataset is
essentially a multidimensional array of data elements, and a group is a
structure for organizing objects in an HDF5 file. Using these two basic
objects, one can create and store almost any kind of scientific data
structure, such as images, arrays of vectors, and structured and unstructured
grids. You can also mix and match them in HDF5 files according to your needs.

%package -n %{libname}-%{hdf5_libver}-openmpi
Summary:        HDF 5 runtime libraries
Group:          System/Libraries

%description -n %{libname}-%{hdf5_libver}-openmpi
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains the HDF 5 runtime libraries.

%package -n %{libname}_hl%{hdf5_libver}-openmpi
Summary:        HDF 5 runtimelibraries
Group:          System/Libraries

%description -n %{libname}_hl%{hdf5_libver}-openmpi
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains the HDF 5 runtime libraries.

%package openmpi-devel
Summary:        Hierarchical Data File Format Version 5
Group:          Development/Libraries/Parallel
Requires:       %{name}-openmpi = %{version}
# Required by Fortran programs?
Requires:       %{libname}-%{hdf5_libver}-openmpi = %{version}
Requires:       %{libname}_hl%{hdf5_libver}-openmpi = %{version}

%description openmpi-devel
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains all files needed to create projects that use
hdf5.

%package  openmpi-devel-static
Summary:        Hierarchical Data File Format Version 5 - static libraries
Group:          Development/Libraries/C and C++
Requires:       hdf5-openmpi-devel

%description openmpi-devel-static
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package provides the static libraries.
%endif

%if 0%{?_mvapich2}
%package -n %{name}-mvapich2
Summary:        A general purpose library and file format for storing scientific data
Group:          Development/Libraries/Other

%description -n %{name}-mvapich2
HDF5 is a general purpose library and file format for storing scientific data.
HDF5 can store two primary objects: datasets and groups. A dataset is
essentially a multidimensional array of data elements, and a group is a
structure for organizing objects in an HDF5 file. Using these two basic
objects, one can create and store almost any kind of scientific data
structure, such as images, arrays of vectors, and structured and unstructured
grids. You can also mix and match them in HDF5 files according to your needs.

%package -n %{libname}-%{hdf5_libver}-mvapich2
Summary:        HDF 5 runtime libraries
Group:          System/Libraries

%description -n %{libname}-%{hdf5_libver}-mvapich2
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains the HDF 5 runtime libraries.

%package -n %{libname}_hl%{hdf5_libver}-mvapich2
Summary:        HDF 5 runtimelibraries
Group:          System/Libraries

%description -n %{libname}_hl%{hdf5_libver}-mvapich2
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains the HDF 5 runtime libraries.

%package mvapich2-devel
Summary:        Hierarchical Data File Format Version 5
Group:          Development/Libraries/Parallel
Requires:       %{name}-mvapich2 = %{version}
# Required by Fortran programs?
Requires:       %{libname}-%{hdf5_libver}-mvapich2 = %{version}
Requires:       %{libname}_hl%{hdf5_libver}-mvapich2 = %{version}

%description mvapich2-devel
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package contains all files needed to create projects that use
hdf5.

%package  mvapich2-devel-static
Summary:        Hierarchical Data File Format Version 5 - static libraries
Group:          Development/Libraries/C and C++
Requires:       hdf5-mvapich2-devel

%description mvapich2-devel-static
The HDF project involves the development and support of software and
file formats for scientific data management. The HDF software includes
I/O libraries and tools for analyzing, visualizing, and converting
scientific data.

This package provides the static libraries.
%endif

%prep
%setup -q -n %{name}-%{xversion}
# don't forget to increase hdf5_libver, see also baselibs.conf
LT_VERS_INTERFACE=$(sed -n 's/^ *LT_VERS_INTERFACE *= *//p' config/lt_vers.am)
test "%{hdf5_libver}" = "${LT_VERS_INTERFACE}" || exit 1
%patch0 -p1 -b .LD_LIBRARY_PATH
%patch1 -p0 -b .non_void_return
%patch2 -p0 -b .abort_unknown_host_config
%ifarch %arm
%patch4 -p0 -b .tests-arm
%endif
%patch5 -p1
%patch6 -p1

echo "prepare parallel builds: %_mpi"
for build_dir in build %_mpi; do
    mkdir $build_dir
    ln -s ../configure $build_dir
done

%build
export CC=gcc
export CXX=g++
export F9X=gfortran
# workaround for known gcc issue, see RELEASE.txt
if gcc --version |grep -q " 4\.[68]"; then
	export CFLAGS="${RPM_OPT_FLAGS/-O2/-O0}"
fi
%ifarch %arm
# we want to have useful H5_CFLAGS on arm too
test -e config/linux-gnueabi || cp config/linux-gnu config/linux-gnueabi
%endif

pushd build
%configure \
  --docdir=%{_docdir}/%{name} \
  --disable-dependency-tracking \
%if 0%{?suse_version} > 1140
  --enable-fortran \
%endif
  --enable-hl \
  --enable-shared \
  --enable-cxx \
  --with-pthread

make V=1 %{?_smp_mflags}
popd

for mpi in %_mpi;
do
cd $mpi
export CC="%{_libdir}/mpi/gcc/$mpi/bin/mpicc"
export FC="%{_libdir}/mpi/gcc/$mpi/bin/mpif90"
export F77="%{_libdir}/mpi/gcc/$mpi/bin/mpif77"
export LD_LIBRARY_PATH="%{_libdir}/mpi/gcc/$mpi/%_lib"
%configure \
  --docdir=%{_docdir}/%{name} \
  --prefix=%{_libdir}/mpi/gcc/$mpi \
  --exec-prefix=%{_libdir}/mpi/gcc/$mpi \
  --bindir=%{_libdir}/mpi/gcc/$mpi/bin \
  --libdir=%{_libdir}/mpi/gcc/$mpi/%_lib \
  --datadir=%{_libdir}/mpi/gcc/$mpi/share \
  --includedir=%{_libdir}/mpi/gcc/$mpi/include \
  --disable-dependency-tracking \
%if 0%{?suse_version} > 1140
  --enable-fortran \
%endif
  --enable-hl \
  --enable-shared \
  --enable-parallel \
  --with-pthread

make %{?_smp_mflags}
cd ..
done

%install
# install serial and parallel builds, (the serial one will win in case of
# duplicate files)
for build_dir in %_mpi build; do
	make install DESTDIR="%buildroot" -C "$build_dir"
done

find "%buildroot/%_libdir" -type f -name "*.la" | xargs rm -f
find %{buildroot}%{_datadir}/hdf5_examples -type f \
                 | grep -v ".sh$" | xargs chmod 644
# delete examples from parallel builds
rm -rf %{buildroot}%{_libdir}/mpi/gcc/*/share/hdf5_examples
%if 0%{?suse_version} >= 1110
%fdupes -s %{buildroot}/%{_datadir}
%endif

# rpm macro for version checking
mkdir -p %{buildroot}%{_sysconfdir}/rpm
cat > %{buildroot}%{_sysconfdir}/rpm/macros.hdf5 <<EOF
#
# RPM macros for R packaging
#

#
# Make R search index.txt
#
%_hdf5_version  %{version}
EOF

%check
%if 0%{?qemu_user_space_build}
# default timeout is 1200 seconds
export HDF5_ALARM_SECONDS=3600
%endif
make -C build check
# ignore errors for parallel builds
export HDF5_Make_Ignore=yes
for mpi in %_mpi; do
    make -C $mpi check
done

%post -n %{libname}-%{hdf5_libver} -p /sbin/ldconfig

%postun -n %{libname}-%{hdf5_libver} -p /sbin/ldconfig

%post -n %{libname}_hl%{hdf5_libver} -p /sbin/ldconfig

%postun -n %{libname}_hl%{hdf5_libver} -p /sbin/ldconfig

%if 0%{?_openmpi}
%post -n %{libname}-%{hdf5_libver}-openmpi -p /sbin/ldconfig

%postun -n %{libname}-%{hdf5_libver}-openmpi -p /sbin/ldconfig

%post -n %{libname}_hl%{hdf5_libver}-openmpi -p /sbin/ldconfig

%postun -n %{libname}_hl%{hdf5_libver}-openmpi -p /sbin/ldconfig
%endif

%if 0%{?_mvapich2}
%post -n %{libname}-%{hdf5_libver}-mvapich2 -p /sbin/ldconfig

%postun -n %{libname}-%{hdf5_libver}-mvapich2 -p /sbin/ldconfig

%post -n %{libname}_hl%{hdf5_libver}-mvapich2 -p /sbin/ldconfig

%postun -n %{libname}_hl%{hdf5_libver}-mvapich2 -p /sbin/ldconfig
%endif

%files
%defattr(-,root,root)
%doc COPYING MANIFEST README.txt release_docs/RELEASE.txt
%doc release_docs/HISTORY-1_0-1_8_0_rc3.txt release_docs/HISTORY-1_8.txt
%doc release_docs/RELEASE.txt
%{_bindir}/gif2h5
%{_bindir}/h52gif
%{_bindir}/h5copy
%{_bindir}/h5debug
%{_bindir}/h5diff
%{_bindir}/h5dump
%{_bindir}/h5import
%{_bindir}/h5jam
%{_bindir}/h5ls
%{_bindir}/h5mkgrp
%{_bindir}/h5perf_serial
%{_bindir}/h5redeploy
%{_bindir}/h5repack
%{_bindir}/h5repart
%{_bindir}/h5stat
%{_bindir}/h5unjam

%files -n %{libname}-%{hdf5_libver}
%defattr(0755,root,root)
%{_libdir}/libhdf5.so.*
%{_libdir}/libhdf5_cpp.so.*
%if 0%{?suse_version} > 1140
%{_libdir}/libhdf5_fortran.so.*
%endif

%files -n libhdf5_hl%{hdf5_libver}
%defattr(0755,root,root)
%{_libdir}/libhdf5_hl.so.*
%{_libdir}/libhdf5_hl_cpp.so.*
%if 0%{?suse_version} > 1140
%{_libdir}/libhdf5hl_fortran.so.*
%endif

%files devel
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/rpm/macros.hdf5
%{_bindir}/h5c++
%{_bindir}/h5cc
%if 0%{?suse_version} > 1140
%{_bindir}/h5fc
%endif
%{_includedir}/*.h
%{_libdir}/*.so
%{_libdir}/*.settings
%if 0%{?suse_version} > 1140
%{_includedir}/*.mod
%endif

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

%files examples
%defattr(-,root,root)
%{_datadir}/hdf5_examples

%if 0%{?_openmpi}
%files -n %{name}-openmpi
%defattr(-,root,root)
%doc COPYING MANIFEST README.txt release_docs/RELEASE.txt
%doc release_docs/HISTORY-1_0-1_8_0_rc3.txt release_docs/HISTORY-1_8.txt
%doc release_docs/RELEASE.txt
%{_libdir}/mpi/gcc/openmpi/bin/gif2h5
%{_libdir}/mpi/gcc/openmpi/bin/h52gif
%{_libdir}/mpi/gcc/openmpi/bin/h5copy
%{_libdir}/mpi/gcc/openmpi/bin/h5debug
%{_libdir}/mpi/gcc/openmpi/bin/h5diff
%{_libdir}/mpi/gcc/openmpi/bin/h5dump
%{_libdir}/mpi/gcc/openmpi/bin/h5import
%{_libdir}/mpi/gcc/openmpi/bin/h5jam
%{_libdir}/mpi/gcc/openmpi/bin/h5ls
%{_libdir}/mpi/gcc/openmpi/bin/h5mkgrp
%{_libdir}/mpi/gcc/openmpi/bin/h5perf
%{_libdir}/mpi/gcc/openmpi/bin/h5perf_serial
%{_libdir}/mpi/gcc/openmpi/bin/h5redeploy
%{_libdir}/mpi/gcc/openmpi/bin/h5repack
%{_libdir}/mpi/gcc/openmpi/bin/h5repart
%{_libdir}/mpi/gcc/openmpi/bin/h5stat
%{_libdir}/mpi/gcc/openmpi/bin/h5unjam
%{_libdir}/mpi/gcc/openmpi/bin/ph5diff

%files -n %{libname}-%{hdf5_libver}-openmpi
%defattr(0755,root,root)
%{_libdir}/mpi/gcc/openmpi/%_lib/libhdf5.so.*
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/openmpi/%_lib/libhdf5_fortran.so.*
%endif

%files -n libhdf5_hl%{hdf5_libver}-openmpi
%defattr(0755,root,root)
%{_libdir}/mpi/gcc/openmpi/%_lib/libhdf5_hl.so.*
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/openmpi/%_lib/libhdf5hl_fortran.so.*
%endif

%files openmpi-devel
%defattr(-,root,root)
%{_libdir}/mpi/gcc/openmpi/bin/h5pcc
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/openmpi/bin/h5pfc
%endif
%{_libdir}/mpi/gcc/openmpi/include/*.h
%{_libdir}/mpi/gcc/openmpi/%_lib/*.so
%{_libdir}/mpi/gcc/openmpi/%_lib/*.settings
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/openmpi/include/*.mod
%endif

%files openmpi-devel-static
%defattr(-,root,root)
%{_libdir}/mpi/gcc/openmpi/%_lib/*.a
%endif

%if 0%{?_mvapich2}
%files -n %{name}-mvapich2
%defattr(-,root,root)
%doc COPYING MANIFEST README.txt release_docs/RELEASE.txt
%doc release_docs/HISTORY-1_0-1_8_0_rc3.txt release_docs/HISTORY-1_8.txt
%doc release_docs/RELEASE.txt
%{_libdir}/mpi/gcc/mvapich2/bin/gif2h5
%{_libdir}/mpi/gcc/mvapich2/bin/h52gif
%{_libdir}/mpi/gcc/mvapich2/bin/h5copy
%{_libdir}/mpi/gcc/mvapich2/bin/h5debug
%{_libdir}/mpi/gcc/mvapich2/bin/h5diff
%{_libdir}/mpi/gcc/mvapich2/bin/h5dump
%{_libdir}/mpi/gcc/mvapich2/bin/h5import
%{_libdir}/mpi/gcc/mvapich2/bin/h5jam
%{_libdir}/mpi/gcc/mvapich2/bin/h5ls
%{_libdir}/mpi/gcc/mvapich2/bin/h5mkgrp
%{_libdir}/mpi/gcc/mvapich2/bin/h5perf
%{_libdir}/mpi/gcc/mvapich2/bin/h5perf_serial
%{_libdir}/mpi/gcc/mvapich2/bin/h5redeploy
%{_libdir}/mpi/gcc/mvapich2/bin/h5repack
%{_libdir}/mpi/gcc/mvapich2/bin/h5repart
%{_libdir}/mpi/gcc/mvapich2/bin/h5stat
%{_libdir}/mpi/gcc/mvapich2/bin/h5unjam
%{_libdir}/mpi/gcc/mvapich2/bin/ph5diff

%files -n %{libname}-%{hdf5_libver}-mvapich2
%defattr(0755,root,root)
%{_libdir}/mpi/gcc/mvapich2/%_lib/libhdf5.so.*
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/mvapich2/%_lib/libhdf5_fortran.so.*
%endif

%files -n libhdf5_hl%{hdf5_libver}-mvapich2
%defattr(0755,root,root)
%{_libdir}/mpi/gcc/mvapich2/%_lib/libhdf5_hl.so.*
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/mvapich2/%_lib/libhdf5hl_fortran.so.*
%endif

%files mvapich2-devel
%defattr(-,root,root)
%{_libdir}/mpi/gcc/mvapich2/bin/h5pcc
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/mvapich2/bin/h5pfc
%endif
%{_libdir}/mpi/gcc/mvapich2/include/*.h
%{_libdir}/mpi/gcc/mvapich2/%_lib/*.so
%{_libdir}/mpi/gcc/mvapich2/%_lib/*.settings
%if 0%{?suse_version} > 1140
%{_libdir}/mpi/gcc/mvapich2/include/*.mod
%endif

%files mvapich2-devel-static
%defattr(-,root,root)
%{_libdir}/mpi/gcc/mvapich2/%_lib/*.a
%endif

%changelog
openSUSE Build Service is sponsored by