File freeimage.spec of Package freeimage

#
# spec file for package freeimage
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define so_ver 3
%define tarver 3170

Name:           freeimage
Version:        3.17.0
Release:        0
Summary:        Multi-format Image Decoder Library
License:        GPL-2.0 or GPL-3.0
Group:          System/Libraries
Url:            http://freeimage.sourceforge.net/
Source0:        http://downloads.sourceforge.net/freeimage/FreeImage%{tarver}.zip
# PATCH-FIX-OPENSUSE unbundle.patch p.drouand@gmail.com -- Use system libraries instead of bundled ones
Patch0:         unbundle.patch
# PATCH-FIX-OPENSUSE doxygen.patch asterios.dramis@gmail.com -- Fix documentation building (Based on patch from Fedora)
Patch1:         doxygen.patch
# PATCH-FIX-UPSTREAM  CVE-2015-0852.patch -- Multiple integer underflows in PluginPCX.cpp in FreeImage 3.17.0  and earlier
Patch2:         CVE-2015-0852.patch
# PATCH-FIX-OPENSUSE makefiles_fixes.patch asterios.dramis@gmail.com -- Fix CFLAGS and CXXFLAGS, removed -s (strip) option, add missing symlinks for libfreeimageplus, remove root user from install
Patch3:         makefiles_fixes.patch
BuildRequires:  doxygen
BuildRequires:  gcc-c++
BuildRequires:  jxrlib-devel
BuildRequires:  libjpeg-devel
BuildRequires:  openjpeg2-devel
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libraw)
%if 0%{?suse_version} >= 1320
BuildRequires:  pkgconfig(libmng)
%else
BuildRequires:  libmng-devel
%endif
BuildRequires:  unzip
BuildRequires:  pkgconfig(OpenEXR)
BuildRequires:  pkgconfig(libtiff-4)
BuildRequires:  pkgconfig(libwebp)
BuildRequires:  pkgconfig(zlib)

%description
FreeImage is an Open Source library project for developers who would like to
support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as
needed by today's multimedia applications. FreeImage is easy to use, fast,
multithreading safe.

%package devel
Summary:        Development Files for FreeImage
Group:          Development/Libraries/C and C++
Requires:       lib%{name}%{so_ver} = %{version}
Requires:       lib%{name}plus%{so_ver} = %{version}
# libfreeimage-devel was last used at version 3.10.0
Provides:       lib%{name}-devel = %{version}
Obsoletes:      lib%{name}-devel < %{version}

%description devel
This package provides development libraries and headers needed to build
software using FreeImage.

%package -n lib%{name}%{so_ver}
Summary:        Multi-format Image Decoder Library
Group:          System/Libraries

%description -n lib%{name}%{so_ver}
FreeImage is an Open Source library project for developers who would like to
support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as
needed by today's multimedia applications. FreeImage is easy to use and fast,
multithreading safe.

%package -n lib%{name}plus%{so_ver}
Summary:        Multi-format Image Decoder Library
Group:          System/Libraries

%description -n lib%{name}plus%{so_ver}
FreeImage is an Open Source library project for developers who would like to
support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as
needed by today's multimedia applications. FreeImage is easy to use and fast,
multithreading safe.

%prep
%setup -q -n FreeImage
%patch0 -p1
%patch1
%patch2 -p1
%patch3 -p1

# Remove bundled libs to make sure these don't get used during compile
rm -rf Source/LibPNG/ Source/LibRawLite/ Source/OpenEXR/ Source/ZLib/ Source/LibOpenJPEG/ Source/LibJPEG/

# clear files which cannot be built due to dependencies on private headers
# (see also unbundle patch)
# It disables the G3 Fax Loader and the JPEG lossless transformations plugins
> Source/FreeImage/PluginG3.cpp
> Source/FreeImageToolkit/JPEGTransform.cpp

# sanitize encodings / line endings
for file in `find . -type f -name '*.c' -or -name '*.cpp' -or -name '*.h' -or -name '*.txt' -or -name Makefile`; do
  iconv --from=ISO-8859-15 --to=UTF-8 $file > $file.new && \
  sed -i 's|\r||g' $file.new && \
  touch -r $file $file.new && mv $file.new $file
done

%build
sh ./gensrclist.sh
sh ./genfipsrclist.sh

export CFLAGS="%{optflags} -fPIC"
export CXXFLAGS="%{optflags} -fPIC"
make %{?_smp_mflags}
make %{?_smp_mflags} -f Makefile.fip

pushd Wrapper/FreeImagePlus/doc
doxygen FreeImagePlus.dox
popd

%install
make DESTDIR=%{buildroot} INSTALLDIR=%{buildroot}%{_libdir} install
make -f Makefile.fip DESTDIR=%{buildroot} INSTALLDIR=%{buildroot}%{_libdir} install

# Remove static libraries
rm -f %{buildroot}%{_libdir}/*.a

%post -n lib%{name}%{so_ver} -p /sbin/ldconfig

%postun -n lib%{name}%{so_ver} -p /sbin/ldconfig

%post -n lib%{name}plus%{so_ver} -p /sbin/ldconfig

%postun -n lib%{name}plus%{so_ver} -p /sbin/ldconfig

%files devel
%defattr(-,root,root,-)
%doc Whatsnew.txt license-*.txt
%doc Wrapper/FreeImagePlus/doc/html/
%{_includedir}/FreeImage.h
%{_includedir}/FreeImagePlus.h
%{_libdir}/libfreeimage.so
%{_libdir}/libfreeimageplus.so

%files -n lib%{name}%{so_ver}
%defattr(-,root,root,-)
%{_libdir}/lib%{name}.so.3*
%{_libdir}/lib%{name}-%{version}.so

%files -n lib%{name}plus%{so_ver}
%defattr(-,root,root,-)
%{_libdir}/lib%{name}plus.so.3*
%{_libdir}/lib%{name}plus-%{version}.so

%changelog
openSUSE Build Service is sponsored by