File rocm-smi.spec of Package rocm-smi

%global rocm_release 6.2
%global rocm_patch 0
%global rocm_version %{rocm_release}.%{rocm_patch}
%global upstreamname rocm_smi_lib

%define rpm_pkg_name rocm-smi
%define python_pkgdir rocm_smi
%define python_entrypoint rocm-smi

%define pythons python3

Name:       %{rpm_pkg_name}
Group:      Development/Libraries/C and C++
Version:    %{rocm_version}
Release:    0
Summary:    ROCm System Management Interface

License:    MIT
URL:        https://github.com/ROCm/%{upstreamname}
Source0:    %{url}/archive/refs/tags/rocm-%{version}.tar.gz#/%{upstreamname}-rocm-%{rocm_version}.tar.gz
Patch0:     rocm-smi-utils-splitstring.patch
Patch1:     rocm-smi-python-pkg.patch
Patch2:     rocm-smi-fix-build-with-gcc15.patch

Requires:       %{rpm_pkg_name}-libs = %{version}

ExclusiveArch:  x86_64

BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  %{pythons}

%if 0%{?sle_version} == 150600
BuildRequires:  gcc12-c++
BuildRequires:  libstdc++6-devel-gcc12
%else
BuildRequires:  gcc-c++
%endif

%python_subpackages

%description
The ROCm System Management Interface Library, or ROCm SMI library, is part of
the Radeon Open Compute ROCm software stack.
This package contains the Python binding for the ROCm SMI library.

%package     -n %{rpm_pkg_name}-libs
Group:          Development/Libraries
Summary:        ROCm System Management Interface Library

%description -n %{rpm_pkg_name}-libs
This package contains the C library for Linux that provides a user space interface
for applications to monitor and control GPU applications.

%package     -n %{rpm_pkg_name}-devel
Group:          Development/Libraries
Summary:        ROCm SMI Library development files

Requires:       %{rpm_pkg_name}-libs = %{version}
Provides:       cmake(rocm-smi)

%description -n %{rpm_pkg_name}-devel
ROCm System Management Interface Library development files.

%prep
%autosetup -n %{upstreamname}-rocm-%{rocm_version} -p1

# Don't change default C FLAGS and CXX FLAGS and don't instrall the license file:
sed -i -e '/CMAKE_C.*_FLAGS/d' -e '/install( FILES ${CPACK_RESOURCE_FILE_LICENSE}/,+3d' CMakeLists.txt

%build
%if 0%{?sle_version} == 150600
export CC=gcc-12
export CXX=g++-12
%endif
%cmake -DFILE_REORG_BACKWARD_COMPATIBILITY=OFF -DCMAKE_INSTALL_LIBDIR=%{_lib} -DCMAKE_SKIP_RPATH=ON
%cmake_build

%install
%cmake_install

install -Dpm 755 %{buildroot}%{_libexecdir}/%{python_pkgdir}/%{python_pkgdir}.py %{buildroot}%{_bindir}/%{python_entrypoint}

sed -i -e '1d' %{buildroot}%{_libexecdir}/%{python_pkgdir}/*.py
chmod 0644 %{buildroot}%{_libexecdir}/%{python_pkgdir}/*.py
%{python_expand \
mkdir -p %{buildroot}%{$python_sitelib}/%{python_pkgdir}
cp -r %{buildroot}%{_libexecdir}/%{python_pkgdir}/*.py %{buildroot}%{$python_sitelib}/%{python_pkgdir}/
}
[ "%{_libexecdir}" == "/usr/lib" ] && rm -rf %{buildroot}%{_libexecdir}/%{python_pkgdir} || rm -rf %{buildroot}%{_libexecdir}

%post -n %{rpm_pkg_name}-libs -p /sbin/ldconfig
%end
%postun -n %{rpm_pkg_name}-libs -p /sbin/ldconfig
%end

%files %{python_files}
%doc python_smi_tools/README.md
%license License.txt
%{python_sitelib}/%{python_pkgdir}
%{_bindir}/%{python_entrypoint}

%files -n %{rpm_pkg_name}-libs
%doc rocm_smi/docs/ROCm_SMI_Manual.pdf
%license License.txt
%{_libdir}/librocm_smi64.so.1{,.0}
%{_libdir}/liboam.so.1{,.0}

%files -n %{name}-devel
%license License.txt
%{_includedir}/rocm_smi/
%{_includedir}/oam/
%{_libdir}/librocm_smi64.so
%{_libdir}/liboam.so
%{_libdir}/cmake/rocm_smi/

%changelog
openSUSE Build Service is sponsored by