File eccodes.spec of Package eccodes

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


#---32bit archs are no longer supported, disable them:
ExcludeArch: %{ix86} %{arm}

%bcond_without netcdf

Name:           eccodes
Version:        2.35.0
Release:        0
Summary:        Library and tools to handle GRIB 1/2 and BUFR files
License:        Apache-2.0
Group:          Productivity/Scientific/Other
URL:            https://confluence.ecmwf.int/display/ECC/ecCodes+Home
# Source repository at https://github.com/ecmwf/eccodes
Source:         https://confluence.ecmwf.int/download/attachments/45757960/%{name}-%{version}-Source.tar.gz
# PATCH-FEATURE-UPSTREAM reproducible.patch
Patch0:         reproducible.patch
# PATCH-FEATURE-OPENSUSE rm-ksh.patch
Patch2:         rm-ksh.patch
BuildRequires:  cmake >= 3.12
BuildRequires:  gcc-c++
BuildRequires:  hdf5-devel >= 1.8.8
BuildRequires:  libaec-devel
BuildRequires:  libpng-devel
BuildRequires:  libsz2-devel
BuildRequires:  openjpeg2
BuildRequires:  openjpeg2-devel
BuildRequires:  zlib-devel
BuildRequires:  sed
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libjpeg)
%if 0%{?suse_version}
BuildRequires:  gcc-fortran
%else
BuildRequires:  gcc-gfortran
%endif
%if 0%{?suse_version}
BuildRequires:  fdupes
%endif
%if %{with netcdf}
BuildRequires:  netcdf-devel
%endif

%description
An application program interface accessible from C and FORTRAN programs
developed for encoding and decoding WMO FM-92 GRIB and WMO FM-94 BUFR messages.
A useful set of command line tools is also provided to give quick access to
GRIB and BUFR messages.

ecCodes is mostly API compatible with its precursor grib_api, with exception
of obsolescent and experimental features, see
https://confluence.ecmwf.int/display/ECC/GRIB-API+migration for details.

%package devel
Summary:        Devel package for eccodes
Group:          Development/Languages/C and C++
Requires:       %{name} = %{version}-%{release}

%description devel
This package contains the files needed for compiling programs using
the eccodes library.

%prep
%autosetup -p1 -n "%{name}-%{version}-Source"

chmod 644 AUTHORS ChangeLog NOTICE LICENSE

# FindOpenJPEG is broken, use the one from openjp2
rm cmake/FindOpenJPEG.cmake

%build
%cmake \
    -DCMAKE_Fortran_FLAGS="%{optflags} -fno-strict-aliasing%{?_fmoddir: -I%{_fmoddir}}" \
    -DCMAKE_CXX_FLAGS="%{optflags} -fno-strict-aliasing -Wno-sign-compare" \
    -DINSTALL_LIB_DIR="%{_lib}" \
    -DHAVE_BIT_REPRODUCIBLE=ON \
    -DENABLE_ECCODES_THREADS=ON \
%if %{with netcdf}
    -DENABLE_NETCDF=ON \
%else
    -DENABLE_NETCDF=OFF \
%endif
    -DENABLE_JPG=ON \
    -DENABLE_PNG=ON \
    -DENABLE_AEC=ON \
    -DENABLE_FORTRAN=ON

%cmake_build

%install
%cmake_install
rm -fv %{buildroot}%{_datadir}/eccodes/definitions/installDefinitions.sh

#---We do not want rpath settings:
sed -i -e 's/^rpath=.*/rpath=""/' -e 's/-Wl,-rpath,[[:alnum:][:punct:]]* *//g' \
  %{buildroot}%{_libdir}/pkgconfig/eccodes{,_f90}.pc

%if 0%{?suse_version}
%fdupes -s %{buildroot}%{_datadir}
%fdupes %{buildroot}%{_bindir}
%endif

%check
export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
%ctest

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

%files
%license LICENSE
%doc AUTHORS ChangeLog NOTICE
%{_bindir}/*
%{_datadir}/*
%{_libdir}/*.so

%files devel
%{_includedir}/*
%{_libdir}/cmake/%{name}
%{_libdir}/pkgconfig/*.pc

%changelog
openSUSE Build Service is sponsored by