File libxrt.spec of Package libxrt

#
# spec file for package libxrt
#
# Copyright (c) 2020 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/
#


%define _lto_cflags %{nil}
%define sover 2

Name:           libxrt
Version:        2019.2_PU2_RC4
Release:        0
Summary:        Xilinx Run Time for FPGA
License:        Apache-2.0 AND GPL-2.0-only
Group:          Hardware/Other
URL:            https://github.com/Xilinx/XRT
Source0:        https://github.com/Xilinx/XRT/archive/%{version}/XRT-%{version}.tar.gz
Source1:        zocl-preamble
Patch0:         0001-zocl-Fix-build-for-Linux-kernel-5.6.patch
Patch1:         0002-edge-Fix-drm_mode.h-include.patch
Patch2:         0003-xdp-Declare-plugins-as-MODULE-in-CMakeLists.txt.patch
Patch3:         0004-xrt_coreutil-Add-dl-to-INTERFACE_LINK_LIBRARIES-in-C.patch
Patch4:         0005-Fix-compilation-on-kernel-5.4.0-2935.patch
Patch5:         0001-Do-not-install-Windows-specific-headers-on-Linux.patch
Patch6:         0002-Install-generated-version.h-into-XRT_INSTALL_INCLUDE.patch
Patch7:         0003-Introduce-XRT_INSTALL_LIB_DIR-variable-in-CMakeLists.patch
Patch8:         0001-Fix-missed-include-stdexcept.patch
BuildRequires:  %{kernel_module_package_buildreqs}
BuildRequires:  clang-tools
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  git-core
BuildRequires:  gtest
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_headers-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_system-devel
BuildRequires:  lsb-release
BuildRequires:  openSUSE-release
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(json-glib-1.0)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(libdrm)
BuildRequires:  pkgconfig(libopenssl)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(ncurses)
BuildRequires:  pkgconfig(ocl-icd)
BuildRequires:  pkgconfig(protobuf)
BuildRequires:  pkgconfig(uuid)
ExclusiveArch:  aarch64 %arm
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%kernel_module_package -p %{_sourcedir}/zocl-preamble -n xilinx-zocl

%description
Xilinx Runtime (XRT) is implemented as as a combination of userspace and kernel
driver components. XRT supports both PCIe based boards like U200, U250, U280
and MPSoC based embedded platforms. XRT provides a standardized software
interface to Xilinx FPGA. The key user APIs are defined in xrt.h header file.

%package -n libxrt%{sover}
Summary:        Xilinx Run Time for FPGA
Group:          Hardware/Other

%description  -n libxrt%{sover}
Xilinx Runtime (XRT) is implemented as as a combination of userspace and kernel
driver components. XRT supports both PCIe based boards like U200, U250, U280
and MPSoC based embedded platforms. XRT provides a standardized software
interface to Xilinx FPGA. The key user APIs are defined in xrt.h header file.

%package -n libxilinxopencl%{sover}
Summary:        OpenCL implementation for Xilinx Run Time
Group:          Development/Libraries/C and C++

%description -n libxilinxopencl%{sover}
This package contains an implementation of the OpenCL specification using the
Xilinx Run Time for FPGA.

%package -n libxdp%{sover}
Summary:        Xilinx Debug and Profile API for Xilinx Run Time
Group:          Hardware/Other

%description  -n libxdp%{sover}
This package contains Xilinx Debug and Profile (XDP) API Xilinx Run Time for
FPGA.

%package devel
Summary:        Development libraries and header files for Xilinx Run Time for FPGA
Group:          Development/Libraries/C and C++
Requires:       libxdp%{sover} = %{version}
Requires:       libxrt%{sover} = %{version}

%description devel
This package contains the header files and libraries for building
programs using the Xilinx Run Time for FPGA.

%package tools
Summary:        Command-line utilities for Xilinx Run Time
Group:          Hardware/Other

%description tools
This package contains the tools for the Xilinx Run Time for FPGA.

%prep
%setup -q -n XRT-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1

%build
%define __builddir  builddir
%define __sourcedir ./src

for flavor in %flavors_to_build; do
  rm -rf $PWD/src/runtime_src/core/edge/drm/.zocl_$flavor
  cp -r $PWD/src/runtime_src/core/edge/drm/zocl $PWD/src/runtime_src/core/edge/drm/.zocl_$flavor
  mkdir -p %{_builddir}/zocl_$flavor
  make V=1 %{?_smp_mflags} -C %{kernel_source $flavor} modules \
    M=$PWD/src/runtime_src/core/edge/drm/.zocl_$flavor
done

export XRT_NATIVE_BUILD=no
%cmake
%cmake_build

%install
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR='%{kernel_module_package_moddir}'
for flavor in %{flavors_to_build}; do
  make V=1 %{?_smp_mflags} -C %{kernel_source $flavor} modules_install \
    M=$PWD/src/runtime_src/core/edge/drm/.zocl_$flavor
done

%cmake_install

mkdir -p %{buildroot}%{_sysconfdir}/OpenCL/vendors
echo "%{_libdir}/libxilinxopencl.so" > %{buildroot}%{_sysconfdir}/OpenCL/vendors/xilinx.icd

%post   -n libxrt%{sover} -p /sbin/ldconfig
%postun -n libxrt%{sover} -p /sbin/ldconfig

%post   -n libxdp%{sover} -p /sbin/ldconfig
%postun -n libxdp%{sover} -p /sbin/ldconfig

%post   -n libxilinxopencl%{sover} -p /sbin/ldconfig
%postun -n libxilinxopencl%{sover} -p /sbin/ldconfig

%files -n libxrt%{sover}
%defattr(-,root,root)
%license LICENSE
%{_libdir}/libxrt_core.so.%{sover}*
%{_libdir}/libxrt_coreutil.so.%{sover}*
%{_libdir}/libxrt_hwemu.so.%{sover}*
%{_libdir}/libxrt++.so.%{sover}*
%{_libdir}/libxrt_swemu.so.%{sover}*
%{_libdir}/libcommon_em.so.%{sover}*

%files -n libxdp%{sover}
%defattr(-,root,root)
%license LICENSE
%{_libdir}/liboclxdp.so.%{sover}*
%{_libdir}/libxdp.so.%{sover}*
%{_libdir}/libxdp_*_plugin.so

%files -n libxilinxopencl%{sover}
%defattr(-,root,root)
%license LICENSE
%{_libdir}/libxilinxopencl.so*
%dir %{_sysconfdir}/OpenCL
%dir %{_sysconfdir}/OpenCL/vendors
%{_sysconfdir}/OpenCL/vendors/xilinx.icd

%files devel
%defattr(-,root,root)
%license LICENSE
%doc CHANGELOG.rst README.rst
%dir %{_includedir}/xrt
%{_includedir}/xrt/*
%{_libdir}/libcommon_em.so
%{_libdir}/liboclxdp.so
%{_libdir}/libxdp.so
%{_libdir}/libxrt++.so
%{_libdir}/libxrt_core.so
%{_libdir}/libxrt_coreutil.so
%{_libdir}/libxrt_hwemu.so
%{_libdir}/libxrt_swemu.so

%files tools
%defattr(-,root,root)
%license LICENSE
%{_bindir}/skd
%{_bindir}/xbutil

%changelog
openSUSE Build Service is sponsored by