## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 11;
    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

# Force out of source build
%undefine __cmake_in_source_build

# Use soversion
%global soversion 11.0

# Set to 1 to enable testsuite. Fails everywhere with GCC 8+.
%global with_tests 0

# Optional supports
%global with_openexr 1
%global with_ax      0
%global with_nanovdb 1

# ax currently incompatible with newer llvm versions
%if 0%{?fedora} >= 38 || 0%{?rhel} >= 8
%global llvm_compat 15
%endif

Name:           openvdb
Version:        11.0.0
Release:        %autorelease
Summary:        C++ library for sparse volumetric data discretized on three-dimensional grids
License:        MPL-2.0
URL:            http://www.openvdb.org/

Source0:        https://github.com/AcademySoftwareFoundation/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz

# OpenVDB no longer builds on 32bits with latest TBB due to OOM.
ExcludeArch:    i686

BuildRequires:  boost-devel >= 1.61
# boost-python3-devel merged in boost-devel for Fedora 33+
# https://src.fedoraproject.org/rpms/boost/c/1f2e448e099a867f9da62b9da009d3dec5e1ad64?branch=master
%if 0%{?rhel}
BuildRequires:  boost-python3-devel
%endif
BuildRequires:  cmake >= 2.8
BuildRequires:  doxygen >= 1.8.11
#BuildRequires:  epydoc
BuildRequires:  gcc-c++
BuildRequires:  ghostscript >= 8.70
BuildRequires:  libstdc++-devel
%if 0%{?with_ax}
BuildRequires:  llvm%{?llvm_compat}-devel
BuildRequires:	pkgconfig(libffi)
%endif
BuildRequires:  pkgconfig(blosc) >= 1.5.0
BuildRequires:  pkgconfig(cppunit) >= 1.10
# RHEL and CentOS only have that build requirement for x86_64
%if 0%{?rhel}
%ifarch x86_64
BuildRequires:  glfw-devel >= 2.7
%endif
%else
BuildRequires:  pkgconfig(glfw3) >= 2.7
%endif
BuildRequires:  pkgconfig(jemalloc)
BuildRequires:  pkgconfig(log4cplus) >= 1.0
BuildRequires:  cmake(pybind11)
%if 0%{?with_openexr}
BuildRequires:  pkgconfig(OpenEXR) >= 3.0
%endif
# Requires v2020.3 in adherence to VFX Reference Platform guideline
# https://vfxplatform.com/
BuildRequires:  cmake(tbb) = 2020.3
BuildRequires:  pkgconfig(xi)
BuildRequires:  pkgconfig(zlib) > 1.2.7

%description
OpenVDB is an Academy Award-winning open-source C++ library comprising a novel
hierarchical data structure and a suite of tools for the efficient storage and
manipulation of sparse volumetric data discretized on three-dimensional grids.
It is developed and maintained by Academy Software Foundation for use in
volumetric applications typically encountered in feature film production.

This package contains some graphical tools.

%package        libs
Summary:        Core OpenVDB libraries

%description    libs
OpenVDB is an Academy Award-winning open-source C++ library comprising a novel
hierarchical data structure and a suite of tools for the efficient storage and
manipulation of sparse volumetric data discretized on three-dimensional grids.
It is developed and maintained by Academy Software Foundation for use in
volumetric applications typically encountered in feature film production.

%package        devel
Summary:        Development files for %{name}
BuildRequires:  texlive-latex
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
# Requires v2020.3 in adherence to VFX Reference Platform guideline
# https://vfxplatform.com/
Requires:       cmake(tbb) = 2020.3
Requires:       pkgconfig(zlib) > 1.2.7
Obsoletes:      %{name}-doc < 6.1.0-1
Provides:       %{name}-doc = %{version}-%{release}

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

%if 0%{?fedora}
%package        -n python3-%{name}
Summary:        OpenVDB Python module
BuildRequires:  pkgconfig(python3)
BuildRequires:  python3dist(numpy)
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
Obsoletes:      %{name}-python3 < 6.2.0
Obsoletes:      %{name}-python2 < 5.1.0-1
Provides:       %{name}-python2 = %{version}-%{release}
%{?python_provide:%python_provide python3-%{name}}

%description    -n python3-%{name}
%{description}

This package contains the Python module.
%endif


%prep
%autosetup -p1

# Hardcoded values
sed -i \
    -e 's|lib$|%{_lib}|g' \
    %{name}/%{name}/CMakeLists.txt %{name}/%{name}/python/CMakeLists.txt


%build
%ifarch %{arm}
# https://bugzilla.redhat.com/show_bug.cgi?id=2021376
%global optflags %(echo %{optflags} | sed 's/-g /-g1 /')
%endif
%ifarch ppc64le
%undefine _smp_mflags
%endif 
export CXXFLAGS="%{build_cxxflags} -Wl,--as-needed"

