# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: MIT

# NEO is the shorthand name for Intel Compute Runtime
%global NEO_MAJOR 23
%global NEO_MINOR 30
%global NEO_BUILD 26918.50

%global pkg_name compute-runtime
%global lib_ver %{NEO_MAJOR}.%{NEO_MINOR}.%{NEO_BUILD}
%global openeuler_release 1

Name:		%{pkg_name}
Version:	%{lib_ver}
Release:	%{openeuler_release}%{?dist}
Summary:	Intel(R) Graphics Compute Runtime for OpenCL(TM)
Group:		System Environment/Libraries
License:	MIT
URL:		https://github.com/intel/compute-runtime
Source0:	%{url}/archive/%{version}/%{name}-%{version}.tar.gz
ExclusiveArch:	x86_64

BuildRequires:	make
BuildRequires:	cmake
BuildRequires:	gcc
BuildRequires:	gcc-c++
BuildRequires:	libudev-devel
BuildRequires:	libnl3-devel
BuildRequires:	libva-devel
BuildRequires:	intel-gmmlib-devel >= 22.3.3
BuildRequires:	intel-igc-opencl-devel >= 1.0.13230
BuildRequires:	intel-igc-cm >= 1.0.144
BuildRequires:	level-zero-devel >= 1.9.4
BuildRequires:	intel-gsc-devel >= 0.8.6

%description
Intel(R) Graphics Compute Runtime for OpenCL(TM) is a open source project to
converge Intel's development efforts on OpenCL(TM) compute stacks supporting
the GEN graphics hardware architecture.

%package -n	intel-opencl
Summary:	Intel(R) Graphics Compute Runtime for OpenCL(TM)
Requires:	intel-gmmlib >= 22.3.3
Requires:	intel-igc-opencl >= 1.0.13230
Recommends:	intel-igc-cm >= 1.0.144
%description -n	intel-opencl
Intel(R) Graphics Compute Runtime for OpenCL(TM) is a open source project to
converge Intel's development efforts on OpenCL(TM) compute stacks supporting
the GEN graphics hardware architecture.

%package -n	intel-ocloc
Summary:	ocloc package for opencl
Requires:	intel-gmmlib >= 22.3.3
Requires:	intel-igc-opencl >= 1.0.13230
Recommends:	intel-igc-cm >= 1.0.144
%description -n	intel-ocloc
Intel(R) Graphics Compute Runtime for OpenCL(TM) is a open source project to
converge Intel's development efforts on OpenCL(TM) compute stacks supporting
the GEN graphics hardware architecture.
.
This package contains the ocloc binaries

%package -n	intel-level-zero-gpu
Summary:	Intel(R) GPU Driver for oneAPI Level Zero.
Requires:	intel-gmmlib >= 22.0.1
Requires:	intel-igc-opencl >= 1.0.9389
Requires:	libnl3
%description -n	intel-level-zero-gpu
Runtime library providing the ability to use Intel GPUs with the oneAPI Level
Zero programming interface.
Level Zero is the primary low-level interface for language and runtime
libraries. Level Zero offers fine-grain control over accelerators capabilities,
delivering a simplified and low-latency interface to hardware, and efficiently
exposing hardware capabilities to applications.

%package -n	intel-level-zero-gpu-devel
Summary:	Development files for Intel(R) GPU Driver for oneAPI Level Zero.
Requires:	intel-level-zero-gpu
%description -n	intel-level-zero-gpu-devel
Intel(R) Graphics Compute Runtime for oneAPI Level Zero
This package containes the development headers

%prep
%autosetup -p1 -n %{name}-%{version}

%build
ls
mkdir build
pushd build
%cmake .. \
	-DNEO_OCL_VERSION_MAJOR=%{NEO_MAJOR} \
	-DNEO_OCL_VERSION_MINOR=%{NEO_MINOR} \
	-DNEO_VERSION_BUILD=%{NEO_BUILD} \
	-DCMAKE_BUILD_TYPE=Release \
	-DSUPPORT_DG1=TRUE \
	-DSUPPORT_XE_HP_CORE=TRUE \
	-DSUPPORT_XE_HP_SDV=TRUE \
	-DTESTS_XE_HP_CORE=TRUE \
	-DTESTS_XE_HP_SDV=TRUE \
	-DCMAKE_INSTALL_PREFIX=%{_prefix} \
	-DL0_INSTALL_UDEV_RULES=1 \
	-DUDEV_RULES_DIR=/etc/udev/rules.d/ \
	-DNEO_SKIP_UNIT_TESTS=TRUE \
	-DNEO_ENABLE_i915_PRELIM_DETECTION=TRUE \
	-DNEO_DISABLE_MITIGATIONS=TRUE
%make_build
popd

%install
pushd build
%make_install
chmod +x %{buildroot}/%{_libdir}/intel-opencl/libigdrcl.so
chmod +x %{buildroot}/%{_libdir}/libocloc.so
popd

%files -n intel-opencl
%defattr(-,root,root)
%config(noreplace)
%license LICENSE.md
%{_libdir}/intel-opencl/libigdrcl.so
/etc/OpenCL/vendors/intel.icd

%files -n intel-ocloc
%defattr(-,root,root)
%config(noreplace)
%license LICENSE.md
%{_bindir}/ocloc
%{_libdir}/libocloc.so
%{_includedir}/ocloc_api.h

%files -n intel-level-zero-gpu
%defattr(-,root,root)
%config(noreplace)
%license LICENSE.md
%{_libdir}/libze_intel_gpu.so.*

%files -n intel-level-zero-gpu-devel
%{_includedir}/level_zero/zet_intel_gpu_debug.h

%changelog
* Mon Nov 27 2023 Aubrey Li <aubrey.li@linux.intel.com> - 23.30.26918.50-1
- Initial spec file
