%global neo_commit_id __NEO_COMMIT_ID__
%global gmmlib_version_required 18.4.348
%global igc_version_required 19.11.1622

Name: intel-opencl
Version: __NEO_PACKAGE_VERSION__
Release: __NEO_PACKAGE_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: https://github.com/intel/compute-runtime/archive/%{neo_commit_id}.tar.gz

%if 0%{?el7}
BuildRequires: centos-release-scl epel-release
BuildRequires: devtoolset-4-gcc-c++ cmake3
BuildRequires: gcc-c++ ninja-build make procps python2 libva-devel
%else
BuildRequires: cmake clang gcc-c++ ninja-build make procps python2 sed libva-devel
%endif

BuildRequires: intel-gmmlib-devel >= %{gmmlib_version_required}
Requires: intel-gmmlib >= %{gmmlib_version_required}

BuildRequires: intel-igc-opencl-devel >= %{igc_version_required}
Requires: intel-igc-opencl >= %{igc_version_required}

%description


%prep


%build
echo "==== BUILD ===="
rm -rf *

mkdir neo gmmlib
tar xzf $RPM_SOURCE_DIR/%{neo_commit_id}.tar.gz -C neo --strip-components=1

mkdir build
cd build

%if 0%{?el7}
scl enable devtoolset-4 "cmake3 ../neo -DCMAKE_BUILD_TYPE=Release -DNEO_DRIVER_VERSION=%{version}"
scl enable devtoolset-4 "make -j`nproc` igdrcl_dll"
%else
cmake ../neo -DCMAKE_BUILD_TYPE=Release -DNEO_DRIVER_VERSION=%{version}
make -j`nproc` igdrcl_dll
%endif

echo "==== DONE ===="


%install
echo "==== INSTALL ===="
mkdir -p $RPM_BUILD_ROOT/usr/lib64
mkdir -p $RPM_BUILD_ROOT/etc/OpenCL/vendors
cp $RPM_BUILD_DIR/build/bin/libigdrcl.so $RPM_BUILD_ROOT/usr/lib64/
strip $RPM_BUILD_ROOT/usr/lib64/libigdrcl.so
echo "/usr/lib64/libigdrcl.so" > $RPM_BUILD_ROOT/etc/OpenCL/vendors/intel.icd
echo "==== DONE ===="


%files
%defattr(-,root,root)
/usr/lib64/libigdrcl.so

%config(noreplace)
/etc/OpenCL/vendors/intel.icd

# %doc


# %changelog