# Ignore versions (python 3, etc.)
# Set ABI version to address blender compatibility for
# Fedora 40 and onward
%cmake \
    -DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE \
    -DDISABLE_DEPENDENCY_VERSION_CHECKS=ON \
    -DOPENVDB_BUILD_DOCS=ON \
%if 0%{?fedora}
    -DOPENVDB_BUILD_PYTHON_MODULE=ON \
%endif
%if 0%{?rhel}
    -DCONCURRENT_MALLOC=None \
%endif
    -DOPENVDB_BUILD_UNITTESTS=OFF \
    -DOPENVDB_ENABLE_RPATH=OFF \
    -DPYOPENVDB_INSTALL_DIRECTORY=%{python3_sitearch} \
%if 0%{?with_ax}
    -DHAVE_FFI_CALL=ON \
    -DUSE_AX=ON \
    -DLLVM_STATIC=0 \
    -DLLVM_CONFIG=$(which llvm-config%{?llvm_compat:-%{llvm_compat}}) \
    -DLLVM=%{_bindir} \
%endif
%if 0%{?with_openexr}
    -DUSE_EXR=ON \
%endif
%if 0%{?with_nanovdb}
    -DUSE_NANOVDB=ON \
    -DNANOVDB_USE_OPENVDB=ON
%endif
# Increase memory reserve to 12GB per build thread for a successful build on
# ppc64le and s390x.
%cmake_build %limit_build -m 12288

%if 0%{?with_tests}
%check
%ctest test
%endif

%install
%cmake_install

# Let RPM pick up html documents in the files section
mv %{buildroot}%{_docdir}/OpenVDB/html .
rm -fr %{buildroot}%{_datadir}/doc

find %{buildroot} -name '*.a' -delete

%files
%{_bindir}/vdb_print
%{_bindir}/nanovdb_{convert,print,validate}

%files libs
%license LICENSE
%doc README.md CHANGES
%{_libdir}/lib%{name}.so.%{version}
%{_libdir}/lib%{name}.so.%{soversion}

%if 0%{?fedora}
%files -n python3-%{name}
%{python3_sitearch}/py%{name}.cpython-*.so
%endif

