%bcond_with check

Name:	        OpenEXR
Summary:        A high dynamic-range (HDR) image file format
Summary(ja):    高ダイナミックレンジ(HDR)画像ファイルフォーマット
Version:        2.4.0
Release:        1%{?_dist_release}

License:        BSD
Group:          Applications/Graphics
URL:            http://www.openexr.com/

Vendor:         Project Vine
Distribution:   Vine Linux

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

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: cmake
BuildRequires: zlib-devel
BuildRequires: pkgconfig
# https://github.com/openexr/openexr/issues/130
BuildConflicts: OpenEXR-devel < 2.2.0

Requires: %{name}-libs = %{version}-%{release}

Obsoletes: openexr < %{version}-%{release}
Provides:  openexr = %{version}-%{release}

%description
OpenEXR is a high dynamic-range (HDR) image file format developed by Industrial
Light & Magic for use in computer imaging applications. This package contains
sample applications for handling the format.

%package        libs
Summary:        %{name} runtime libraries
Summary(ja):    %{name} のランタイムライブラリ
Group:          System Environment/Libraries

%description    libs
%{summary}.


%package        devel
Summary:        Development files for %{name}
Summary(ja):    %{name} の開発用ファイル
Group:          Development/Libraries
Requires:       %{name}-libs = %{version}-%{release}
Requires:       ilmbase-devel
Obsoletes:      openexr-devel < %{version}-%{release}
Provides:       openexr-devel = %{version}-%{release}

%description devel
%{summary}.


%package -n     ilmbase 
Summary:        Abraction/convenience libraries
Group:          System Environment/Libraries
BuildRequires:  libGL-devel
BuildRequires:  libGLU-devel

%description -n ilmbase 
Half is a class that encapsulates the ilm 16-bit floating-point format.

IlmThread is a thread abstraction library for use with OpenEXR
and other software packages.

Imath implements 2D and 3D vectors, 3x3 and 4x4 matrices, quaternions
and other useful 2D and 3D math functions.

Iex is an exception-handling library.


%package -n     ilmbase-devel
Summary:        Headers and libraries for building apps that use ilmbase
Summary(ja):    ilmbaseを使うアプリケーションをビルドするためのヘッダファイル及びライブラリ
Group:          Development/Libraries
Requires:       ilmbase = %{version}-%{release}
Requires:       pkgconfig
Requires:       libGL-devel
Requires:       libGLU-devel

%description -n ilmbase-devel
Headers and libraries for building apps that use ilmbase.


%prep
%setup -q -n openexr-%{version}

pushd IlmBase
echo "Requires.private: gl glu" >> IlmBase.pc.in
popd

# *.pc built by cmake is broken
# https://github.com/openexr/openexr/issues/595
sed -i \
	-e 's,@exec_prefix@,${prefix}/@exec_prefix@,' \
	-e 's,@libdir@,\${prefix}/@libdir@,' \
	-e 's,@includedir@,${prefix}/@includedir@,' \
	IlmBase/IlmBase.pc.in
sed -i \
	-e 's,@exec_prefix@,${prefix}/@exec_prefix@,' \
	-e 's,@libdir@,\${prefix}/@libdir@,' \
	-e 's,@includedir@,${prefix}/@includedir@,' \
	OpenEXR/OpenEXR.pc.in


%build

mkdir build
pushd build
%cmake \
	-DPYILMBASE_ENABLE=no \
	-DOPENEXR_VIEWERS_ENABLE=no \
	..
make %{?_smp_mflags}
popd


%install
rm -rf %{buildroot}

pushd build
make install DESTDIR=%{buildroot}
popd

