## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 2;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global __cmake_in_source_build 1

%global		with_snapshot	0
%global		with_examples	0
#%%global		prerelease	beta
#%%global		commit		40b9aca2668f443cae6bfbfa7cc5a354f1087011
#%%global		shortcommit	%%(c=%%{commit}; echo ${c:0:7})
%bcond_without	ispc

Name:		embree
Version:	3.13.5
Release:	%autorelease
Summary:	Collection of high-performance ray tracing kernels

License:	Apache-2.0
URL:		https://embree.github.io
%if %{with_snapshot}
Source:		https://github.com/%{name}/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz#/%{name}-%{version}-%{shortcommit}.tar.gz
%else
Source:		https://github.com/%{name}/%{name}/archive/v%{version}%{?prerelease:%{-prerelease}.0}.tar.gz#/%{name}-%{version}%{?prerelease:-%{prerelease}.0}.tar.gz
%endif

#[PATCH] Fix Linux aarch64 support on GCC with lax vector conversions
# https://github.com/embree/embree/pull/408/commits/ace05ce4e3bcee8ff4d6204f4dac835f86f17d4a
Patch:		ace05ce4e3bcee8ff4d6204f4dac835f86f17d4a.patch

BuildRequires:	cmake
BuildRequires:	gcc-c++
BuildRequires:	giflib-devel
%if %{with ispc} 
BuildRequires:	ispc
%endif
BuildRequires:	pkgconfig(glut)
BuildRequires:	pkgconfig(glfw3)
BuildRequires:	pkgconfig(xmu)
# Optional dependencies needed for examples
%if %{with_examples}
BuildRequires:	pkgconfig(libjpeg)
BuildRequires:	pkgconfig(libopenjp2)
BuildRequires:	pkgconfig(libpng)
BuildRequires:	pkgconfig(libtiff-4)
BuildRequires:	pkgconfig(OpenImageIO)
%endif
BuildRequires:	pkgconfig(tbb)

# Embree only supports these architectures with SSE2 and up enabled
ExclusiveArch:	aarch64 x86_64

%description
A collection of high-performance ray tracing kernels intended to graphics 
application engineers that want to improve the performance of their application.

%package	devel
Summary:	Development files for %{name}
Requires:	%{name}%{?_isa} = %{version}-%{release}

%description	devel
The %{name}-devel package contains libraries and header files for
 applications that use %{name}.

%if %{with_examples}
%package	examples
Summary:	Example of application using %{name}
Requires:	%{name}%{?_isa} = %{version}-%{release}

%description	examples
The %{name}-examples package contains sample binaries using %{name}.
%endif

%prep
%if %{with_snapshot}
%autosetup -n %{name}-%{commit}
%else 
%autosetup -p1 -n %{name}-%{version}%{?prerelease:-%{prerelease}.0}
%endif

%build
%cmake \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_CXX_FLAGS="%{optflags} -Wl,--as-needed" \
	-DCMAKE_INSTALL_LIBDIR=%{_libdir} \
	-DCMAKE_INSTALL_PREFIX=%{_prefix} \
	-DEMBREE_COMPACT_POLYS=ON \
	-DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF \
%if %{with ispc}
        -DEMBREE_ISPC_SUPPORT=ON \
%else
        -DEMBREE_ISPC_SUPPORT=OFF \
%endif
        -DEMBREE_MAX_ISA=DEFAULT \
	-DEMBREE_TUTORIALS=OFF 
%cmake_build

%install
%cmake_install

# Relocate doc files
mv %{buildroot}%{_docdir}/%{name}3 %{buildroot}%{_docdir}/%{name}
rm %{buildroot}%{_docdir}/%{name}/LICENSE.txt

%files
%license LICENSE.txt
%doc README.md CHANGELOG.md readme.pdf third-party-programs-TBB.txt third-party-programs.txt
%{_libdir}/lib%{name}3.so.3
%{_libdir}/lib%{name}3.so.3.*
%{_mandir}/man3/*

%files devel
%{_libdir}/lib%{name}3.so
%{_includedir}/%{name}3/
%{_libdir}/cmake/%{name}-%{version}/

%if %{with_examples}
%files examples
%{_bindir}/%{name}3/*
%endif

%changelog
* Sun Jan 08 2023 Luya Tshimbalanga <luya@fedoraproject.org> 3.13.5-2
- Migrate license to SPDX standard

* Fri Nov 25 2022 Luya Tshimbalanga <luya@fedoraproject.org> 3.13.5-1
- Update to 3.13.5 (#2126963)

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> 3.13.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Sat Jul 02 2022 Luya Tshimbalanga <luya@fedoraproject.org> 3.13.3-1
- Update to embree 3.13.3

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> 3.13.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Sat Nov 13 2021 Luya Tshimbalanga <luya@fedoraproject.org> 3.13.2-1
- Update to embre 3.13.2 - Resolves rhbz#1993527

* Tue Jun 15 2021 Luya Tshimbalanga <luya@fedoraproject.org> 3.13.0-2
- Rebuild for ispc 1.6.0

* Tue May 11 2021 Luya Tshimbalanga <luya@fedoraproject.org> 3.13.0-1
- Update to 3.13.0 Set Max ISA detection to SSE4.2 (AVX support is broken)
  Enable aarch64 architecture support without ISA Exclude ar Resolves:
  #1958600

* Fri Feb 26 2021 Luya Tshimbalanga <luya@fedoraproject.org> 3.12.2-1
- Update to 3.12.2 (#1920141)

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> 3.12.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sat Dec 19 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.12.1-3
- Rebuild for ispc 1.5.0

* Sat Nov 28 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.12.1-2
- Update to 3.12.1 (#1880382) Set Max ISA detection to default Drop support
  for EOL Fedora 31

* Sun Nov 01 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.12.1-1
- Update to 3.12.1 (#1880382)

* Sat Aug 29 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.11.0-4
- Rebuild for ispc 1.14.1 (#1855915)

* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> 3.11.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Fri Jul 24 2020 Jeff Law <law@redhat.com> 3.11.0-2
- Use __cmake_in_source_build

* Fri Jun 26 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.11.0-1
- Update to 3.11.0 (#1850917)

* Tue Jun 09 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.10.0-3
- Rebuild for ispc 1.13.0 and Blender 2.83.0

* Tue May 12 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.10.0-1
- Update to 3.10.0 (#1834394)

* Sat Apr 11 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.9.0-1
- Update to 3.9.0

* Wed Feb 12 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.8.0-2
- Update to 3.8.0 (#1792573)

* Wed Feb 12 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.8.0-1
- Update to 3.8.0 (#1792573)

* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> 3.7.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Sat Jan 11 2020 Luya Tshimbalanga <luya@fedoraproject.org> 3.7.0-1
- Update to 3.7.0 (#1747113)

* Thu Sep 26 2019 Luya Tshimbalanga <luya@fedoraproject.org> 3.6.1-2
- Drop renaming libraries parameter on cmake

* Sat Sep 07 2019 Luya Tshimbalanga <luya@fedoraproject.org> 3.6.1-1
- Update to 3.6.1 Rebuild for ispc 1.12.0

* Wed Aug 21 2019 Luya Tshimbalanga <luya@fedoraproject.org> 3.6.0-3
- Update to 3.6.0

* Sat Aug 17 2019 Luya Tshimbalanga <luya@fedoraproject.org> 3.6.0-2
- RPMAUTOSPEC: unresolvable merge