# Note that this is NOT a relocatable package

%define glib2_base_version 2.36.0
%define glib2_version %{glib2_base_version}-1
%define pango_base_version 1.34.0
%define pango_version %{pango_base_version}-1
%define atk_base_version 2.8.0
%define atk_version %{atk_base_version}-1
%define cairo_base_version 1.12.14
%define cairo_version %{cairo_base_version}-1
%define gdkpixbuf2_base_version 2.28.0
%define gdkpixbuf2_version %{gdkpixbuf2_base_version}-1
%define gobject_introspection_version 1.36.0


%define base_version 3.8.1
%define bin_version 3.0.0

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

Summary: The GIMP ToolKit (GTK+), a library for creating GUIs for X.
Summary(ja): X 用 GUI 作成ライブラリ: GIMP ツールキット(GTK+)
Name: gtk3
Version: %{base_version}
Release: 1%{?_dist_release}
License: LGPL
Group: System Environment/Libraries

Source: http://ftp.gnome.org/pub/GNOME/sources/gtk+/3.8/gtk+-%{version}.tar.xz

Patch0: gtk3-3.1.12-gtk-widget-size-allocate.patch
Patch100: gtk+-3.4.0-vine-default-theme.patch

BuildRequires: atk-devel >= %{atk_version}
BuildRequires: at-spi2-atk-devel
BuildRequires: pango-devel >= %{pango_version}
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: cairo-devel >= %{cairo_version}
BuildRequires: gdk-pixbuf2-devel >= %{gdkpixbuf2_version}
BuildRequires: gobject-introspection-devel >= %{gobject_introspection_version}
BuildRequires: libtiff-devel >= 3.7
BuildRequires: libjpeg-turbo-devel
BuildRequires: libpng-devel
BuildRequires: jasper-devel
BuildRequires: colord-devel
BuildRequires: gtk-doc
BuildRequires: gamin-devel
BuildRequires: cups-devel
BuildRequires: libICE-devel
BuildRequires: libXext-devel
BuildRequires: libXi-devel
BuildRequires: libXrandr-devel >= 1.3.0
BuildRequires: libXrender-devel
BuildRequires: libXcursor-devel
BuildRequires: libXfixes-devel
BuildRequires: libXinerama-devel
BuildRequires: libXcomposite-devel
BuildRequires: libXdamage-devel

BuildRoot: %{_tmppath}/gtk-%{version}-root

URL: http://www.gtk.org

# required for icon themes apis to work
Requires: hicolor-icon-theme

# We need to prereq these so we can run gtk-query-immodules-2.0
Requires(post): glib2 >= %{glib2_version}
Requires(post): atk >= %{atk_version}
Requires(post): pango >= %{pango_version}
Requires(post): libSM >= 1.1.0
# We need to prereq libtiff >= 3.7 to run gdk-pixbuf-query-loaders
Requires(post): libtiff >= 3.7
Requires: libXrandr >= 1.3.0

Vendor: Project Vine
Distribution: Vine Linux
Packager: Takemikaduchi


%description
GTK+ is a multi-platform toolkit for creating graphical user
interfaces. Offering a complete set of widgets, GTK+ is suitable for
projects ranging from small one-off tools to complete application
suites.

%package devel
Summary: Development tools for GTK+ applications.
Summary(ja): GTK+ (GIMP ツールキット) アプリケーション開発ツール
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pango-devel >= %{pango_version}
Requires: atk-devel >= %{atk_version}
Requires: glib2-devel >= %{glib2_version}
Requires: gdk-pixbuf2-devel >= %{gdkpixbuf2_version}
Requires: libX11-devel, libXcursor-devel, libXinerama-devel
Requires: libXext-devel, libXi-devel, libXrandr-devel
Requires: libXfixes-devel, libXcomposite-devel
Requires: libpng-devel

%description devel
The gtk+-devel package contains the header files and developer
docs for the GTK+ widget toolkit.  

#######################################################################
# compat32
%package -n compat32-%{name}
Summary: The GIMP ToolKit (GTK+), a library for creating GUIs for X.
Summary(ja): X 用 GUI 作成ライブラリ: GIMP ツールキット(GTK+)
Group: System Environment/Libraries
Requires(post): compat32-glib2 >= %{glib2_version}
Requires(post): compat32-atk >= %{atk_version}
Requires(post): compat32-pango >= %{pango_version}
Requires(post): compat32-libSM >= 1.1.0
Requires(post): compat32-libtiff >= 3.7
Requires: compat32-libXrandr >= 1.3.0

