%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

# biarch support
%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%define _query_suffix %{nil}
%if %{build_compat32}
%define _query_suffix -32
%endif

Name:           gdk-pixbuf2
Version:        2.26.5
Release:        1%{?_dist_release}
Summary:        An image loading library

Group:          System Environment/Libraries
License:        LGPLv2+
URL:            http://www.gt.org
Source0:        http://download.gnome.org/sources/gdk-pixbuf/2.26/gdk-pixbuf-%{version}.tar.xz

BuildRequires:  glib2-devel >= 2.26.0
BuildRequires:  libpng-devel
BuildRequires:  libjpeg-turbo-devel
BuildRequires:  libtiff-devel
BuildRequires:  jasper-devel
BuildRequires:  libX11-devel
BuildRequires:  gobject-introspection-devel

# gdk-pixbuf does a configure time check which uses the GIO mime
# layer; we need to actually have the mime type database.
BuildRequires:  shared-mime-info

BuildRequires: gtk-doc
## BuildRequires: libtool >= 2.2.10
BuildRequires: libtool
BuildRequires: gettext

# We also need MIME information at runtime
Requires: shared-mime-info

# gdk-pixbuf was included in gtk2 until 2.21.2
Conflicts: gtk2 <= 2.21.2

# https://bugzilla.gnome.org/show_bug.cgi?id=624712
Patch0: 0001-Fix-linking-when-libpng-loader-is-builtin.patch

Vendor: Project Vine
Distribution: Vine Linux
Packager: Takemikaduchi

%description
gdk-pixbuf is an image loading library that can be extended by loadable
modules for new image formats. It is used by toolkits such as GTK+ or
clutter.

%package devel
Summary: Development files for gdk-pixbuf
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: glib2-devel
Requires: gobject-introspection-devel
Requires: libpng-devel

# gdk-pixbuf was included in gtk2 until 2.21.2
Conflicts: gtk2-devel <= 2.21.2

%description devel
This package contains the libraries and header files that are needed
for writing applications that are using gdk-pixbuf.

%if %{build_compat32}
#######################################################################
# compat32
%package -n compat32-%{name}
Summary:        An image loading library
Group:          System Environment/Libraries
Requires(post): compat32-glib2 >= %{glib2_version}
# gdk-pixbuf was included in gtk2 until 2.21.2
Conflicts: compat32-gtk2 <= 2.21.2

%description -n compat32-%{name}
gdk-pixbuf is an image loading library that can be extended by loadable
modules for new image formats. It is used by toolkits such as GTK+ or
clutter.

%package -n compat32-%{name}-devel
Summary: Development files for gdk-pixbuf
Group: Development/Libraries
Requires: compat32-%{name} = %{version}-%{release}
Requires: %{name} = %{version}-%{release}
Requires: compat32-libpng-devel

# gdk-pixbuf was included in gtk2 until 2.21.2
Conflicts: compat32-gtk2-devel <= 2.21.2

%description -n compat32-%{name}-devel
This package contains the libraries and header files that are needed
for writing applications that are using gdk-pixbuf.

%endif


%prep
%setup -q -n gdk-pixbuf-%{version}
## %patch0 -p1 -b .libpng-linking

%build
libtoolize --copy --force
autoreconf
(if ! test -x configure; then NOCONFIGURE=1 ./autogen.sh; CONFIGFLAGS=--enable-gtk-doc; fi;
 %configure $CONFIGFLAGS \
	--with-libjasper             \
	--with-x11	             \
        --with-included-loaders=png  \
        --enable-introspection=yes  )
make %{?_smp_mflags}


%install
make install DESTDIR=$RPM_BUILD_ROOT    \
             RUN_QUERY_LOADER_TEST=false

