File nvtop.spec of Package nvtop

%define realname nvtop
%define realver  3.2.0
%define srcext   tar.gz


# Common info
Name:          nvtop
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-3.0+
Group:         System/Monitoring
URL:           https://github.com/Syllo/nvtop
Summary:       GPU & Accelerator process monitoring for AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm

# Build-time parameters
BuildRequires: cmake >= 3.18
BuildRequires: ninja
BuildRequires: gcc-c++
BuildRequires: pkg-config
BuildRequires: pkgconfig(ncurses)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(libdrm)
Source0:       https://codeload.github.com/Syllo/nvtop/%{srcext}/refs/tags/%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
NVTOP stands for Neat Videocard TOP, a (h)top like task monitor for GPUs and
accelerators. It can handle multiple GPUs and print information about them in
a htop-familiar way.

Currently supported vendors are AMD (Linux amdgpu driver), Apple (limited
M1 & M2 support), Huawei (Ascend), Intel (Linux i915/Xe drivers), NVIDIA (Linux
proprietary divers), Qualcomm Adreno (Linux MSM driver), Broadcom VideoCore
(Linux v3d driver).

%prep
%setup -q -n %{realname}-%{version}%{?extraver}

%build
_CFLAGS='%{optflags}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,defs -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
_CMAKE_ARGS=(
 -G Ninja \
 -Wno-dev
 -DCMAKE_INSTALL_PREFIX=%{_prefix}
 -DCMAKE_BUILD_TYPE=Release
 -DCMAKE_C_FLAGS_RELEASE="$_CFLAGS"
 -DCMAKE_CXX_FLAGS_RELEASE="$_CFLAGS"
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS"
 -DCMAKE_VERBOSE_MAKEFILE=YES
)
cmake -B build -S . \
 "${_CMAKE_ARGS[@]}"
ninja -v -C build %{?_smp_mflags}

%install
DESTDIR=%{buildroot} ninja -v -C build install

%files
%defattr(-,root,root)
%license COPYING LICENSE
%doc README.markdown
%{_bindir}/nvtop
%{_datadir}/icons/nvtop.svg
%{_datadir}/applications/nvtop.desktop
%{_datadir}/metainfo/nvtop.metainfo.xml
%doc %{_mandir}/man1/nvtop.1*

%changelog
openSUSE Build Service is sponsored by