%description -n compat32-%{name}
GTK+ is a multi-platform toolkit for creating graphical user
interfaces. Offering a complete set of widgets, GTK+ is suitable for
projects ranging from small one-off tools to complete application
suites.

%package -n compat32-%{name}-devel
Summary: Development tools for GTK+ applications.
Summary(ja): GTK+ (GIMP ツールキット) アプリケーション開発ツール
Group: Development/Libraries
Requires: compat32-%{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}
Requires: compat32-libX11-devel, compat32-libXcursor-devel, compat32-libXinerama-devel
Requires: compat32-libXext-devel, compat32-libXi-devel, compat32-libXrandr-devel
Requires: compat32-libXfixes-devel, compat32-libXcomposite-devel
Requires: compat32-libpng-devel

%description -n compat32-%{name}-devel
The gtk+-devel package contains the header files and developer
docs for the GTK+ widget toolkit.  


%prep
%setup -q -n gtk+-%{version}
%patch0 -p1 -b .allocate
%patch100 -p1 -b .vine-default-theme

#for i in config.guess config.sub ; do
#	test -f %{_datadir}/libtool/$i && cp %{_datadir}/libtool/$i .
#done

%build

# if ! pkg-config --exists pangoxft ; then
#         echo "No pangoxft.pc!"
#         exit 1
# fi

#libtoolize --force --copy
#autoreconf -i

%configure \
	--enable-gtk-doc \
	--enable-man \
	--enable-debug=minimum \
	--disable-rebuilds \
	--disable-glibtest \
	--enable-introspection=yes \
	--enable-xkb=yes \
	--enable-xinerama=yes \
	--enable-xrandr=yes \
	--enable-xfixes=yes \
	--enable-xcomposite=yes \
	--enable-xdamage=yes \
	--enable-x11-backend \
	--disable-packagekit \
	--enable-colord=yes

# fight unused direct deps
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT RUN_QUERY_IMMODULES_TEST=false RUN_QUERY_LOADER_TEST=false

%find_lang gtk30
%find_lang gtk30-properties