# Remove unpackaged files
rm $RPM_BUILD_ROOT%{_libdir}/*.la
rm $RPM_BUILD_ROOT%{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders/*.la

touch $RPM_BUILD_ROOT%{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders.cache

%if %{build_compat32}
   cp $RPM_BUILD_ROOT%{_bindir}/gdk-pixbuf-query-loaders \
      $RPM_BUILD_ROOT%{_bindir}/gdk-pixbuf-query-loaders%{_query_suffix}
%endif

%find_lang gdk-pixbuf

%post
/sbin/ldconfig
gdk-pixbuf-query-loaders --update-cache || : > /dev/null 2>&1

%postun
/sbin/ldconfig
if [ $1 -gt 0 ]; then
  gdk-pixbuf-query-loaders --update-cache || : > /dev/null 2>&1
fi

%if %{build_compat32}
%post -n compat32-%{name}
/sbin/ldconfig
gdk-pixbuf-query-loaders%{_query_suffix} --update-cache || : > /dev/null 2>&1

%postun -n compat32-%{name}
/sbin/ldconfig
if [ $1 -gt 0 ]; then
  gdk-pixbuf-query-loaders%{_query_suffix} --update-cache || : > /dev/null 2>&1
fi
%endif


%files -f gdk-pixbuf.lang
%defattr(-,root,root,-)
%doc AUTHORS COPYING NEWS
%{_bindir}/gdk-pixbuf-pixdata
%{_libdir}/libgdk_pixbuf-2.0.so.*
%{_libdir}/libgdk_pixbuf_xlib-2.0.so.*
%{_libdir}/girepository-1.0
%dir %{_libdir}/gdk-pixbuf-2.0
%dir %{_libdir}/gdk-pixbuf-2.0/2.10.0
%dir %{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders
%{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders/*.so
%ghost %{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders.cache
%{_bindir}/gdk-pixbuf-query-loaders
%{_mandir}/man1/gdk-pixbuf-query-loaders.1.gz

%files devel
%defattr(-,root,root,-)
%{_includedir}/gdk-pixbuf-2.0
%{_libdir}/libgdk_pixbuf-2.0.so
%{_libdir}/libgdk_pixbuf_xlib-2.0.so
%{_libdir}/pkgconfig/gdk-pixbuf-2.0.pc
%{_libdir}/pkgconfig/gdk-pixbuf-xlib-2.0.pc
%{_bindir}/gdk-pixbuf-csource
%{_datadir}/gtk-doc/html/*
%{_datadir}/gir-1.0
%{_mandir}/man1/gdk-pixbuf-csource.1.gz

%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/libgdk_pixbuf-2.0.so.*
%{_libdir}/libgdk_pixbuf_xlib-2.0.so.*
%dir %{_libdir}/gdk-pixbuf-2.0
%dir %{_libdir}/gdk-pixbuf-2.0/2.10.0
%dir %{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders
%{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders/*.so
%ghost %{_libdir}/gdk-pixbuf-2.0/2.10.0/loaders.cache
%{_bindir}/gdk-pixbuf-query-loaders%{_query_suffix}

%files -n compat32-%{name}-devel
%defattr(-,root,root,-)
%{_libdir}/libgdk_pixbuf-2.0.so
%{_libdir}/libgdk_pixbuf_xlib-2.0.so
%endif

%changelog
* Sat Nov 10 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.26.5-1
- new upstream release

* Wed Sep 26 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.26.4-1
- new upstream release

* Fri Aug 17 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.26.2-1
- new upstream release

* Sun Apr 22 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.26.1-1
- new upstream release

* Fri Dec 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.24.1-1
- new upstream release
- add configure option (--with-x11)

* Sat Sep 03 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.24.0-1
- new upstream release

* Sun Aug 14 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.23.5-1
- new upstream release

* Sat Nov 20 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.22.1-1
- new upstream release

* Sat Oct 02 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.22.0-1
- new upstream release
- add configure option (--enable-introspection=yes)
- drop Patch0

* Sat Oct 02 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.21.3-1
- initial build for Vine Linux


* Mon Jul 19 2010 Bastien Nocera <bnocera@redhat.com> 2.21.6-3
- Require libpng for linking

* Thu Jul 15 2010 Colin Walters <walters@verbum.org> - 2.21.6-2
- Rebuild with new gobject-introspection

* Mon Jul 12 2010 Matthias Clasen <mclasen@redhat.com> - 2.21.6-1
- Update to 2.21.6

* Fri Jul  2 2010 Colin Walters <walters@verbum.org> - 2.21.5-4
- Also Require shared-mime-info for same reason

* Fri Jul  2 2010 Colin Walters <walters@verbum.org> - 2.21.5-3
- BR shared-mime-info; see comment above it

* Tue Jun 29 2010 Colin Walters <walters@pocket> - 2.21.5-2
- Changes to support snapshot builds

* Mon Jun 28 2010 Matthias Clasen <mclasen@redhat.com> 2.21.5-1
- Update to 2.21.5

* Sat Jun 26 2010 Matthias Clasen <mclasen@redhat.com> 2.21.4-2
- Rename to gdk-pixbuf2 to avoid conflict with the
  existing gdk-pixbuf package

* Sat Jun 26 2010 Matthias Clasen <mclasen@redhat.com> 2.21.4-1
- Update to 2.21.4
- Incorporate package review feedback

* Sat Jun 26 2010 Matthias Clasen <mclasen@redhat.com> 2.21.3-1
- Initial packaging
