File nceplibs-g2c.spec of Package nceplibs-g2c

#
# spec file for package nceplibs-g2c
#
# Copyright (c) 2025 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 build but have several testsuite failures, disable them, as we don't need them:
ExcludeArch: %{ix86} %{arm}

#---LOGGING needs -data package, but provided files are read from $PWD,
#---so is disfunctional out-of-shelf. Therefore OFF by default.
%bcond_with g2c_logging

%define name2 NCEPLIBS-g2c
%define sover 0
%define libname libg2c%{sover}

Name:           nceplibs-g2c
Version:        2.2.0
Release:        0
Summary:        NCEP C decoder/encoder routines for GRIB edition 2
License:        LGPL-3.0-only
Group:          Productivity/Scientific/Other
URL:            https://github.com/NOAA-EMC/NCEPLIBS-g2c
Source:         https://github.com/NOAA-EMC/NCEPLIBS-g2c/archive/refs/tags/%{version}.tar.gz#/%{name2}-%{version}.tar.gz
BuildRequires:  cmake
BuildRequires:  libaec-devel
BuildRequires:  libpng-devel
BuildRequires:  openjpeg2-devel
BuildRequires:  zlib-devel
%if %{with g2c_logging}
Requires:       %{name}-data = %{version}
%endif

%description
NCEP C decoder/encoder routines for GRIB edition 2. This library is part of the NCEPLIBS project.

%package -n %{libname}
Summary:        Libraries for %{name}
Group:          Productivity/Scientific/Other
%if %{with g2c_logging}
Requires:       %{name}-data = %{version}
%endif

%package -n %{name}-data
Summary:        GRIB table data for %{name}
Group:          Productivity/Scientific/Other

%package devel
Summary:        Headers and development libraries for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{libname} = %{version}

%description -n %{name}-data
This package contains GRIB table data for %{name}, only used for verbose logging.

%description -n %{libname}
This package contains the runtime libraries for %{name}.

%description devel
This package contains the files needed for compiling programs using
the %{libname} library from the %{name} package.

%prep
%autosetup -p1 -n "%{name2}-%{version}"

%build
%cmake \
    -DUSE_AEC=ON \
    -DUSE_PNG=ON \
    -DUSE_Jasper=OFF \
    -DUSE_OpenJPEG=ON \
    -DPTHREADS=OFF \
%if %{with g2c_logging}
    -DLOGGING=ON \
%else
    -DLOGGING=OFF \
%endif
    -DUTILS=ON \
    -DBUILD_STATIC_LIBS=OFF \
    -DCMAKE_SHARED_LINKER_FLAGS="%{?build_ldflags:%{build_ldflags}} -lm"

%cmake_build

%install
%cmake_install
%if %{without g2c_logging}
  rm -v %{buildroot}%{_datadir}/g2c/CodeFlag.txt \
        %{buildroot}%{_datadir}/g2c/Template.txt
%endif

%check
%ctest

%ldconfig_scriptlets -n %{libname}

%files
%license LICENSE.md
%doc README.md docs/GRIB2_conversion_and_its_usage_at_NCEP.pdf docs/user_guide.md
%{_bindir}/g2c_degrib2
%{_bindir}/g2c_compare
%{_bindir}/g2c_index

%if %{with g2c_logging}
%files -n %{name}-data
%license LICENSE.md
%{_datadir}/g2c/CodeFlag.txt
%{_datadir}/g2c/Template.txt
%endif

%files -n %{libname}
%license LICENSE.md
%{_libdir}/libg2c.so.*

%files devel
%license LICENSE.md
%{_libdir}/libg2c.so
%{_libdir}/cmake/g2c/
%{_includedir}/grib2.h

%changelog
openSUSE Build Service is sponsored by