cat gtk30.lang gtk30-properties.lang > all.lang

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/gtk-3.0
#
# Make cleaned-up versions of examples and tutorial for installation
#
mkdir -p tmpdocs/tutorial
# install -m 0644 docs/html/gtk_tut.html docs/html/gtk_tut-[0-9]*.html docs/html/*.gif tmpdocs/tutorial
for dir in examples/* ; do
    if [ -d $dir ] ; then
       mkdir -p tmpdocs/$dir
       for file in $dir/* ; do
          case $file in
	     *pre1.2.7)
	        ;;
	     *)
                install -m 0644 $file tmpdocs/$dir
		;;
	  esac
       done
    fi
done


# We need to have separate 32-bit and 64-bit binaries
# for places where we have two copies of the GTK+ package installed.
# (we might have x86_64 and i686 packages on the same system, for example.)
%if %{build_compat32}
   cp $RPM_BUILD_ROOT%{_bindir}/gtk-query-immodules-3.0 \
      $RPM_BUILD_ROOT%{_bindir}/gtk-query-immodules-3.0%{_query_suffix}
%endif
touch $RPM_BUILD_ROOT%{_libdir}/gtk-3.0/%{bin_version}/immodules.cache

mkdir -p $RPM_BUILD_ROOT%{_libdir}/gtk-3.0/modules
mkdir -p $RPM_BUILD_ROOT%{_libdir}/gtk-3.0/immodules

# Remove unpackaged files
find $RPM_BUILD_ROOT -type f -name "*.la" -exec rm -f {} ';'
rm -rf $RPM_BUILD_ROOT%{_datadir}/themes/Raleigh

mv $RPM_BUILD_ROOT%{_bindir}/gtk-update-icon-cache \
   $RPM_BUILD_ROOT%{_bindir}/gtk-update-icon-cache-3.0

%clean
rm -rf $RPM_BUILD_ROOT

%post
/sbin/ldconfig
%{_bindir}/gtk-query-immodules-3.0 --update-cache || : > /dev/null 2>&1

%postun 
/sbin/ldconfig
if [ $1 -gt 0 ]; then
  %{_bindir}/gtk-query-immodules-3.0 --update-cache || : > /dev/null 2>&1
fi
glib-compile-schemas %{_datadir}/glib-2.0/schemas ||:

%posttrans
glib-compile-schemas %{_datadir}/glib-2.0/schemas ||:

%if %{build_compat32}
%post -n compat32-%{name}
/sbin/ldconfig
%{_bindir}/gtk-query-immodules-3.0%{_query_suffix} --update-cache || : > /dev/null 2>&1

%postun -n compat32-%{name}
/sbin/ldconfig
if [ $1 = 0 ]; then
  %{_bindir}/gtk-query-immodules-3.0%{_query_suffix} --update-cache || : > /dev/null 2>&1
fi
%endif

%files -f all.lang
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog NEWS README
%{_bindir}/gtk3-demo
%{_bindir}/gtk3-demo-application
%{_bindir}/gtk3-widget-factory
%{_bindir}/gtk-launch
%{_bindir}/gtk-query-immodules-3.0
%{_bindir}/gtk-update-icon-cache-3.0
%{_libdir}/libgtk-3.so.*
%{_libdir}/libgdk-3.so.*
%{_libdir}/libgailutil-3.so.*
%dir %{_libdir}/gtk-3.0
%{_libdir}/gtk-3.0/%{bin_version}
%dir %{_libdir}/gtk-3.0/modules
#%{_libdir}/gtk-3.0/modules/lib*.so
%{_libdir}/girepository-1.0/*.typelib
%{_datadir}/gtk-3.0
%{_datadir}/themes/Default
%{_datadir}/themes/Emacs
%dir %{_sysconfdir}/gtk-3.0
%{_sysconfdir}/gtk-3.0/im-multipress.conf
%{_datadir}/glib-2.0/schemas/*.xml

%files devel
%defattr(-, root, root)
%{_libdir}/lib*.so
%dir %{_libdir}/gtk-3.0
%{_datadir}/gtk-doc/
%{_datadir}/gir-1.0/*.gir
%{_mandir}/man1/*
%exclude %{_mandir}/man1/gtk-update-icon-cache.1.gz
%{_includedir}/*
%{_datadir}/aclocal/*
%{_libdir}/pkgconfig/*
%doc tmpdocs/tutorial

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-, root, root)
%{_bindir}/gtk-query-immodules-3.0%{_query_suffix}
%{_libdir}/libgtk-3.so.*
%{_libdir}/libgdk-3.so.*
%{_libdir}/libgailutil-3.so.*
%dir %{_libdir}/gtk-3.0
%{_libdir}/gtk-3.0/%{bin_version}
%dir %{_libdir}/gtk-3.0/modules
#%{_libdir}/gtk-3.0/modules/lib*.so
%dir %{_sysconfdir}/gtk-3.0

%files -n compat32-%{name}-devel
%defattr(-, root, root)
%{_libdir}/lib*.so
%dir %{_libdir}/gtk-3.0
%endif

%changelog
* Fri Apr 26 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.8.1-1
- new upstream release

* Tue Jan 08 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.4-1
- new upstream release

* Fri Jan 04 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.3-1
- new upstream release

* Sun Nov 11 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.2-1
- new upstream release

* Tue Oct 16 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.1-1
- new upstream release

* Wed Sep 26 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.0-1
- new upstream release
- add BuildRequires: at-spi2-atk-devel

* Mon Jul 16 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.4-1
- new upstream release

* Sat May 12 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.3-1
- new upstream release

* Sun May 06 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.2-1
- new upstream release

* Sun Apr 22 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.1-1
- new upstream release
- update Patch100 (gtk+-3.4.0-vine-default-theme.patch)

* Sun Mar 18 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.4-1
- new upstream release

* Fri Dec 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.3-1
- new upstream release

* Wed Nov 16 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.2-1
- new upstream release
- remove Patch1

* Sun Oct 16 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.1-1
- new upstream release
- add Patch1 (gtk3-3.2.1-bug658772.patch)

* Wed Sep 28 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.0-1
- new upstream release

* Fri Sep 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.92-1
- new upstream release

* Tue Sep 06 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.18-1
- new upstream release

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

* Tue Aug 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.12-1
- new upstream release
- add Patch0 (gtk3-3.1.12-gtk-widget-size-allocate.patch)

* Sun Aug 14 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.10-2
- fix %%files

* Sat Jul 30 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.10-1
- new upstream release
- add BuildRequires: colord-devel

* Sun Jun 26 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.11-1
- new upstream release

* Sun Apr 24 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.9-1
- new upstream release

* Sat Apr 09 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.8-1
- new upstream release

* Sun Apr 03 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.7-1
- new upstream release

* Sun Mar 27 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.6-1
- new upstream release

* Wed Mar 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.4-1
- new upstream release

* Sat Mar 19 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.3-1
- new upstream release

* Sun Mar 13 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.2-1
- new upstream release

* Tue Feb 22 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.1-1
- new upstream release

* Fri Feb 18 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.0-1
- initial build for Vine Linux