# prepare docs
mkdir -p rpmdocs
cp -a %{buildroot}%{_docdir}/OpenEXR/* rpmdocs/
rm -rf %{buildroot}%{_docdir}/OpenEXR


%if %{with check}
%check
pushd build
%ifarch %{ix86}
make %{_smp_mflags} test ||:
%else
make %{_smp_mflags} test
%endif
popd
%endif


%clean
rm -rf %{buildroot}


%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig


%files
%defattr(-,root,root,-)
%license LICENSE.md
%doc README.md
%{_bindir}/*

%files libs
%defattr(-,root,root,-)
%license LICENSE.md
%doc OpenEXR/README.md
%doc rpmdocs/*
%{_libdir}/libIlmImf*.so.*

%files devel
%defattr(-,root,root,-)
%{_includedir}/OpenEXR/Imf*.h
%{_includedir}/OpenEXR/OpenEXRConfig.h
%{_libdir}/lib*.so
%dir %{_libdir}/pkgconfig
%{_libdir}/pkgconfig/OpenEXR.pc
%dir %{_libdir}/cmake
%{_libdir}/cmake/OpenEXR

%files -n ilmbase
%doc IlmBase/README.md
%license LICENSE.md
%{_libdir}/lib*.so.*
%exclude %{_libdir}/libIlmImf*.so.*

%files -n ilmbase-devel
%dir %{_includedir}/OpenEXR/
%{_includedir}/OpenEXR/Iex*.h
%{_includedir}/OpenEXR/Ilm*.h
%{_includedir}/OpenEXR/Imath*.h
%{_includedir}/OpenEXR/half*.h
%{_libdir}/lib*.so
%exclude %{_libdir}/libIlmImf*.so
%dir %{_libdir}/pkgconfig
%{_libdir}/pkgconfig/IlmBase.pc
%dir %{_libdir}/cmake
%{_libdir}/cmake/IlmBase


%changelog
* Fri Oct 25 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.0-1
- new upstream release.
- unified IlmBase into OpenEXR.

* Tue Jun 28 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.2.0-2
- rebuild with gcc-5.4.0

* Thu Dec 18 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 2.2.0-1
- new upstream release
- removed Patch100 and 101
- built with ilmbase 2.2.0

* Mon Dec 30 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.1.0-1
- new upstream release
- remove Patch1,2,102
- update Patch100 (openexr-2.1.0-CVE-2009-1720-1.patch)
- update Patch101 (openexr-2.1.0-CVE-2009-1720-2.patch)

* Sun Sep 26 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.1-3
- rebuilt with rpm-4.8.1 for pkg-config 

* Wed Aug  5 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 1.6.1-2
- add Patch100,101 for fix CVE-2009-1720 (Integer BOF)
- add Patch102 for fix CVE-2009-1721
- Patch100-102 are from FC11

* Mon Oct 06 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.6.1-1
- initial build for Vine Linux

* Fri May 09 2008 Rex Dieter <rdieter@fedoraproject.org> 1.6.1-4
- drop: Obsoletes: OpenEXR-utils (see OpenEXR_Viewers review, bug #428228c3)

* Fri Feb 01 2008 Rex Dieter <rdieter@fedoraproject.org> 1.6.1-3
- gcc43 patch
- purge rpaths

* Wed Jan 09 2008 Rex Dieter <rdieter[AT]fedoraproject.org> 1.6.1-2
- hack to omit unused-direct-shlib-dependencies
- conditionalize -libs (f8+)

* Mon Jan 07 2008 Rex Dieter <rdieter[AT]fedoraproject.org> 1.6.1-1
- openexr-1.6.1

* Tue Oct 30 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 1.6.0-5
- multiarch conflicts in OpenEXR (#342781)
- don't own %%_includedir/OpenEXR (leave that to ilmbase)

* Mon Oct 15 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 1.6.0-4
- -libs: %%post/%%postun -p /sbin/ldconfig

* Fri Oct 12 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 1.6.0-2
- openexr-1.6.0

* Mon Sep 17 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 1.4.0a-6
- libs: -Requires: %%name

* Wed Aug 22 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 1.4.0a-5
- -libs: new subpkg to be multilib friendly
- -utils: package exrdisplay separately (separate fltk dep)

* Sat Oct 28 2006 Rex Dieter <rexdieter[AT]users.sf.net> 1.4.0a-4
- Obsoletes/Provides: openexr(-devel) (rpmforge compatibility)

* Thu Sep 14 2006 Rex Dieter <rexdieter[AT]users.sf.net> 1.4.0a-3
- pkgconfig patch to use Libs.private

* Thu Sep 14 2006 Rex Dieter <rexdieter[AT]users.sf.net> 1.4.0a-2
- -devel: +Requires: pkgconfig

* Tue Aug 29 2006 Rex Dieter <rexdieter[AT]users.sf.net> 1.4.0a-1
- openexr-1.4.0a

* Sat Feb 18 2006 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-7
- Further zlib fixes (#165729)

* Mon Feb 13 2006 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-6
- Rebuild for Fedora Extras 5

* Wed Aug 17 2005 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-5
- Remove *.a from %%files devel

* Tue Aug 16 2005 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-4
- Removed -devel dep on zlib-devel (#165729)
- Added --disable-static to %%configure
- Fixed build with GCC 4.0.1
- Added .so links to -devel

* Wed May 18 2005 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-3
- Add zlib-devel to BR
- Delete all .la files (#157652)

* Mon May  9 2005 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-2
- Add disttag

* Sun May  8 2005 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-2
- Fix BuildRequires
- Fix Requires on -devel
- Add %%post[un] scriptlets
- Fix ownership in -devel
- Don't have .deps files in %%doc

* Wed Mar 30 2005 Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> 1.2.2-1
- Initial RPM release