%files devel
%doc html
%{_includedir}/*
%{_libdir}/lib%{name}.so
%{_libdir}/cmake/OpenVDB/

%changelog
## START: Generated by rpmautospec
* Sun Jun 09 2024 Luya Tshimbalanga <luya@fedoraproject.org> - 11.0.0-11
- Requires tbb 2020.3 for VFX Reference Platform guideline

* Sun Jun 09 2024 Python Maint <python-maint@redhat.com> - 11.0.0-10
- Rebuilt for Python 3.13

* Tue Apr 23 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 11.0.0-9
- Rebuilt for openexr 3.2.4

* Sat Apr 20 2024 Luya Tshimbalanga <luya@fedoraproject.org> - 11.0.0-8
- Drop backward compatibility ABI changes ... This commit reverted changes
  aiming to resolve Blender build failure

* Fri Mar 29 2024 Luya Tshimbalanga <luya@fedoraproject.org> - 11.0.0-7
- Enable backward compatibility for ABI 10
- This update fixes built for Blender with OpenVDB enabled

* Sun Jan 28 2024 Richard Shaw <hobbes1069@gmail.com> - 11.0.0-6
- i686 no longer builds due to 4GB memory per thread limitation on 32bit
  arches.

* Sun Jan 28 2024 Richard Shaw <hobbes1069@gmail.com> - 11.0.0-5
- Change build requirements of tbb from pkgconfig to cmake to fix i686
  pulling in the wrong package.

* Sat Jan 27 2024 Richard Shaw <hobbes1069@gmail.com> - 11.0.0-4
- Increase per core memory build limit from 8GB to 10GB so s390x and ppc64
  don't arches don't OOM kill.

* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 11.0.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Wed Jan 17 2024 Jonathan Wakely <jwakely@redhat.com> - 11.0.0-2
- Rebuilt for Boost 1.83

* Thu Nov 16 2023 Luya Tshimbalanga <luya@fedoraproject.org> - 11.0.0-1
- Update to 11.0.0 (rhbz#2243424)

* Sat Oct 21 2023 Ali Erdinc Koroglu <aekoroglu@linux.intel.com> - 10.1.0-1
- Update to 10.1.0

* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 10.0.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon Jul 03 2023 Python Maint <python-maint@redhat.com> - 10.0.1-7
- Rebuilt for Python 3.12

* Thu Jun 01 2023 Ali Erdinc Koroglu <aekoroglu@linux.intel.com> - 10.0.1-6
- tbb-devel and zlib-devel run-require for openvdb-devel

* Mon Mar 06 2023 aekoroglu <aekoroglu@linux.intel.com> - 10.0.1-5
- CMAKE_MODULES enabled for openvkl

* Mon Feb 20 2023 Jonathan Wakely <jwakely@redhat.com> - 10.0.1-4
- Rebuilt for Boost 1.81

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 10.0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Thu Dec 15 2022 Luya Tshimbalanga <luya@fedoraproject.org> - 10.0.1-2
- Increase memory usage for ppc64le architecture

* Mon Dec 12 2022 Luya Tshimbalanga <luya@fedoraproject.org> - 10.0.1-1
- Update to 10.0.1 (#2095665)

* Wed Sep 14 2022 Tom Rix <trix@redhat.com> - 9.1.0-4
- Disable smp builds for ppc64le and s390 epel

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 9.1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 9.1.0-2
- Rebuilt for Python 3.11

* Sun Jun 12 2022 Luya Tshimbalanga <luya@fedoraproject.org> - 9.1.0-1
- local build

* Wed May 04 2022 Thomas Rodgers <trodgers@redhat.com> - 9.0.0-6
- Rebuilt for Boost 1.78

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

* Thu Nov 25 2021 Luya Tshimbalanga <luya@fedoraproject.org> - 9.0.0-4
- Enable NanoVDB support as module for OpenVDB

* Wed Nov 24 2021 Dan Horák <dan@danny.cz> - 9.0.0-3
- workaround OOM on armv7 builders (#2021376)

* Fri Nov 19 2021 Luya Tshimbalanga <luya@fedoraproject.org> - 9.0.0-2
- Update to 9.0.0

* Sat Nov 13 2021 Luya Tshimbalanga <luya@fedoraproject.org> - 9.0.0-1
- Update to 9.0.0

* Fri Aug 20 2021 Richard Shaw <hobbes1069@gmail.com> - 8.1.0-6
- Rebuild for OpenEXR/Imath 3.1.

* Sat Aug 07 2021 Jonathan Wakely <jwakely@redhat.com> - 8.1.0-5
- Rebuilt for Boost 1.76

* Sun Aug 01 2021 Luya Tshimbalanga <luya@fedoraproject.org> - 8.1.0-4
- Drop no longer needed OpenEXR and Imath dependencies

* Fri Jul 23 2021 Richard Shaw <hobbes1069@gmail.com> - 8.1.0-3
- Move to OpenEXR 3.x.

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 8.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Mon Jun 14 2021 Luya Tshimbalanga <luya@fedoraproject.org> - 8.1.0-1
- Update to 8.1.0 Resolves rhbz#1971100

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 8.0.1-3
- Rebuilt for Python 3.10

* Tue Mar 30 2021 Jonathan Wakely <jwakely@redhat.com> - 8.0.1-2
- Rebuilt for removed libstdc++ symbol (#1937698)

* Sat Feb 06 2021 Luya Tshimbalanga <luya@fedoraproject.org> - 8.0.1-1
- Update to 8.0.1

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

* Mon Jan 25 2021 Kalev Lember <klember@redhat.com> - 8.0.0-5
- Rebuilt for Boost 1.75

* Mon Jan 25 2021 Luya Tshimbalanga <luya@fedoraproject.org> - 8.0.0-4
- Rebuild to resolve .so dependency

* Fri Jan 22 2021 Jonathan Wakely <jwakely@redhat.com> - 8.0.0-3
- Rebuilt for Boost 1.75

* Fri Jan 01 2021 Richard Shaw <hobbes1069@gmail.com> - 8.0.0-2
- Rebuild for OpenEXR 2.5.3.

* Sat Dec 26 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 8.0.0-1
- Update to 8.0.0

* Mon Aug 24 2020 Simone Caronni <negativo17@gmail.com> - 7.1.0-3
- Fix typo

* Mon Aug 24 2020 Simone Caronni <negativo17@gmail.com> - 7.1.0-2
- List shared object versions

* Fri Aug 14 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 7.1.0-1
- Update to 7.1.0 Adhere to https://docs.fedoraproject.org/en-US/packaging-
  guidelines/CMake/

* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 7.0.0-13
- Second attempt - Rebuilt for
  https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 7.0.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Sun Jun 21 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 7.0.0-11
- Disable jemalloc build for RHEL and its derivative

* Thu May 28 2020 Jonathan Wakely <jwakely@redhat.com> - 7.0.0-10
- Rebuilt for Boost 1.73

* Tue May 26 2020 Miro Hrončok <miro@hroncok.cz> - 7.0.0-9
- Rebuilt for Python 3.9

* Sat May 23 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 7.0.0-8
- Drop boost-python3-devel build requirement for Fedora 33+

* Sat May 23 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 7.0.0-7
- Drop removed boost-python3-devel from Fedora 33+

* Sat May 23 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 7.0.0-6
- Disable python3 binding for CentOS and Red Hat Enterprise On RHEL and
  CentOS, glfw is exclusive for x86_64 Switch to pkgconfig build
  requirements as possible

* Sat May 23 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 7.0.0-5
- Disable python3 binding for CentOS and Red Hat Enterprise Switch to
  pkgconfig build requirements as possible

* Sat May 23 2020 Luya Tshimbalanga <luya@fedoraproject.org> - 7.0.0-4
- RPMAUTOSPEC: unresolvable merge
## END: Generated by rpmautospec