File spirv-llvm-translator.spec of Package spirv-llvm-translator

%define realname SPIRV-LLVM-Translator
%define realver  15.0.15
%define srcext   tar.gz

# See spirv-headers-tag.conf
%define  spirv_headers_revision aa6cef192b8e693916eb713e7a9ccadf06062ceb

%define so_ver   15
%define llvm_ver 15

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

# Common info
Name:          libLLVMSPIRVLib%{?so_ver}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause
Group:         System/Libraries
URL:           https://github.com/KhronosGroup/SPIRV-LLVM-Translator
Summary:       LLVM/SPIR-V Bi-Directional Translator library

# Install-time parameters
Provides:      libllvmspirvlib%{?so_ver}
Provides:      %{realname} = %{version}-%{release}
Obsoletes:     %{realname} < %{version}-%{release}

# Build-time parameters
BuildRequires: cmake >= 3.13.4
BuildRequires: gcc-c++
BuildRequires: ninja
BuildRequires: llvm%{llvm_ver}-devel
BuildRequires: spirv-tools-devel
Source0:       https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v%{realver}%{?extraver}.%{srcext}#/%{realname}-%{realver}%{?extraver}.%{srcext}
Source16:      https://github.com/KhronosGroup/SPIRV-Headers/archive/%{spirv_headers_revision}.%{srcext}#/spirv-headers.%{srcext}

%description
The LLVM/SPIR-V Bi-Directional Translator, a library and tool for translation
between LLVM IR and SPIR-V.

%package -n libLLVMSPIRVLib-devel
Group:         Development/Languages/C and C++
Summary:       Development files for LLVM/SPIR-V Bi-Directional Translator library
Requires:      %{name} = %{version}-%{release}
Provides:      libllvmspirvlib-devel = %{version}-%{release}
Provides:      %{name}-devel = %{version}-%{release}
Provides:      %{realname}-devel = %{version}-%{release}

%description -n libLLVMSPIRVLib-devel
The LLVM/SPIR-V Bi-Directional Translator, a library and tool for translation
between LLVM IR and SPIR-V.

This package provides headers and libraries required for building software using
the LLVM/SPIR-V Bi-Directional Translator library.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver} -a16

# Build step (compile/build binaries, documentation, etc)
%build
_CXXFLAGS='%{optflags} %{?gcc_lto} -include cstdint'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
SPIRV_DIR=$(readlink -f `find . -name SPIRV-Headers-\*`)
cmake -S . -B tmp_build \
 -Wno-dev \
 -G Ninja \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_CXX_FLAGS_RELEASE="$_CXXFLAGS" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_SKIP_RPATH=YES \
 -DCMAKE_VERBOSE_MAKEFILE=YES \
 \
 -DBUILD_SHARED_LIBS=YES \
 -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=$SPIRV_DIR
ninja -v -C tmp_build %{?_smp_mflags}

# Install built stuff
%install
DESTDIR=%{buildroot} ninja -v -C tmp_build install

# Files list
%files
%defattr(-,root,root)
%license LICENSE.TXT
%doc README.md
%{_bindir}/llvm-spirv
%{_libdir}/*.so.*

%files -n libLLVMSPIRVLib-devel
%defattr(-,root,root)
%license LICENSE.TXT
%doc README.md
%{_includedir}/LLVMSPIRVLib/
%{_libdir}/*.so
%{_libdir}/pkgconfig/LLVMSPIRVLib.pc

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

%changelog
openSUSE Build Service is sponsored by