File cdo.spec of Package cdo

#
# spec file for package cdo
#
# Copyright (c) 2019 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


#---code does not build on 32bit atm, and eccodes/Magics are not available either:
ExcludeArch: %{ix86} %{arm}

%define want_grib 1
%define want_plot 1

Name:           cdo
Version:        1.9.7.1
Release:        0
Summary:        A program for manipulating GRIB/NetCDF/SERVICE/EXTRA/IEG files
License:        GPL-2.0-only
Group:          Productivity/Scientific/Other
URL:            https://code.zmaw.de/projects/cdo
Source0:        https://code.mpimet.mpg.de/attachments/download/20124/cdo-%{version}.tar.gz
# PATCH-FIX-OPENSUSE deregister.patch
Patch0:         deregister.patch
# PATCH-FIX-UPSTREAM fix_Ydrunstat_crash.patch
Patch1:         fix_Ydrunstat_crash.patch
# PATCH-FIX-UPSTREAM fix_vfldavg.patch
Patch2:         fix_vfldavg.patch
BuildRequires:  gcc-c++
BuildRequires:  hdf5-devel >= 1.8.8
BuildRequires:  libcurl-devel
BuildRequires:  proj-devel
BuildRequires:  netcdf-devel
BuildRequires:  perl
BuildRequires:  udunits2-devel
BuildRequires:  zlib-devel
%if 0%{?want_grib} || 0%{?fedora_version}
BuildRequires:  libaec-devel
BuildRequires:  libsz2-devel
%endif
%if 0%{?want_grib}
BuildRequires:  eccodes-devel
%endif
%if 0%{?want_plot}
BuildRequires:  Magics-devel
#---explicit indication of geotiff because of multiple choices
BuildRequires:  libgeotiff-devel >= 1.4.2
BuildRequires:  libxml2-devel
%endif
BuildRequires:  bash-completion
Requires:       bash-completion

%description
CDO (Climate Data Operators) is a collection of command line Operators
to manipulate and analyse Climate and NWP model Data.
Supported data formats are GRIB 1/2, netCDF 3/4, SERVICE, EXTRA and IEG.
There are more than 600 operators available.

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1

%build
%if 0%{?want_plot}
export CFLAGS="%{optflags} -fno-strict-aliasing -I/usr/include/magics"
export CXXFLAGS="%{optflags} -fno-strict-aliasing -I/usr/include/magics"
export CPPFLAGS="%{optflags} -I/usr/include/magics"
%else
export CFLAGS="%{optflags} -fno-strict-aliasing"
export CXXFLAGS="%{optflags} -fno-strict-aliasing"
%endif
#---needed for proj6:
CFLAGS="$CFLAGS -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H"
CXXFLAGS="$CXXFLAGS -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H"
%configure --with-netcdf \
           --with-proj \
           --with-zlib \
           --with-hdf5 \
           --with-curl \
%if 0%{?want_grib}
           --enable-grib \
           --with-eccodes \
           --with-szlib \
%else
           --disable-grib \
%endif
%if 0%{?want_plot}
           --with-magics \
           --with-libxml2 \
%endif
           --with-udunits2 LOGNAME=abuild HOST=OBS

#---we want reproducible builds:
find . -type f -regex ".*[.]cc?" -exec perl -i -pe 's{__(DATE|TIME)__}{""}g' "{}" "+"

make %{?_smp_mflags}

%check
##export HDF5_DISABLE_VERSION_CHECK=1
make check VERBOSE=1 AM_COLOR_TESTS=no

%install
%make_install
install -D -m 644 contrib/cdoCompletion.bash \
  %{buildroot}%{_datadir}/bash-completion/completions/%{name}

%files
%license COPYING
%doc README NEWS OPERATORS ChangeLog doc/cdo.pdf doc/cdo_refcard.pdf
%{_bindir}/%{name}
%{_datadir}/bash-completion/completions/%{name}

%changelog
openSUSE Build Service is sponsored by