File netcdf.spec of Package netcdf
#
# spec file for package netcdf
#
# Copyright (c) 2017 SUSE LINUX 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/
#
%global flavor @BUILD_FLAVOR@%{nil}
%define _do_check 1
%define ver 4.4.1.1
%define _ver 4_4_1_1
%define pname netcdf
%bcond_with ringdisabled
%if "%flavor" == ""
%define package_name %{pname}
ExclusiveArch: do_not_build
%endif
# Magic for OBS Staging. Only build the flavors required by
# other packages in the ring.
%if %{with ringdisabled}
%if "%flavor" != "serial"
ExclusiveArch: do_not_build
%endif
%endif
%if "%{flavor}" == "serial"
%bcond_with hpc
%endif
%if "%{flavor}" == "gnu-hpc"
%global compiler_family gnu
%undefine c_f_ver
%undefine mpi_flavor
%bcond_without hpc
%endif
%if "%{flavor}" == "gnu-openmpi-hpc"
%global compiler_family gnu
%undefine c_f_ver
%define mpi_flavor openmpi
%define mpi_ver 1
%bcond_without hpc
%endif
%if "%{flavor}" == "gnu-mvapich2-hpc"
%global compiler_family gnu
%undefine c_f_ver
%define mpi_flavor mvapich2
%bcond_without hpc
%endif
%if "%{flavor}" == "gnu6-hpc"
%global compiler_family gnu
%define c_f_ver 6
%undefine mpi_flavor
%bcond_without hpc
%endif
%if "%{flavor}" == "gnu6-openmpi-hpc"
%global compiler_family gnu
%define c_f_ver 6
%define mpi_flavor openmpi
%define mpi_ver 1
%bcond_without hpc
%endif
%if "%{flavor}" == "gnu6-mvapich2-hpc"
%global compiler_family gnu
%define c_f_ver 6
%define mpi_flavor mvapich2
%bcond_without hpc
%endif
%if "%{flavor}" == "mvapich2"
%define mpi_flavor mvapich2
%bcond_with hpc
%endif
%if "%{flavor}" == "openmpi"
%define mpi_flavor openmpi
%bcond_with hpc
%endif
%{?mpi_flavor:%{bcond_without mpi}}%{!?mpi_flavor:%{bcond_with mpi}}
%{?with_hpc:%{!?compiler_family:%global compiler_family gnu}}
%{?with_mpi:%{!?mpi_flavor:%global mpi_flavor openmpi}}
%if %{with hpc}
%{hpc_init -c %compiler_family %{?c_f_ver:-v %{c_f_ver}} %{?with_mpi:-m {%mpi_flavor}} %{?mpi_ver:-V %{mpi_ver}} %{?ext:-e %{ext}}}
%define package_name %{hpc_package_name %_ver}
%define libname(s:) lib%{pname}%{hpc_package_name_tail %_ver}
%define p_bindir %hpc_bindir
%define p_libdir %hpc_libdir
%define p_mandir %hpc_mandir
%define p_includedir %hpc_includedir
%else
%define package_name %{pname}%{p_suffix}
%define libname(s:) lib%{pname}%{-s*}%{?p_suffix}
%define p_bindir %_bindir
%define p_libdir %_libdir
%define p_mandir %_mandir
%define p_includedir %_includedir
%endif
%define p_suffix %{?with_mpi:-%{mpi_flavor}}
%define hdf5_module_file %{?with_mpi:p}hdf5
Name: %{package_name}
Summary: Command-line programs for the NetCDF scientific data format
License: NetCDF
Group: Productivity/Scientific/Other
Version: %ver
Release: 0
%define sonum 11
Url: http://www.unidata.ucar.edu/software/netcdf/
Source: ftp://ftp.unidata.ucar.edu/pub/%{pname}/%{pname}-%{version}.tar.gz
Source1: nc-config.1.gz
Source100: netcdf-rpmlintrc
Patch0: %{pname}-no_date_time.patch
# PATCH-FIX-UPSTREAM netcdf-disable-szip-linking.patch badshah400@gmail.com -- Disable building with szip support for now, since test nc_test4/tst_interops5.c fails otherwise; this is likely to be fixed with version 4.5.0 of netcdf, but requires big enough changes that we don't backport it here.
Patch1: netcdf-disable-szip-linking.patch
Patch2: netcdf-h5-test-fix-type-mismatch.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: gawk
BuildRequires: libtool
BuildRequires: m4
BuildRequires: pkg-config
BuildRequires: zlib-devel >= 1.2.5
%ifarch %ix86 x86_64 ppc ppc64 s390x armv7l
BuildRequires: valgrind
%endif
%if %{without hpc}
BuildRequires: gcc-c++
BuildRequires: gcc-fortran
BuildRequires: hdf%{p_suffix}-devel
BuildRequires: hdf5%{p_suffix}-devel
BuildRequires: libcurl-devel >= 7.18.0
BuildRequires: libhdf%{p_suffix}
#BuildRequires: libhdf5%{p_suffix}
BuildRequires: libhdf5_hl%{p_suffix}
%if %{with mpi}
BuildRequires: %{mpi_flavor}-devel
BuildRequires: libpnetcdf%{p_suffix}
BuildRequires: parallel-netcdf%{p_suffix}-devel
%endif
%else
BuildRequires: %{compiler_family}%{?c_f_ver}-compilers-hpc-macros-devel
BuildRequires: hdf5-%{compiler_family}%{?c_f_ver}%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-hpc-devel
BuildRequires: lua-lmod
BuildRequires: suse-hpc
%if %{with mpi}
BuildRequires: %{mpi_flavor}%{?mpi_ver}-%{compiler_family}%{?c_f_ver}-hpc-macros-devel
%endif
%endif
Requires: %{libname -s %{sonum}} = %{version}
%description
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.
%if %{without mpi}
This package contains utility functions for working with NetCDF files.
%else
This package contains the %{mpi_flavor} version of utility functions for
working with NetCDF files.
%endif
%{?with_hpc:%{hpc_master_package}}
%package -n %{libname -s %{sonum}}
Summary: Shared libraries for the NetCDF scientific data format
Group: Productivity/Scientific/Other
%if %{without mpi} && %{without hpc}
Provides: %{libname}-4 = %{version}
Obsoletes: %{libname}-4 < %{version}
%endif
# To avoid unresolvable errors due to multiple providers of the library
%{!?with_hpc:Provides: %{libname} = %{version}}
Obsoletes: %{libname} < %{version}
%if %{without hpc}
Requires: libhdf%{p_suffix}
Requires: libhdf5%{p_suffix}
Requires: libhdf5_hl%{p_suffix}
%else
%{hpc_requires}
%endif
%{!?with_hpc:%{?with_mpi:Requires: libpnetcdf-mvapich2}}
%description -n %{libname -s %{sonum}}
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.
NetCDF (network Common Data Form) is an interface for array-oriented
data access and a collection of software libraries
for C, Fortran, C++, and Perl that provides an implementation of the
interface. The NetCDF library also defines a machine-independent
format for representing scientific data. Together, the interface,
library, and format support the creation, access, and sharing of
scientific data.
NetCDF data is:
- Self-Describing: A NetCDF file includes information about the
data it contains.
- Network-transparent: A NetCDF file is represented in a form that
can be accessed by computers with different ways of storing
integers, characters, and floating-point numbers.
- Direct-access: A small subset of a large dataset may be accessed
efficiently, without first reading through all the preceding
data.
- Appendable: Data can be appended to a NetCDF dataset along one
dimension without copying the dataset or redefining its
structure. The structure of a NetCDF dataset can be changed,
though this sometimes causes the dataset to be copied.
- Sharable: One writer and multiple readers may simultaneously
access the same NetCDF file.
%if %{without mpi}
This package contains the NetCDF runtime libraries.
%else
This package contains the %{mpi_flavor} versuib if the NetCDF runtime
libraries.
%endif
%{?with_hpc:%{hpc_master_package -L -l}}
%package devel-data
Summary: Development data files for %{name}
Group: Development/Libraries/C and C++
%description devel-data
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.
This package contains generic files needed to create projects that use
any version of NetCDF.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries/%{!?mpi_flavor:C and C++}%{?mpi_flavor:Parallel}
Requires: %{libname -s %{sonum}} = %{version}
%{!?with_hpc:Requires: %{pname}-devel-data = %{version}}
Requires: libcurl-devel >= 7.18.0
Requires: pkgconfig
Requires: zlib-devel >= 1.2.5
%if %{without hpc}
Requires: hdf%{p_suffix}-devel
Requires: hdf5%{p_suffix}-devel >= 1.8.8
%{?with_mpi:Requires: %{mpi_flavor}-devel}
%{?with_mpi:Requires: parallel-netcdf-%{mpi_flavor}-devel}
%else
%{hpc_requires_devel}
Requires: hdf5%{hpc_package_name_tail}-devel >= 1.8.8
%endif
%description devel
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.
%if %{with mpi}
This package contains all files needed to create projects that use NetCDF.
%else
This package contains all files needed to create projects that use
the %{mpi_flavor} version of NetCDF.
%endif
%{?with_hpc:%{hpc_master_package devel}}
%package devel-static
Summary: Static development files for %{name}
Group: Development/Libraries/%{!?mpi_flavor:C and C++}%{?mpi_flavor:Parallel}
%if %{without hpc}
Requires: hdf%{p_suffix}-devel
Requires: hdf5%{p_suffix}-devel >= 1.8.8
%else
Requires: hdf5-%{hpc_package_name_tail}-devel >= 1.8.8
%endif
Requires: libcurl-devel >= 7.18.0
Requires: zlib-devel >= 1.2.5
%description devel-static
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.
%if %{without mpi}
This package contains the static libraries for NetCDF.
%else
This package contains the %{mpi_flavor} versions of the static libraries
for NetCDF.
%endif
%prep
%{?with_hpc:%hpc_debug}
%setup -q -n %{pname}-%{version}
%patch0 -p0 -b .no_date_time
%patch1 -p1
%patch2 -p1
m4 libsrc/ncx.m4 > libsrc/ncx.c
# Create baselib.conf dynamically (non-HPC build only).
%if %{without hpc}
cat > %{_sourcedir}/baselibs.conf <<EOF
%{libname -s %{sonum}}
EOF
%endif
# Fix spurious-executable-perm RPMLINT warning
chmod a-x RELEASE_NOTES.md
%build
%{?with_hpc:%{hpc_setup}}
%{?with_hpc:module load %{hdf5_module_file}}
%if %{without mpi}
export CC=gcc CXX=g++ FC=gfortran
%else
export CC=%{!?with_hpc:/usr/%_lib/mpi/gcc/%{mpi_flavor}/bin/}mpicc
export FC=%{!?with_hpc:/usr/%_lib/mpi/gcc/%{mpi_flavor}/bin/}mpif90
export CXX=%{!?with_hpc:/usr/%_lib/mpi/gcc/%{mpi_flavor}/bin/}mpic++
%endif
autoreconf -fv
export CFLAGS="-fno-strict-aliasing %{?with_hpc:-L$HDF5_LIB -I$HDF5_INC}"
export CXXFLAGS="%{optflags} %{?with_hpc:-L$HDF5_LIB -I$HDF5_INC}"
export FCFLAGS="%{optflags} %{?with_hpc:-L$HDF5_LIB -I$HDF5_INC}"
%{?with_hpc:export LDFLAGS="-L$HDF5_LIB"}
%if %{without hpc}
%configure \
%else
%hpc_configure \
%endif
--enable-shared \
--enable-netcdf-4 \
--enable-dap \
--enable-ncgen4 \
--enable-extra-example-tests \
--disable-dap-remote-tests \
--with-pic \
--disable-doxygen \
--enable-static \
%{!?with_hpc:--enable-hdf4}
make %{?_smp_mflags}
%install
%{?with_hpc:%{hpc_setup}}
%{?with_hpc:module load %{hdf5_module_file}}
%{?with_hpc:export CFLAGS="-L$HDF5_LIB -I$HDF5_INC"}
make install DESTDIR="%{buildroot}"
mkdir -p %{buildroot}%{_mandir}/man1
install -m644 %{S:1} %{buildroot}%{p_mandir}/man1
rm -f %{buildroot}%{p_libdir}/*.la
# install netcdf_par.h which is skipped when mpicc in not detected
install -m644 include/netcdf_par.h %{buildroot}%{p_includedir}/netcdf_par.h
%if %{without hpc}
# rpm macro for version checking
mkdir -p %{buildroot}%{_sysconfdir}/rpm
cat > %{buildroot}%{_sysconfdir}/rpm/macros.netcdf <<EOF
#
# RPM macros for hdf5 packaging
#
%_netcdf_sonum %{sonum}
%_netcdf_version %{version}
EOF
%else
%hpc_write_modules_files
#%%Module1.0#####################################################################
proc ModulesHelp { } {
puts stderr " "
puts stderr "This module loads the NetCDF C API built with the %{compiler_family} compiler"
puts stderr "toolchain and the %{mpi_flavor} MPI stack."
puts stderr " "
puts stderr "Note that this build of NetCDF leverages the HDF I/O library and requires linkage"
puts stderr "against hdf5. Consequently, the phdf5 package is loaded automatically with this module."
puts stderr "A typical compilation step for C applications requiring NetCDF is as follows:"
puts stderr " "
puts stderr "\\\$CC -I\\\$NETCDF_INC app.c -L\\\$NETCDF_LIB -lnetcdf -L\\\$HDF5_LIB -lhdf5"
puts stderr "\nVersion %{version}\n"
}
module-whatis "Name: %{hpc_upcase %pname} built with %{compiler_family} toolchain"
module-whatis "Version: %{version}"
module-whatis "Category: runtime library"
module-whatis "Description: %{summary}"
module-whatis "%{url}"
set version %{version}
# Require phdf5
if [ expr [ module-info mode load ] || [module-info mode display ] ] {
if { ![is-loaded %{hdf5_module_file}] } {
module load %{hdf5_module_file}
}
}
prepend-path PATH %{hpc_bindir}
prepend-path MANPATH %{hpc_mandir}
prepend-path LD_LIBRARY_PATH %{hpc_libdir}
setenv %{hpc_upcase %pname}_DIR %{hpc_prefix}
setenv %{hpc_upcase %pname}_BIN %{hpc_bindir}
if {[file isdirectory %{hpc_includedir}]} {
prepend-path LIBRARY_PATH %{hpc_libdir}
prepend-path CPATH %{hpc_includedir}
prepend-path C_INCLUDE_PATH %{hpc_includedir}
prepend-path CPLUS_INCLUDE_PATH %{hpc_includedir}
prepend-path INCLUDE %{hpc_includedir}
%hpc_modulefile_add_pkgconfig_path
setenv %{hpc_upcase %pname}_LIB %{hpc_libdir}
setenv %{hpc_upcase %pname}_INC %{hpc_includedir}
}
EOF
%endif
%if 0%{?_do_check}
%check
%if %{with hpc}
%{hpc_setup}
module load %{hdf5_module_file}
%else
%if %{with mpi}
. /usr/%_lib/mpi/gcc/%{mpi_flavor}/bin/mpivars.sh
%endif
%endif
make check
%endif
%post -n %{libname -s %{sonum}} -p /sbin/ldconfig
%postun -n %{libname -s %{sonum}}
/sbin/ldconfig
%{?with_hpc:%hpc_module_delete_if_default}
%files
%defattr(-,root,root,-)
%doc COPYRIGHT README.md RELEASE_NOTES.md
%{?with_hpc:%dir %hpc_datadir}
%{?with_hpc:%dir %p_mandir}
%{p_bindir}%{!?with_hpc:/*}
%exclude %{p_bindir}/nc-config
%{p_mandir}/man1%{!?with_hpc:/*}
%files -n %{libname -s %{sonum}}
%defattr(-,root,root,-)
%{?with_hpc:%hpc_dirs}
%{?with_hpc:%hpc_modules_files}
%{p_libdir}/libnetcdf.so.*
%if %{without hpc}
%files devel-data
%defattr(-,root,root,-)
%config %{_sysconfdir}/rpm/macros.netcdf
%endif
%files devel
%defattr(-,root,root,-)
%{p_bindir}/nc-config
%{p_includedir}%{!?with_hpc:/*}
%{p_libdir}/*.so
%{?with_hpc:%hpc_pkgconfig_file}
%{p_libdir}/pkgconfig/netcdf.pc
%{p_mandir}/man3%{!?with_hpc:/*}
%{p_libdir}/libnetcdf.settings
%files devel-static
%defattr(-,root,root,-)
%{p_libdir}/libnetcdf.a
%changelog