File dxvk.spec of Package dxvk

#
# spec file for package dxvk
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Name:           dxvk
Version:        1.9
Release:        0
Summary:        Vulkan-based D3D11 implementation for Linux / Wine
License:        zlib-acknowledgement
Group:          System/Emulators/PC
Url:            https://github.com/doitsujin/dxvk
Source0:        %{name}-%{version}.tar.gz

BuildRequires:  wine
BuildRequires:  meson
BuildRequires:  ninja
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  glslang-devel

%ifarch x86_64
BuildRequires:  mingw64-cross-cpp
BuildRequires:  mingw64-cross-gcc
BuildRequires:  mingw64-cross-gcc-c++
BuildRequires:  mingw64-headers

#Require 32bit version
Requires:       %{name}-32bit
%else
BuildRequires:  mingw32-cross-cpp
BuildRequires:  mingw32-cross-gcc
BuildRequires:  mingw32-cross-gcc-c++
BuildRequires:  mingw32-headers
%endif

%description
Provides a Vulkan-based implementation of DXGI and D3D11 in order to run 3D
applications on Linux using Wine.

%prep
%setup -q

%build
#export CFLAGS="%optflags" 
#export CXXFLAGS="%optflags"
### Disable lto + stack protection for now, be verbose at the same time

### -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type
%ifarch x86_64
export CFLAGS="$CFLAGS -funwind-tables -fasynchronous-unwind-tables -ffat-lto-objects -flto=auto" 
export CXXFLAGS="$CXXFLAGS -funwind-tables -fasynchronous-unwind-tables -ffat-lto-objects -flto=auto"
%endif

%ifarch i586
export CFLAGS="$CFLAGS -funwind-tables -fasynchronous-unwind-tables -msse -msse2 -ffat-lto-objects -flto=auto" 
export CXXFLAGS="$CXXFLAGS -funwind-tables -fasynchronous-unwind-tables -msse -msse2 -ffat-lto-objects -flto=auto"
%endif

%if 0%{?sle_version} == 150200 && 0%{?is_opensuse} 
mkdir build
%endif

meson \
    --cross-file build-win$(arch | tail -c 3 | sed 's|86|32|g').txt \
    --buildtype "release" \
    --strip \
    --unity off \
    --prefix /%{name} \
    -Denable_tests=false \
    -Dc_args="$CFLAGS" \
    -Dcpp_args="$CXXFLAGS" \
%if 0%{?sle_version} == 150200 && 0%{?is_opensuse} 
    build
%else
%ifarch x86_64
    x86_64-suse-linux
%endif
%ifarch i586
    i586-suse-linux
%endif
%endif

%meson_build

%install
#install wrapper scripts
mkdir -p %{buildroot}%{_bindir} %{buildroot}%{_libexecdir}/%{name}/bin
sed \
    -e 's|basedir=.*|basedir="%{_libexecdir}/%{name}"|g' \
    -e 's|x32|lib|g' -e 's|x64|lib64|g' \
    setup_dxvk.sh > %{buildroot}%{_libexecdir}/%{name}/bin/setup_dxvk.sh
ln -s %{_libexecdir}/%{name}/bin/setup_dxvk.sh %{buildroot}%{_bindir}/wine%{name}


#install dxvk proper
### DESTDIR=%{buildroot}%{_libexecdir} ninja install
%meson_install
rm -rf %{buildroot}/%{name}/lib/*.dll.a

mkdir %{buildroot}%{_libexecdir}/%{name}/%{_lib}/

mv %{buildroot}/%{name}/bin/*.dll %{buildroot}%{_libexecdir}/%{name}/%{_lib}/

%files
%defattr(644,root,root)
%doc README.md
%license LICENSE

%{_bindir}/wine%{name}
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/%{_lib}
%attr(755, root, root) %{_libexecdir}/%{name}/bin

%changelog
openSUSE Build Service is sponsored by